source: trunk/src/entity.h @ 1105

Last change on this file since 1105 was 1105, checked in by sam, 11 years ago

core: start working on the Emcee class.

  • 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
33protected:
34    Entity();
35    virtual ~Entity();
36
37    virtual char const *GetName();
38    inline int IsDestroying() { return destroy; }
39
40    virtual void TickGame(float deltams);
41    virtual void TickDraw(float deltams);
42
43    enum
44    {
45        GAMEGROUP_BEFORE = 0,
46        GAMEGROUP_DEFAULT,
47        GAMEGROUP_AFTER,
48        // Must be the last element
49        GAMEGROUP_END
50    }
51    gamegroup;
52
53    enum
54    {
55        DRAWGROUP_BEFORE = GAMEGROUP_END,
56        DRAWGROUP_DEFAULT,
57        DRAWGROUP_HUD,
58        DRAWGROUP_CAPTURE,
59        // Must be the last element
60        DRAWGROUP_END
61    }
62    drawgroup;
63
64    static int const GAMEGROUP_BEGIN = 0;
65    static int const DRAWGROUP_BEGIN = GAMEGROUP_END;
66    static int const ALLGROUP_END = DRAWGROUP_END;
67
68#if !LOL_RELEASE
69    enum
70    {
71        STATE_IDLE = 0,
72        STATE_PRETICK_GAME,
73        STATE_POSTTICK_GAME,
74        STATE_PRETICK_DRAW,
75        STATE_POSTTICK_DRAW,
76    }
77    state;
78#endif
79
80    // Emcee begin
81private:
82    void SetState(uint32_t newstate);
83    void SetStateWhenMatch(uint32_t newstate,
84                           Entity *other_entity, uint32_t other_state);
85    virtual uint32_t OnStateChanged(uint32_t newstate)
86    {
87        return m_state = newstate;
88    }
89
90    uint32_t m_state;
91    // Emcee end
92
93private:
94    Entity *gamenext, *drawnext, *autonext;
95    int ref, autorelease, destroy;
96};
97
98} /* namespace lol */
99
100#endif // __LOL_ENTITY_H__
101
Note: See TracBrowser for help on using the repository browser.