1
This commit is contained in:
parent
140761a8d2
commit
e298ca53f1
@ -4,6 +4,8 @@
|
|||||||
#include "moveableentity.h"
|
#include "moveableentity.h"
|
||||||
#include "room.h"
|
#include "room.h"
|
||||||
#include "mapinstance.h"
|
#include "mapinstance.h"
|
||||||
|
#include "creature.h"
|
||||||
|
#include "metamgr.h"
|
||||||
|
|
||||||
MoveHelper::MoveHelper(class MoveableEntity* owner)
|
MoveHelper::MoveHelper(class MoveableEntity* owner)
|
||||||
{
|
{
|
||||||
@ -31,16 +33,36 @@ void MoveHelper::CalcTargetPos(float distance)
|
|||||||
end.z = target_pos2d.y / 10.0f;
|
end.z = target_pos2d.y / 10.0f;
|
||||||
|
|
||||||
MovePathPoint point;
|
MovePathPoint point;
|
||||||
int ret = owner_->room->map_instance->Raycast(0, start, end, hit_point);
|
Creature* c = (Creature*)owner_;
|
||||||
if (ret > 1) {
|
if (c->HasBuffEffect(kBET_ThroughWall) ||
|
||||||
point.pos = hit_point * 10.f;
|
c->HasBuffEffect(kBET_Fly)) {
|
||||||
|
point.tar_pos = end * 10.f;
|
||||||
|
if (point.tar_pos.x > owner_->room->GetMapMeta()->i->map_width() + 10) {
|
||||||
|
point.tar_pos.x = owner_->room->GetMapMeta()->i->map_width() - 10;
|
||||||
|
}
|
||||||
|
if (point.tar_pos.z > owner_->room->GetMapMeta()->i->map_height() + 10) {
|
||||||
|
point.tar_pos.z = owner_->room->GetMapMeta()->i->map_height() - 10;
|
||||||
|
}
|
||||||
|
if (point.tar_pos.x < 10) {
|
||||||
|
point.tar_pos.x = 10;
|
||||||
|
}
|
||||||
|
if (point.tar_pos.y < 10) {
|
||||||
|
point.tar_pos.y = 10;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
point.pos = end * 10.f;
|
int ret = owner_->room->map_instance->Raycast(0, start, end, hit_point);
|
||||||
|
if (ret > 1) {
|
||||||
|
point.tar_pos = hit_point * 10.f;
|
||||||
|
} else {
|
||||||
|
point.tar_pos = end * 10.f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
a8::Vec2 v2;
|
a8::Vec2 v2;
|
||||||
v2.x = point.pos.x;
|
v2.x = point.tar_pos.x;
|
||||||
v2.y = point.pos.z;
|
v2.y = point.tar_pos.z;
|
||||||
point.distance = v2.Distance(owner_->GetPos());
|
point.distance = v2.Distance(owner_->GetPos());
|
||||||
|
point.src_pos.x = owner_->GetPos().x;
|
||||||
|
point.src_pos.z = owner_->GetPos().y;
|
||||||
|
|
||||||
paths_.push_back(point);
|
paths_.push_back(point);
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
struct MovePathPoint
|
struct MovePathPoint
|
||||||
{
|
{
|
||||||
glm::vec3 pos;
|
glm::vec3 src_pos;
|
||||||
|
glm::vec3 tar_pos;
|
||||||
|
glm::vec3 dir;
|
||||||
float distance = 0.0f;
|
float distance = 0.0f;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user