mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-02-07 00:25:54 +01:00
Cang formatted everything in the new module.
This commit is contained in:
parent
0d2aa86bc3
commit
402e8ff689
@ -1,7 +1,6 @@
|
||||
|
||||
#include "gsai_kinematic_body_2d_agent.h"
|
||||
|
||||
|
||||
KinematicBody2D GSAIKinematicBody2DAgent::get_ *body() {
|
||||
return *body;
|
||||
}
|
||||
@ -10,7 +9,6 @@ void GSAIKinematicBody2DAgent::set_*body(const KinematicBody2D &val) {
|
||||
*body = val;
|
||||
}
|
||||
|
||||
|
||||
int GSAIKinematicBody2DAgent::get_movement_type() const {
|
||||
return movement_type;
|
||||
}
|
||||
@ -19,7 +17,6 @@ void GSAIKinematicBody2DAgent::set_movement_type(const int val) {
|
||||
movement_type = val;
|
||||
}
|
||||
|
||||
|
||||
Vector2 GSAIKinematicBody2DAgent::get__last_position() {
|
||||
return _last_position;
|
||||
}
|
||||
@ -28,7 +25,6 @@ void GSAIKinematicBody2DAgent::set__last_position(const Vector2 &val) {
|
||||
_last_position = val;
|
||||
}
|
||||
|
||||
|
||||
Ref<WeakRef> GSAIKinematicBody2DAgent::get__body_ref() {
|
||||
return _body_ref;
|
||||
}
|
||||
@ -37,15 +33,14 @@ void GSAIKinematicBody2DAgent::set__body_ref(const Ref<WeakRef> &val) {
|
||||
_body_ref = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// A specialized steering agent that updates itself every frame so the user does;
|
||||
// not have to using a KinematicBody2D;
|
||||
// @category - Specialized agents;
|
||||
// SLIDE uses `move_and_slide`;
|
||||
// COLLIDE uses `move_and_collide`;
|
||||
// POSITION changes the `global_position` directly;
|
||||
};
|
||||
}
|
||||
;
|
||||
// The KinematicBody2D to keep track of;
|
||||
// setget _set_body;
|
||||
KinematicBody2D *body;
|
||||
@ -69,12 +64,10 @@ _body_ref = val;
|
||||
_apply_collide_steering(acceleration.linear, delta);
|
||||
}
|
||||
|
||||
|
||||
else if (movement_type == MovementType.SLIDE) {
|
||||
_apply_sliding_steering(acceleration.linear, delta);
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
_apply_position_steering(acceleration.linear, delta);
|
||||
}
|
||||
@ -82,7 +75,6 @@ _body_ref = val;
|
||||
_apply_orientation_steering(acceleration.angular, delta);
|
||||
}
|
||||
|
||||
|
||||
void GSAIKinematicBody2DAgent::_apply_sliding_steering(const Vector3 &accel, const float delta) {
|
||||
KinematicBody2D *_body = _body_ref.get_ref();
|
||||
|
||||
@ -90,7 +82,6 @@ _body_ref = val;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!_body.is_inside_tree() || _body.get_tree().paused) {
|
||||
return;
|
||||
}
|
||||
@ -106,10 +97,8 @@ _body_ref = val;
|
||||
if (calculate_velocities) {
|
||||
linear_velocity = GSAIUtils.to_vector3(velocity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GSAIKinematicBody2DAgent::_apply_collide_steering(const Vector3 &accel, const float delta) {
|
||||
KinematicBody2D *_body = _body_ref.get_ref();
|
||||
|
||||
@ -129,10 +118,8 @@ _body_ref = val;
|
||||
if (calculate_velocities) {
|
||||
linear_velocity = velocity;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GSAIKinematicBody2DAgent::_apply_position_steering(const Vector3 &accel, const float delta) {
|
||||
KinematicBody2D *_body = _body_ref.get_ref();
|
||||
|
||||
@ -151,10 +138,8 @@ _body_ref = val;
|
||||
if (calculate_velocities) {
|
||||
linear_velocity = velocity;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GSAIKinematicBody2DAgent::_apply_orientation_steering(const float angular_acceleration, const float delta) {
|
||||
KinematicBody2D *_body = _body_ref.get_ref();
|
||||
|
||||
@ -173,10 +158,8 @@ _body_ref = val;
|
||||
if (calculate_velocities) {
|
||||
angular_velocity = velocity;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GSAIKinematicBody2DAgent::_set_body(const KinematicBody2D &value) {
|
||||
bool had_body = false;
|
||||
|
||||
@ -192,21 +175,16 @@ _body_ref = val;
|
||||
orientation = last_orientation;
|
||||
|
||||
if (!had_body) {
|
||||
|
||||
if (!body.is_inside_tree()) {
|
||||
body.connect("ready", self, "_body_ready");
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
_body_ready();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GSAIKinematicBody2DAgent::_on_SceneTree_physics_frame() {
|
||||
KinematicBody2D *_body = _body_ref.get_ref();
|
||||
|
||||
@ -220,12 +198,10 @@ _body_ref = val;
|
||||
orientation = current_orientation;
|
||||
|
||||
if (calculate_velocities) {
|
||||
|
||||
if (applied_steering) {
|
||||
applied_steering = false;
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
linear_velocity = GSAIUtils.clampedv3(GSAIUtils.to_vector3(current_position - _last_position), linear_speed_max);
|
||||
|
||||
@ -242,11 +218,8 @@ _body_ref = val;
|
||||
_last_position = current_position;
|
||||
last_orientation = current_orientation;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAIKinematicBody2DAgent::GSAIKinematicBody2DAgent() {
|
||||
@ -259,28 +232,23 @@ _body_ref = val;
|
||||
GSAIKinematicBody2DAgent::~GSAIKinematicBody2DAgent() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAIKinematicBody2DAgent::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_*body"), &GSAIKinematicBody2DAgent::get_ * body);
|
||||
ClassDB::bind_method(D_METHOD("set_*body", "value"), &GSAIKinematicBody2DAgent::set_ * body);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*body", PROPERTY_HINT_RESOURCE_TYPE, "KinematicBody2D"), "set_*body", "get_*body");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_movement_type"), &GSAIKinematicBody2DAgent::get_movement_type);
|
||||
ClassDB::bind_method(D_METHOD("set_movement_type", "value"), &GSAIKinematicBody2DAgent::set_movement_type);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "movement_type"), "set_movement_type", "get_movement_type");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get__last_position"), &GSAIKinematicBody2DAgent::get__last_position);
|
||||
ClassDB::bind_method(D_METHOD("set__last_position", "value"), &GSAIKinematicBody2DAgent::set__last_position);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "_last_position"), "set__last_position", "get__last_position");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get__body_ref"), &GSAIKinematicBody2DAgent::get__body_ref);
|
||||
ClassDB::bind_method(D_METHOD("set__body_ref", "value"), &GSAIKinematicBody2DAgent::set__body_ref);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "_body_ref", PROPERTY_HINT_RESOURCE_TYPE, "Ref<WeakRef>"), "set__body_ref", "get__body_ref");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_body_ready"), &GSAIKinematicBody2DAgent::_body_ready);
|
||||
ClassDB::bind_method(D_METHOD("_apply_steering", "acceleration", "delta"), &GSAIKinematicBody2DAgent::_apply_steering);
|
||||
ClassDB::bind_method(D_METHOD("_apply_sliding_steering", "accel", "delta"), &GSAIKinematicBody2DAgent::_apply_sliding_steering);
|
||||
@ -289,8 +257,4 @@ _body_ref = val;
|
||||
ClassDB::bind_method(D_METHOD("_apply_orientation_steering", "angular_acceleration", "delta"), &GSAIKinematicBody2DAgent::_apply_orientation_steering);
|
||||
ClassDB::bind_method(D_METHOD("_set_body", "value"), &GSAIKinematicBody2DAgent::_set_body);
|
||||
ClassDB::bind_method(D_METHOD("_on_SceneTree_physics_frame"), &GSAIKinematicBody2DAgent::_on_SceneTree_physics_frame);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef GSAIKINEMATICBODY2DAGENT_H
|
||||
#define GSAIKINEMATICBODY2DAGENT_H
|
||||
|
||||
|
||||
class GSAIKinematicBody2DAgent : public GSAISpecializedAgent {
|
||||
GDCLASS(GSAIKinematicBody2DAgent, GSAISpecializedAgent);
|
||||
|
||||
public:
|
||||
|
||||
KinematicBody2D get_ *body();
|
||||
void set_ *body(const KinematicBody2D &val);
|
||||
|
||||
@ -57,7 +55,7 @@ class GSAIKinematicBody2DAgent : public GSAISpecializedAgent {
|
||||
Ref<WeakRef> _body_ref;
|
||||
// Moves the agent's `body` by target `acceleration`.
|
||||
// @tags - virtual
|
||||
};
|
||||
|
||||
}
|
||||
;
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "gsai_kinematic_body_3d_agent.h"
|
||||
|
||||
|
||||
KinematicBody GSAIKinematicBody3DAgent::get_ *body() {
|
||||
return *body;
|
||||
}
|
||||
@ -10,7 +9,6 @@ void GSAIKinematicBody3DAgent::set_*body(const KinematicBody &val) {
|
||||
*body = val;
|
||||
}
|
||||
|
||||
|
||||
int GSAIKinematicBody3DAgent::get_movement_type() const {
|
||||
return movement_type;
|
||||
}
|
||||
@ -19,7 +17,6 @@ void GSAIKinematicBody3DAgent::set_movement_type(const int val) {
|
||||
movement_type = val;
|
||||
}
|
||||
|
||||
|
||||
Vector3 GSAIKinematicBody3DAgent::get__last_position() {
|
||||
return _last_position;
|
||||
}
|
||||
@ -28,7 +25,6 @@ void GSAIKinematicBody3DAgent::set__last_position(const Vector3 &val) {
|
||||
_last_position = val;
|
||||
}
|
||||
|
||||
|
||||
Ref<WeakRef> GSAIKinematicBody3DAgent::get__body_ref() {
|
||||
return _body_ref;
|
||||
}
|
||||
@ -37,15 +33,14 @@ void GSAIKinematicBody3DAgent::set__body_ref(const Ref<WeakRef> &val) {
|
||||
_body_ref = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// A specialized steering agent that updates itself every frame so the user does;
|
||||
// not have to using a KinematicBody;
|
||||
// @category - Specialized agents;
|
||||
// SLIDE uses `move_and_slide`;
|
||||
// COLLIDE uses `move_and_collide`;
|
||||
// POSITION changes the global_position directly;
|
||||
};
|
||||
}
|
||||
;
|
||||
// The KinematicBody to keep track of;
|
||||
// setget _set_body;
|
||||
KinematicBody *body;
|
||||
@ -69,12 +64,10 @@ _body_ref = val;
|
||||
_apply_collide_steering(acceleration.linear, delta);
|
||||
}
|
||||
|
||||
|
||||
else if (movement_type == MovementType.SLIDE) {
|
||||
_apply_sliding_steering(acceleration.linear, delta);
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
_apply_position_steering(acceleration.linear, delta);
|
||||
}
|
||||
@ -82,7 +75,6 @@ _body_ref = val;
|
||||
_apply_orientation_steering(acceleration.angular, delta);
|
||||
}
|
||||
|
||||
|
||||
void GSAIKinematicBody3DAgent::_apply_sliding_steering(const Vector3 &accel, const float delta) {
|
||||
KinematicBody *_body = _body_ref.get_ref();
|
||||
|
||||
@ -101,10 +93,8 @@ _body_ref = val;
|
||||
if (calculate_velocities) {
|
||||
linear_velocity = velocity;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GSAIKinematicBody3DAgent::_apply_collide_steering(const Vector3 &accel, const float delta) {
|
||||
KinematicBody *_body = _body_ref.get_ref();
|
||||
|
||||
@ -124,10 +114,8 @@ _body_ref = val;
|
||||
if (calculate_velocities) {
|
||||
linear_velocity = velocity;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GSAIKinematicBody3DAgent::_apply_position_steering(const Vector3 &accel, const float delta) {
|
||||
KinematicBody *_body = _body_ref.get_ref();
|
||||
|
||||
@ -146,10 +134,8 @@ _body_ref = val;
|
||||
if (calculate_velocities) {
|
||||
linear_velocity = velocity;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GSAIKinematicBody3DAgent::_apply_orientation_steering(const float angular_acceleration, const float delta) {
|
||||
KinematicBody *_body = _body_ref.get_ref();
|
||||
|
||||
@ -168,10 +154,8 @@ _body_ref = val;
|
||||
if (calculate_velocities) {
|
||||
angular_velocity = velocity;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GSAIKinematicBody3DAgent::_set_body(const KinematicBody &value) {
|
||||
bool had_body = false;
|
||||
|
||||
@ -187,21 +171,16 @@ _body_ref = val;
|
||||
orientation = last_orientation;
|
||||
|
||||
if (!had_body) {
|
||||
|
||||
if (!body.is_inside_tree()) {
|
||||
body.connect("ready", self, "_body_ready");
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
_body_ready();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GSAIKinematicBody3DAgent::_on_SceneTree_physics_frame() {
|
||||
KinematicBody *_body = _body_ref.get_ref();
|
||||
|
||||
@ -209,7 +188,6 @@ _body_ref = val;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!_body.is_inside_tree() || _body.get_tree().paused) {
|
||||
return;
|
||||
}
|
||||
@ -220,12 +198,10 @@ _body_ref = val;
|
||||
orientation = current_orientation;
|
||||
|
||||
if (calculate_velocities) {
|
||||
|
||||
if (applied_steering) {
|
||||
applied_steering = false;
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
linear_velocity = GSAIUtils.clampedv3(current_position - _last_position, linear_speed_max);
|
||||
|
||||
@ -242,11 +218,8 @@ _body_ref = val;
|
||||
_last_position = current_position;
|
||||
last_orientation = current_orientation;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAIKinematicBody3DAgent::GSAIKinematicBody3DAgent() {
|
||||
@ -259,28 +232,23 @@ _body_ref = val;
|
||||
GSAIKinematicBody3DAgent::~GSAIKinematicBody3DAgent() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAIKinematicBody3DAgent::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_*body"), &GSAIKinematicBody3DAgent::get_ * body);
|
||||
ClassDB::bind_method(D_METHOD("set_*body", "value"), &GSAIKinematicBody3DAgent::set_ * body);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*body", PROPERTY_HINT_RESOURCE_TYPE, "KinematicBody"), "set_*body", "get_*body");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_movement_type"), &GSAIKinematicBody3DAgent::get_movement_type);
|
||||
ClassDB::bind_method(D_METHOD("set_movement_type", "value"), &GSAIKinematicBody3DAgent::set_movement_type);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "movement_type"), "set_movement_type", "get_movement_type");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get__last_position"), &GSAIKinematicBody3DAgent::get__last_position);
|
||||
ClassDB::bind_method(D_METHOD("set__last_position", "value"), &GSAIKinematicBody3DAgent::set__last_position);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "_last_position"), "set__last_position", "get__last_position");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get__body_ref"), &GSAIKinematicBody3DAgent::get__body_ref);
|
||||
ClassDB::bind_method(D_METHOD("set__body_ref", "value"), &GSAIKinematicBody3DAgent::set__body_ref);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "_body_ref", PROPERTY_HINT_RESOURCE_TYPE, "Ref<WeakRef>"), "set__body_ref", "get__body_ref");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_body_ready"), &GSAIKinematicBody3DAgent::_body_ready);
|
||||
ClassDB::bind_method(D_METHOD("_apply_steering", "acceleration", "delta"), &GSAIKinematicBody3DAgent::_apply_steering);
|
||||
ClassDB::bind_method(D_METHOD("_apply_sliding_steering", "accel", "delta"), &GSAIKinematicBody3DAgent::_apply_sliding_steering);
|
||||
@ -289,8 +257,4 @@ _body_ref = val;
|
||||
ClassDB::bind_method(D_METHOD("_apply_orientation_steering", "angular_acceleration", "delta"), &GSAIKinematicBody3DAgent::_apply_orientation_steering);
|
||||
ClassDB::bind_method(D_METHOD("_set_body", "value"), &GSAIKinematicBody3DAgent::_set_body);
|
||||
ClassDB::bind_method(D_METHOD("_on_SceneTree_physics_frame"), &GSAIKinematicBody3DAgent::_on_SceneTree_physics_frame);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef GSAIKINEMATICBODY3DAGENT_H
|
||||
#define GSAIKINEMATICBODY3DAGENT_H
|
||||
|
||||
|
||||
class GSAIKinematicBody3DAgent : public GSAISpecializedAgent {
|
||||
GDCLASS(GSAIKinematicBody3DAgent, GSAISpecializedAgent);
|
||||
|
||||
public:
|
||||
|
||||
KinematicBody get_ *body();
|
||||
void set_ *body(const KinematicBody &val);
|
||||
|
||||
@ -57,7 +55,7 @@ class GSAIKinematicBody3DAgent : public GSAISpecializedAgent {
|
||||
Ref<WeakRef> _body_ref;
|
||||
// Moves the agent's `body` by target `acceleration`.
|
||||
// @tags - virtual
|
||||
};
|
||||
|
||||
}
|
||||
;
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "gsai_rigid_body_2d_agent.h"
|
||||
|
||||
|
||||
RigidBody2D GSAIRigidBody2DAgent::get_ *body() {
|
||||
return *body;
|
||||
}
|
||||
@ -10,7 +9,6 @@ void GSAIRigidBody2DAgent::set_*body(const RigidBody2D &val) {
|
||||
*body = val;
|
||||
}
|
||||
|
||||
|
||||
Vector2 GSAIRigidBody2DAgent::get__last_position() {
|
||||
return _last_position;
|
||||
}
|
||||
@ -19,7 +17,6 @@ void GSAIRigidBody2DAgent::set__last_position(const Vector2 &val) {
|
||||
_last_position = val;
|
||||
}
|
||||
|
||||
|
||||
Ref<WeakRef> GSAIRigidBody2DAgent::get__body_ref() {
|
||||
return _body_ref;
|
||||
}
|
||||
@ -28,8 +25,6 @@ void GSAIRigidBody2DAgent::set__body_ref(const Ref<WeakRef> &val) {
|
||||
_body_ref = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// A specialized steering agent that updates itself every frame so the user does;
|
||||
// not have to using a RigidBody2D;
|
||||
// @category - Specialized agents;
|
||||
@ -62,10 +57,8 @@ _body_ref = val;
|
||||
linear_velocity = GSAIUtils.to_vector3(_body.linear_velocity);
|
||||
angular_velocity = _body.angular_velocity;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GSAIRigidBody2DAgent::_set_body(const RigidBody2D &value) {
|
||||
bool had_body = false;
|
||||
|
||||
@ -81,21 +74,16 @@ _body_ref = val;
|
||||
orientation = last_orientation;
|
||||
|
||||
if (!had_body) {
|
||||
|
||||
if (!body.is_inside_tree()) {
|
||||
body.connect("ready", self, "_body_ready");
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
_body_ready();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GSAIRigidBody2DAgent::_on_SceneTree_frame() {
|
||||
RigidBody2D *_body = _body_ref.get_ref();
|
||||
|
||||
@ -103,7 +91,6 @@ _body_ref = val;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!_body.is_inside_tree() || _body.get_tree().paused) {
|
||||
return;
|
||||
}
|
||||
@ -114,21 +101,16 @@ _body_ref = val;
|
||||
orientation = current_orientation;
|
||||
|
||||
if (calculate_velocities) {
|
||||
|
||||
if (applied_steering) {
|
||||
applied_steering = false;
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
linear_velocity = GSAIUtils.to_vector3(_body.linear_velocity);
|
||||
angular_velocity = _body.angular_velocity;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAIRigidBody2DAgent::GSAIRigidBody2DAgent() {
|
||||
@ -140,29 +122,21 @@ _body_ref = val;
|
||||
GSAIRigidBody2DAgent::~GSAIRigidBody2DAgent() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAIRigidBody2DAgent::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_*body"), &GSAIRigidBody2DAgent::get_ * body);
|
||||
ClassDB::bind_method(D_METHOD("set_*body", "value"), &GSAIRigidBody2DAgent::set_ * body);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*body", PROPERTY_HINT_RESOURCE_TYPE, "RigidBody2D"), "set_*body", "get_*body");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get__last_position"), &GSAIRigidBody2DAgent::get__last_position);
|
||||
ClassDB::bind_method(D_METHOD("set__last_position", "value"), &GSAIRigidBody2DAgent::set__last_position);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "_last_position"), "set__last_position", "get__last_position");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get__body_ref"), &GSAIRigidBody2DAgent::get__body_ref);
|
||||
ClassDB::bind_method(D_METHOD("set__body_ref", "value"), &GSAIRigidBody2DAgent::set__body_ref);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "_body_ref", PROPERTY_HINT_RESOURCE_TYPE, "Ref<WeakRef>"), "set__body_ref", "get__body_ref");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_body_ready"), &GSAIRigidBody2DAgent::_body_ready);
|
||||
ClassDB::bind_method(D_METHOD("_apply_steering", "acceleration", "_delta"), &GSAIRigidBody2DAgent::_apply_steering);
|
||||
ClassDB::bind_method(D_METHOD("_set_body", "value"), &GSAIRigidBody2DAgent::_set_body);
|
||||
ClassDB::bind_method(D_METHOD("_on_SceneTree_frame"), &GSAIRigidBody2DAgent::_on_SceneTree_frame);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef GSAIRIGIDBODY2DAGENT_H
|
||||
#define GSAIRIGIDBODY2DAGENT_H
|
||||
|
||||
|
||||
class GSAIRigidBody2DAgent : public GSAISpecializedAgent {
|
||||
GDCLASS(GSAIRigidBody2DAgent, GSAISpecializedAgent);
|
||||
|
||||
public:
|
||||
|
||||
RigidBody2D get_ *body();
|
||||
void set_ *body(const RigidBody2D &val);
|
||||
|
||||
@ -39,5 +37,4 @@ class GSAIRigidBody2DAgent : public GSAISpecializedAgent {
|
||||
// @tags - virtual
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "gsai_rigid_body_3d_agent.h"
|
||||
|
||||
|
||||
RigidBody GSAIRigidBody3DAgent::get_ *body() {
|
||||
return *body;
|
||||
}
|
||||
@ -10,7 +9,6 @@ void GSAIRigidBody3DAgent::set_*body(const RigidBody &val) {
|
||||
*body = val;
|
||||
}
|
||||
|
||||
|
||||
Vector3 GSAIRigidBody3DAgent::get__last_position() {
|
||||
return _last_position;
|
||||
}
|
||||
@ -19,7 +17,6 @@ void GSAIRigidBody3DAgent::set__last_position(const Vector3 &val) {
|
||||
_last_position = val;
|
||||
}
|
||||
|
||||
|
||||
Ref<WeakRef> GSAIRigidBody3DAgent::get__body_ref() {
|
||||
return _body_ref;
|
||||
}
|
||||
@ -28,8 +25,6 @@ void GSAIRigidBody3DAgent::set__body_ref(const Ref<WeakRef> &val) {
|
||||
_body_ref = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// A specialized steering agent that updates itself every frame so the user does;
|
||||
// not have to using a RigidBody;
|
||||
// @category - Specialized agents;
|
||||
@ -62,10 +57,8 @@ _body_ref = val;
|
||||
linear_velocity = _body.linear_velocity;
|
||||
angular_velocity = _body.angular_velocity.y;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GSAIRigidBody3DAgent::_set_body(const RigidBody &value) {
|
||||
bool had_body = false;
|
||||
|
||||
@ -81,21 +74,16 @@ _body_ref = val;
|
||||
orientation = last_orientation;
|
||||
|
||||
if (!had_body) {
|
||||
|
||||
if (!body.is_inside_tree()) {
|
||||
body.connect("ready", self, "_body_ready");
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
_body_ready();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GSAIRigidBody3DAgent::_on_SceneTree_frame() {
|
||||
RigidBody *_body = _body_ref.get_ref();
|
||||
|
||||
@ -103,7 +91,6 @@ _body_ref = val;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (not _body.is_inside_tree() || _body.get_tree().paused) {
|
||||
return;
|
||||
}
|
||||
@ -114,21 +101,16 @@ _body_ref = val;
|
||||
orientation = current_orientation;
|
||||
|
||||
if (calculate_velocities) {
|
||||
|
||||
if (applied_steering) {
|
||||
applied_steering = false;
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
linear_velocity = _body.linear_velocity;
|
||||
angular_velocity = _body.angular_velocity.y;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAIRigidBody3DAgent::GSAIRigidBody3DAgent() {
|
||||
@ -140,29 +122,21 @@ _body_ref = val;
|
||||
GSAIRigidBody3DAgent::~GSAIRigidBody3DAgent() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAIRigidBody3DAgent::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_*body"), &GSAIRigidBody3DAgent::get_ * body);
|
||||
ClassDB::bind_method(D_METHOD("set_*body", "value"), &GSAIRigidBody3DAgent::set_ * body);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*body", PROPERTY_HINT_RESOURCE_TYPE, "RigidBody"), "set_*body", "get_*body");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get__last_position"), &GSAIRigidBody3DAgent::get__last_position);
|
||||
ClassDB::bind_method(D_METHOD("set__last_position", "value"), &GSAIRigidBody3DAgent::set__last_position);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "_last_position"), "set__last_position", "get__last_position");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get__body_ref"), &GSAIRigidBody3DAgent::get__body_ref);
|
||||
ClassDB::bind_method(D_METHOD("set__body_ref", "value"), &GSAIRigidBody3DAgent::set__body_ref);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "_body_ref", PROPERTY_HINT_RESOURCE_TYPE, "Ref<WeakRef>"), "set__body_ref", "get__body_ref");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_body_ready"), &GSAIRigidBody3DAgent::_body_ready);
|
||||
ClassDB::bind_method(D_METHOD("_apply_steering", "acceleration", "_delta"), &GSAIRigidBody3DAgent::_apply_steering);
|
||||
ClassDB::bind_method(D_METHOD("_set_body", "value"), &GSAIRigidBody3DAgent::_set_body);
|
||||
ClassDB::bind_method(D_METHOD("_on_SceneTree_frame"), &GSAIRigidBody3DAgent::_on_SceneTree_frame);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef GSAIRIGIDBODY3DAGENT_H
|
||||
#define GSAIRIGIDBODY3DAGENT_H
|
||||
|
||||
|
||||
class GSAIRigidBody3DAgent : public GSAISpecializedAgent {
|
||||
GDCLASS(GSAIRigidBody3DAgent, GSAISpecializedAgent);
|
||||
|
||||
public:
|
||||
|
||||
RigidBody get_ *body();
|
||||
void set_ *body(const RigidBody &val);
|
||||
|
||||
@ -39,5 +37,4 @@ class GSAIRigidBody3DAgent : public GSAISpecializedAgent {
|
||||
// @tags - virtual
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "gsai_specialize_dagent.h"
|
||||
|
||||
|
||||
bool GSAISpecializedAgent::get_calculate_velocities() const {
|
||||
return calculate_velocities;
|
||||
}
|
||||
@ -10,7 +9,6 @@ void GSAISpecializedAgent::set_calculate_velocities(const bool val) {
|
||||
calculate_velocities = val;
|
||||
}
|
||||
|
||||
|
||||
bool GSAISpecializedAgent::get_apply_linear_drag() const {
|
||||
return apply_linear_drag;
|
||||
}
|
||||
@ -19,7 +17,6 @@ void GSAISpecializedAgent::set_apply_linear_drag(const bool val) {
|
||||
apply_linear_drag = val;
|
||||
}
|
||||
|
||||
|
||||
bool GSAISpecializedAgent::get_apply_angular_drag() const {
|
||||
return apply_angular_drag;
|
||||
}
|
||||
@ -28,7 +25,6 @@ void GSAISpecializedAgent::set_apply_angular_drag(const bool val) {
|
||||
apply_angular_drag = val;
|
||||
}
|
||||
|
||||
|
||||
float GSAISpecializedAgent::get_linear_drag_percentage() const {
|
||||
return linear_drag_percentage;
|
||||
}
|
||||
@ -37,7 +33,6 @@ void GSAISpecializedAgent::set_linear_drag_percentage(const float val) {
|
||||
linear_drag_percentage = val;
|
||||
}
|
||||
|
||||
|
||||
float GSAISpecializedAgent::get_angular_drag_percentage() const {
|
||||
return angular_drag_percentage;
|
||||
}
|
||||
@ -46,7 +41,6 @@ void GSAISpecializedAgent::set_angular_drag_percentage(const float val) {
|
||||
angular_drag_percentage = val;
|
||||
}
|
||||
|
||||
|
||||
float GSAISpecializedAgent::get_last_orientation() const {
|
||||
return last_orientation;
|
||||
}
|
||||
@ -55,7 +49,6 @@ void GSAISpecializedAgent::set_last_orientation(const float val) {
|
||||
last_orientation = val;
|
||||
}
|
||||
|
||||
|
||||
bool GSAISpecializedAgent::get_applied_steering() const {
|
||||
return applied_steering;
|
||||
}
|
||||
@ -64,8 +57,6 @@ void GSAISpecializedAgent::set_applied_steering(const bool val) {
|
||||
applied_steering = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// A base class for a specialized steering agent that updates itself every frame;
|
||||
// so the user does not have to. All other specialized agents derive from this.;
|
||||
// @category - Specialized agents;
|
||||
@ -102,7 +93,6 @@ applied_steering = val;
|
||||
void GSAISpecializedAgent::_apply_steering(const GSAITargetAcceleration &_acceleration, const float _delta) {
|
||||
pass;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAISpecializedAgent::GSAISpecializedAgent() {
|
||||
@ -118,47 +108,35 @@ applied_steering = val;
|
||||
GSAISpecializedAgent::~GSAISpecializedAgent() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAISpecializedAgent::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_calculate_velocities"), &GSAISpecializedAgent::get_calculate_velocities);
|
||||
ClassDB::bind_method(D_METHOD("set_calculate_velocities", "value"), &GSAISpecializedAgent::set_calculate_velocities);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "calculate_velocities"), "set_calculate_velocities", "get_calculate_velocities");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_apply_linear_drag"), &GSAISpecializedAgent::get_apply_linear_drag);
|
||||
ClassDB::bind_method(D_METHOD("set_apply_linear_drag", "value"), &GSAISpecializedAgent::set_apply_linear_drag);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "apply_linear_drag"), "set_apply_linear_drag", "get_apply_linear_drag");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_apply_angular_drag"), &GSAISpecializedAgent::get_apply_angular_drag);
|
||||
ClassDB::bind_method(D_METHOD("set_apply_angular_drag", "value"), &GSAISpecializedAgent::set_apply_angular_drag);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "apply_angular_drag"), "set_apply_angular_drag", "get_apply_angular_drag");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_linear_drag_percentage"), &GSAISpecializedAgent::get_linear_drag_percentage);
|
||||
ClassDB::bind_method(D_METHOD("set_linear_drag_percentage", "value"), &GSAISpecializedAgent::set_linear_drag_percentage);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "linear_drag_percentage"), "set_linear_drag_percentage", "get_linear_drag_percentage");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_angular_drag_percentage"), &GSAISpecializedAgent::get_angular_drag_percentage);
|
||||
ClassDB::bind_method(D_METHOD("set_angular_drag_percentage", "value"), &GSAISpecializedAgent::set_angular_drag_percentage);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_drag_percentage"), "set_angular_drag_percentage", "get_angular_drag_percentage");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_last_orientation"), &GSAISpecializedAgent::get_last_orientation);
|
||||
ClassDB::bind_method(D_METHOD("set_last_orientation", "value"), &GSAISpecializedAgent::set_last_orientation);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "last_orientation"), "set_last_orientation", "get_last_orientation");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_applied_steering"), &GSAISpecializedAgent::get_applied_steering);
|
||||
ClassDB::bind_method(D_METHOD("set_applied_steering", "value"), &GSAISpecializedAgent::set_applied_steering);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "applied_steering"), "set_applied_steering", "get_applied_steering");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("apply_steering", "_acceleration", "_delta"), &GSAISpecializedAgent::apply_steering);
|
||||
ClassDB::bind_method(D_METHOD("_apply_steering", "_acceleration", "_delta"), &GSAISpecializedAgent::_apply_steering);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef GSAISPECIALIZEDAGENT_H
|
||||
#define GSAISPECIALIZEDAGENT_H
|
||||
|
||||
|
||||
class GSAISpecializedAgent : public GSAISteeringAgent {
|
||||
GDCLASS(GSAISpecializedAgent, GSAISteeringAgent);
|
||||
|
||||
public:
|
||||
|
||||
bool get_calculate_velocities() const;
|
||||
void set_calculate_velocities(const bool val);
|
||||
|
||||
@ -66,5 +64,4 @@ class GSAISpecializedAgent : public GSAISteeringAgent {
|
||||
// @tags - virtual
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "gsai_arrive.h"
|
||||
|
||||
|
||||
GSAIAgentLocation GSAIArrive::get_ *target() {
|
||||
return *target;
|
||||
}
|
||||
@ -10,7 +9,6 @@ void GSAIArrive::set_*target(const GSAIAgentLocation &val) {
|
||||
*target = val;
|
||||
}
|
||||
|
||||
|
||||
float GSAIArrive::get_arrival_tolerance() const {
|
||||
return arrival_tolerance;
|
||||
}
|
||||
@ -19,7 +17,6 @@ void GSAIArrive::set_arrival_tolerance(const float val) {
|
||||
arrival_tolerance = val;
|
||||
}
|
||||
|
||||
|
||||
float GSAIArrive::get_deceleration_radius() const {
|
||||
return deceleration_radius;
|
||||
}
|
||||
@ -28,7 +25,6 @@ void GSAIArrive::set_deceleration_radius(const float val) {
|
||||
deceleration_radius = val;
|
||||
}
|
||||
|
||||
|
||||
float GSAIArrive::get_time_to_reach() const {
|
||||
return time_to_reach;
|
||||
}
|
||||
@ -37,8 +33,6 @@ void GSAIArrive::set_time_to_reach(const float val) {
|
||||
time_to_reach = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Calculates acceleration to take an agent to its target's location. The;
|
||||
// calculation attempts to arrive with zero remaining velocity.;
|
||||
// @category - Individual behaviors;
|
||||
@ -56,7 +50,6 @@ time_to_reach = val;
|
||||
call("_arrive", acceleration, target_position);
|
||||
}
|
||||
|
||||
|
||||
void GSAIArrive::_arrive(const GSAITargetAcceleration &acceleration, const Vector3 &target_position) {
|
||||
Vector3 to_target = target_position - agent.position;
|
||||
float distance = to_target.length();
|
||||
@ -65,7 +58,6 @@ time_to_reach = val;
|
||||
acceleration.set_zero();
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
float desired_speed = agent.linear_speed_max;
|
||||
|
||||
@ -78,14 +70,11 @@ time_to_reach = val;
|
||||
acceleration.linear = GSAIUtils.clampedv3(desired_velocity, agent.linear_acceleration_max);
|
||||
acceleration.angular = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GSAIArrive::_calculate_steering(const GSAITargetAcceleration &acceleration) {
|
||||
arrive(acceleration, target.position);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAIArrive::GSAIArrive() {
|
||||
@ -98,33 +87,24 @@ time_to_reach = val;
|
||||
GSAIArrive::~GSAIArrive() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAIArrive::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_*target"), &GSAIArrive::get_ * target);
|
||||
ClassDB::bind_method(D_METHOD("set_*target", "value"), &GSAIArrive::set_ * target);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*target", PROPERTY_HINT_RESOURCE_TYPE, "GSAIAgentLocation"), "set_*target", "get_*target");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_arrival_tolerance"), &GSAIArrive::get_arrival_tolerance);
|
||||
ClassDB::bind_method(D_METHOD("set_arrival_tolerance", "value"), &GSAIArrive::set_arrival_tolerance);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "arrival_tolerance"), "set_arrival_tolerance", "get_arrival_tolerance");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_deceleration_radius"), &GSAIArrive::get_deceleration_radius);
|
||||
ClassDB::bind_method(D_METHOD("set_deceleration_radius", "value"), &GSAIArrive::set_deceleration_radius);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "deceleration_radius"), "set_deceleration_radius", "get_deceleration_radius");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_time_to_reach"), &GSAIArrive::get_time_to_reach);
|
||||
ClassDB::bind_method(D_METHOD("set_time_to_reach", "value"), &GSAIArrive::set_time_to_reach);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "time_to_reach"), "set_time_to_reach", "get_time_to_reach");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("arrive", "acceleration", "target_position"), &GSAIArrive::arrive);
|
||||
ClassDB::bind_method(D_METHOD("_arrive", "acceleration", "target_position"), &GSAIArrive::_arrive);
|
||||
ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAIArrive::_calculate_steering);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef GSAIARRIVE_H
|
||||
#define GSAIARRIVE_H
|
||||
|
||||
|
||||
class GSAIArrive : public GSAISteeringBehavior {
|
||||
GDCLASS(GSAIArrive, GSAISteeringBehavior);
|
||||
|
||||
public:
|
||||
|
||||
GSAIAgentLocation get_ *target();
|
||||
void set_ *target(const GSAIAgentLocation &val);
|
||||
|
||||
@ -43,5 +41,4 @@ class GSAIArrive : public GSAISteeringBehavior {
|
||||
float time_to_reach = 0.1;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "gsai_avoid_collisions.h"
|
||||
|
||||
|
||||
GSAISteeringAgent GSAIAvoidCollisions::get_ *_first_neighbor() {
|
||||
return *_first_neighbor;
|
||||
}
|
||||
@ -10,7 +9,6 @@ void GSAIAvoidCollisions::set_*_first_neighbor(const GSAISteeringAgent &val) {
|
||||
*_first_neighbor = val;
|
||||
}
|
||||
|
||||
|
||||
float GSAIAvoidCollisions::get__shortest_time() const {
|
||||
return _shortest_time;
|
||||
}
|
||||
@ -19,7 +17,6 @@ void GSAIAvoidCollisions::set__shortest_time(const float val) {
|
||||
_shortest_time = val;
|
||||
}
|
||||
|
||||
|
||||
float GSAIAvoidCollisions::get__first_minimum_separation() const {
|
||||
return _first_minimum_separation;
|
||||
}
|
||||
@ -28,7 +25,6 @@ void GSAIAvoidCollisions::set__first_minimum_separation(const float val) {
|
||||
_first_minimum_separation = val;
|
||||
}
|
||||
|
||||
|
||||
float GSAIAvoidCollisions::get__first_distance() const {
|
||||
return _first_distance;
|
||||
}
|
||||
@ -37,7 +33,6 @@ void GSAIAvoidCollisions::set__first_distance(const float val) {
|
||||
_first_distance = val;
|
||||
}
|
||||
|
||||
|
||||
Vector3 GSAIAvoidCollisions::get__first_relative_position() {
|
||||
return _first_relative_position;
|
||||
}
|
||||
@ -46,7 +41,6 @@ void GSAIAvoidCollisions::set__first_relative_position(const Vector3 &val) {
|
||||
_first_relative_position = val;
|
||||
}
|
||||
|
||||
|
||||
Vector3 GSAIAvoidCollisions::get__first_relative_velocity() {
|
||||
return _first_relative_velocity;
|
||||
}
|
||||
@ -55,8 +49,6 @@ void GSAIAvoidCollisions::set__first_relative_velocity(const Vector3 &val) {
|
||||
_first_relative_velocity = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Steers the agent to avoid obstacles in its path. Approximates obstacles as;
|
||||
// spheres.;
|
||||
// @category - Group behaviors;
|
||||
@ -78,18 +70,14 @@ _first_relative_velocity = val;
|
||||
acceleration.set_zero();
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
|
||||
if ((_first_minimum_separation <= 0 || _first_distance < agent.bounding_radius + _first_neighbor.bounding_radius)) {
|
||||
acceleration.linear = _first_neighbor.position - agent.position;
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
acceleration.linear = (_first_relative_position + (_first_relative_velocity * _shortest_time));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
acceleration.linear = (acceleration.linear.normalized() * -agent.linear_acceleration_max);
|
||||
@ -109,7 +97,6 @@ _first_relative_velocity = val;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
float time_to_collision = -relative_position.dot(relative_velocity) / relative_speed_squared;
|
||||
|
||||
@ -117,7 +104,6 @@ _first_relative_velocity = val;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
Variant = relative_position.length();
|
||||
float minimum_separation = (distance - sqrt(relative_speed_squared) * time_to_collision);
|
||||
@ -126,7 +112,6 @@ _first_relative_velocity = val;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
_shortest_time = time_to_collision;
|
||||
_first_neighbor = neighbor;
|
||||
@ -136,13 +121,9 @@ _first_relative_velocity = val;
|
||||
_first_relative_velocity = relative_velocity;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAIAvoidCollisions::GSAIAvoidCollisions() {
|
||||
@ -157,42 +138,31 @@ _first_relative_velocity = val;
|
||||
GSAIAvoidCollisions::~GSAIAvoidCollisions() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAIAvoidCollisions::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_*_first_neighbor"), &GSAIAvoidCollisions::get_ * _first_neighbor);
|
||||
ClassDB::bind_method(D_METHOD("set_*_first_neighbor", "value"), &GSAIAvoidCollisions::set_ * _first_neighbor);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*_first_neighbor", PROPERTY_HINT_RESOURCE_TYPE, "GSAISteeringAgent"), "set_*_first_neighbor", "get_*_first_neighbor");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get__shortest_time"), &GSAIAvoidCollisions::get__shortest_time);
|
||||
ClassDB::bind_method(D_METHOD("set__shortest_time", "value"), &GSAIAvoidCollisions::set__shortest_time);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "_shortest_time"), "set__shortest_time", "get__shortest_time");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get__first_minimum_separation"), &GSAIAvoidCollisions::get__first_minimum_separation);
|
||||
ClassDB::bind_method(D_METHOD("set__first_minimum_separation", "value"), &GSAIAvoidCollisions::set__first_minimum_separation);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "_first_minimum_separation"), "set__first_minimum_separation", "get__first_minimum_separation");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get__first_distance"), &GSAIAvoidCollisions::get__first_distance);
|
||||
ClassDB::bind_method(D_METHOD("set__first_distance", "value"), &GSAIAvoidCollisions::set__first_distance);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "_first_distance"), "set__first_distance", "get__first_distance");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get__first_relative_position"), &GSAIAvoidCollisions::get__first_relative_position);
|
||||
ClassDB::bind_method(D_METHOD("set__first_relative_position", "value"), &GSAIAvoidCollisions::set__first_relative_position);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "_first_relative_position"), "set__first_relative_position", "get__first_relative_position");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get__first_relative_velocity"), &GSAIAvoidCollisions::get__first_relative_velocity);
|
||||
ClassDB::bind_method(D_METHOD("set__first_relative_velocity", "value"), &GSAIAvoidCollisions::set__first_relative_velocity);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "_first_relative_velocity"), "set__first_relative_velocity", "get__first_relative_velocity");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAIAvoidCollisions::_calculate_steering);
|
||||
ClassDB::bind_method(D_METHOD("_report_neighbor", "neighbor"), &GSAIAvoidCollisions::_report_neighbor);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef GSAIAVOIDCOLLISIONS_H
|
||||
#define GSAIAVOIDCOLLISIONS_H
|
||||
|
||||
|
||||
class GSAIAvoidCollisions : public GSAIGroupBehavior {
|
||||
GDCLASS(GSAIAvoidCollisions, GSAIGroupBehavior);
|
||||
|
||||
public:
|
||||
|
||||
GSAISteeringAgent get_ *_first_neighbor();
|
||||
void set_ *_first_neighbor(const GSAISteeringAgent &val);
|
||||
|
||||
@ -48,5 +46,4 @@ class GSAIAvoidCollisions : public GSAIGroupBehavior {
|
||||
// @tags - virtual
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "gsai_blend.h"
|
||||
|
||||
|
||||
Array GSAIBlend::get__behaviors() {
|
||||
return _behaviors;
|
||||
}
|
||||
@ -10,7 +9,6 @@ void GSAIBlend::set__behaviors(const Array &val) {
|
||||
_behaviors = val;
|
||||
}
|
||||
|
||||
|
||||
GSAITargetAcceleration GSAIBlend::get_ *_accel() {
|
||||
return *_accel;
|
||||
}
|
||||
@ -19,8 +17,6 @@ void GSAIBlend::set_*_accel(const GSAITargetAcceleration &val) {
|
||||
*_accel = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Blends multiple steering behaviors into one, and returns a weighted;
|
||||
// acceleration from their calculations.;
|
||||
//;
|
||||
@ -46,7 +42,6 @@ void GSAIBlend::set_*_accel(const GSAITargetAcceleration &val) {
|
||||
// none was found.;
|
||||
|
||||
Dictionary GSAIBlend::get_behavior(const int index) {
|
||||
|
||||
if (_behaviors.size() > index) {
|
||||
return _behaviors[index];
|
||||
}
|
||||
@ -55,9 +50,7 @@ void GSAIBlend::set_*_accel(const GSAITargetAcceleration &val) {
|
||||
return Dictionary();
|
||||
}
|
||||
|
||||
|
||||
void GSAIBlend::remove_behavior(const int index) {
|
||||
|
||||
if (_behaviors.size() > index) {
|
||||
_behaviors.remove(index);
|
||||
return;
|
||||
@ -67,17 +60,14 @@ void GSAIBlend::set_*_accel(const GSAITargetAcceleration &val) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int GSAIBlend::get_behaviour_count() {
|
||||
return _behaviors.size();
|
||||
}
|
||||
|
||||
|
||||
GSAITargetAcceleration GSAIBlend::get_accel() {
|
||||
return _accel;
|
||||
}
|
||||
|
||||
|
||||
void GSAIBlend::_calculate_steering(const GSAITargetAcceleration &blended_accel) {
|
||||
blended_accel.set_zero();
|
||||
|
||||
@ -90,7 +80,6 @@ void GSAIBlend::set_*_accel(const GSAITargetAcceleration &val) {
|
||||
blended_accel.linear = GSAIUtils.clampedv3(blended_accel.linear, agent.linear_acceleration_max);
|
||||
blended_accel.angular = clamp(blended_accel.angular, -agent.angular_acceleration_max, agent.angular_acceleration_max);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAIBlend::GSAIBlend() {
|
||||
@ -101,26 +90,19 @@ void GSAIBlend::set_*_accel(const GSAITargetAcceleration &val) {
|
||||
GSAIBlend::~GSAIBlend() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAIBlend::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get__behaviors"), &GSAIBlend::get__behaviors);
|
||||
ClassDB::bind_method(D_METHOD("set__behaviors", "value"), &GSAIBlend::set__behaviors);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "_behaviors"), "set__behaviors", "get__behaviors");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_*_accel"), &GSAIBlend::get_ * _accel);
|
||||
ClassDB::bind_method(D_METHOD("set_*_accel", "value"), &GSAIBlend::set_ * _accel);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*_accel", PROPERTY_HINT_RESOURCE_TYPE, "GSAITargetAcceleration"), "set_*_accel", "get_*_accel");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("add_behavior", "behavior", "weight"), &GSAIBlend::add_behavior);
|
||||
ClassDB::bind_method(D_METHOD("get_behavior", "index"), &GSAIBlend::get_behavior);
|
||||
ClassDB::bind_method(D_METHOD("remove_behavior", "index"), &GSAIBlend::remove_behavior);
|
||||
ClassDB::bind_method(D_METHOD("get_behaviour_count"), &GSAIBlend::get_behaviour_count);
|
||||
ClassDB::bind_method(D_METHOD("get_accel"), &GSAIBlend::get_accel);
|
||||
ClassDB::bind_method(D_METHOD("_calculate_steering", "blended_accel"), &GSAIBlend::_calculate_steering);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef GSAIBLEND_H
|
||||
#define GSAIBLEND_H
|
||||
|
||||
|
||||
class GSAIBlend : public GSAISteeringBehavior {
|
||||
GDCLASS(GSAIBlend, GSAISteeringBehavior);
|
||||
|
||||
public:
|
||||
|
||||
Array get__behaviors();
|
||||
void set__behaviors(const Array &val);
|
||||
|
||||
@ -42,5 +40,4 @@ class GSAIBlend : public GSAISteeringBehavior {
|
||||
// none was found.
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "gsai_cohesion.h"
|
||||
|
||||
|
||||
Vector3 GSAICohesion::get__center_of_mass() {
|
||||
return _center_of_mass;
|
||||
}
|
||||
@ -10,8 +9,6 @@ void GSAICohesion::set__center_of_mass(const Vector3 &val) {
|
||||
_center_of_mass = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Calculates an acceleration that attempts to move the agent towards the center;
|
||||
// of mass of the agents in the area defined by the `GSAIProximity`.;
|
||||
// @category - Group behaviors;
|
||||
@ -32,12 +29,10 @@ _center_of_mass = val;
|
||||
// @tags - virtual;
|
||||
}
|
||||
|
||||
|
||||
bool GSAICohesion::_report_neighbor(const GSAISteeringAgent &neighbor) {
|
||||
_center_of_mass += neighbor.position;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAICohesion::GSAICohesion() {
|
||||
@ -47,17 +42,11 @@ _center_of_mass = val;
|
||||
GSAICohesion::~GSAICohesion() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAICohesion::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get__center_of_mass"), &GSAICohesion::get__center_of_mass);
|
||||
ClassDB::bind_method(D_METHOD("set__center_of_mass", "value"), &GSAICohesion::set__center_of_mass);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "_center_of_mass"), "set__center_of_mass", "get__center_of_mass");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAICohesion::_calculate_steering);
|
||||
ClassDB::bind_method(D_METHOD("_report_neighbor", "neighbor"), &GSAICohesion::_report_neighbor);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef GSAICOHESION_H
|
||||
#define GSAICOHESION_H
|
||||
|
||||
|
||||
class GSAICohesion : public GSAIGroupBehavior {
|
||||
GDCLASS(GSAICohesion, GSAIGroupBehavior);
|
||||
|
||||
public:
|
||||
|
||||
Vector3 get__center_of_mass();
|
||||
void set__center_of_mass(const Vector3 &val);
|
||||
|
||||
@ -25,5 +23,4 @@ class GSAICohesion : public GSAIGroupBehavior {
|
||||
Vector3 _center_of_mass = ;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,8 +1,6 @@
|
||||
|
||||
#include "gsai_evade.h"
|
||||
|
||||
|
||||
|
||||
// Calculates acceleration to take an agent away from where a target agent is;
|
||||
// moving.;
|
||||
// @category - Individual behaviors;
|
||||
@ -10,7 +8,6 @@
|
||||
float GSAIEvade::_get_modified_acceleration() {
|
||||
return -agent.linear_acceleration_max;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAIEvade::GSAIEvade() {
|
||||
@ -19,11 +16,6 @@
|
||||
GSAIEvade::~GSAIEvade() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAIEvade::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_get_modified_acceleration"), &GSAIEvade::_get_modified_acceleration);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef GSAIEVADE_H
|
||||
#define GSAIEVADE_H
|
||||
|
||||
|
||||
class GSAIEvade : public GSAIPursue {
|
||||
GDCLASS(GSAIEvade, GSAIPursue);
|
||||
|
||||
public:
|
||||
|
||||
float _get_modified_acceleration();
|
||||
|
||||
GSAIEvade();
|
||||
@ -20,5 +18,4 @@ class GSAIEvade : public GSAIPursue {
|
||||
// @category - Individual behaviors
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,8 +1,6 @@
|
||||
|
||||
#include "gsai_face.h"
|
||||
|
||||
|
||||
|
||||
// Calculates angular acceleration to rotate a target to face its target's;
|
||||
// position. The behavior attemps to arrive with zero remaining angular velocity.;
|
||||
// @category - Individual behaviors;
|
||||
@ -11,7 +9,6 @@
|
||||
call("_face", acceleration, target_position);
|
||||
}
|
||||
|
||||
|
||||
void GSAIFace::_face(const GSAITargetAcceleration &acceleration, const Vector3 &target_position) {
|
||||
Vector3 to_target = target_position - agent.position;
|
||||
float distance_squared = to_target.length_squared();
|
||||
@ -20,7 +17,6 @@
|
||||
acceleration.set_zero();
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
float orientation = ;
|
||||
|
||||
@ -28,21 +24,17 @@
|
||||
orientation = GSAIUtils.vector3_to_angle(to_target);
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
orientation = GSAIUtils.vector2_to_angle(GSAIUtils.to_vector2(to_target));
|
||||
}
|
||||
|
||||
match_orientation(acceleration, orientation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GSAIFace::_calculate_steering(const GSAITargetAcceleration &acceleration) {
|
||||
face(acceleration, target.position);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAIFace::GSAIFace() {
|
||||
@ -51,13 +43,8 @@
|
||||
GSAIFace::~GSAIFace() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAIFace::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("face", "acceleration", "target_position"), &GSAIFace::face);
|
||||
ClassDB::bind_method(D_METHOD("_face", "acceleration", "target_position"), &GSAIFace::_face);
|
||||
ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAIFace::_calculate_steering);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef GSAIFACE_H
|
||||
#define GSAIFACE_H
|
||||
|
||||
|
||||
class GSAIFace : public GSAIMatchOrientation {
|
||||
GDCLASS(GSAIFace, GSAIMatchOrientation);
|
||||
|
||||
public:
|
||||
|
||||
void face(const GSAITargetAcceleration &acceleration, const Vector3 &target_position);
|
||||
void _face(const GSAITargetAcceleration &acceleration, const Vector3 &target_position);
|
||||
void _calculate_steering(const GSAITargetAcceleration &acceleration);
|
||||
@ -22,5 +20,4 @@ class GSAIFace : public GSAIMatchOrientation {
|
||||
// @category - Individual behaviors
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,8 +1,6 @@
|
||||
|
||||
#include "gsai_flee.h"
|
||||
|
||||
|
||||
|
||||
// Calculates acceleration to take an agent directly away from a target agent.;
|
||||
// @category - Individual behaviors;
|
||||
|
||||
@ -10,7 +8,6 @@
|
||||
acceleration.linear = ((agent.position - target.position).normalized() * agent.linear_acceleration_max);
|
||||
acceleration.angular = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAIFlee::GSAIFlee() {
|
||||
@ -19,11 +16,6 @@
|
||||
GSAIFlee::~GSAIFlee() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAIFlee::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAIFlee::_calculate_steering);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef GSAIFLEE_H
|
||||
#define GSAIFLEE_H
|
||||
|
||||
|
||||
class GSAIFlee : public GSAISeek {
|
||||
GDCLASS(GSAIFlee, GSAISeek);
|
||||
|
||||
public:
|
||||
|
||||
void _calculate_steering(const GSAITargetAcceleration &acceleration);
|
||||
|
||||
GSAIFlee();
|
||||
@ -19,5 +17,4 @@ class GSAIFlee : public GSAISeek {
|
||||
// @category - Individual behaviors
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "gsai_follow_path.h"
|
||||
|
||||
|
||||
GSAIPath GSAIFollowPath::get_ *path() {
|
||||
return *path;
|
||||
}
|
||||
@ -10,7 +9,6 @@ void GSAIFollowPath::set_*path(const GSAIPath &val) {
|
||||
*path = val;
|
||||
}
|
||||
|
||||
|
||||
float GSAIFollowPath::get_path_offset() const {
|
||||
return path_offset;
|
||||
}
|
||||
@ -19,7 +17,6 @@ void GSAIFollowPath::set_path_offset(const float val) {
|
||||
path_offset = val;
|
||||
}
|
||||
|
||||
|
||||
bool GSAIFollowPath::get_is_arrive_enabled() const {
|
||||
return is_arrive_enabled;
|
||||
}
|
||||
@ -28,7 +25,6 @@ void GSAIFollowPath::set_is_arrive_enabled(const bool val) {
|
||||
is_arrive_enabled = val;
|
||||
}
|
||||
|
||||
|
||||
float GSAIFollowPath::get_prediction_time() const {
|
||||
return prediction_time;
|
||||
}
|
||||
@ -37,8 +33,6 @@ void GSAIFollowPath::set_prediction_time(const float val) {
|
||||
prediction_time = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Produces a linear acceleration that moves the agent along the specified path.;
|
||||
// @category - Individual behaviors;
|
||||
// The path to follow and travel along.;
|
||||
@ -58,7 +52,6 @@ prediction_time = val;
|
||||
location = agent.position;
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
location = agent.position + (agent.linear_velocity * prediction_time);
|
||||
}
|
||||
@ -67,19 +60,15 @@ prediction_time = val;
|
||||
float target_distance = distance + path_offset;
|
||||
|
||||
if (prediction_time > 0 && path.is_open) {
|
||||
|
||||
if (target_distance < path.calculate_distance(agent.position)) {
|
||||
target_distance = path.length;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Vector3 target_position = path.calculate_target_position(target_distance);
|
||||
|
||||
if (is_arrive_enabled && path.is_open) {
|
||||
|
||||
if (path_offset >= 0) {
|
||||
|
||||
if (target_distance > path.length - deceleration_radius) {
|
||||
arrive(acceleration, target_position);
|
||||
return;
|
||||
@ -87,23 +76,18 @@ prediction_time = val;
|
||||
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
|
||||
if (target_distance < deceleration_radius) {
|
||||
arrive(acceleration, target_position);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
acceleration.linear = (target_position - agent.position).normalized();
|
||||
acceleration.linear *= agent.linear_acceleration_max;
|
||||
acceleration.angular = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAIFollowPath::GSAIFollowPath() {
|
||||
@ -116,31 +100,22 @@ prediction_time = val;
|
||||
GSAIFollowPath::~GSAIFollowPath() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAIFollowPath::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_*path"), &GSAIFollowPath::get_ * path);
|
||||
ClassDB::bind_method(D_METHOD("set_*path", "value"), &GSAIFollowPath::set_ * path);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*path", PROPERTY_HINT_RESOURCE_TYPE, "GSAIPath"), "set_*path", "get_*path");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_path_offset"), &GSAIFollowPath::get_path_offset);
|
||||
ClassDB::bind_method(D_METHOD("set_path_offset", "value"), &GSAIFollowPath::set_path_offset);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "path_offset"), "set_path_offset", "get_path_offset");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_is_arrive_enabled"), &GSAIFollowPath::get_is_arrive_enabled);
|
||||
ClassDB::bind_method(D_METHOD("set_is_arrive_enabled", "value"), &GSAIFollowPath::set_is_arrive_enabled);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_arrive_enabled"), "set_is_arrive_enabled", "get_is_arrive_enabled");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_prediction_time"), &GSAIFollowPath::get_prediction_time);
|
||||
ClassDB::bind_method(D_METHOD("set_prediction_time", "value"), &GSAIFollowPath::set_prediction_time);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "prediction_time"), "set_prediction_time", "get_prediction_time");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAIFollowPath::_calculate_steering);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef GSAIFOLLOWPATH_H
|
||||
#define GSAIFOLLOWPATH_H
|
||||
|
||||
|
||||
class GSAIFollowPath : public GSAIArrive {
|
||||
GDCLASS(GSAIFollowPath, GSAIArrive);
|
||||
|
||||
public:
|
||||
|
||||
GSAIPath get_ *path();
|
||||
void set_ *path(const GSAIPath &val);
|
||||
|
||||
@ -40,5 +38,4 @@ class GSAIFollowPath : public GSAIArrive {
|
||||
float prediction_time = 0.0;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,19 +1,15 @@
|
||||
|
||||
#include "gsai_look_where_you_go.h"
|
||||
|
||||
|
||||
|
||||
// Calculates an angular acceleration to match an agent's orientation to its;
|
||||
// direction of travel.;
|
||||
// @category - Individual behaviors;
|
||||
|
||||
void GSAILookWhereYouGo::_calculate_steering(const GSAITargetAcceleration &accel) {
|
||||
|
||||
if (agent.linear_velocity.length_squared() < agent.zero_linear_speed_threshold) {
|
||||
accel.set_zero();
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
float orientation = ;
|
||||
|
||||
@ -21,16 +17,13 @@
|
||||
orientation = GSAIUtils.vector3_to_angle(agent.linear_velocity);
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
orientation = GSAIUtils.vector2_to_angle(GSAIUtils.to_vector2(agent.linear_velocity));
|
||||
}
|
||||
|
||||
match_orientation(accel, orientation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAILookWhereYouGo::GSAILookWhereYouGo() {
|
||||
@ -39,11 +32,6 @@
|
||||
GSAILookWhereYouGo::~GSAILookWhereYouGo() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAILookWhereYouGo::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_calculate_steering", "accel"), &GSAILookWhereYouGo::_calculate_steering);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef GSAILOOKWHEREYOUGO_H
|
||||
#define GSAILOOKWHEREYOUGO_H
|
||||
|
||||
|
||||
class GSAILookWhereYouGo : public GSAIMatchOrientation {
|
||||
GDCLASS(GSAILookWhereYouGo, GSAIMatchOrientation);
|
||||
|
||||
public:
|
||||
|
||||
void _calculate_steering(const GSAITargetAcceleration &accel);
|
||||
|
||||
GSAILookWhereYouGo();
|
||||
@ -20,5 +18,4 @@ class GSAILookWhereYouGo : public GSAIMatchOrientation {
|
||||
// @category - Individual behaviors
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "gsai_match_orientation.h"
|
||||
|
||||
|
||||
GSAIAgentLocation GSAIMatchOrientation::get_ *target() {
|
||||
return *target;
|
||||
}
|
||||
@ -10,7 +9,6 @@ void GSAIMatchOrientation::set_*target(const GSAIAgentLocation &val) {
|
||||
*target = val;
|
||||
}
|
||||
|
||||
|
||||
float GSAIMatchOrientation::get_alignment_tolerance() const {
|
||||
return alignment_tolerance;
|
||||
}
|
||||
@ -19,7 +17,6 @@ void GSAIMatchOrientation::set_alignment_tolerance(const float val) {
|
||||
alignment_tolerance = val;
|
||||
}
|
||||
|
||||
|
||||
float GSAIMatchOrientation::get_deceleration_radius() const {
|
||||
return deceleration_radius;
|
||||
}
|
||||
@ -28,7 +25,6 @@ void GSAIMatchOrientation::set_deceleration_radius(const float val) {
|
||||
deceleration_radius = val;
|
||||
}
|
||||
|
||||
|
||||
float GSAIMatchOrientation::get_time_to_reach() const {
|
||||
return time_to_reach;
|
||||
}
|
||||
@ -37,7 +33,6 @@ void GSAIMatchOrientation::set_time_to_reach(const float val) {
|
||||
time_to_reach = val;
|
||||
}
|
||||
|
||||
|
||||
bool GSAIMatchOrientation::get_use_z() const {
|
||||
return use_z;
|
||||
}
|
||||
@ -46,8 +41,6 @@ void GSAIMatchOrientation::set_use_z(const bool val) {
|
||||
use_z = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Calculates an angular acceleration to match an agent's orientation to that of;
|
||||
// its target. Attempts to make the agent arrive with zero remaining angular;
|
||||
// velocity.;
|
||||
@ -69,7 +62,6 @@ use_z = val;
|
||||
call("_match_orientation", acceleration, desired_orientation);
|
||||
}
|
||||
|
||||
|
||||
void GSAIMatchOrientation::_match_orientation(const GSAITargetAcceleration &acceleration, const float desired_orientation) {
|
||||
float rotation = wrapf(desired_orientation - agent.orientation, -PI, PI);
|
||||
float rotation_size = abs(rotation);
|
||||
@ -78,7 +70,6 @@ use_z = val;
|
||||
acceleration.set_zero();
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
float desired_rotation = agent.angular_speed_max;
|
||||
|
||||
@ -93,17 +84,14 @@ use_z = val;
|
||||
if (limited_acceleration > agent.angular_acceleration_max) {
|
||||
acceleration.angular *= (agent.angular_acceleration_max / limited_acceleration);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
acceleration.linear = Vector3.ZERO;
|
||||
}
|
||||
|
||||
|
||||
void GSAIMatchOrientation::_calculate_steering(const GSAITargetAcceleration &acceleration) {
|
||||
match_orientation(acceleration, target.orientation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAIMatchOrientation::GSAIMatchOrientation() {
|
||||
@ -117,38 +105,28 @@ use_z = val;
|
||||
GSAIMatchOrientation::~GSAIMatchOrientation() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAIMatchOrientation::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_*target"), &GSAIMatchOrientation::get_ * target);
|
||||
ClassDB::bind_method(D_METHOD("set_*target", "value"), &GSAIMatchOrientation::set_ * target);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*target", PROPERTY_HINT_RESOURCE_TYPE, "GSAIAgentLocation"), "set_*target", "get_*target");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_alignment_tolerance"), &GSAIMatchOrientation::get_alignment_tolerance);
|
||||
ClassDB::bind_method(D_METHOD("set_alignment_tolerance", "value"), &GSAIMatchOrientation::set_alignment_tolerance);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "alignment_tolerance"), "set_alignment_tolerance", "get_alignment_tolerance");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_deceleration_radius"), &GSAIMatchOrientation::get_deceleration_radius);
|
||||
ClassDB::bind_method(D_METHOD("set_deceleration_radius", "value"), &GSAIMatchOrientation::set_deceleration_radius);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "deceleration_radius"), "set_deceleration_radius", "get_deceleration_radius");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_time_to_reach"), &GSAIMatchOrientation::get_time_to_reach);
|
||||
ClassDB::bind_method(D_METHOD("set_time_to_reach", "value"), &GSAIMatchOrientation::set_time_to_reach);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "time_to_reach"), "set_time_to_reach", "get_time_to_reach");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_use_z"), &GSAIMatchOrientation::get_use_z);
|
||||
ClassDB::bind_method(D_METHOD("set_use_z", "value"), &GSAIMatchOrientation::set_use_z);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_z"), "set_use_z", "get_use_z");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("match_orientation", "acceleration", "desired_orientation"), &GSAIMatchOrientation::match_orientation);
|
||||
ClassDB::bind_method(D_METHOD("_match_orientation", "acceleration", "desired_orientation"), &GSAIMatchOrientation::_match_orientation);
|
||||
ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAIMatchOrientation::_calculate_steering);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef GSAIMATCHORIENTATION_H
|
||||
#define GSAIMATCHORIENTATION_H
|
||||
|
||||
|
||||
class GSAIMatchOrientation : public GSAISteeringBehavior {
|
||||
GDCLASS(GSAIMatchOrientation, GSAISteeringBehavior);
|
||||
|
||||
public:
|
||||
|
||||
GSAIAgentLocation get_ *target();
|
||||
void set_ *target(const GSAIAgentLocation &val);
|
||||
|
||||
@ -50,5 +48,4 @@ class GSAIMatchOrientation : public GSAISteeringBehavior {
|
||||
bool use_z = false;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "gsai_priority.h"
|
||||
|
||||
|
||||
float GSAIPriority::get_zero_threshold() const {
|
||||
return zero_threshold;
|
||||
}
|
||||
@ -10,7 +9,6 @@ void GSAIPriority::set_zero_threshold(const float val) {
|
||||
zero_threshold = val;
|
||||
}
|
||||
|
||||
|
||||
int GSAIPriority::get__last_selected_index() const {
|
||||
return _last_selected_index;
|
||||
}
|
||||
@ -19,7 +17,6 @@ void GSAIPriority::set__last_selected_index(const int val) {
|
||||
_last_selected_index = val;
|
||||
}
|
||||
|
||||
|
||||
Array GSAIPriority::get__behaviors() {
|
||||
return _behaviors;
|
||||
}
|
||||
@ -28,8 +25,6 @@ void GSAIPriority::set__behaviors(const Array &val) {
|
||||
_behaviors = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Container for multiple behaviors that returns the result of the first child;
|
||||
// behavior with non-zero acceleration.;
|
||||
// @category - Combination behaviors;
|
||||
@ -49,7 +44,6 @@ _behaviors = val;
|
||||
// `null` if no behavior was found.;
|
||||
|
||||
GSAISteeringBehavior GSAIPriority::get_behavior(const int index) {
|
||||
|
||||
if (_behaviors.size() > index) {
|
||||
return _behaviors[index];
|
||||
}
|
||||
@ -58,9 +52,7 @@ _behaviors = val;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
void GSAIPriority::remove_behavior(const int index) {
|
||||
|
||||
if (_behaviors.size() > index) {
|
||||
_behaviors.remove(index);
|
||||
return;
|
||||
@ -70,19 +62,16 @@ _behaviors = val;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int GSAIPriority::get_behaviour_count() {
|
||||
return _behaviors.size();
|
||||
}
|
||||
|
||||
|
||||
void GSAIPriority::_calculate_steering(const GSAITargetAcceleration &accel) {
|
||||
float threshold_squared = zero_threshold * zero_threshold;
|
||||
_last_selected_index = -1;
|
||||
int size = _behaviors.size();
|
||||
|
||||
if (size > 0) {
|
||||
|
||||
for (int i = 0; i < size; ++i) { //i in range(size)
|
||||
_last_selected_index = i;
|
||||
GSAISteeringBehavior *behavior = _behaviors[i];
|
||||
@ -91,18 +80,14 @@ _behaviors = val;
|
||||
if (accel.get_magnitude_squared() > threshold_squared) {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
accel.set_zero();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAIPriority::GSAIPriority() {
|
||||
@ -114,30 +99,22 @@ _behaviors = val;
|
||||
GSAIPriority::~GSAIPriority() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAIPriority::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_zero_threshold"), &GSAIPriority::get_zero_threshold);
|
||||
ClassDB::bind_method(D_METHOD("set_zero_threshold", "value"), &GSAIPriority::set_zero_threshold);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "zero_threshold"), "set_zero_threshold", "get_zero_threshold");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get__last_selected_index"), &GSAIPriority::get__last_selected_index);
|
||||
ClassDB::bind_method(D_METHOD("set__last_selected_index", "value"), &GSAIPriority::set__last_selected_index);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "_last_selected_index"), "set__last_selected_index", "get__last_selected_index");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get__behaviors"), &GSAIPriority::get__behaviors);
|
||||
ClassDB::bind_method(D_METHOD("set__behaviors", "value"), &GSAIPriority::set__behaviors);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "_behaviors"), "set__behaviors", "get__behaviors");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("add_behavior", "behavior"), &GSAIPriority::add_behavior);
|
||||
ClassDB::bind_method(D_METHOD("get_behavior", "index"), &GSAIPriority::get_behavior);
|
||||
ClassDB::bind_method(D_METHOD("remove_behavior", "index"), &GSAIPriority::remove_behavior);
|
||||
ClassDB::bind_method(D_METHOD("get_behaviour_count"), &GSAIPriority::get_behaviour_count);
|
||||
ClassDB::bind_method(D_METHOD("_calculate_steering", "accel"), &GSAIPriority::_calculate_steering);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef GSAIPRIORITY_H
|
||||
#define GSAIPRIORITY_H
|
||||
|
||||
|
||||
class GSAIPriority : public GSAISteeringBehavior {
|
||||
GDCLASS(GSAIPriority, GSAISteeringBehavior);
|
||||
|
||||
public:
|
||||
|
||||
float get_zero_threshold() const;
|
||||
void set_zero_threshold(const float val);
|
||||
|
||||
@ -42,5 +40,4 @@ class GSAIPriority : public GSAISteeringBehavior {
|
||||
// `null` if no behavior was found.
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "gsai_pursue.h"
|
||||
|
||||
|
||||
GSAISteeringAgent GSAIPursue::get_ *target() {
|
||||
return *target;
|
||||
}
|
||||
@ -10,7 +9,6 @@ void GSAIPursue::set_*target(const GSAISteeringAgent &val) {
|
||||
*target = val;
|
||||
}
|
||||
|
||||
|
||||
float GSAIPursue::get_predict_time_max() const {
|
||||
return predict_time_max;
|
||||
}
|
||||
@ -19,8 +17,6 @@ void GSAIPursue::set_predict_time_max(const float val) {
|
||||
predict_time_max = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Calculates an acceleration to make an agent intercept another based on the;
|
||||
// target agent's movement.;
|
||||
// @category - Individual behaviors;
|
||||
@ -42,7 +38,6 @@ predict_time_max = val;
|
||||
if (predict_time_squared < predict_time_max * predict_time_max) {
|
||||
predict_time = sqrt(predict_time_squared);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
acceleration.linear = ((target_position + (target.linear_velocity * predict_time)) - agent.position).normalized();
|
||||
@ -50,16 +45,13 @@ predict_time_max = val;
|
||||
acceleration.angular = 0;
|
||||
}
|
||||
|
||||
|
||||
float GSAIPursue::get_modified_acceleration() {
|
||||
return call("_get_modified_acceleration");
|
||||
}
|
||||
|
||||
|
||||
float GSAIPursue::_get_modified_acceleration() {
|
||||
return agent.linear_acceleration_max;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAIPursue::GSAIPursue() {
|
||||
@ -70,23 +62,16 @@ predict_time_max = val;
|
||||
GSAIPursue::~GSAIPursue() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAIPursue::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_*target"), &GSAIPursue::get_ * target);
|
||||
ClassDB::bind_method(D_METHOD("set_*target", "value"), &GSAIPursue::set_ * target);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*target", PROPERTY_HINT_RESOURCE_TYPE, "GSAISteeringAgent"), "set_*target", "get_*target");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_predict_time_max"), &GSAIPursue::get_predict_time_max);
|
||||
ClassDB::bind_method(D_METHOD("set_predict_time_max", "value"), &GSAIPursue::set_predict_time_max);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "predict_time_max"), "set_predict_time_max", "get_predict_time_max");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAIPursue::_calculate_steering);
|
||||
ClassDB::bind_method(D_METHOD("get_modified_acceleration"), &GSAIPursue::get_modified_acceleration);
|
||||
ClassDB::bind_method(D_METHOD("_get_modified_acceleration"), &GSAIPursue::_get_modified_acceleration);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef GSAIPURSUE_H
|
||||
#define GSAIPURSUE_H
|
||||
|
||||
|
||||
class GSAIPursue : public GSAISteeringBehavior {
|
||||
GDCLASS(GSAIPursue, GSAISteeringBehavior);
|
||||
|
||||
public:
|
||||
|
||||
GSAISteeringAgent get_ *target();
|
||||
void set_ *target(const GSAISteeringAgent &val);
|
||||
|
||||
@ -33,5 +31,4 @@ class GSAIPursue : public GSAISteeringBehavior {
|
||||
float predict_time_max = 1.0;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "gsai_seek.h"
|
||||
|
||||
|
||||
GSAIAgentLocation GSAISeek::get_ *target() {
|
||||
return *target;
|
||||
}
|
||||
@ -10,8 +9,6 @@ void GSAISeek::set_*target(const GSAIAgentLocation &val) {
|
||||
*target = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Calculates an acceleration to take an agent to a target agent's position;
|
||||
// directly.;
|
||||
// @category - Individual behaviors;
|
||||
@ -22,7 +19,6 @@ void GSAISeek::set_*target(const GSAIAgentLocation &val) {
|
||||
acceleration.linear = ((target.position - agent.position).normalized() * agent.linear_acceleration_max);
|
||||
acceleration.angular = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAISeek::GSAISeek() {
|
||||
@ -32,16 +28,10 @@ void GSAISeek::set_*target(const GSAIAgentLocation &val) {
|
||||
GSAISeek::~GSAISeek() {
|
||||
}
|
||||
|
||||
|
||||
static 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");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAISeek::_calculate_steering);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef GSAISEEK_H
|
||||
#define GSAISEEK_H
|
||||
|
||||
|
||||
class GSAISeek : public GSAISteeringBehavior {
|
||||
GDCLASS(GSAISeek, GSAISteeringBehavior);
|
||||
|
||||
public:
|
||||
|
||||
GSAIAgentLocation get_ *target();
|
||||
void set_ *target(const GSAIAgentLocation &val);
|
||||
|
||||
@ -25,5 +23,4 @@ class GSAISeek : public GSAISteeringBehavior {
|
||||
GSAIAgentLocation *target;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "gsai_separation.h"
|
||||
|
||||
|
||||
float GSAISeparation::get_decay_coefficient() const {
|
||||
return decay_coefficient;
|
||||
}
|
||||
@ -10,7 +9,6 @@ void GSAISeparation::set_decay_coefficient(const float val) {
|
||||
decay_coefficient = val;
|
||||
}
|
||||
|
||||
|
||||
GSAITargetAcceleration GSAISeparation::get_ *acceleration() {
|
||||
return *acceleration;
|
||||
}
|
||||
@ -19,8 +17,6 @@ void GSAISeparation::set_*acceleration(const GSAITargetAcceleration &val) {
|
||||
*acceleration = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Calculates an acceleration that repels the agent from its neighbors in the;
|
||||
// given `GSAIProximity`.;
|
||||
//;
|
||||
@ -56,7 +52,6 @@ void GSAISeparation::set_*acceleration(const GSAITargetAcceleration &val) {
|
||||
acceleration.linear += to_agent * (strength / sqrt(distance_squared));
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAISeparation::GSAISeparation() {
|
||||
@ -67,22 +62,15 @@ void GSAISeparation::set_*acceleration(const GSAITargetAcceleration &val) {
|
||||
GSAISeparation::~GSAISeparation() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAISeparation::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_decay_coefficient"), &GSAISeparation::get_decay_coefficient);
|
||||
ClassDB::bind_method(D_METHOD("set_decay_coefficient", "value"), &GSAISeparation::set_decay_coefficient);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "decay_coefficient"), "set_decay_coefficient", "get_decay_coefficient");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_*acceleration"), &GSAISeparation::get_ * acceleration);
|
||||
ClassDB::bind_method(D_METHOD("set_*acceleration", "value"), &GSAISeparation::set_ * acceleration);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*acceleration", PROPERTY_HINT_RESOURCE_TYPE, "GSAITargetAcceleration"), "set_*acceleration", "get_*acceleration");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_calculate_steering", "_acceleration"), &GSAISeparation::_calculate_steering);
|
||||
ClassDB::bind_method(D_METHOD("_report_neighbor", "neighbor"), &GSAISeparation::_report_neighbor);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef GSAISEPARATION_H
|
||||
#define GSAISEPARATION_H
|
||||
|
||||
|
||||
class GSAISeparation : public GSAIGroupBehavior {
|
||||
GDCLASS(GSAISeparation, GSAIGroupBehavior);
|
||||
|
||||
public:
|
||||
|
||||
float get_decay_coefficient() const;
|
||||
void set_decay_coefficient(const float val);
|
||||
|
||||
@ -37,5 +35,4 @@ class GSAISeparation : public GSAIGroupBehavior {
|
||||
// @tags - virtual
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "gsai_agent_location.h"
|
||||
|
||||
|
||||
Vector3 GSAIAgentLocation::get_position() {
|
||||
return position;
|
||||
}
|
||||
@ -10,7 +9,6 @@ void GSAIAgentLocation::set_position(const Vector3 &val) {
|
||||
position = val;
|
||||
}
|
||||
|
||||
|
||||
float GSAIAgentLocation::get_orientation() const {
|
||||
return orientation;
|
||||
}
|
||||
@ -19,8 +17,6 @@ void GSAIAgentLocation::set_orientation(const float val) {
|
||||
orientation = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Represents an agent with only a location and an orientation.;
|
||||
// @category - Base types;
|
||||
// The agent's position in space.;
|
||||
@ -37,20 +33,12 @@ orientation = val;
|
||||
GSAIAgentLocation::~GSAIAgentLocation() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAIAgentLocation::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_position"), &GSAIAgentLocation::get_position);
|
||||
ClassDB::bind_method(D_METHOD("set_position", "value"), &GSAIAgentLocation::set_position);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "position"), "set_position", "get_position");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_orientation"), &GSAIAgentLocation::get_orientation);
|
||||
ClassDB::bind_method(D_METHOD("set_orientation", "value"), &GSAIAgentLocation::set_orientation);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "orientation"), "set_orientation", "get_orientation");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,19 +1,16 @@
|
||||
#ifndef GSAIAGENTLOCATION_H
|
||||
#define GSAIAGENTLOCATION_H
|
||||
|
||||
|
||||
class GSAIAgentLocation : public Reference {
|
||||
GDCLASS(GSAIAgentLocation, Reference);
|
||||
|
||||
public:
|
||||
|
||||
Vector3 get_position();
|
||||
void set_position(const Vector3 &val);
|
||||
|
||||
float get_orientation() const;
|
||||
void set_orientation(const float val);
|
||||
|
||||
|
||||
GSAIAgentLocation();
|
||||
~GSAIAgentLocation();
|
||||
|
||||
@ -28,5 +25,4 @@ class GSAIAgentLocation : public Reference {
|
||||
float orientation = 0.0;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "gsai_group_behavior.h"
|
||||
|
||||
|
||||
GSAIProximity GSAIGroupBehavior::get_ *proximity() {
|
||||
return *proximity;
|
||||
}
|
||||
@ -10,7 +9,6 @@ void GSAIGroupBehavior::set_*proximity(const GSAIProximity &val) {
|
||||
*proximity = val;
|
||||
}
|
||||
|
||||
|
||||
Ref<FuncRef> GSAIGroupBehavior::get__callback() {
|
||||
return _callback;
|
||||
}
|
||||
@ -19,8 +17,6 @@ void GSAIGroupBehavior::set__callback(const Ref<FuncRef> &val) {
|
||||
_callback = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Base type for group-based steering behaviors.;
|
||||
// @category - Base types;
|
||||
// Container to find neighbors of the agent and calculate group behavior.;
|
||||
@ -38,7 +34,6 @@ _callback = val;
|
||||
bool GSAIGroupBehavior::_report_neighbor(const GSAISteeringAgent &_neighbor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAIGroupBehavior::GSAIGroupBehavior() {
|
||||
@ -49,22 +44,15 @@ _callback = val;
|
||||
GSAIGroupBehavior::~GSAIGroupBehavior() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAIGroupBehavior::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_*proximity"), &GSAIGroupBehavior::get_ * proximity);
|
||||
ClassDB::bind_method(D_METHOD("set_*proximity", "value"), &GSAIGroupBehavior::set_ * proximity);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*proximity", PROPERTY_HINT_RESOURCE_TYPE, "GSAIProximity"), "set_*proximity", "get_*proximity");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get__callback"), &GSAIGroupBehavior::get__callback);
|
||||
ClassDB::bind_method(D_METHOD("set__callback", "value"), &GSAIGroupBehavior::set__callback);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "_callback", PROPERTY_HINT_RESOURCE_TYPE, "Ref<FuncRef>"), "set__callback", "get__callback");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_callback"), &GSAIGroupBehavior::get_callback);
|
||||
ClassDB::bind_method(D_METHOD("_report_neighbor", "_neighbor"), &GSAIGroupBehavior::_report_neighbor);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef GSAIGROUPBEHAVIOR_H
|
||||
#define GSAIGROUPBEHAVIOR_H
|
||||
|
||||
|
||||
class GSAIGroupBehavior : public GSAISteeringBehavior {
|
||||
GDCLASS(GSAIGroupBehavior, GSAISteeringBehavior);
|
||||
|
||||
public:
|
||||
|
||||
GSAIProximity get_ *proximity();
|
||||
void set_ *proximity(const GSAIProximity &val);
|
||||
|
||||
@ -32,5 +30,4 @@ class GSAIGroupBehavior : public GSAISteeringBehavior {
|
||||
// @tags - virtual
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "gsai_path.h"
|
||||
|
||||
|
||||
bool GSAIPath::get_is_open() const {
|
||||
return is_open;
|
||||
}
|
||||
@ -10,7 +9,6 @@ void GSAIPath::set_is_open(const bool val) {
|
||||
is_open = val;
|
||||
}
|
||||
|
||||
|
||||
float GSAIPath::get_length() const {
|
||||
return length;
|
||||
}
|
||||
@ -19,7 +17,6 @@ void GSAIPath::set_length(const float val) {
|
||||
length = val;
|
||||
}
|
||||
|
||||
|
||||
Array GSAIPath::get__segments() {
|
||||
return _segments;
|
||||
}
|
||||
@ -28,7 +25,6 @@ void GSAIPath::set__segments(const Array &val) {
|
||||
_segments = val;
|
||||
}
|
||||
|
||||
|
||||
Vector3 GSAIPath::get__nearest_point_on_segment() {
|
||||
return _nearest_point_on_segment;
|
||||
}
|
||||
@ -37,7 +33,6 @@ void GSAIPath::set__nearest_point_on_segment(const Vector3 &val) {
|
||||
_nearest_point_on_segment = val;
|
||||
}
|
||||
|
||||
|
||||
Vector3 GSAIPath::get__nearest_point_on_path() {
|
||||
return _nearest_point_on_path;
|
||||
}
|
||||
@ -46,8 +41,6 @@ void GSAIPath::set__nearest_point_on_path(const Vector3 &val) {
|
||||
_nearest_point_on_path = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Represents a path made up of Vector3 waypoints, split into segments path;
|
||||
// follow behaviors can use.;
|
||||
// @category - Base types;
|
||||
@ -69,7 +62,6 @@ _nearest_point_on_path = val;
|
||||
// Creates a path from a list of waypoints.;
|
||||
|
||||
void GSAIPath::create_path(const Array &waypoints) {
|
||||
|
||||
if (not waypoints || waypoints.size() < 2) {
|
||||
printerr("Waypoints cannot be null and must contain at least two (2) waypoints.");
|
||||
return;
|
||||
@ -87,12 +79,10 @@ _nearest_point_on_path = val;
|
||||
current = waypoints[i];
|
||||
}
|
||||
|
||||
|
||||
else if (is_open) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
current = waypoints[0];
|
||||
}
|
||||
@ -106,9 +96,7 @@ _nearest_point_on_path = val;
|
||||
// Returns the distance from `agent_current_position` to the next waypoint.;
|
||||
}
|
||||
|
||||
|
||||
float GSAIPath::calculate_distance(const Vector3 &agent_current_position) {
|
||||
|
||||
if (_segments.size() == 0) {
|
||||
return 0.0;
|
||||
}
|
||||
@ -125,7 +113,6 @@ _nearest_point_on_path = val;
|
||||
smallest_distance_squared = distance_squared;
|
||||
nearest_segment = segment;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
float length_on_path = nearest_segment.cumulative_length - _nearest_point_on_path.distance_to(nearest_segment.end);
|
||||
@ -135,23 +122,18 @@ _nearest_point_on_path = val;
|
||||
// Calculates a target position from the path's starting point based on the `target_distance`.;
|
||||
|
||||
Vector3 GSAIPath::calculate_target_position(const float target_distance) {
|
||||
|
||||
if (is_open) {
|
||||
target_distance = clamp(target_distance, 0, length);
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
|
||||
if (target_distance < 0) {
|
||||
target_distance = length + fmod(target_distance, length);
|
||||
}
|
||||
|
||||
|
||||
else if (target_distance > length) {
|
||||
target_distance = fmod(target_distance, length);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAISegment *desired_segment;
|
||||
@ -163,10 +145,8 @@ _nearest_point_on_path = val;
|
||||
desired_segment = segment;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (not desired_segment) {
|
||||
desired_segment = _segments.back();
|
||||
}
|
||||
@ -187,7 +167,6 @@ _nearest_point_on_path = val;
|
||||
return _segments.back().end;
|
||||
}
|
||||
|
||||
|
||||
float GSAIPath::_calculate_point_segment_distance_squared(const Vector3 &start, const Vector3 &end, const Vector3 &position) {
|
||||
_nearest_point_on_segment = start;
|
||||
Vector3 start_end = end - start;
|
||||
@ -211,7 +190,6 @@ _nearest_point_on_path = val;
|
||||
begin = val;
|
||||
}
|
||||
|
||||
|
||||
Vector3 GSAISegment::get_end() {
|
||||
return end;
|
||||
}
|
||||
@ -220,7 +198,6 @@ _nearest_point_on_path = val;
|
||||
end = val;
|
||||
}
|
||||
|
||||
|
||||
float GSAISegment::get_length() const {
|
||||
return length;
|
||||
}
|
||||
@ -229,7 +206,6 @@ _nearest_point_on_path = val;
|
||||
length = val;
|
||||
}
|
||||
|
||||
|
||||
float GSAISegment::get_cumulative_length() const {
|
||||
return cumulative_length;
|
||||
}
|
||||
@ -238,8 +214,6 @@ _nearest_point_on_path = val;
|
||||
cumulative_length = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Vector3 begin = ;
|
||||
Vector3 end = ;
|
||||
float length = ;
|
||||
@ -250,7 +224,6 @@ _nearest_point_on_path = val;
|
||||
self.end = _end;
|
||||
length = _begin.distance_to(_end);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAISegment::GSAISegment() {
|
||||
@ -263,33 +236,25 @@ _nearest_point_on_path = val;
|
||||
GSAISegment::~GSAISegment() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAISegment::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_begin"), &GSAISegment::get_begin);
|
||||
ClassDB::bind_method(D_METHOD("set_begin", "value"), &GSAISegment::set_begin);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "begin"), "set_begin", "get_begin");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_end"), &GSAISegment::get_end);
|
||||
ClassDB::bind_method(D_METHOD("set_end", "value"), &GSAISegment::set_end);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "end"), "set_end", "get_end");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_length"), &GSAISegment::get_length);
|
||||
ClassDB::bind_method(D_METHOD("set_length", "value"), &GSAISegment::set_length);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "length"), "set_length", "get_length");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_cumulative_length"), &GSAISegment::get_cumulative_length);
|
||||
ClassDB::bind_method(D_METHOD("set_cumulative_length", "value"), &GSAISegment::set_cumulative_length);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "cumulative_length"), "set_cumulative_length", "get_cumulative_length");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_init", "_begin", "_end"), &GSAISegment::_init);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
GSAIPath::GSAIPath() {
|
||||
@ -303,33 +268,27 @@ _nearest_point_on_path = val;
|
||||
GSAIPath::~GSAIPath() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAIPath::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_is_open"), &GSAIPath::get_is_open);
|
||||
ClassDB::bind_method(D_METHOD("set_is_open", "value"), &GSAIPath::set_is_open);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_open"), "set_is_open", "get_is_open");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_length"), &GSAIPath::get_length);
|
||||
ClassDB::bind_method(D_METHOD("set_length", "value"), &GSAIPath::set_length);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "length"), "set_length", "get_length");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get__segments"), &GSAIPath::get__segments);
|
||||
ClassDB::bind_method(D_METHOD("set__segments", "value"), &GSAIPath::set__segments);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "_segments"), "set__segments", "get__segments");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get__nearest_point_on_segment"), &GSAIPath::get__nearest_point_on_segment);
|
||||
ClassDB::bind_method(D_METHOD("set__nearest_point_on_segment", "value"), &GSAIPath::set__nearest_point_on_segment);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "_nearest_point_on_segment"), "set__nearest_point_on_segment", "get__nearest_point_on_segment");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get__nearest_point_on_path"), &GSAIPath::get__nearest_point_on_path);
|
||||
ClassDB::bind_method(D_METHOD("set__nearest_point_on_path", "value"), &GSAIPath::set__nearest_point_on_path);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "_nearest_point_on_path"), "set__nearest_point_on_path", "get__nearest_point_on_path");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("initialize", "waypoints", "_is_open"), &GSAIPath::initialize, false);
|
||||
ClassDB::bind_method(D_METHOD("create_path", "waypoints"), &GSAIPath::create_path);
|
||||
ClassDB::bind_method(D_METHOD("calculate_distance", "agent_current_position"), &GSAIPath::calculate_distance);
|
||||
@ -337,8 +296,4 @@ _nearest_point_on_path = val;
|
||||
ClassDB::bind_method(D_METHOD("get_start_point"), &GSAIPath::get_start_point);
|
||||
ClassDB::bind_method(D_METHOD("get_end_point"), &GSAIPath::get_end_point);
|
||||
ClassDB::bind_method(D_METHOD("_calculate_point_segment_distance_squared", "start", "end", "position"), &GSAIPath::_calculate_point_segment_distance_squared);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef GSAIPATH_H
|
||||
#define GSAIPATH_H
|
||||
|
||||
|
||||
class GSAIPath : public Reference {
|
||||
GDCLASS(GSAIPath, Reference);
|
||||
|
||||
public:
|
||||
|
||||
bool get_is_open() const;
|
||||
void set_is_open(const bool val);
|
||||
|
||||
@ -31,7 +29,6 @@ class GSAIPath : public Reference {
|
||||
float _calculate_point_segment_distance_squared(const Vector3 &start, const Vector3 &end, const Vector3 &position);
|
||||
class GSAISegment {
|
||||
public:
|
||||
|
||||
Vector3 get_begin();
|
||||
void set_begin(const Vector3 &val);
|
||||
|
||||
@ -58,7 +55,6 @@ class GSAIPath : public Reference {
|
||||
float cumulative_length = ;
|
||||
};
|
||||
|
||||
|
||||
GSAIPath();
|
||||
~GSAIPath();
|
||||
|
||||
@ -82,5 +78,4 @@ class GSAIPath : public Reference {
|
||||
// not exposed helper struct
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "gsai_steering_agent.h"
|
||||
|
||||
|
||||
float GSAISteeringAgent::get_zero_linear_speed_threshold() const {
|
||||
return zero_linear_speed_threshold;
|
||||
}
|
||||
@ -10,7 +9,6 @@ void GSAISteeringAgent::set_zero_linear_speed_threshold(const float val) {
|
||||
zero_linear_speed_threshold = val;
|
||||
}
|
||||
|
||||
|
||||
float GSAISteeringAgent::get_linear_speed_max() const {
|
||||
return linear_speed_max;
|
||||
}
|
||||
@ -19,7 +17,6 @@ void GSAISteeringAgent::set_linear_speed_max(const float val) {
|
||||
linear_speed_max = val;
|
||||
}
|
||||
|
||||
|
||||
float GSAISteeringAgent::get_linear_acceleration_max() const {
|
||||
return linear_acceleration_max;
|
||||
}
|
||||
@ -28,7 +25,6 @@ void GSAISteeringAgent::set_linear_acceleration_max(const float val) {
|
||||
linear_acceleration_max = val;
|
||||
}
|
||||
|
||||
|
||||
float GSAISteeringAgent::get_angular_speed_max() const {
|
||||
return angular_speed_max;
|
||||
}
|
||||
@ -37,7 +33,6 @@ void GSAISteeringAgent::set_angular_speed_max(const float val) {
|
||||
angular_speed_max = val;
|
||||
}
|
||||
|
||||
|
||||
float GSAISteeringAgent::get_angular_acceleration_max() const {
|
||||
return angular_acceleration_max;
|
||||
}
|
||||
@ -46,7 +41,6 @@ void GSAISteeringAgent::set_angular_acceleration_max(const float val) {
|
||||
angular_acceleration_max = val;
|
||||
}
|
||||
|
||||
|
||||
Vector3 GSAISteeringAgent::get_linear_velocity() {
|
||||
return linear_velocity;
|
||||
}
|
||||
@ -55,7 +49,6 @@ void GSAISteeringAgent::set_linear_velocity(const Vector3 &val) {
|
||||
linear_velocity = val;
|
||||
}
|
||||
|
||||
|
||||
float GSAISteeringAgent::get_angular_velocity() const {
|
||||
return angular_velocity;
|
||||
}
|
||||
@ -64,7 +57,6 @@ void GSAISteeringAgent::set_angular_velocity(const float val) {
|
||||
angular_velocity = val;
|
||||
}
|
||||
|
||||
|
||||
float GSAISteeringAgent::get_bounding_radius() const {
|
||||
return bounding_radius;
|
||||
}
|
||||
@ -73,7 +65,6 @@ void GSAISteeringAgent::set_bounding_radius(const float val) {
|
||||
bounding_radius = val;
|
||||
}
|
||||
|
||||
|
||||
bool GSAISteeringAgent::get_is_tagged() const {
|
||||
return is_tagged;
|
||||
}
|
||||
@ -82,8 +73,6 @@ void GSAISteeringAgent::set_is_tagged(const bool val) {
|
||||
is_tagged = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Adds velocity, speed, and size data to `GSAIAgentLocation`.;
|
||||
//;
|
||||
// It is the character's responsibility to keep this information up to date for;
|
||||
@ -126,55 +115,40 @@ is_tagged = val;
|
||||
GSAISteeringAgent::~GSAISteeringAgent() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAISteeringAgent::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_zero_linear_speed_threshold"), &GSAISteeringAgent::get_zero_linear_speed_threshold);
|
||||
ClassDB::bind_method(D_METHOD("set_zero_linear_speed_threshold", "value"), &GSAISteeringAgent::set_zero_linear_speed_threshold);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "zero_linear_speed_threshold"), "set_zero_linear_speed_threshold", "get_zero_linear_speed_threshold");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_linear_speed_max"), &GSAISteeringAgent::get_linear_speed_max);
|
||||
ClassDB::bind_method(D_METHOD("set_linear_speed_max", "value"), &GSAISteeringAgent::set_linear_speed_max);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "linear_speed_max"), "set_linear_speed_max", "get_linear_speed_max");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_linear_acceleration_max"), &GSAISteeringAgent::get_linear_acceleration_max);
|
||||
ClassDB::bind_method(D_METHOD("set_linear_acceleration_max", "value"), &GSAISteeringAgent::set_linear_acceleration_max);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "linear_acceleration_max"), "set_linear_acceleration_max", "get_linear_acceleration_max");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_angular_speed_max"), &GSAISteeringAgent::get_angular_speed_max);
|
||||
ClassDB::bind_method(D_METHOD("set_angular_speed_max", "value"), &GSAISteeringAgent::set_angular_speed_max);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_speed_max"), "set_angular_speed_max", "get_angular_speed_max");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_angular_acceleration_max"), &GSAISteeringAgent::get_angular_acceleration_max);
|
||||
ClassDB::bind_method(D_METHOD("set_angular_acceleration_max", "value"), &GSAISteeringAgent::set_angular_acceleration_max);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_acceleration_max"), "set_angular_acceleration_max", "get_angular_acceleration_max");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_linear_velocity"), &GSAISteeringAgent::get_linear_velocity);
|
||||
ClassDB::bind_method(D_METHOD("set_linear_velocity", "value"), &GSAISteeringAgent::set_linear_velocity);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "linear_velocity"), "set_linear_velocity", "get_linear_velocity");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_angular_velocity"), &GSAISteeringAgent::get_angular_velocity);
|
||||
ClassDB::bind_method(D_METHOD("set_angular_velocity", "value"), &GSAISteeringAgent::set_angular_velocity);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular_velocity"), "set_angular_velocity", "get_angular_velocity");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_bounding_radius"), &GSAISteeringAgent::get_bounding_radius);
|
||||
ClassDB::bind_method(D_METHOD("set_bounding_radius", "value"), &GSAISteeringAgent::set_bounding_radius);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "bounding_radius"), "set_bounding_radius", "get_bounding_radius");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_is_tagged"), &GSAISteeringAgent::get_is_tagged);
|
||||
ClassDB::bind_method(D_METHOD("set_is_tagged", "value"), &GSAISteeringAgent::set_is_tagged);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_tagged"), "set_is_tagged", "get_is_tagged");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef GSAISTEERINGAGENT_H
|
||||
#define GSAISTEERINGAGENT_H
|
||||
|
||||
|
||||
class GSAISteeringAgent : public GSAIAgentLocation {
|
||||
GDCLASS(GSAISteeringAgent, GSAIAgentLocation);
|
||||
|
||||
public:
|
||||
|
||||
float get_zero_linear_speed_threshold() const;
|
||||
void set_zero_linear_speed_threshold(const float val);
|
||||
|
||||
@ -34,7 +32,6 @@ class GSAISteeringAgent : public GSAIAgentLocation {
|
||||
bool get_is_tagged() const;
|
||||
void set_is_tagged(const bool val);
|
||||
|
||||
|
||||
GSAISteeringAgent();
|
||||
~GSAISteeringAgent();
|
||||
|
||||
@ -68,5 +65,4 @@ class GSAISteeringAgent : public GSAIAgentLocation {
|
||||
bool is_tagged = false;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "gsai_steering_behavior.h"
|
||||
|
||||
|
||||
bool GSAISteeringBehavior::get_is_enabled() const {
|
||||
return is_enabled;
|
||||
}
|
||||
@ -10,7 +9,6 @@ void GSAISteeringBehavior::set_is_enabled(const bool val) {
|
||||
is_enabled = val;
|
||||
}
|
||||
|
||||
|
||||
GSAISteeringAgent GSAISteeringBehavior::get_ *agent() {
|
||||
return *agent;
|
||||
}
|
||||
@ -19,8 +17,6 @@ void GSAISteeringBehavior::set_*agent(const GSAISteeringAgent &val) {
|
||||
*agent = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Base class for all steering behaviors.;
|
||||
//;
|
||||
// Steering behaviors calculate the linear and the angular acceleration to be;
|
||||
@ -36,23 +32,18 @@ void GSAISteeringBehavior::set_*agent(const GSAISteeringAgent &val) {
|
||||
// Sets the `acceleration` with the behavior's desired amount of acceleration.;
|
||||
|
||||
void GSAISteeringBehavior::calculate_steering(const GSAITargetAcceleration &acceleration) {
|
||||
|
||||
if (is_enabled) {
|
||||
call("_calculate_steering", acceleration);
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
acceleration.set_zero();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GSAISteeringBehavior::_calculate_steering(const GSAITargetAcceleration &acceleration) {
|
||||
acceleration.set_zero();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAISteeringBehavior::GSAISteeringBehavior() {
|
||||
@ -63,22 +54,15 @@ void GSAISteeringBehavior::set_*agent(const GSAISteeringAgent &val) {
|
||||
GSAISteeringBehavior::~GSAISteeringBehavior() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAISteeringBehavior::_bind_methods() {
|
||||
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");
|
||||
|
||||
|
||||
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");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("calculate_steering", "acceleration"), &GSAISteeringBehavior::calculate_steering);
|
||||
ClassDB::bind_method(D_METHOD("_calculate_steering", "acceleration"), &GSAISteeringBehavior::_calculate_steering);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef GSAISTEERINGBEHAVIOR_H
|
||||
#define GSAISTEERINGBEHAVIOR_H
|
||||
|
||||
|
||||
class GSAISteeringBehavior : public Reference {
|
||||
GDCLASS(GSAISteeringBehavior, Reference);
|
||||
|
||||
public:
|
||||
|
||||
bool get_is_enabled() const;
|
||||
void set_is_enabled(const bool val);
|
||||
|
||||
@ -37,5 +35,4 @@ class GSAISteeringBehavior : public Reference {
|
||||
// Sets the `acceleration` with the behavior's desired amount of acceleration.
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "gsai_target_acceleration.h"
|
||||
|
||||
|
||||
Vector3 GSAITargetAcceleration::get_linear() {
|
||||
return linear;
|
||||
}
|
||||
@ -10,7 +9,6 @@ void GSAITargetAcceleration::set_linear(const Vector3 &val) {
|
||||
linear = val;
|
||||
}
|
||||
|
||||
|
||||
float GSAITargetAcceleration::get_angular() const {
|
||||
return angular;
|
||||
}
|
||||
@ -19,8 +17,6 @@ void GSAITargetAcceleration::set_angular(const float val) {
|
||||
angular = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// A desired linear and angular amount of acceleration requested by the steering;
|
||||
// system.;
|
||||
// @category - Base types;
|
||||
@ -55,7 +51,6 @@ angular = val;
|
||||
float GSAITargetAcceleration::get_magnitude() {
|
||||
return sqrt(get_magnitude_squared());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAITargetAcceleration::GSAITargetAcceleration() {
|
||||
@ -66,24 +61,17 @@ angular = val;
|
||||
GSAITargetAcceleration::~GSAITargetAcceleration() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAITargetAcceleration::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_linear"), &GSAITargetAcceleration::get_linear);
|
||||
ClassDB::bind_method(D_METHOD("set_linear", "value"), &GSAITargetAcceleration::set_linear);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "linear"), "set_linear", "get_linear");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_angular"), &GSAITargetAcceleration::get_angular);
|
||||
ClassDB::bind_method(D_METHOD("set_angular", "value"), &GSAITargetAcceleration::set_angular);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "angular"), "set_angular", "get_angular");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_zero"), &GSAITargetAcceleration::set_zero);
|
||||
ClassDB::bind_method(D_METHOD("add_scaled_accel", "accel", "scalar"), &GSAITargetAcceleration::add_scaled_accel);
|
||||
ClassDB::bind_method(D_METHOD("get_magnitude_squared"), &GSAITargetAcceleration::get_magnitude_squared);
|
||||
ClassDB::bind_method(D_METHOD("get_magnitude"), &GSAITargetAcceleration::get_magnitude);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef GSAITARGETACCELERATION_H
|
||||
#define GSAITARGETACCELERATION_H
|
||||
|
||||
|
||||
class GSAITargetAcceleration : public Reference {
|
||||
GDCLASS(GSAITargetAcceleration, Reference);
|
||||
|
||||
public:
|
||||
|
||||
Vector3 get_linear();
|
||||
void set_linear(const Vector3 &val);
|
||||
|
||||
@ -37,5 +35,4 @@ class GSAITargetAcceleration : public Reference {
|
||||
// Returns the magnitude of the linear and angular components.
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,8 +1,6 @@
|
||||
|
||||
#include "gsai_utils.h"
|
||||
|
||||
|
||||
|
||||
// Math and vector utility functions.;
|
||||
// @Category - Utilities;
|
||||
// Returns the `vector` with its length capped to `limit`.;
|
||||
@ -53,7 +51,6 @@
|
||||
Vector3 GSAIUtils::to_vector3(const Vector2 &vector) {
|
||||
return Vector3(vector.x, vector.y, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAIUtils::GSAIUtils() {
|
||||
@ -62,10 +59,5 @@
|
||||
GSAIUtils::~GSAIUtils() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAIUtils::_bind_methods() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,10 +1,8 @@
|
||||
#ifndef GSAIUTILS_H
|
||||
#define GSAIUTILS_H
|
||||
|
||||
|
||||
class GSAIUtils {
|
||||
public:
|
||||
|
||||
static Vector3 clampedv3(const Vector3 &vector, const float limit);
|
||||
static float vector3_to_angle(const Vector3 &vector);
|
||||
static float vector2_to_angle(const Vector2 &vector);
|
||||
@ -34,5 +32,4 @@ class GSAIUtils {
|
||||
// Returns a vector3 with `vector`'s x and y components and 0 in z.
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,8 +1,6 @@
|
||||
|
||||
#include "gsai_infinite_proximity.h"
|
||||
|
||||
|
||||
|
||||
// Determines any agent that is in the specified list as being neighbors with the;
|
||||
// owner agent, regardless of distance.;
|
||||
// @category - Proximities;
|
||||
@ -20,18 +18,14 @@
|
||||
GSAISteeringAgent *current_agent = agents[i] as GSAISteeringAgent;
|
||||
|
||||
if (current_agent != agent) {
|
||||
|
||||
if (callback.call_func(current_agent)) {
|
||||
neighbor_count += 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return neighbor_count;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAIInfiniteProximity::GSAIInfiniteProximity() {
|
||||
@ -40,11 +34,6 @@
|
||||
GSAIInfiniteProximity::~GSAIInfiniteProximity() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAIInfiniteProximity::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_find_neighbors", "callback"), &GSAIInfiniteProximity::_find_neighbors);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef GSAIINFINITEPROXIMITY_H
|
||||
#define GSAIINFINITEPROXIMITY_H
|
||||
|
||||
|
||||
class GSAIInfiniteProximity : public GSAIProximity {
|
||||
GDCLASS(GSAIInfiniteProximity, GSAIProximity);
|
||||
|
||||
public:
|
||||
|
||||
int _find_neighbors(const FuncRef &callback);
|
||||
|
||||
GSAIInfiniteProximity();
|
||||
@ -25,5 +23,4 @@ class GSAIInfiniteProximity : public GSAIProximity {
|
||||
// @tags - virtual
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "gsai_proximity.h"
|
||||
|
||||
|
||||
GSAISteeringAgent GSAIProximity::get_ *agent() {
|
||||
return *agent;
|
||||
}
|
||||
@ -10,7 +9,6 @@ void GSAIProximity::set_*agent(const GSAISteeringAgent &val) {
|
||||
*agent = val;
|
||||
}
|
||||
|
||||
|
||||
Array GSAIProximity::get_agents() {
|
||||
return agents;
|
||||
}
|
||||
@ -19,8 +17,6 @@ void GSAIProximity::set_agents(const Array &val) {
|
||||
agents = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Base container type that stores data to find the neighbors of an agent.;
|
||||
// @category - Proximities;
|
||||
// @tags - abstract;
|
||||
@ -42,7 +38,6 @@ agents = val;
|
||||
int GSAIProximity::_find_neighbors(const FuncRef &_callback) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAIProximity::GSAIProximity() {
|
||||
@ -53,22 +48,15 @@ agents = val;
|
||||
GSAIProximity::~GSAIProximity() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAIProximity::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_*agent"), &GSAIProximity::get_ * agent);
|
||||
ClassDB::bind_method(D_METHOD("set_*agent", "value"), &GSAIProximity::set_ * agent);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*agent", PROPERTY_HINT_RESOURCE_TYPE, "GSAISteeringAgent"), "set_*agent", "get_*agent");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_agents"), &GSAIProximity::get_agents);
|
||||
ClassDB::bind_method(D_METHOD("set_agents", "value"), &GSAIProximity::set_agents);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "agents"), "set_agents", "get_agents");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("find_neighbors", "_callback"), &GSAIProximity::find_neighbors);
|
||||
ClassDB::bind_method(D_METHOD("_find_neighbors", "_callback"), &GSAIProximity::_find_neighbors);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef GSAIPROXIMITY_H
|
||||
#define GSAIPROXIMITY_H
|
||||
|
||||
|
||||
class GSAIProximity : public Reference {
|
||||
GDCLASS(GSAIProximity, Reference);
|
||||
|
||||
public:
|
||||
|
||||
GSAISteeringAgent get_ *agent();
|
||||
void set_ *agent(const GSAISteeringAgent &val);
|
||||
|
||||
@ -36,5 +34,4 @@ class GSAIProximity : public Reference {
|
||||
// @tags - virtual
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "gsai_radius_proximity.h"
|
||||
|
||||
|
||||
float GSAIRadiusProximity::get_radius() const {
|
||||
return radius;
|
||||
}
|
||||
@ -10,7 +9,6 @@ void GSAIRadiusProximity::set_radius(const float val) {
|
||||
radius = val;
|
||||
}
|
||||
|
||||
|
||||
int GSAIRadiusProximity::get__last_frame() const {
|
||||
return _last_frame;
|
||||
}
|
||||
@ -19,7 +17,6 @@ void GSAIRadiusProximity::set__last_frame(const int val) {
|
||||
_last_frame = val;
|
||||
}
|
||||
|
||||
|
||||
SceneTree GSAIRadiusProximity::get_ *_scene_tree() {
|
||||
return *_scene_tree;
|
||||
}
|
||||
@ -28,8 +25,6 @@ void GSAIRadiusProximity::set_*_scene_tree(const SceneTree &val) {
|
||||
*_scene_tree = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Determines any agent that is in the specified list as being neighbors with the owner agent if;
|
||||
// they lie within the specified radius.;
|
||||
// @category - Proximities;
|
||||
@ -57,12 +52,10 @@ void GSAIRadiusProximity::set_*_scene_tree(const SceneTree &val) {
|
||||
current_frame = _scene_tree.get_frame();
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
current_frame = -_last_frame;
|
||||
}
|
||||
|
||||
|
||||
if (current_frame != _last_frame) {
|
||||
_last_frame = current_frame;
|
||||
Vector3 owner_position = agent.position;
|
||||
@ -75,15 +68,12 @@ void GSAIRadiusProximity::set_*_scene_tree(const SceneTree &val) {
|
||||
float range_to = radius + current_agent.bounding_radius;
|
||||
|
||||
if (distance_squared < range_to * range_to) {
|
||||
|
||||
if (callback.call_func(current_agent)) {
|
||||
current_agent.is_tagged = true;
|
||||
neighbor_count += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
current_agent.is_tagged = false;
|
||||
@ -91,27 +81,20 @@ void GSAIRadiusProximity::set_*_scene_tree(const SceneTree &val) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
|
||||
for (int i = 0; i < agent_count; ++i) { //i in range(agent_count)
|
||||
GSAISteeringAgent *current_agent = agents[i] as GSAISteeringAgent;
|
||||
|
||||
if (current_agent != agent && current_agent.is_tagged) {
|
||||
|
||||
if (callback.call_func(current_agent)) {
|
||||
neighbor_count += 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return neighbor_count;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSAIRadiusProximity::GSAIRadiusProximity() {
|
||||
@ -123,27 +106,19 @@ void GSAIRadiusProximity::set_*_scene_tree(const SceneTree &val) {
|
||||
GSAIRadiusProximity::~GSAIRadiusProximity() {
|
||||
}
|
||||
|
||||
|
||||
static void GSAIRadiusProximity::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_radius"), &GSAIRadiusProximity::get_radius);
|
||||
ClassDB::bind_method(D_METHOD("set_radius", "value"), &GSAIRadiusProximity::set_radius);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius"), "set_radius", "get_radius");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get__last_frame"), &GSAIRadiusProximity::get__last_frame);
|
||||
ClassDB::bind_method(D_METHOD("set__last_frame", "value"), &GSAIRadiusProximity::set__last_frame);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "_last_frame"), "set__last_frame", "get__last_frame");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_*_scene_tree"), &GSAIRadiusProximity::get_ * _scene_tree);
|
||||
ClassDB::bind_method(D_METHOD("set_*_scene_tree", "value"), &GSAIRadiusProximity::set_ * _scene_tree);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "*_scene_tree", PROPERTY_HINT_RESOURCE_TYPE, "SceneTree"), "set_*_scene_tree", "get_*_scene_tree");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_init"), &GSAIRadiusProximity::_init);
|
||||
ClassDB::bind_method(D_METHOD("_find_neighbors", "callback"), &GSAIRadiusProximity::_find_neighbors);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef GSAIRADIUSPROXIMITY_H
|
||||
#define GSAIRADIUSPROXIMITY_H
|
||||
|
||||
|
||||
class GSAIRadiusProximity : public GSAIProximity {
|
||||
GDCLASS(GSAIRadiusProximity, GSAIProximity);
|
||||
|
||||
public:
|
||||
|
||||
float get_radius() const;
|
||||
void set_radius(const float val);
|
||||
|
||||
@ -39,5 +37,4 @@ class GSAIRadiusProximity : public GSAIProximity {
|
||||
// @tags - virtual
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user