This commit is contained in:
aozhiwei 2022-12-29 14:35:55 +08:00
parent e438ca145e
commit 562e26ee75

View File

@ -7,32 +7,21 @@
#include "creature.h" #include "creature.h"
#include "room.h" #include "room.h"
#include "mapinstance.h"
void PullToWalkableBuff::Activate() void PullToWalkableBuff::Activate()
{ {
if (!owner->CollisonDetection()) { glm::vec3 center = owner->GetPos().ToGlmVec3();
return; owner->room->map_instance->Scale(center);
} glm::vec3 point;
glm::vec3 move_dir = owner->GetMoveDir(); bool ok = owner->room->map_instance->FindNearestPoint(center, 2, point);
if (std::abs(move_dir.x) > FLT_EPSILON || if (!ok) {
std::abs(move_dir.y) > FLT_EPSILON abort();
) {
Position old_pos = owner->GetPos();
for (int i = 1; i < 2000; i += 5) {
// 999
#if 1
#else
owner->SetPos(old_pos + move_dir * i);
#endif
if (!owner->CollisonDetection()) {
owner->room->grid_service->MoveCreature(owner);
return;
}
}
owner->FindLocation();
} else {
owner->FindLocation();
} }
owner->room->map_instance->UnScale(point);
Global::Instance()->verify_set_pos = 1;
owner->GetMutablePos().FromGlmVec3(point);
Global::Instance()->verify_set_pos = 0;
} }
void PullToWalkableBuff::Deactivate() void PullToWalkableBuff::Deactivate()