source: trunk/src/entity.h @ 1888

Last change on this file since 1888 was 1888, checked in by lolbot, 7 years ago

fixed 23 files out of 277:

  • fixed 1270 CR characters
  • fixed 56 trailing spaces
  • fixed 5085 tabs
  • Property svn:keywords set to Id
File size: 2.3 KB
Line 
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
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 m_destroy; }
40
41    virtual void TickGame(float seconds);
42    virtual void TickDraw(float seconds);
43
44    enum
45    {
46        GAMEGROUP_BEFORE = 0,
47        GAMEGROUP_DEFAULT,
48        GAMEGROUP_AFTER,
49        GAMEGROUP_AFTER_0,
50        GAMEGROUP_AFTER_1,
51
52        // Must be the last element
53        GAMEGROUP_END
54    }
55    m_gamegroup;
56
57    enum
58    {
59        DRAWGROUP_BEFORE = GAMEGROUP_END,
60        DRAWGROUP_CAMERA,
61        DRAWGROUP_DEFAULT,
62        DRAWGROUP_HUD,
63        DRAWGROUP_CAPTURE,
64        // Must be the last element
65        DRAWGROUP_END
66    }
67    m_drawgroup;
68
69    static int const GAMEGROUP_BEGIN = 0;
70    static int const DRAWGROUP_BEGIN = GAMEGROUP_END;
71    static int const ALLGROUP_END = DRAWGROUP_END;
72
73#if !LOL_RELEASE
74    enum
75    {
76        STATE_IDLE = 0,
77        STATE_PRETICK_GAME,
78        STATE_POSTTICK_GAME,
79        STATE_PRETICK_DRAW,
80        STATE_POSTTICK_DRAW,
81    }
82    m_tickstate;
83#endif
84
85    // Emcee begin
86private:
87    void SetState(uint32_t newstate);
88    void SetStateWhenMatch(uint32_t newstate,
89                           Entity *other_entity, uint32_t other_state);
90    virtual uint32_t OnStateChanged(uint32_t newstate)
91    {
92        return LOLm_state = newstate;
93    }
94
95    uint32_t LOLm_state;
96    // Emcee end
97
98private:
99    Entity *m_gamenext, *m_drawnext, *m_autonext;
100    int m_ref, m_autorelease, m_destroy;
101};
102
103} /* namespace lol */
104
105#endif // __LOL_ENTITY_H__
106
Note: See TracBrowser for help on using the repository browser.