ddnet/src/game/server/entity.h

126 lines
2.9 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. */
#ifndef GAME_SERVER_ENTITY_H
#define GAME_SERVER_ENTITY_H
2010-05-29 07:25:38 +00:00
#include <base/vmath.h>
#include <game/server/gameworld.h>
#include "alloc.h"
/*
Class: Entity
Basic entity class.
*/
2010-05-29 07:25:38 +00:00
class CEntity
{
MACRO_ALLOC_HEAP()
friend class CGameWorld; // entity list handling
2010-05-29 07:25:38 +00:00
CEntity *m_pPrevTypeEntity;
CEntity *m_pNextTypeEntity;
protected:
2013-11-13 12:25:26 +00:00
class CGameWorld *m_pGameWorld;
2010-05-29 07:25:38 +00:00
bool m_MarkedForDestroy;
int m_ID;
int m_ObjType;
public:
2010-05-29 07:25:38 +00:00
CEntity(CGameWorld *pGameWorld, int Objtype);
virtual ~CEntity();
2010-05-29 07:25:38 +00:00
class CGameWorld *GameWorld() { return m_pGameWorld; }
class CGameContext *GameServer() { return GameWorld()->GameServer(); }
class IServer *Server() { return GameWorld()->Server(); }
2010-05-29 07:25:38 +00:00
CEntity *TypeNext() { return m_pNextTypeEntity; }
CEntity *TypePrev() { return m_pPrevTypeEntity; }
/*
Function: destroy
2018-07-10 09:29:02 +00:00
Destroys the entity.
*/
2010-05-29 07:25:38 +00:00
virtual void Destroy() { delete this; }
/*
Function: reset
Called when the game resets the map. Puts the entity
back to it's starting state or perhaps destroys it.
*/
2010-05-29 07:25:38 +00:00
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.
*/
2010-05-29 07:25:38 +00:00
virtual void Tick() {}
/*
Function: tick_defered
Called after all entities tick() function has been called.
*/
2010-05-29 07:25:38 +00:00
virtual void TickDefered() {}
2012-01-09 23:49:31 +00:00
/*
Function: TickPaused
Called when the game is paused, to freeze the state and position of the entity.
*/
virtual void TickPaused() {}
/*
Function: snap
Called when a new snapshot is being generated for a specific
client.
Arguments:
snapping_client - 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.
*/
2010-05-29 07:25:38 +00:00
virtual void Snap(int SnappingClient) {}
/*
Function: networkclipped(int snapping_client)
Performs a series of test to see if a client can see the
entity.
Arguments:
snapping_client - 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.
Returns:
Non-zero if the entity doesn't have to be in the snapshot.
*/
virtual int NetworkClipped(int SnappingClient);
virtual int NetworkClipped(int SnappingClient, vec2 CheckPos);
bool GameLayerClipped(vec2 CheckPos);
/*
Variable: proximity_radius
Contains the physical size of the entity.
*/
2010-05-29 07:25:38 +00:00
float m_ProximityRadius;
/*
Variable: pos
Contains the current posititon of the entity.
*/
2010-05-29 07:25:38 +00:00
vec2 m_Pos;
2011-01-29 00:59:50 +00:00
// DDRace
bool GetNearestAirPos(vec2 Pos, vec2 ColPos, vec2 *pOutPos);
bool GetNearestAirPosPlayer(vec2 PlayerPos, vec2 *OutPos);
int m_Number;
int m_Layer;
};
#endif