修复
This commit is contained in:
parent
5e24ee27d2
commit
05624058fd
@ -8,6 +8,7 @@
|
||||
#include "collider.h"
|
||||
#include "loot.h"
|
||||
#include "collision.h"
|
||||
#include "building.h"
|
||||
|
||||
Human::Human()
|
||||
{
|
||||
@ -642,18 +643,20 @@ void Human::FindLocation()
|
||||
{
|
||||
{
|
||||
std::vector<Entity*> objects;
|
||||
int detection_flags = 0;
|
||||
{
|
||||
a8::SetBitFlag(detection_flags, ET_Building);
|
||||
}
|
||||
room->CollisionDetection(this, detection_flags, objects);
|
||||
room->BuildingBoxBoundCollisionDetection(this, objects);
|
||||
if (objects.size() > 1) {
|
||||
abort();
|
||||
}
|
||||
if (!objects.empty()) {
|
||||
Building* building = (Building*)objects[0];
|
||||
Vector2D a_min;
|
||||
Vector2D a_max;
|
||||
Vector2D a_min = Vector2D(
|
||||
building->pos.x - building->meta->i->tilewidth()/2.0,
|
||||
building->pos.y - building->meta->i->tileheight()/2.0
|
||||
);
|
||||
Vector2D a_max = Vector2D(
|
||||
building->pos.x + building->meta->i->tilewidth()/2.0,
|
||||
building->pos.y + building->meta->i->tileheight()/2.0
|
||||
);
|
||||
Vector2D new_pos;
|
||||
bool ret = CalcCircleAabbSafePoint(
|
||||
a_min,
|
||||
@ -665,6 +668,9 @@ void Human::FindLocation()
|
||||
if (!ret) {
|
||||
abort();
|
||||
}
|
||||
if (ret) {
|
||||
pos = new_pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -400,6 +400,31 @@ void Room::CollisionDetection(Entity* sender, int detection_flags, std::vector<E
|
||||
}
|
||||
}
|
||||
|
||||
void Room::BuildingBoxBoundCollisionDetection(Human* hum, std::vector<Entity*>& objects)
|
||||
{
|
||||
for (auto& pair : uniid_hash_) {
|
||||
if (pair.second->entity_type == ET_Building) {
|
||||
Building* building = (Building*)pair.second;
|
||||
Vector2D a_min = Vector2D(
|
||||
building->pos.x - building->meta->i->tilewidth()/2.0,
|
||||
building->pos.y - building->meta->i->tileheight()/2.0
|
||||
);
|
||||
Vector2D a_max = Vector2D(
|
||||
building->pos.x + building->meta->i->tilewidth()/2.0,
|
||||
building->pos.y + building->meta->i->tileheight()/2.0
|
||||
);
|
||||
if (IntersectAabbCircle(
|
||||
a_min,
|
||||
a_max,
|
||||
hum->pos,
|
||||
hum->GetRadius()
|
||||
)) {
|
||||
objects.push_back(pair.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Room::AddDeletedObject(unsigned short obj_uniid, bool soft_delete)
|
||||
{
|
||||
std::set<unsigned short>* deleted_objects = nullptr;
|
||||
@ -781,6 +806,7 @@ void Room::UpdateGas()
|
||||
gas_data.gas_start_frameno = frame_no;
|
||||
ShuaPlane();
|
||||
RoomMgr::Instance()->RemoveFromInactiveRoomHash(room_uuid);
|
||||
#if 1
|
||||
xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * 3,
|
||||
a8::XParams()
|
||||
.SetSender(this),
|
||||
@ -800,6 +826,7 @@ void Room::UpdateGas()
|
||||
});
|
||||
},
|
||||
&xtimer_attacher.timer_list_);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -53,6 +53,7 @@ public:
|
||||
Human* FindEnemy(Human* hum);
|
||||
|
||||
void CollisionDetection(Entity* sender, int detection_flags, std::vector<Entity*>& objects);
|
||||
void BuildingBoxBoundCollisionDetection(Human* hum, std::vector<Entity*>& objects);
|
||||
void AddDeletedObject(unsigned short obj_uniid, bool soft_delete);
|
||||
void BeAddedObject(Entity* entity);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user