添加地图对象共享机制
This commit is contained in:
parent
5236df1188
commit
dd8d5ab3e8
@ -49,6 +49,8 @@ void Room::Init()
|
|||||||
xtimer_attacher.xtimer = &xtimer;
|
xtimer_attacher.xtimer = &xtimer;
|
||||||
|
|
||||||
CreateSpawnPoints();
|
CreateSpawnPoints();
|
||||||
|
CreateLoots();
|
||||||
|
CreateDropObjs();
|
||||||
ShuaAndroid();
|
ShuaAndroid();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1385,6 +1387,58 @@ void Room::CreateSpawnPoints()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Room::CreateLoots()
|
||||||
|
{
|
||||||
|
if (loots) {
|
||||||
|
for (auto& thing_tpl : *loots) {
|
||||||
|
int thing_id = thing_tpl->RandThing();
|
||||||
|
MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(thing_id);
|
||||||
|
if (equip_meta) {
|
||||||
|
int entity_uniid = CreateLoot(
|
||||||
|
equip_meta->i->id(),
|
||||||
|
a8::Vec2
|
||||||
|
(
|
||||||
|
thing_tpl->i->x(),
|
||||||
|
thing_tpl->i->y()
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
1
|
||||||
|
);
|
||||||
|
if (entity_uniid && equip_meta->i->equip_type() == EQUIP_TYPE_CAR) {
|
||||||
|
Entity* loot_entity = GetEntityByUniId(entity_uniid);
|
||||||
|
if (loot_entity && loot_entity->entity_type == ET_Loot) {
|
||||||
|
((Loot*)loot_entity)->bullet_num = equip_meta->i->clip_volume();
|
||||||
|
((Loot*)loot_entity)->param1 = MetaMgr::Instance()->max_oil;
|
||||||
|
((Loot*)loot_entity)->param2 = MetaMgr::Instance()->max_oil;
|
||||||
|
CarObject car;
|
||||||
|
car.car_id = equip_meta->i->id();
|
||||||
|
car.pos = loot_entity->GetPos();
|
||||||
|
car_hash_[loot_entity->entity_uniid] = car;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Room::CreateDropObjs()
|
||||||
|
{
|
||||||
|
if (buildings) {
|
||||||
|
for (auto& building : *buildings) {
|
||||||
|
for (auto& obj : building->meta->i->dropobj()) {
|
||||||
|
CreateLoot(obj.id(),
|
||||||
|
a8::Vec2(
|
||||||
|
building->GetX() + obj.x() - building->meta->i->tilewidth() / 2.0,
|
||||||
|
building->GetY() + obj.y() - building->meta->i->tileheight() / 2.0
|
||||||
|
),
|
||||||
|
1,
|
||||||
|
1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Room::IncBornPointHumanNum(BornPoint* point, Human* hum)
|
void Room::IncBornPointHumanNum(BornPoint* point, Human* hum)
|
||||||
{
|
{
|
||||||
switch (hum->entity_subtype) {
|
switch (hum->entity_subtype) {
|
||||||
|
@ -17,6 +17,11 @@ namespace MetaData
|
|||||||
struct MapTplThing;
|
struct MapTplThing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace metatable
|
||||||
|
{
|
||||||
|
class DropObjJson;
|
||||||
|
}
|
||||||
|
|
||||||
struct timer_list;
|
struct timer_list;
|
||||||
struct xtimer_list;
|
struct xtimer_list;
|
||||||
class Entity;
|
class Entity;
|
||||||
@ -51,6 +56,8 @@ public:
|
|||||||
RoomType_e room_type = RT_NewBrid;
|
RoomType_e room_type = RT_NewBrid;
|
||||||
long long last_add_player_tick = 0;
|
long long last_add_player_tick = 0;
|
||||||
std::vector<MetaData::MapTplThing*>* spawn_points = nullptr;
|
std::vector<MetaData::MapTplThing*>* spawn_points = nullptr;
|
||||||
|
std::vector<MetaData::MapTplThing*>* loots = nullptr;
|
||||||
|
std::vector<Building*>* buildings = nullptr;
|
||||||
|
|
||||||
~Room();
|
~Room();
|
||||||
void Init();
|
void Init();
|
||||||
@ -127,6 +134,8 @@ private:
|
|||||||
void NotifyWxVoip();
|
void NotifyWxVoip();
|
||||||
BornPoint* AllocBornPoint(Human* hum);
|
BornPoint* AllocBornPoint(Human* hum);
|
||||||
void CreateSpawnPoints();
|
void CreateSpawnPoints();
|
||||||
|
void CreateLoots();
|
||||||
|
void CreateDropObjs();
|
||||||
void IncBornPointHumanNum(BornPoint* point, Human* hum);
|
void IncBornPointHumanNum(BornPoint* point, Human* hum);
|
||||||
void DecBornPointHumanNum(BornPoint* point, Human* hum);
|
void DecBornPointHumanNum(BornPoint* point, Human* hum);
|
||||||
void SecondRandPoint();
|
void SecondRandPoint();
|
||||||
|
@ -136,6 +136,8 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
|||||||
room->room_type = self_room_type;
|
room->room_type = self_room_type;
|
||||||
room->room_uuid = App::Instance()->NewUuid();
|
room->room_uuid = App::Instance()->NewUuid();
|
||||||
room->spawn_points = &spawn_points_;
|
room->spawn_points = &spawn_points_;
|
||||||
|
room->loots = &loots_;
|
||||||
|
room->buildings = &buildings_;
|
||||||
if (GetRoomByUuid(room->room_uuid)) {
|
if (GetRoomByUuid(room->room_uuid)) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
@ -470,9 +472,7 @@ void RoomMgr::CreateBuilding(int thing_id, float building_x, float building_y)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (auto& obj : building_meta->i->dropobj()) {
|
buildings_.push_back(building);
|
||||||
dropobjs_.push_back(&obj);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Obstacle* RoomMgr::InternalCreateObstacle(int id, float x, float y,
|
Obstacle* RoomMgr::InternalCreateObstacle(int id, float x, float y,
|
||||||
|
@ -21,6 +21,7 @@ namespace metatable
|
|||||||
class Room;
|
class Room;
|
||||||
class Entity;
|
class Entity;
|
||||||
class Obstacle;
|
class Obstacle;
|
||||||
|
class Building;
|
||||||
class MapService;
|
class MapService;
|
||||||
class GridService;
|
class GridService;
|
||||||
class RoomMgr : public a8::Singleton<RoomMgr>
|
class RoomMgr : public a8::Singleton<RoomMgr>
|
||||||
@ -72,5 +73,5 @@ class RoomMgr : public a8::Singleton<RoomMgr>
|
|||||||
MetaData::Map* map_meta_ = nullptr;
|
MetaData::Map* map_meta_ = nullptr;
|
||||||
std::vector<MetaData::MapTplThing*> spawn_points_;
|
std::vector<MetaData::MapTplThing*> spawn_points_;
|
||||||
std::vector<MetaData::MapTplThing*> loots_;
|
std::vector<MetaData::MapTplThing*> loots_;
|
||||||
std::vector<const metatable::DropObjJson*> dropobjs_;
|
std::vector<Building*> buildings_;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user