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 "gameworld.h"
7
8#include <base/vmath.h>
9
10#include <game/alloc.h>
11
12class CEntity
13{
14 MACRO_ALLOC_HEAP()
15
16private:
17 friend CGameWorld; // entity list handling
18 CEntity *m_pPrevTypeEntity;
19 CEntity *m_pNextTypeEntity;
20
21protected:
22 CGameWorld *m_pGameWorld;
23 bool m_MarkedForDestroy;
24 int m_Id;
25 int m_ObjType;
26
27public:
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 *GlobalTuning() { return &GameWorld()->TuningList()[0]; }
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 virtual bool CanCollide(int ClientId) { return true; }
44
45 virtual void Destroy() { delete this; }
46 virtual void PreTick() {}
47 virtual void Tick() {}
48 virtual void TickDeferred() {}
49
50 bool GameLayerClipped(vec2 CheckPos);
51 float m_ProximityRadius;
52 vec2 m_Pos;
53 int m_Number;
54 int m_Layer;
55
56 int m_SnapTicks;
57 int m_DestroyTick;
58 int m_LastRenderTick;
59 CEntity *m_pParent;
60 CEntity *m_pChild;
61 CEntity *NextEntity() { return m_pNextTypeEntity; }
62 void Keep()
63 {
64 m_SnapTicks = 0;
65 m_MarkedForDestroy = false;
66 }
67
68 CEntity()
69 {
70 m_Id = -1;
71 m_pGameWorld = nullptr;
72 }
73};
74
75#endif
76