1
This commit is contained in:
parent
528ffb1b67
commit
c1b20c8ac1
@ -170,6 +170,12 @@ enum PropertyType_e
|
|||||||
kPropTankOil = 7
|
kPropTankOil = 7
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum MapObjectType_e
|
||||||
|
{
|
||||||
|
kMOT_Object = 1,
|
||||||
|
kMOT_SpawnPoint = 2
|
||||||
|
};
|
||||||
|
|
||||||
const char* const PROJ_NAME_FMT = "game%d_gameserver";
|
const char* const PROJ_NAME_FMT = "game%d_gameserver";
|
||||||
const char* const PROJ_ROOT_FMT = "/data/logs/%s";
|
const char* const PROJ_ROOT_FMT = "/data/logs/%s";
|
||||||
|
|
||||||
|
@ -326,6 +326,12 @@ namespace MetaData
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
metatable::MapTplThingJson* mutable_i = (metatable::MapTplThingJson*)i;
|
||||||
|
if (mutable_i->object_type() == "spawn_point") {
|
||||||
|
mutable_i->set__object_type(kMOT_SpawnPoint);
|
||||||
|
} else {
|
||||||
|
mutable_i->set__object_type(kMOT_Object);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int MapTplThing::RandThing()
|
int MapTplThing::RandThing()
|
||||||
|
@ -358,45 +358,19 @@ void Room::CreateThings()
|
|||||||
if (things) {
|
if (things) {
|
||||||
for (auto& thing_tpl : *things) {
|
for (auto& thing_tpl : *things) {
|
||||||
if (thing_tpl.i->weight() >= rand() % 10000) {
|
if (thing_tpl.i->weight() >= rand() % 10000) {
|
||||||
int thing_id = thing_tpl.RandThing();
|
switch (thing_tpl.i->_object_type()) {
|
||||||
MetaData::MapThing* thing_meta = MetaMgr::Instance()->GetMapThing(thing_id);
|
case kMOT_Object:
|
||||||
if (thing_meta) {
|
{
|
||||||
if (thing_meta->i->is_house()) {
|
CreateMapObject(thing_tpl);
|
||||||
CreateBuilding(thing_id, thing_tpl.i->x(), thing_tpl.i->y());
|
|
||||||
} else {
|
|
||||||
CreateObstacle(thing_id, thing_tpl.i->x(), thing_tpl.i->y());
|
|
||||||
}
|
|
||||||
} else if (thing_id == BORN_POINT_THINGID) {
|
|
||||||
CreateBornPoint(thing_tpl.i->x(),
|
|
||||||
thing_tpl.i->y(),
|
|
||||||
thing_tpl.i->width(),
|
|
||||||
thing_tpl.i->height(),
|
|
||||||
thing_tpl.i->param1()
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
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->is_luck() == 2) {
|
|
||||||
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->pos;
|
|
||||||
car_hash_[loot_entity->entity_uniid] = car;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case kMOT_SpawnPoint:
|
||||||
|
{
|
||||||
|
CreateMapSpawnPoint(thing_tpl);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1536,3 +1510,50 @@ BornPoint* Room::AllocBornPoint(Human* hum)
|
|||||||
}
|
}
|
||||||
return born_point;
|
return born_point;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Room::CreateMapObject(MetaData::MapTplThing& thing_tpl)
|
||||||
|
{
|
||||||
|
int thing_id = thing_tpl.RandThing();
|
||||||
|
MetaData::MapThing* thing_meta = MetaMgr::Instance()->GetMapThing(thing_id);
|
||||||
|
if (thing_meta) {
|
||||||
|
if (thing_meta->i->is_house()) {
|
||||||
|
CreateBuilding(thing_id, thing_tpl.i->x(), thing_tpl.i->y());
|
||||||
|
} else {
|
||||||
|
CreateObstacle(thing_id, thing_tpl.i->x(), thing_tpl.i->y());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
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->is_luck() == 2) {
|
||||||
|
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->pos;
|
||||||
|
car_hash_[loot_entity->entity_uniid] = car;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Room::CreateMapSpawnPoint(MetaData::MapTplThing& thing_tpl)
|
||||||
|
{
|
||||||
|
CreateBornPoint(thing_tpl.i->x(),
|
||||||
|
thing_tpl.i->y(),
|
||||||
|
thing_tpl.i->width(),
|
||||||
|
thing_tpl.i->height(),
|
||||||
|
thing_tpl.i->param1()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
@ -14,6 +14,7 @@ namespace MetaData
|
|||||||
struct SafeArea;
|
struct SafeArea;
|
||||||
struct Building;
|
struct Building;
|
||||||
struct AirLine;
|
struct AirLine;
|
||||||
|
struct MapTplThing;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct timer_list;
|
struct timer_list;
|
||||||
@ -122,6 +123,8 @@ private:
|
|||||||
void NotifyWxVoip();
|
void NotifyWxVoip();
|
||||||
void CreateBornPoint(int x, int y, int width, int height, int hum_limit);
|
void CreateBornPoint(int x, int y, int width, int height, int hum_limit);
|
||||||
BornPoint* AllocBornPoint(Human* hum);
|
BornPoint* AllocBornPoint(Human* hum);
|
||||||
|
void CreateMapObject(MetaData::MapTplThing& thing_tpl);
|
||||||
|
void CreateMapSpawnPoint(MetaData::MapTplThing& thing_tpl);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int elapsed_time_ = 0;
|
int elapsed_time_ = 0;
|
||||||
|
@ -253,4 +253,6 @@ message MapTplThingJson
|
|||||||
optional float param1 = 9;
|
optional float param1 = 9;
|
||||||
optional float param2 = 10;
|
optional float param2 = 10;
|
||||||
optional float param3 = 11;
|
optional float param3 = 11;
|
||||||
|
optional string object_type = 12;
|
||||||
|
optional int32 _object_type = 13;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user