1 | /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ |
---|---|
2 | /* If you are missing that file, acquire a complete release at teeworlds.com. */ |
3 | #ifndef GAME_CLIENT_PREDICTION_ENTITY_H |
4 | #define GAME_CLIENT_PREDICTION_ENTITY_H |
5 | |
6 | #include <base/vmath.h> |
7 | |
8 | #include <game/alloc.h> |
9 | |
10 | #include "gameworld.h" |
11 | |
12 | class CEntity |
13 | { |
14 | MACRO_ALLOC_HEAP() |
15 | |
16 | private: |
17 | friend CGameWorld; // entity list handling |
18 | CEntity *m_pPrevTypeEntity; |
19 | CEntity *m_pNextTypeEntity; |
20 | |
21 | protected: |
22 | CGameWorld *m_pGameWorld; |
23 | bool m_MarkedForDestroy; |
24 | int m_Id; |
25 | int m_ObjType; |
26 | |
27 | public: |
28 | int GetId() const { return m_Id; } |
29 | |
30 | CEntity(CGameWorld *pGameWorld, int Objtype, vec2 Pos = vec2(0, 0), int ProximityRadius = 0); |
31 | virtual ~CEntity(); |
32 | |
33 | std::vector<SSwitchers> &Switchers() { return m_pGameWorld->Switchers(); } |
34 | CGameWorld *GameWorld() { return m_pGameWorld; } |
35 | CTuningParams *Tuning() { return GameWorld()->Tuning(); } |
36 | CTuningParams *TuningList() { return GameWorld()->TuningList(); } |
37 | CTuningParams *GetTuning(int i) { return GameWorld()->GetTuning(i); } |
38 | class CCollision *Collision() { return GameWorld()->Collision(); } |
39 | CEntity *TypeNext() { return m_pNextTypeEntity; } |
40 | CEntity *TypePrev() { return m_pPrevTypeEntity; } |
41 | const vec2 &GetPos() const { return m_Pos; } |
42 | float GetProximityRadius() const { return m_ProximityRadius; } |
43 | |
44 | void Destroy() { delete this; } |
45 | virtual void PreTick() {} |
46 | virtual void Tick() {} |
47 | virtual void TickDeferred() {} |
48 | |
49 | bool GameLayerClipped(vec2 CheckPos); |
50 | float m_ProximityRadius; |
51 | vec2 m_Pos; |
52 | int m_Number; |
53 | int m_Layer; |
54 | |
55 | int m_SnapTicks; |
56 | int m_DestroyTick; |
57 | int m_LastRenderTick; |
58 | CEntity *m_pParent; |
59 | CEntity *m_pChild; |
60 | CEntity *NextEntity() { return m_pNextTypeEntity; } |
61 | void Keep() |
62 | { |
63 | m_SnapTicks = 0; |
64 | m_MarkedForDestroy = false; |
65 | } |
66 | |
67 | CEntity() |
68 | { |
69 | m_Id = -1; |
70 | m_pGameWorld = 0; |
71 | } |
72 | }; |
73 | |
74 | #endif |
75 |