2019-04-11 22:46:54 +00:00
|
|
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
|
|
|
|
|
|
|
#include "entity.h"
|
|
|
|
|
2022-06-16 16:06:35 +00:00
|
|
|
#include <game/collision.h>
|
|
|
|
|
2019-04-11 22:46:54 +00:00
|
|
|
//////////////////////////////////////////////////
|
|
|
|
// Entity
|
|
|
|
//////////////////////////////////////////////////
|
2022-05-28 18:11:16 +00:00
|
|
|
CEntity::CEntity(CGameWorld *pGameWorld, int ObjType, vec2 Pos, int ProximityRadius)
|
2019-04-11 22:46:54 +00:00
|
|
|
{
|
|
|
|
m_pGameWorld = pGameWorld;
|
|
|
|
|
|
|
|
m_ObjType = ObjType;
|
2022-05-28 18:11:16 +00:00
|
|
|
m_Pos = Pos;
|
|
|
|
m_ProximityRadius = ProximityRadius;
|
2019-04-11 22:46:54 +00:00
|
|
|
|
|
|
|
m_MarkedForDestroy = false;
|
|
|
|
m_ID = -1;
|
|
|
|
|
|
|
|
m_pPrevTypeEntity = 0;
|
|
|
|
m_pNextTypeEntity = 0;
|
|
|
|
m_SnapTicks = -1;
|
|
|
|
|
|
|
|
// DDRace
|
2022-06-26 08:32:03 +00:00
|
|
|
m_pParent = nullptr;
|
|
|
|
m_pChild = nullptr;
|
2019-04-11 22:46:54 +00:00
|
|
|
m_DestroyTick = -1;
|
|
|
|
m_LastRenderTick = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
CEntity::~CEntity()
|
|
|
|
{
|
|
|
|
if(GameWorld())
|
|
|
|
GameWorld()->RemoveEntity(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CEntity::GameLayerClipped(vec2 CheckPos)
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
return round_to_int(CheckPos.x) / 32 < -200 || round_to_int(CheckPos.x) / 32 > Collision()->GetWidth() + 200 ||
|
2022-01-22 16:34:23 +00:00
|
|
|
round_to_int(CheckPos.y) / 32 < -200 || round_to_int(CheckPos.y) / 32 > Collision()->GetHeight() + 200;
|
2019-04-11 22:46:54 +00:00
|
|
|
}
|