source: trunk/src/entity.h @ 1768

Last change on this file since 1768 was 1768, checked in by touky, 8 years ago

Added Attachment/base logic with working attachment with EasyCharacterController.
Added RayCastResult & a naïve integration for EasyCharacterController.
Enjoy !

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