mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Entity: Add API changes from the upstream
The upstream restricted access to the class member.
Keep the some protected API as public and some private API as protected
for now to avoid massive changes in a hundreds places (related to m_Pos).
See upstream commit e86a486688
.
This commit is contained in:
parent
476c2c60d7
commit
b865306b56
|
@ -8,13 +8,13 @@
|
|||
//////////////////////////////////////////////////
|
||||
// Entity
|
||||
//////////////////////////////////////////////////
|
||||
CEntity::CEntity(CGameWorld *pGameWorld, int ObjType)
|
||||
CEntity::CEntity(CGameWorld *pGameWorld, int ObjType, vec2 Pos, int ProximityRadius)
|
||||
{
|
||||
m_pGameWorld = pGameWorld;
|
||||
|
||||
m_ObjType = ObjType;
|
||||
m_Pos = vec2(0, 0);
|
||||
m_ProximityRadius = 0;
|
||||
m_Pos = Pos;
|
||||
m_ProximityRadius = ProximityRadius;
|
||||
|
||||
m_MarkedForDestroy = false;
|
||||
m_ID = Server()->SnapNewID();
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
#define GAME_SERVER_ENTITY_H
|
||||
|
||||
#include <base/vmath.h>
|
||||
#include <game/server/gameworld.h>
|
||||
|
||||
#include "alloc.h"
|
||||
#include "gameworld.h"
|
||||
|
||||
/*
|
||||
Class: Entity
|
||||
|
@ -16,50 +16,86 @@ class CEntity
|
|||
{
|
||||
MACRO_ALLOC_HEAP()
|
||||
|
||||
private:
|
||||
friend class CGameWorld; // entity list handling
|
||||
CEntity *m_pPrevTypeEntity;
|
||||
CEntity *m_pNextTypeEntity;
|
||||
|
||||
protected:
|
||||
/* Identity */
|
||||
class CGameWorld *m_pGameWorld;
|
||||
bool m_MarkedForDestroy;
|
||||
|
||||
int m_ID;
|
||||
int m_ObjType;
|
||||
|
||||
public:
|
||||
CEntity(CGameWorld *pGameWorld, int Objtype);
|
||||
virtual ~CEntity();
|
||||
/*
|
||||
Variable: m_ProximityRadius
|
||||
Contains the physical size of the entity.
|
||||
*/
|
||||
float m_ProximityRadius;
|
||||
|
||||
class CGameWorld *GameWorld() { return m_pGameWorld; }
|
||||
class CGameContext *GameServer() { return GameWorld()->GameServer(); }
|
||||
class IServer *Server() { return GameWorld()->Server(); }
|
||||
/* State */
|
||||
bool m_MarkedForDestroy;
|
||||
|
||||
CEntity *TypeNext() { return m_pNextTypeEntity; }
|
||||
CEntity *TypePrev() { return m_pPrevTypeEntity; }
|
||||
public: // TODO: Maybe make protected
|
||||
/* State */
|
||||
|
||||
/*
|
||||
Function: destroy
|
||||
Variable: m_Pos
|
||||
Contains the current posititon of the entity.
|
||||
*/
|
||||
vec2 m_Pos;
|
||||
|
||||
/* Getters */
|
||||
int GetID() const { return m_ID; }
|
||||
|
||||
public:
|
||||
/* Constructor */
|
||||
CEntity(CGameWorld *pGameWorld, int Objtype, vec2 Pos = vec2(0, 0), int ProximityRadius = 0);
|
||||
|
||||
/* Destructor */
|
||||
virtual ~CEntity();
|
||||
|
||||
/* Objects */
|
||||
class CGameWorld *GameWorld() { return m_pGameWorld; }
|
||||
class CGameContext *GameServer() { return m_pGameWorld->GameServer(); }
|
||||
class IServer *Server() { return m_pGameWorld->Server(); }
|
||||
|
||||
/* Getters */
|
||||
CEntity *TypeNext() { return m_pNextTypeEntity; }
|
||||
CEntity *TypePrev() { return m_pPrevTypeEntity; }
|
||||
const vec2 &GetPos() const { return m_Pos; }
|
||||
float GetProximityRadius() const { return m_ProximityRadius; }
|
||||
bool IsMarkedForDestroy() const { return m_MarkedForDestroy; }
|
||||
|
||||
/* Setters */
|
||||
void MarkForDestroy() { m_MarkedForDestroy = true; }
|
||||
|
||||
/* Other functions */
|
||||
|
||||
/*
|
||||
Function: Destroy
|
||||
Destroys the entity.
|
||||
*/
|
||||
virtual void Destroy() { delete this; }
|
||||
|
||||
/*
|
||||
Function: reset
|
||||
Function: Reset
|
||||
Called when the game resets the map. Puts the entity
|
||||
back to it's starting state or perhaps destroys it.
|
||||
back to its starting state or perhaps destroys it.
|
||||
*/
|
||||
virtual void Reset() {}
|
||||
|
||||
/*
|
||||
Function: tick
|
||||
Called progress the entity to the next tick. Updates
|
||||
and moves the entity to it's new state and position.
|
||||
Function: Tick
|
||||
Called to progress the entity to the next tick. Updates
|
||||
and moves the entity to its new state and position.
|
||||
*/
|
||||
virtual void Tick() {}
|
||||
|
||||
/*
|
||||
Function: tick_defered
|
||||
Called after all entities tick() function has been called.
|
||||
Function: TickDefered
|
||||
Called after all entities Tick() function has been called.
|
||||
*/
|
||||
virtual void TickDefered() {}
|
||||
|
||||
|
@ -70,12 +106,12 @@ public:
|
|||
virtual void TickPaused() {}
|
||||
|
||||
/*
|
||||
Function: snap
|
||||
Function: Snap
|
||||
Called when a new snapshot is being generated for a specific
|
||||
client.
|
||||
|
||||
Arguments:
|
||||
snapping_client - ID of the client which snapshot is
|
||||
SnappingClient - ID of the client which snapshot is
|
||||
being generated. Could be -1 to create a complete
|
||||
snapshot of everything in the game for demo
|
||||
recording.
|
||||
|
@ -88,7 +124,7 @@ public:
|
|||
entity.
|
||||
|
||||
Arguments:
|
||||
snapping_client - ID of the client which snapshot is
|
||||
SnappingClient - ID of the client which snapshot is
|
||||
being generated. Could be -1 to create a complete
|
||||
snapshot of everything in the game for demo
|
||||
recording.
|
||||
|
@ -101,18 +137,6 @@ public:
|
|||
|
||||
bool GameLayerClipped(vec2 CheckPos);
|
||||
|
||||
/*
|
||||
Variable: proximity_radius
|
||||
Contains the physical size of the entity.
|
||||
*/
|
||||
float m_ProximityRadius;
|
||||
|
||||
/*
|
||||
Variable: pos
|
||||
Contains the current posititon of the entity.
|
||||
*/
|
||||
vec2 m_Pos;
|
||||
|
||||
// DDRace
|
||||
|
||||
bool GetNearestAirPos(vec2 Pos, vec2 ColPos, vec2 *pOutPos);
|
||||
|
|
|
@ -83,7 +83,7 @@ void IGameController::EvaluateSpawnType(CSpawnEval *pEval, int Type)
|
|||
break;
|
||||
for(int c = 0; c < Num; ++c)
|
||||
if(GameServer()->Collision()->CheckPoint(m_aaSpawnPoints[Type][i] + Positions[Index]) ||
|
||||
distance(aEnts[c]->m_Pos, m_aaSpawnPoints[Type][i] + Positions[Index]) <= aEnts[c]->m_ProximityRadius)
|
||||
distance(aEnts[c]->m_Pos, m_aaSpawnPoints[Type][i] + Positions[Index]) <= aEnts[c]->GetProximityRadius())
|
||||
{
|
||||
Result = -1;
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue