pandemonium_engine/modules/steering_ai/behaviors/gsai_seek.cpp

35 lines
974 B
C++
Raw Normal View History

2023-01-13 21:29:17 +01:00
#include "gsai_seek.h"
2023-01-14 01:43:20 +01:00
#include "../gsai_agent_location.h"
#include "../gsai_steering_agent.h"
#include "../gsai_target_acceleration.h"
Ref<GSAIAgentLocation> GSAISeek::get_target() {
return target;
}
2023-01-14 01:43:20 +01:00
void GSAISeek::set_target(const Ref<GSAIAgentLocation> &val) {
target = val;
}
2023-01-14 01:43:20 +01:00
void GSAISeek::_calculate_steering(Ref<GSAITargetAcceleration> acceleration) {
ERR_FAIL_COND(!agent.is_valid());
ERR_FAIL_COND(!target.is_valid());
2023-01-14 01:43:20 +01:00
acceleration->set_linear(((target->get_position() - agent->get_position()).normalized() * agent->get_linear_acceleration_max()));
acceleration->set_angular(0);
}
GSAISeek::GSAISeek() {
}
GSAISeek::~GSAISeek() {
}
2023-01-14 01:43:20 +01:00
void GSAISeek::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_target"), &GSAISeek::get_target);
ClassDB::bind_method(D_METHOD("set_target", "value"), &GSAISeek::set_target);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "target", PROPERTY_HINT_RESOURCE_TYPE, "GSAIAgentLocation"), "set_target", "get_target");
}