source: trunk/src/entity.h @ 1687

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

core: move some of the camera view logic from the Video class to the
Scene and Camera classes.

  • 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        // Must be the last element
50        GAMEGROUP_END
51    }
52    m_gamegroup;
53
54    enum
55    {
56        DRAWGROUP_BEFORE = GAMEGROUP_END,
57        DRAWGROUP_CAMERA,
58        DRAWGROUP_DEFAULT,
59        DRAWGROUP_HUD,
60        DRAWGROUP_CAPTURE,
61        // Must be the last element
62        DRAWGROUP_END
63    }
64    m_drawgroup;
65
66    static int const GAMEGROUP_BEGIN = 0;
67    static int const DRAWGROUP_BEGIN = GAMEGROUP_END;
68    static int const ALLGROUP_END = DRAWGROUP_END;
69
70#if !LOL_RELEASE
71    enum
72    {
73        STATE_IDLE = 0,
74        STATE_PRETICK_GAME,
75        STATE_POSTTICK_GAME,
76        STATE_PRETICK_DRAW,
77        STATE_POSTTICK_DRAW,
78    }
79    m_tickstate;
80#endif
81
82    // Emcee begin
83private:
84    void SetState(uint32_t newstate);
85    void SetStateWhenMatch(uint32_t newstate,
86                           Entity *other_entity, uint32_t other_state);
87    virtual uint32_t OnStateChanged(uint32_t newstate)
88    {
89        return LOLm_state = newstate;
90    }
91
92    uint32_t LOLm_state;
93    // Emcee end
94
95private:
96    Entity *m_gamenext, *m_drawnext, *m_autonext;
97    int m_ref, m_autorelease, m_destroy;
98};
99
100} /* namespace lol */
101
102#endif // __LOL_ENTITY_H__
103
Note: See TracBrowser for help on using the repository browser.