2023-01-13 21:13:57 +01:00
|
|
|
|
2023-01-13 21:29:17 +01:00
|
|
|
#include "gsai_steering_behavior.h"
|
2023-01-13 21:13:57 +01:00
|
|
|
|
2023-01-13 23:01:38 +01:00
|
|
|
#include "gsai_target_acceleration.h"
|
|
|
|
#include "gsai_steering_agent.h"
|
|
|
|
|
2023-01-13 21:13:57 +01:00
|
|
|
bool GSAISteeringBehavior::get_is_enabled() const {
|
2023-01-13 21:35:07 +01:00
|
|
|
return is_enabled;
|
2023-01-13 21:13:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void GSAISteeringBehavior::set_is_enabled(const bool val) {
|
2023-01-13 21:35:07 +01:00
|
|
|
is_enabled = val;
|
2023-01-13 21:13:57 +01:00
|
|
|
}
|
|
|
|
|
2023-01-13 23:01:38 +01:00
|
|
|
Ref<GSAISteeringAgent> GSAISteeringBehavior::get_agent() {
|
|
|
|
return agent;
|
2023-01-13 21:13:57 +01:00
|
|
|
}
|
|
|
|
|
2023-01-13 23:01:38 +01:00
|
|
|
void GSAISteeringBehavior::set_agent(const Ref<GSAISteeringAgent> &val) {
|
|
|
|
agent = val;
|
2023-01-13 21:13:57 +01:00
|
|
|
}
|
|
|
|
|
2023-01-13 23:01:38 +01:00
|
|
|
void GSAISteeringBehavior::calculate_steering(Ref<GSAITargetAcceleration> acceleration) {
|
2023-01-13 21:35:07 +01:00
|
|
|
if (is_enabled) {
|
|
|
|
call("_calculate_steering", acceleration);
|
2023-01-13 23:01:38 +01:00
|
|
|
} else {
|
|
|
|
acceleration->set_zero();
|
2023-01-13 21:35:07 +01:00
|
|
|
}
|
2023-01-13 21:13:57 +01:00
|
|
|
}
|
|
|
|
|
2023-01-13 23:01:38 +01:00
|
|
|
void GSAISteeringBehavior::_calculate_steering(Ref<GSAITargetAcceleration> acceleration) {
|
|
|
|
acceleration->set_zero();
|
2023-01-13 21:13:57 +01:00
|
|
|
}
|
|
|
|
|
2023-01-13 21:35:07 +01:00
|
|
|
GSAISteeringBehavior::GSAISteeringBehavior() {
|
|
|
|
is_enabled = true;
|
2023-01-13 21:13:57 +01:00
|
|
|
}
|
|
|
|
|
2023-01-13 21:35:07 +01:00
|
|
|
GSAISteeringBehavior::~GSAISteeringBehavior() {
|
2023-01-13 21:13:57 +01:00
|
|
|
}
|
|
|
|
|
2023-01-13 23:01:38 +01:00
|
|
|
void GSAISteeringBehavior::_bind_methods() {
|
2023-01-13 21:35:07 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("get_is_enabled"), &GSAISteeringBehavior::get_is_enabled);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_is_enabled", "value"), &GSAISteeringBehavior::set_is_enabled);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_enabled"), "set_is_enabled", "get_is_enabled");
|
2023-01-13 21:13:57 +01:00
|
|
|
|
2023-01-13 23:01:38 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("get_agent"), &GSAISteeringBehavior::get_agent);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_agent", "value"), &GSAISteeringBehavior::set_agent);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "agent", PROPERTY_HINT_RESOURCE_TYPE, "GSAISteeringAgent"), "set_agent", "get_agent");
|
|
|
|
|
|
|
|
BIND_VMETHOD(MethodInfo("_calculate_steering", PropertyInfo(Variant::OBJECT, "acceleration", PROPERTY_HINT_RESOURCE_TYPE, "GSAITargetAcceleration")));
|
2023-01-13 21:13:57 +01:00
|
|
|
|
2023-01-13 21:35:07 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("calculate_steering", "acceleration"), &GSAISteeringBehavior::calculate_steering);
|
|
|
|
ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAISteeringBehavior::_calculate_steering);
|
|
|
|
}
|