source: trunk/src/entity.h @ 1106

Last change on this file since 1106 was 1106, checked in by sam, 9 years ago

core: try to merge Ticker and Emcee. Still not very good.

  • Property svn:keywords set to Id
File size: 2.2 KB
Line 
1//
2// Lol Engine
3//
4// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
5//   This program is free software; you can redistribute it and/or
6//   modify it under the terms of the Do What The Fuck You Want To
7//   Public License, Version 2, as published by Sam Hocevar. See
8//   http://sam.zoy.org/projects/COPYING.WTFPL for more details.
9//
10
11//
12// The Entity class
13// ---------------
14// Entities are objects that can be ticked by the game loop and/or the render
15// loop. Entities are implemented as one or several linked lists. See the
16// Ticker class for the ticking logic and the linked list implementation.
17//
18
19#if !defined __LOL_ENTITY_H__
20#define __LOL_ENTITY_H__
21
22#include <stdint.h>
23
24namespace lol
25{
26
27class Entity
28{
29    friend class Ticker;
30    friend class TickerData;
31    friend class Dict;
32    friend class Emcee;
33
34protected:
35    Entity();
36    virtual ~Entity();
37
38    virtual char const *GetName();
39    inline int IsDestroying() { return destroy; }
40
41    virtual void TickGame(float deltams);
42    virtual void TickDraw(float deltams);
43
44    enum
45    {
46        GAMEGROUP_BEFORE = 0,
47        GAMEGROUP_DEFAULT,
48        GAMEGROUP_AFTER,
49        // Must be the last element
50        GAMEGROUP_END
51    }
52    gamegroup;
53
54    enum
55    {
56        DRAWGROUP_BEFORE = GAMEGROUP_END,
57        DRAWGROUP_DEFAULT,
58        DRAWGROUP_HUD,
59        DRAWGROUP_CAPTURE,
60        // Must be the last element
61        DRAWGROUP_END
62    }
63    drawgroup;
64
65    static int const GAMEGROUP_BEGIN = 0;
66    static int const DRAWGROUP_BEGIN = GAMEGROUP_END;
67    static int const ALLGROUP_END = DRAWGROUP_END;
68
69#if !LOL_RELEASE
70    enum
71    {
72        STATE_IDLE = 0,
73        STATE_PRETICK_GAME,
74        STATE_POSTTICK_GAME,
75        STATE_PRETICK_DRAW,
76        STATE_POSTTICK_DRAW,
77    }
78    state;
79#endif
80
81    // Emcee begin
82private:
83    void SetState(uint32_t newstate);
84    void SetStateWhenMatch(uint32_t newstate,
85                           Entity *other_entity, uint32_t other_state);
86    virtual uint32_t OnStateChanged(uint32_t newstate)
87    {
88        return m_state = newstate;
89    }
90
91    uint32_t m_state;
92    // Emcee end
93
94private:
95    Entity *gamenext, *drawnext, *autonext;
96    int ref, autorelease, destroy;
97};
98
99} /* namespace lol */
100
101#endif // __LOL_ENTITY_H__
102
Note: See TracBrowser for help on using the repository browser.