1
This commit is contained in:
parent
3fc0c50c98
commit
5466fdc96b
@ -66,6 +66,9 @@ void Building::RecalcSelfCollider()
|
||||
Obstacle* entity = new Obstacle();
|
||||
entity->room = room;
|
||||
entity->meta = thing;
|
||||
#if 1
|
||||
entity->building = this;
|
||||
#endif
|
||||
entity->entity_uniid = room->AllocUniid();
|
||||
entity->pos = Vector2D(pos.x + obj.x() - meta->i->tilewidth() / 2.0,
|
||||
pos.y + obj.y() - meta->i->tileheight() / 2.0);
|
||||
|
@ -16,6 +16,7 @@ class Building : public Entity
|
||||
{
|
||||
public:
|
||||
MetaData::Building* meta = nullptr;
|
||||
int building_id = 0;
|
||||
|
||||
Building();
|
||||
virtual ~Building() override;
|
||||
|
@ -15,7 +15,7 @@ namespace MetaData
|
||||
std::vector<std::string> strings2;
|
||||
a8::Split(str, strings2, ':');
|
||||
assert(strings2.size() == 2);
|
||||
rand_space += a8::XValue(strings[1]).GetInt();
|
||||
rand_space += a8::XValue(strings2[1]).GetInt();
|
||||
template_list.push_back(std::make_tuple(
|
||||
strings2[0],
|
||||
rand_space
|
||||
@ -26,7 +26,7 @@ namespace MetaData
|
||||
|
||||
std::string Map::RandTemplate()
|
||||
{
|
||||
if (rand_space > 0) {
|
||||
if (rand_space <= 0) {
|
||||
return "";
|
||||
}
|
||||
int rnd = rand() % rand_space;
|
||||
|
@ -86,6 +86,8 @@ private:
|
||||
if (itr == maptpl_meta_hash.end()) {
|
||||
maptpl_meta_hash[std::get<0>(tuple)] = std::list<metatable::MapTplThingJson>();
|
||||
itr = maptpl_meta_hash.find(std::get<0>(tuple));
|
||||
} else {
|
||||
itr->second.clear();
|
||||
}
|
||||
f8::ReadJsonMetaFile(res_path + std::get<0>(tuple) + ".json", itr->second);
|
||||
}
|
||||
|
@ -411,6 +411,7 @@ void Room::CreateThings()
|
||||
Building* entity = new Building();
|
||||
entity->room = this;
|
||||
entity->meta = building_meta;
|
||||
entity->building_id = thing_id;
|
||||
entity->entity_uniid = AllocUniid();
|
||||
entity->pos = Vector2D(thing_tpl.i->x(), thing_tpl.i->y());
|
||||
entity->Initialize();
|
||||
@ -439,6 +440,37 @@ void Room::CreateThings()
|
||||
}
|
||||
}
|
||||
|
||||
void Room::FillSMMapInfo(cs::SMMapInfo& map_info)
|
||||
{
|
||||
for (auto& pair :uniid_hash_) {
|
||||
switch (pair.second->entity_type) {
|
||||
case ET_Obstacle:
|
||||
{
|
||||
Obstacle* entity = (Obstacle*)pair.second;
|
||||
if (!entity->building) {
|
||||
cs::MFMapObject* p = map_info.add_objects();
|
||||
p->set_object_id(entity->meta->i->thing_id());
|
||||
entity->pos.ToPB(p->mutable_pos());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ET_Building:
|
||||
{
|
||||
Building* entity = (Building*)pair.second;
|
||||
cs::MFMapObject* p = map_info.add_objects();
|
||||
p->set_object_id(entity->building_id);
|
||||
entity->pos.ToPB(p->mutable_pos());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Room::ClearDeletedObjects()
|
||||
{
|
||||
for (auto& obj_uniid : frame_data.deleted_objects) {
|
||||
|
@ -62,6 +62,7 @@ public:
|
||||
void BeAddedObject(Entity* entity);
|
||||
void ProcDrop(Vector2D center, int drop_id);
|
||||
void CreateThings();
|
||||
void FillSMMapInfo(cs::SMMapInfo& map_info);
|
||||
|
||||
private:
|
||||
void ClearDeletedObjects();
|
||||
|
@ -52,8 +52,12 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
||||
hum->socket_handle = hdr.socket_handle;
|
||||
hum->Initialize();
|
||||
room->AddPlayer(hum);
|
||||
#if 1
|
||||
room->CreateThings();
|
||||
#else
|
||||
room->ShuaObstacle(hum);
|
||||
room->ShuaBuilding(hum);
|
||||
#endif
|
||||
|
||||
{
|
||||
cs::SMJoinedNotify notifymsg;
|
||||
@ -64,6 +68,7 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
||||
{
|
||||
cs::SMMapInfo notifymsg;
|
||||
notifymsg.set_map_id(room->map_meta->i->map_id());
|
||||
room->FillSMMapInfo(notifymsg);
|
||||
GGListener::Instance()->SendToClient(hdr.socket_handle, hdr.seqid, notifymsg);
|
||||
}
|
||||
}
|
||||
|
@ -91,10 +91,8 @@ message MFVector2D
|
||||
//地图物件
|
||||
message MFMapObject
|
||||
{
|
||||
//type
|
||||
optional MFVector2D pos = 1; //位置
|
||||
optional int32 ori = 2; //zzzzz
|
||||
optional int32 scale = 3; //缩放比
|
||||
optional int32 object_id = 1; //物件id(mapThing表id)
|
||||
optional MFVector2D pos = 2; //位置
|
||||
}
|
||||
|
||||
//玩家信息
|
||||
|
Loading…
x
Reference in New Issue
Block a user