ddnet/src/game/server/entity.cpp

46 lines
1.1 KiB
C++
Raw Normal View History

2010-11-20 10:37:14 +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. */
2010-05-29 07:25:38 +00:00
#include "entity.h"
#include "gamecontext.h"
//////////////////////////////////////////////////
// Entity
//////////////////////////////////////////////////
2010-05-29 07:25:38 +00:00
CEntity::CEntity(CGameWorld *pGameWorld, int ObjType)
{
2010-05-29 07:25:38 +00:00
m_pGameWorld = pGameWorld;
m_ObjType = ObjType;
2010-05-29 07:25:38 +00:00
m_Pos = vec2(0,0);
m_ProximityRadius = 0;
m_MarkedForDestroy = false;
m_ID = Server()->SnapNewID();
2010-05-29 07:25:38 +00:00
m_pPrevTypeEntity = 0;
m_pNextTypeEntity = 0;
}
2010-05-29 07:25:38 +00:00
CEntity::~CEntity()
{
2010-05-29 07:25:38 +00:00
GameWorld()->RemoveEntity(this);
Server()->SnapFreeID(m_ID);
}
2010-05-29 07:25:38 +00:00
int CEntity::NetworkClipped(int SnappingClient)
{
2010-05-29 07:25:38 +00:00
return NetworkClipped(SnappingClient, m_Pos);
}
2010-05-29 07:25:38 +00:00
int CEntity::NetworkClipped(int SnappingClient, vec2 CheckPos)
{
return 0;
}
bool CEntity::GameLayerClipped(vec2 CheckPos)
{
return round(CheckPos.x)/32 < -200 || round(CheckPos.x)/32 > GameServer()->Collision()->GetWidth()+200 ||
round(CheckPos.y)/32 < -200 || round(CheckPos.y)/32 > GameServer()->Collision()->GetHeight()+200 ? true : false;
}