mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-11 02:28:18 +00:00
47 lines
1.4 KiB
C++
47 lines
1.4 KiB
C++
|
/*#include <game/server/gamecontext.h>
|
||
|
#include "character.h"
|
||
|
#include "flag.h"
|
||
|
|
||
|
CFlag::CFlag(CGameWorld *pGameWorld, int Team, vec2 Pos, CCharacter *pOwner)
|
||
|
: CEntity(pGameWorld, NETOBJTYPE_FLAG)
|
||
|
{
|
||
|
m_Team = Team;
|
||
|
m_Pos = Pos;
|
||
|
m_ProximityRadius = m_PhysSize;
|
||
|
m_pCarryingCCharacter = pOwner;
|
||
|
|
||
|
GameServer()->m_World.InsertEntity(this);
|
||
|
}
|
||
|
|
||
|
void CFlag::Reset()
|
||
|
{
|
||
|
if(!m_pCarryingCCharacter)
|
||
|
return;
|
||
|
|
||
|
GameServer()->m_World.DestroyEntity(this);
|
||
|
}
|
||
|
|
||
|
void CFlag::Tick()
|
||
|
{
|
||
|
if(m_pCarryingCCharacter)
|
||
|
m_Pos = m_pCarryingCCharacter->m_Pos;
|
||
|
}
|
||
|
|
||
|
void CFlag::Snap(int SnappingClient)
|
||
|
{
|
||
|
if((!m_pCarryingCCharacter && GameServer()->m_apPlayers[SnappingClient]->GetTeam() != m_Team && GameServer()->m_apPlayers[SnappingClient]->GetCharacter() && GameServer()->m_apPlayers[SnappingClient]->GetCharacter()->m_RaceState == CCharacter::RACE_STARTED)
|
||
|
||(m_pCarryingCCharacter && !GameServer()->m_apPlayers[SnappingClient]->m_ShowOthers && SnappingClient != m_pCarryingCCharacter->GetPlayer()->GetCID()))
|
||
|
return;
|
||
|
|
||
|
CNetObj_Flag *pFlag = (CNetObj_Flag *)Server()->SnapNewItem(NETOBJTYPE_FLAG, m_Id, sizeof(CNetObj_Flag));
|
||
|
pFlag->m_X = (int)m_Pos.x;
|
||
|
pFlag->m_Y = (int)m_Pos.y;
|
||
|
pFlag->m_Team = m_Team;
|
||
|
pFlag->m_CarriedBy = -1;
|
||
|
|
||
|
if(!m_pCarryingCCharacter)
|
||
|
pFlag->m_CarriedBy = -2;
|
||
|
else if(m_pCarryingCCharacter && m_pCarryingCCharacter->GetPlayer())
|
||
|
pFlag->m_CarriedBy = m_pCarryingCCharacter->GetPlayer()->GetCID();
|
||
|
}*/
|