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