diff --git a/server/gameserver/constant.h b/server/gameserver/constant.h index 6eb6498..62b8e04 100644 --- a/server/gameserver/constant.h +++ b/server/gameserver/constant.h @@ -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; diff --git a/server/gameserver/constant_export.h b/server/gameserver/constant_export.h index 71cfe37..24beb56 100644 --- a/server/gameserver/constant_export.h +++ b/server/gameserver/constant_export.h @@ -106,7 +106,7 @@ enum EntityType_e ET_Bullet = 20, - //ET_Android = 30, + ET_MapBlock = 28, ET_Dummy = 29, ET_Unuse = 30, ET_MAX diff --git a/server/gameserver/dummyentity.h b/server/gameserver/dummyentity.h index 170b622..38c2096 100644 --- a/server/gameserver/dummyentity.h +++ b/server/gameserver/dummyentity.h @@ -7,6 +7,7 @@ namespace metatable class MapBlockJson; } +class MapInstance; class DummyEntity : public Entity { public: diff --git a/server/gameserver/entityfactory.cc b/server/gameserver/entityfactory.cc index e0ccee1..f17c9e4 100644 --- a/server/gameserver/entityfactory.cc +++ b/server/gameserver/entityfactory.cc @@ -11,6 +11,7 @@ #include "car.h" #include "hero.h" #include "dummyentity.h" +#include "mapblock.h" void EntityFactory::Init() { @@ -105,3 +106,11 @@ DummyEntity* EntityFactory::MakeDummy(int entity_uniid) dummy->entity_type_ = ET_Dummy; return dummy; } + +MapBlock* EntityFactory::MakeBlock(int entity_uniid) +{ + MapBlock* p = new MapBlock(); + p->uniid_ = entity_uniid; + p->entity_type_ = ET_MapBlock; + return p; +} diff --git a/server/gameserver/entityfactory.h b/server/gameserver/entityfactory.h index d9f010d..042802a 100644 --- a/server/gameserver/entityfactory.h +++ b/server/gameserver/entityfactory.h @@ -10,6 +10,7 @@ class Player; class Car; class Hero; class DummyEntity; +class MapBlock; class EntityFactory : public a8::Singleton { private: @@ -30,6 +31,7 @@ class EntityFactory : public a8::Singleton Car* MakeCar(int entity_uniid); Hero* MakeHero(int entity_uniid); DummyEntity* MakeDummy(int entity_uniid); + MapBlock* MakeBlock(int entity_uniid); private: }; diff --git a/server/gameserver/mapblock.cc b/server/gameserver/mapblock.cc new file mode 100644 index 0000000..bfa9ead --- /dev/null +++ b/server/gameserver/mapblock.cc @@ -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; +} diff --git a/server/gameserver/mapblock.h b/server/gameserver/mapblock.h new file mode 100644 index 0000000..357ccef --- /dev/null +++ b/server/gameserver/mapblock.h @@ -0,0 +1,52 @@ +#pragma once + +#include "entity.h" + +namespace MetaData +{ + struct MapThing; +} + +namespace metatable +{ + class MapBlockJson; +} + +class Room; +class CircleCollider; +class AabbCollider; +class MapService; +class MapBlock : public Entity +{ + public: + MetaData::MapThing* meta = nullptr; + MapService* permanent_map_service = nullptr; + int shape = 0; + float width = 0; + float height = 0; + float rad = 0; + + 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; +}; diff --git a/server/gameserver/mapinstance.cc b/server/gameserver/mapinstance.cc index 443af9e..640ff9e 100644 --- a/server/gameserver/mapinstance.cc +++ b/server/gameserver/mapinstance.cc @@ -11,11 +11,13 @@ #include "room.h" #include "entityfactory.h" #include "dummyentity.h" +#include "mapblock.h" const int MAP_GRID_WIDTH = 64; void MapInstance::Init() { + current_map_block_uniid_ = MAP_BLOCK_START_ID; map_meta_ = MetaMgr::Instance()->GetMap(map_id); if (!map_meta_) { abort(); @@ -273,6 +275,25 @@ void MapInstance::CreateBlock() dummy->Initialize(); uniid_hash_[dummy->GetUniId()] = dummy; grid_service_->AddPermanentEntity(dummy); + + if (blocks) { + for (auto& obj : *blocks) { + switch (obj.shape()) { + case 1: + { + } + break; + case 2: + { + } + break; + default: + { + } + break; + } + } + } } void MapInstance::CreateMapObject(MetaData::MapTplThing& thing_tpl) @@ -412,3 +433,12 @@ int MapInstance::AllocUniid() } return current_uniid_; } + +MapBlock* MapInstance::InternalCreateMapBlock(int id, float x, float y, + int shape, float width, float height) +{ + MapBlock* p = EntityFactory::Instance()->MakeBlock(++current_map_block_uniid_); + //building->meta = building_meta; + p->permanent_map_service = map_service_; + return p; +} diff --git a/server/gameserver/mapinstance.h b/server/gameserver/mapinstance.h index d56e893..17166c5 100644 --- a/server/gameserver/mapinstance.h +++ b/server/gameserver/mapinstance.h @@ -6,12 +6,18 @@ namespace MetaData struct MapTplThing; } +namespace metatable +{ + class MapBlockJson; +} + class Entity; class Obstacle; class Building; class MapService; class GridService; class Room; +class MapBlock; class MapInstance { @@ -35,10 +41,13 @@ class MapInstance bool no_grid_service = false, int collider_param1 = 0, int collider_param2 = 0); + MapBlock* InternalCreateMapBlock(int id, float x, float y, + int shape, float width, float height); int AllocUniid(); private: int current_uniid_ = 0; + int current_map_block_uniid_ = 0; std::map uniid_hash_; std::string map_tpl_name_;