1 | // |
---|
2 | // Lol Engine |
---|
3 | // |
---|
4 | // Copyright: (c) 2010-2012 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 | |
---|
24 | namespace lol |
---|
25 | { |
---|
26 | |
---|
27 | class Entity |
---|
28 | { |
---|
29 | friend class Ticker; |
---|
30 | friend class TickerData; |
---|
31 | friend class Dict; |
---|
32 | friend class Emcee; |
---|
33 | |
---|
34 | public: |
---|
35 | virtual char const *GetName(); |
---|
36 | |
---|
37 | protected: |
---|
38 | Entity(); |
---|
39 | virtual ~Entity(); |
---|
40 | |
---|
41 | inline int IsDestroying() { return m_destroy; } |
---|
42 | |
---|
43 | virtual void TickGame(float seconds); |
---|
44 | virtual void TickDraw(float seconds); |
---|
45 | |
---|
46 | enum |
---|
47 | { |
---|
48 | GAMEGROUP_BEFORE = 0, |
---|
49 | GAMEGROUP_DEFAULT, |
---|
50 | GAMEGROUP_AFTER, |
---|
51 | GAMEGROUP_AFTER_0, |
---|
52 | GAMEGROUP_AFTER_1, |
---|
53 | |
---|
54 | // Must be the last element |
---|
55 | GAMEGROUP_END |
---|
56 | } |
---|
57 | m_gamegroup; |
---|
58 | |
---|
59 | enum |
---|
60 | { |
---|
61 | DRAWGROUP_BEFORE = GAMEGROUP_END, |
---|
62 | DRAWGROUP_CAMERA, |
---|
63 | DRAWGROUP_DEFAULT, |
---|
64 | DRAWGROUP_HUD, |
---|
65 | DRAWGROUP_CAPTURE, |
---|
66 | // Must be the last element |
---|
67 | DRAWGROUP_END |
---|
68 | } |
---|
69 | m_drawgroup; |
---|
70 | |
---|
71 | static int const GAMEGROUP_BEGIN = 0; |
---|
72 | static int const DRAWGROUP_BEGIN = GAMEGROUP_END; |
---|
73 | static int const ALLGROUP_END = DRAWGROUP_END; |
---|
74 | |
---|
75 | #if !LOL_RELEASE |
---|
76 | enum |
---|
77 | { |
---|
78 | STATE_IDLE = 0, |
---|
79 | STATE_PRETICK_GAME, |
---|
80 | STATE_POSTTICK_GAME, |
---|
81 | STATE_PRETICK_DRAW, |
---|
82 | STATE_POSTTICK_DRAW, |
---|
83 | } |
---|
84 | m_tickstate; |
---|
85 | #endif |
---|
86 | |
---|
87 | // Emcee begin |
---|
88 | private: |
---|
89 | void SetState(uint32_t newstate); |
---|
90 | void SetStateWhenMatch(uint32_t newstate, |
---|
91 | Entity *other_entity, uint32_t other_state); |
---|
92 | virtual uint32_t OnStateChanged(uint32_t newstate) |
---|
93 | { |
---|
94 | return LOLm_state = newstate; |
---|
95 | } |
---|
96 | |
---|
97 | uint32_t LOLm_state; |
---|
98 | // Emcee end |
---|
99 | |
---|
100 | private: |
---|
101 | Entity *m_gamenext, *m_drawnext, *m_autonext; |
---|
102 | int m_ref, m_autorelease, m_destroy; |
---|
103 | }; |
---|
104 | |
---|
105 | } /* namespace lol */ |
---|
106 | |
---|
107 | #endif // __LOL_ENTITY_H__ |
---|
108 | |
---|