add mapblock
This commit is contained in:
parent
e666cd558b
commit
d0975b1701
@ -512,3 +512,4 @@ const long long SPEC_MAP_OBJECT_FLAGS = A8_DEFINE_RANGE_BIT(long long, kCollider
|
||||
|
||||
const float DEFAULT_FLY_DISTANCE = 5.0f;
|
||||
|
||||
const int MAP_BLOCK_START_ID = 1000000000;
|
||||
|
@ -106,7 +106,7 @@ enum EntityType_e
|
||||
|
||||
ET_Bullet = 20,
|
||||
|
||||
//ET_Android = 30,
|
||||
ET_MapBlock = 28,
|
||||
ET_Dummy = 29,
|
||||
ET_Unuse = 30,
|
||||
ET_MAX
|
||||
|
@ -44,3 +44,70 @@ void DummyEntity::Initialize()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DummyEntity::ScatterObstacle(MapInstance* map_instance)
|
||||
{
|
||||
if (blocks) {
|
||||
for (auto& obj : *blocks) {
|
||||
switch (obj.shape()) {
|
||||
case 1:
|
||||
{
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma once
|
||||
|
||||
class Entity;
|
||||
class Human;
|
||||
class Bullet;
|
||||
class Room;
|
||||
class Creature;
|
||||
|
||||
class GridCell
|
||||
{
|
||||
public:
|
||||
|
||||
GridCell();
|
||||
void ClearRoomData(Room* room);
|
||||
|
||||
void TraverseHumanList(std::function<void (Human*, bool&)> func,
|
||||
int room_idx,
|
||||
bool& stop);
|
||||
void TraverseCreatures(std::function<void (Creature*, bool&)>& func,
|
||||
int room_idx,
|
||||
bool& stop);
|
||||
|
||||
void AddCreature(Creature* c);
|
||||
void RemoveCreature(Creature* c);
|
||||
bool CreatureExists(Creature* c);
|
||||
void AddBullet(Bullet* bullet);
|
||||
void RemoveBullet(Bullet* bullet);
|
||||
void AddPermanentEntity(Entity* entity);
|
||||
void AddRoomEntity(Room* room, Entity* entity);
|
||||
void RemoveRoomEntity(Room* room, Entity* entity);
|
||||
bool EntityExists(Room* room, Entity* Entity);
|
||||
void TraverseLayer0EntityList(std::function<void (Entity*, bool&)>& func,
|
||||
bool& stop);
|
||||
void TraverseLayer1EntityList(std::function<void (Entity*, bool&)>& func,
|
||||
int room_idx,
|
||||
bool& stop);
|
||||
void TraverseAllLayerEntityList(std::function<void (Entity*, bool&)>& func,
|
||||
int room_idx,
|
||||
bool& stop);
|
||||
|
||||
private:
|
||||
std::vector<std::set<Entity*>> entitys_;
|
||||
std::vector<std::set<Bullet*>> bullets_;
|
||||
std::vector<std::set<Creature*>> creatures_;
|
||||
};
|
||||
|
@ -7,6 +7,7 @@ namespace metatable
|
||||
class MapBlockJson;
|
||||
}
|
||||
|
||||
class MapInstance;
|
||||
class DummyEntity : public Entity
|
||||
{
|
||||
public:
|
||||
@ -14,4 +15,5 @@ class DummyEntity : public Entity
|
||||
std::list<metatable::MapBlockJson>* blocks = nullptr;
|
||||
|
||||
virtual void Initialize() override;
|
||||
void ScatterObstacle(MapInstance* map_instance);
|
||||
};
|
||||
|
78
server/gameserver/mapblock.cc
Normal file
78
server/gameserver/mapblock.cc
Normal file
@ -0,0 +1,78 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include "mapblock.h"
|
||||
|
||||
MapBlock::MapBlock()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
MapBlock::~MapBlock()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MapBlock::Initialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MapBlock::RecalcSelfCollider()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MapBlock::FillMFObjectPart(Room* room, Human* hum, cs::MFObjectPart* part_data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MapBlock::FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MapBlock::GetAabbBox(AabbCollider& aabb_box)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MapBlock::GetCircleBox(CircleCollider& circle_box)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool MapBlock::IsDead(Room* room)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
long long MapBlock::GetDeadFrameNo(Room* room)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MapBlock::OnPreCollision(Room* room)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MapBlock::OnBulletHit(Bullet* bullet)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MapBlock::OnExplosionHit(Explosion* explosion)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool MapBlock::Attackable(Room* room)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MapBlock::ReceiveExplosionDmg(Explosion* explosion)
|
||||
{
|
||||
return false;
|
||||
}
|
42
server/gameserver/mapblock.h
Normal file
42
server/gameserver/mapblock.h
Normal file
@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include "entity.h"
|
||||
|
||||
namespace MetaData
|
||||
{
|
||||
struct MapThing;
|
||||
}
|
||||
|
||||
class Room;
|
||||
class CircleCollider;
|
||||
class AabbCollider;
|
||||
class MapBlock : public Entity
|
||||
{
|
||||
public:
|
||||
MetaData::MapThing* meta = nullptr;
|
||||
MapService* permanent_map_service = nullptr;
|
||||
|
||||
virtual ~MapBlock() override;
|
||||
virtual void Initialize() override;
|
||||
virtual void RecalcSelfCollider();
|
||||
virtual void FillMFObjectPart(Room* room, Human* hum, cs::MFObjectPart* part_data) override;
|
||||
virtual void FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data) override;
|
||||
virtual void GetAabbBox(AabbCollider& aabb_box) override;
|
||||
virtual void GetCircleBox(CircleCollider& circle_box) override;
|
||||
virtual bool IsDead(Room* room) override;
|
||||
virtual long long GetDeadFrameNo(Room* room) override;
|
||||
virtual void OnPreCollision(Room* room) override;
|
||||
virtual void OnBulletHit(Bullet* bullet) override;
|
||||
virtual void OnExplosionHit(Explosion* explosion) override;
|
||||
virtual bool Attackable(Room* room) override;
|
||||
virtual bool ReceiveExplosionDmg(Explosion* explosion) override;
|
||||
|
||||
protected:
|
||||
MapBlock();
|
||||
|
||||
protected:
|
||||
CircleCollider* self_collider_ = nullptr;
|
||||
AabbCollider* self_collider2_ = nullptr;
|
||||
|
||||
friend class EntityFactory;
|
||||
};
|
@ -273,6 +273,8 @@ void MapInstance::CreateBlock()
|
||||
dummy->Initialize();
|
||||
uniid_hash_[dummy->GetUniId()] = dummy;
|
||||
grid_service_->AddPermanentEntity(dummy);
|
||||
|
||||
dummy->ScatterObstacle(this);
|
||||
}
|
||||
|
||||
void MapInstance::CreateMapObject(MetaData::MapTplThing& thing_tpl)
|
||||
|
Loading…
x
Reference in New Issue
Block a user