This commit is contained in:
aozhiwei 2021-08-10 11:18:54 +00:00
parent 1b8b0852ee
commit 24b1944909
4 changed files with 25 additions and 0 deletions

View File

@ -19,6 +19,7 @@ void DummyEntity::Initialize()
collider->owner = this;
collider->pos = a8::Vec2(obj.x(), obj.y());
collider->rad = obj.rad();
collider->tag = obj.collider_tag();
if (obj.bullet_penetrate()) {
a8::SetBitFlag(collider->tag, kHalfWallTag);
}
@ -34,6 +35,7 @@ void DummyEntity::Initialize()
obj.y() - obj.height()/2.0);
collider->_max = a8::Vec2(obj.x() + obj.width()/2.0,
obj.y() + obj.height()/2.0);
collider->tag = obj.collider_tag();
if (obj.bullet_penetrate()) {
a8::SetBitFlag(collider->tag, kHalfWallTag);
}

View File

@ -259,6 +259,17 @@ void MapInstance::CreateTerrain()
assert(collider_tag > 0);
}
if (collider_tag != 0) {
#if 1
auto& block = a8::FastAppend(terrain_blocks_);
block.set_shape(2);
block.set_x(x);
block.set_y(y);
block.set_height(thing_meta->i->height());
block.set_width(thing_meta->i->width());
block.set_rad(std::max(thing_meta->i->height(), thing_meta->i->width()));
block.set_bullet_penetrate(0);
block.set_collider_tag(collider_tag);
#else
assert(w < 300 && h < 300);
assert(collider_tag > 0);
InternalCreateObstacle(thing_meta->i->thing_id(), x, y, collider_tag,
@ -268,11 +279,21 @@ void MapInstance::CreateTerrain()
true,
w,
h);
#endif
}
}
}
}
}
{
DummyEntity* dummy = EntityFactory::Instance()->MakeDummy(AllocUniid());
dummy->SetPos(a8::Vec2());
dummy->permanent_map_service = map_service_;
dummy->blocks = &terrain_blocks_;
dummy->Initialize();
uniid_hash_[dummy->GetUniId()] = dummy;
grid_service_->AddPermanentEntity(dummy);
}
}
void MapInstance::CreateBlock()

View File

@ -62,6 +62,7 @@ class MapInstance
std::vector<MetaData::MapTplThing*> loots_;
std::vector<Building*> buildings_;
std::vector<MetaData::MapTplThing*> level0room_spec_things_;
std::list<metatable::MapBlockJson> terrain_blocks_;
int building_num_ = 0;
int obstacle_num_ = 0;

View File

@ -462,4 +462,5 @@ message MapBlockJson
optional float width = 8;
optional float rad = 9;
optional int32 bullet_penetrate = 10;
optional int32 collider_tag = 11;
}