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
4#include "entity.h"
5
6#include <game/collision.h>
7
8//////////////////////////////////////////////////
9// Entity
10//////////////////////////////////////////////////
11CEntity::CEntity(CGameWorld *pGameWorld, int ObjType, vec2 Pos, int ProximityRadius)
12{
13 m_pGameWorld = pGameWorld;
14
15 m_ObjType = ObjType;
16 m_Pos = Pos;
17 m_ProximityRadius = ProximityRadius;
18
19 m_MarkedForDestroy = false;
20 m_Id = -1;
21
22 m_pPrevTypeEntity = 0;
23 m_pNextTypeEntity = 0;
24 m_SnapTicks = -1;
25
26 // DDRace
27 m_pParent = nullptr;
28 m_pChild = nullptr;
29 m_DestroyTick = -1;
30 m_LastRenderTick = -1;
31}
32
33CEntity::~CEntity()
34{
35 if(GameWorld())
36 GameWorld()->RemoveEntity(pEntity: this);
37}
38
39bool CEntity::GameLayerClipped(vec2 CheckPos)
40{
41 return round_to_int(f: CheckPos.x) / 32 < -200 || round_to_int(f: CheckPos.x) / 32 > Collision()->GetWidth() + 200 ||
42 round_to_int(f: CheckPos.y) / 32 < -200 || round_to_int(f: CheckPos.y) / 32 > Collision()->GetHeight() + 200;
43}
44