1
This commit is contained in:
commit
f35c9b7c18
@ -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 float DEFAULT_FLY_DISTANCE = 5.0f;
|
||||||
|
|
||||||
|
const int MAP_BLOCK_START_ID = 1000000000;
|
||||||
|
@ -106,7 +106,7 @@ enum EntityType_e
|
|||||||
|
|
||||||
ET_Bullet = 20,
|
ET_Bullet = 20,
|
||||||
|
|
||||||
//ET_Android = 30,
|
ET_MapBlock = 28,
|
||||||
ET_Dummy = 29,
|
ET_Dummy = 29,
|
||||||
ET_Unuse = 30,
|
ET_Unuse = 30,
|
||||||
ET_MAX
|
ET_MAX
|
||||||
|
@ -7,6 +7,7 @@ namespace metatable
|
|||||||
class MapBlockJson;
|
class MapBlockJson;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class MapInstance;
|
||||||
class DummyEntity : public Entity
|
class DummyEntity : public Entity
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "car.h"
|
#include "car.h"
|
||||||
#include "hero.h"
|
#include "hero.h"
|
||||||
#include "dummyentity.h"
|
#include "dummyentity.h"
|
||||||
|
#include "mapblock.h"
|
||||||
|
|
||||||
void EntityFactory::Init()
|
void EntityFactory::Init()
|
||||||
{
|
{
|
||||||
@ -105,3 +106,11 @@ DummyEntity* EntityFactory::MakeDummy(int entity_uniid)
|
|||||||
dummy->entity_type_ = ET_Dummy;
|
dummy->entity_type_ = ET_Dummy;
|
||||||
return dummy;
|
return dummy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MapBlock* EntityFactory::MakeBlock(int entity_uniid)
|
||||||
|
{
|
||||||
|
MapBlock* p = new MapBlock();
|
||||||
|
p->uniid_ = entity_uniid;
|
||||||
|
p->entity_type_ = ET_MapBlock;
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
@ -10,6 +10,7 @@ class Player;
|
|||||||
class Car;
|
class Car;
|
||||||
class Hero;
|
class Hero;
|
||||||
class DummyEntity;
|
class DummyEntity;
|
||||||
|
class MapBlock;
|
||||||
class EntityFactory : public a8::Singleton<EntityFactory>
|
class EntityFactory : public a8::Singleton<EntityFactory>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@ -30,6 +31,7 @@ class EntityFactory : public a8::Singleton<EntityFactory>
|
|||||||
Car* MakeCar(int entity_uniid);
|
Car* MakeCar(int entity_uniid);
|
||||||
Hero* MakeHero(int entity_uniid);
|
Hero* MakeHero(int entity_uniid);
|
||||||
DummyEntity* MakeDummy(int entity_uniid);
|
DummyEntity* MakeDummy(int entity_uniid);
|
||||||
|
MapBlock* MakeBlock(int entity_uniid);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
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;
|
||||||
|
}
|
52
server/gameserver/mapblock.h
Normal file
52
server/gameserver/mapblock.h
Normal file
@ -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;
|
||||||
|
};
|
@ -11,11 +11,13 @@
|
|||||||
#include "room.h"
|
#include "room.h"
|
||||||
#include "entityfactory.h"
|
#include "entityfactory.h"
|
||||||
#include "dummyentity.h"
|
#include "dummyentity.h"
|
||||||
|
#include "mapblock.h"
|
||||||
|
|
||||||
const int MAP_GRID_WIDTH = 64;
|
const int MAP_GRID_WIDTH = 64;
|
||||||
|
|
||||||
void MapInstance::Init()
|
void MapInstance::Init()
|
||||||
{
|
{
|
||||||
|
current_map_block_uniid_ = MAP_BLOCK_START_ID;
|
||||||
map_meta_ = MetaMgr::Instance()->GetMap(map_id);
|
map_meta_ = MetaMgr::Instance()->GetMap(map_id);
|
||||||
if (!map_meta_) {
|
if (!map_meta_) {
|
||||||
abort();
|
abort();
|
||||||
@ -273,6 +275,25 @@ void MapInstance::CreateBlock()
|
|||||||
dummy->Initialize();
|
dummy->Initialize();
|
||||||
uniid_hash_[dummy->GetUniId()] = dummy;
|
uniid_hash_[dummy->GetUniId()] = dummy;
|
||||||
grid_service_->AddPermanentEntity(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)
|
void MapInstance::CreateMapObject(MetaData::MapTplThing& thing_tpl)
|
||||||
@ -412,3 +433,12 @@ int MapInstance::AllocUniid()
|
|||||||
}
|
}
|
||||||
return current_uniid_;
|
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;
|
||||||
|
}
|
||||||
|
@ -6,12 +6,18 @@ namespace MetaData
|
|||||||
struct MapTplThing;
|
struct MapTplThing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace metatable
|
||||||
|
{
|
||||||
|
class MapBlockJson;
|
||||||
|
}
|
||||||
|
|
||||||
class Entity;
|
class Entity;
|
||||||
class Obstacle;
|
class Obstacle;
|
||||||
class Building;
|
class Building;
|
||||||
class MapService;
|
class MapService;
|
||||||
class GridService;
|
class GridService;
|
||||||
class Room;
|
class Room;
|
||||||
|
class MapBlock;
|
||||||
|
|
||||||
class MapInstance
|
class MapInstance
|
||||||
{
|
{
|
||||||
@ -35,10 +41,13 @@ class MapInstance
|
|||||||
bool no_grid_service = false,
|
bool no_grid_service = false,
|
||||||
int collider_param1 = 0,
|
int collider_param1 = 0,
|
||||||
int collider_param2 = 0);
|
int collider_param2 = 0);
|
||||||
|
MapBlock* InternalCreateMapBlock(int id, float x, float y,
|
||||||
|
int shape, float width, float height);
|
||||||
int AllocUniid();
|
int AllocUniid();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int current_uniid_ = 0;
|
int current_uniid_ = 0;
|
||||||
|
int current_map_block_uniid_ = 0;
|
||||||
std::map<int, Entity*> uniid_hash_;
|
std::map<int, Entity*> uniid_hash_;
|
||||||
|
|
||||||
std::string map_tpl_name_;
|
std::string map_tpl_name_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user