mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-13 11:38:19 +00:00
51 lines
1.1 KiB
C++
51 lines
1.1 KiB
C++
|
|
#include "entity.h"
|
|
#include "gamecontext.h"
|
|
|
|
//////////////////////////////////////////////////
|
|
// Entity
|
|
//////////////////////////////////////////////////
|
|
CEntity::CEntity(CGameWorld *pGameWorld, int ObjType)
|
|
{
|
|
m_pGameWorld = pGameWorld;
|
|
|
|
m_Objtype = ObjType;
|
|
m_Pos = vec2(0,0);
|
|
m_ProximityRadius = 0;
|
|
|
|
m_MarkedForDestroy = false;
|
|
m_Id = Server()->SnapNewID();
|
|
|
|
m_pNextEntity = 0;
|
|
m_pPrevEntity = 0;
|
|
m_pPrevTypeEntity = 0;
|
|
m_pNextTypeEntity = 0;
|
|
}
|
|
|
|
CEntity::~CEntity()
|
|
{
|
|
GameWorld()->RemoveEntity(this);
|
|
Server()->SnapFreeID(m_Id);
|
|
}
|
|
|
|
int CEntity::NetworkClipped(int SnappingClient)
|
|
{
|
|
return NetworkClipped(SnappingClient, m_Pos);
|
|
}
|
|
|
|
int CEntity::NetworkClipped(int SnappingClient, vec2 CheckPos)
|
|
{
|
|
if(SnappingClient == -1)
|
|
return 0;
|
|
|
|
float dx = GameServer()->m_apPlayers[SnappingClient]->m_ViewPos.x-CheckPos.x;
|
|
float dy = GameServer()->m_apPlayers[SnappingClient]->m_ViewPos.y-CheckPos.y;
|
|
|
|
if(absolute(dx) > 1000.0f || absolute(dy) > 800.0f)
|
|
return 1;
|
|
|
|
if(distance(GameServer()->m_apPlayers[SnappingClient]->m_ViewPos, CheckPos) > 1100.0f)
|
|
return 1;
|
|
return 0;
|
|
}
|