87 lines
2.0 KiB
C++
87 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include "gridservice.h"
|
|
#include "room.h"
|
|
|
|
namespace cs
|
|
{
|
|
class MFObjectPart;
|
|
class MFObjectFull;
|
|
}
|
|
|
|
class Room;
|
|
class Obstacle;
|
|
class ColliderComponent;
|
|
class AabbCollider;
|
|
class CircleCollider;
|
|
class Entity
|
|
{
|
|
public:
|
|
int entity_uniid = 0;
|
|
EntityType_e entity_type = ET_None;
|
|
EntitySubType_e entity_subtype = EST_None;
|
|
long long create_frameno = 0;
|
|
Room* room = nullptr;
|
|
int updated_times = 0;
|
|
bool deleted = false;
|
|
a8::XTimerAttacher xtimer_attacher;
|
|
bool dead = false;
|
|
long long dead_frameno = 0;
|
|
|
|
int grid_id = 0;
|
|
std::set<GridCell*> grid_list;
|
|
Entity* last_collision_door = nullptr;
|
|
|
|
Entity();
|
|
virtual ~Entity();
|
|
virtual void Initialize();
|
|
virtual void Update(int delta_time) {};
|
|
virtual void FillMFObjectPart(cs::MFObjectPart* part_data) {};
|
|
virtual void FillMFObjectFull(cs::MFObjectFull* full_data) {};
|
|
virtual float GetSpeed() { return 1.0f;};
|
|
virtual void GetAabbBox(AabbCollider& aabb_box);
|
|
virtual void GetCircleBox(CircleCollider& circle_box);
|
|
bool TestCollision(Entity* b);
|
|
bool TestCollision(ColliderComponent* b);
|
|
bool TestCollisionEx(const a8::Vec2& aabb_pos, AabbCollider& aabb_box);
|
|
void BroadcastFullState();
|
|
void BroadcastDeleteState();
|
|
void AddCollider(ColliderComponent* collider);
|
|
a8::Vec2 GetPos() { return pos_; };
|
|
void SetPos(a8::Vec2 pos)
|
|
{
|
|
#if 0
|
|
if (room && entity_subtype == EST_Player) {
|
|
if (room->frame_no > SERVER_FRAME_RATE * 35) {
|
|
if (pos.Distance(pos_) > 500) {
|
|
abort();
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
pos_ = pos;
|
|
}
|
|
float GetX()
|
|
{
|
|
return pos_.x;
|
|
}
|
|
float GetY()
|
|
{
|
|
return pos_.y;
|
|
}
|
|
void SetX(float x)
|
|
{
|
|
pos_.x = x;
|
|
}
|
|
void SetY(float y)
|
|
{
|
|
pos_.y = y;
|
|
}
|
|
|
|
private:
|
|
a8::Vec2 pos_;
|
|
std::list<ColliderComponent*> colliders;
|
|
|
|
void ClearColliders();
|
|
};
|