2019-04-11 22:46:54 +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_CLIENT_PREDICTION_ENTITY_H
|
|
|
|
#define GAME_CLIENT_PREDICTION_ENTITY_H
|
|
|
|
|
|
|
|
#include "gameworld.h"
|
2020-09-26 19:41:58 +00:00
|
|
|
#include <base/vmath.h>
|
2019-04-11 22:46:54 +00:00
|
|
|
|
|
|
|
#define MACRO_ALLOC_HEAP() \
|
2020-09-26 19:41:58 +00:00
|
|
|
public: \
|
2019-04-11 22:46:54 +00:00
|
|
|
void *operator new(size_t Size) \
|
|
|
|
{ \
|
|
|
|
void *p = malloc(Size); \
|
|
|
|
mem_zero(p, Size); \
|
|
|
|
return p; \
|
|
|
|
} \
|
|
|
|
void operator delete(void *pPtr) \
|
|
|
|
{ \
|
|
|
|
free(pPtr); \
|
|
|
|
} \
|
2020-09-26 19:41:58 +00:00
|
|
|
\
|
|
|
|
private:
|
2019-04-11 22:46:54 +00:00
|
|
|
|
|
|
|
class CEntity
|
|
|
|
{
|
|
|
|
MACRO_ALLOC_HEAP()
|
2020-09-26 19:41:58 +00:00
|
|
|
friend class CGameWorld; // entity list handling
|
2019-04-11 22:46:54 +00:00
|
|
|
CEntity *m_pPrevTypeEntity;
|
|
|
|
CEntity *m_pNextTypeEntity;
|
2020-09-26 19:41:58 +00:00
|
|
|
|
2019-04-11 22:46:54 +00:00
|
|
|
protected:
|
|
|
|
class CGameWorld *m_pGameWorld;
|
|
|
|
bool m_MarkedForDestroy;
|
|
|
|
int m_ID;
|
|
|
|
int m_ObjType;
|
2020-09-26 19:41:58 +00:00
|
|
|
|
2019-04-11 22:46:54 +00:00
|
|
|
public:
|
2022-05-28 18:11:16 +00:00
|
|
|
CEntity(CGameWorld *pGameWorld, int Objtype, vec2 Pos = vec2(0, 0), int ProximityRadius = 0);
|
2019-04-11 22:46:54 +00:00
|
|
|
virtual ~CEntity();
|
|
|
|
|
2022-02-13 19:57:27 +00:00
|
|
|
std::vector<SSwitchers> &Switchers() { return m_pGameWorld->Switchers(); }
|
2019-04-11 22:46:54 +00:00
|
|
|
class CGameWorld *GameWorld() { return m_pGameWorld; }
|
|
|
|
CTuningParams *Tuning() { return GameWorld()->Tuning(); }
|
2019-09-08 22:53:07 +00:00
|
|
|
CTuningParams *TuningList() { return GameWorld()->TuningList(); }
|
2019-09-15 22:07:42 +00:00
|
|
|
CTuningParams *GetTuning(int i) { return GameWorld()->GetTuning(i); }
|
2019-04-11 22:46:54 +00:00
|
|
|
class CCollision *Collision() { return GameWorld()->Collision(); }
|
|
|
|
CEntity *TypeNext() { return m_pNextTypeEntity; }
|
|
|
|
CEntity *TypePrev() { return m_pPrevTypeEntity; }
|
2022-05-28 18:11:16 +00:00
|
|
|
float GetProximityRadius() const { return m_ProximityRadius; }
|
2019-04-11 22:46:54 +00:00
|
|
|
|
2022-05-27 22:17:29 +00:00
|
|
|
void Destroy() { delete this; }
|
2019-04-11 22:46:54 +00:00
|
|
|
virtual void Tick() {}
|
|
|
|
virtual void TickDefered() {}
|
|
|
|
|
|
|
|
bool GameLayerClipped(vec2 CheckPos);
|
|
|
|
float m_ProximityRadius;
|
|
|
|
vec2 m_Pos;
|
|
|
|
int m_Number;
|
|
|
|
int m_Layer;
|
|
|
|
|
|
|
|
int m_SnapTicks;
|
|
|
|
int m_DestroyTick;
|
|
|
|
int m_LastRenderTick;
|
|
|
|
CEntity *m_pParent;
|
2022-06-26 08:32:03 +00:00
|
|
|
CEntity *m_pChild;
|
2019-04-11 22:46:54 +00:00
|
|
|
CEntity *NextEntity() { return m_pNextTypeEntity; }
|
|
|
|
int ID() { return m_ID; }
|
2020-09-26 19:41:58 +00:00
|
|
|
void Keep()
|
|
|
|
{
|
|
|
|
m_SnapTicks = 0;
|
|
|
|
m_MarkedForDestroy = false;
|
|
|
|
}
|
2019-04-11 22:46:54 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
CEntity()
|
|
|
|
{
|
|
|
|
m_ID = -1;
|
|
|
|
m_pGameWorld = 0;
|
|
|
|
}
|
2019-04-11 22:46:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|