添加半墙处理

This commit is contained in:
aozhiwei 2020-07-30 13:14:38 +08:00
parent f87b417923
commit 5b3286f3fa
5 changed files with 22 additions and 1 deletions

View File

@ -43,6 +43,19 @@ void Building::RecalcSelfCollider()
permanent_map_service->AddCollider(collider); permanent_map_service->AddCollider(collider);
} }
for (auto& obj : meta->i->halfwallobj()) {
AabbCollider* collider = new AabbCollider();
collider->owner = this;
collider->_min = a8::Vec2(obj.x() - obj.width()/2.0 - meta->i->tilewidth()/2.0,
obj.y() - obj.height()/2.0 - meta->i->tileheight()/2.0);
collider->_max = a8::Vec2(obj.x() + obj.width()/2.0 - meta->i->tilewidth()/2.0,
obj.y() + obj.height()/2.0 - meta->i->tileheight()/2.0);
a8::SetBitFlag(collider->tag, kHalfWallTag);
AddEntityCollider(collider);
collider_list.push_back(collider);
permanent_map_service->AddCollider(collider);
}
AutoAdjust(collider_list); AutoAdjust(collider_list);
} }

View File

@ -216,7 +216,7 @@ void Bullet::MapServiceUpdate()
std::set<ColliderComponent*> colliders; std::set<ColliderComponent*> colliders;
room->map_service->GetColliders(room, GetX(), GetY(), colliders); room->map_service->GetColliders(room, GetX(), GetY(), colliders);
for (ColliderComponent* collider : colliders) { for (ColliderComponent* collider : colliders) {
if (TestCollision(room, collider)) { if (TestCollision(room, collider) && !a8::HasBitFlag(collider->tag, kHalfWallTag)) {
objects.insert(collider->owner); objects.insert(collider->owner);
} }
} }

View File

@ -14,6 +14,7 @@ class ColliderComponent
Entity* owner = nullptr; Entity* owner = nullptr;
ColliderType_e type = CT_None; ColliderType_e type = CT_None;
bool active = true; bool active = true;
int tag = 0;
bool Intersect(ColliderComponent* b); bool Intersect(ColliderComponent* b);
bool IntersectEx(const a8::Vec2& pos, ColliderComponent* b); bool IntersectEx(const a8::Vec2& pos, ColliderComponent* b);

View File

@ -312,6 +312,11 @@ enum AIMode_e
kZombieAiMode = 2 kZombieAiMode = 2
}; };
enum ColliderTag_e
{
kHalfWallTag = 1
};
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";
@ -368,3 +373,4 @@ const int ZOMBIE_RACE_META_START_ID = 6001;
const int TERMINATOR_BUFF_ID = 1033; const int TERMINATOR_BUFF_ID = 1033;
const int TURN_OVER_SKILL_ID = 41001; const int TURN_OVER_SKILL_ID = 41001;

View File

@ -312,6 +312,7 @@ message BuildingJson
repeated DropObjJson dropObj = 5; repeated DropObjJson dropObj = 5;
repeated StaticObjJson staticObj = 6; repeated StaticObjJson staticObj = 6;
repeated LootObjJson lootObj = 7; repeated LootObjJson lootObj = 7;
repeated StaticObjJson halfwallObj = 8;
optional int32 mapId = 20; optional int32 mapId = 20;
} }