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 const vec2 &GetPos() const { return m_Pos; }
40 float GetProximityRadius() const { return m_ProximityRadius; }
41 virtual bool CanCollide(int ClientId) { return true; }
42
43 virtual void Destroy() { delete this; }
44 virtual void PreTick() {}
45 virtual void Tick() {}
46 virtual void TickDeferred() {}
47
48 bool GameLayerClipped(vec2 CheckPos);
49 float m_ProximityRadius;
50 vec2 m_Pos;
51 int m_Number;
52 int m_Layer;
53
54 int m_SnapTicks;
55 int m_DestroyTick;
56 int m_LastRenderTick;
57 CEntity *m_pParent;
58 CEntity *m_pChild;
59 CEntity *NextEntity() { return m_pNextTypeEntity; }
60 void Keep()
61 {
62 m_SnapTicks = 0;
63 m_MarkedForDestroy = false;
64 }
65
66 CEntity()
67 {
68 m_Id = -1;
69 m_pGameWorld = nullptr;
70 }
71};
72
73#endif
74