mirror of
https://github.com/Relintai/godot-steering-ai-framework.git
synced 2024-11-14 04:57:19 +01:00
Move comments from the top of the addon's scripts down under extends and class_name to make absolutely sure that my c++ convererter script doesn't choke on it.
This commit is contained in:
parent
a9df2d5842
commit
eaa2475279
@ -1,8 +1,9 @@
|
|||||||
|
extends GSAISpecializedAgent
|
||||||
|
class_name GSAIKinematicBody2DAgent
|
||||||
|
|
||||||
# A specialized steering agent that updates itself every frame so the user does
|
# A specialized steering agent that updates itself every frame so the user does
|
||||||
# not have to using a KinematicBody2D
|
# not have to using a KinematicBody2D
|
||||||
# @category - Specialized agents
|
# @category - Specialized agents
|
||||||
extends GSAISpecializedAgent
|
|
||||||
class_name GSAIKinematicBody2DAgent
|
|
||||||
|
|
||||||
# SLIDE uses `move_and_slide`
|
# SLIDE uses `move_and_slide`
|
||||||
# COLLIDE uses `move_and_collide`
|
# COLLIDE uses `move_and_collide`
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
extends GSAISpecializedAgent
|
||||||
|
class_name GSAIKinematicBody3DAgent
|
||||||
|
|
||||||
# A specialized steering agent that updates itself every frame so the user does
|
# A specialized steering agent that updates itself every frame so the user does
|
||||||
# not have to using a KinematicBody
|
# not have to using a KinematicBody
|
||||||
# @category - Specialized agents
|
# @category - Specialized agents
|
||||||
extends GSAISpecializedAgent
|
|
||||||
class_name GSAIKinematicBody3DAgent
|
|
||||||
|
|
||||||
# SLIDE uses `move_and_slide`
|
# SLIDE uses `move_and_slide`
|
||||||
# COLLIDE uses `move_and_collide`
|
# COLLIDE uses `move_and_collide`
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
extends GSAISpecializedAgent
|
||||||
|
class_name GSAIRigidBody2DAgent
|
||||||
|
|
||||||
# A specialized steering agent that updates itself every frame so the user does
|
# A specialized steering agent that updates itself every frame so the user does
|
||||||
# not have to using a RigidBody2D
|
# not have to using a RigidBody2D
|
||||||
# @category - Specialized agents
|
# @category - Specialized agents
|
||||||
extends GSAISpecializedAgent
|
|
||||||
class_name GSAIRigidBody2DAgent
|
|
||||||
|
|
||||||
# The RigidBody2D to keep track of
|
# The RigidBody2D to keep track of
|
||||||
var body : RigidBody2D setget _set_body
|
var body : RigidBody2D setget _set_body
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
extends GSAISpecializedAgent
|
||||||
|
class_name GSAIRigidBody3DAgent
|
||||||
|
|
||||||
# A specialized steering agent that updates itself every frame so the user does
|
# A specialized steering agent that updates itself every frame so the user does
|
||||||
# not have to using a RigidBody
|
# not have to using a RigidBody
|
||||||
# @category - Specialized agents
|
# @category - Specialized agents
|
||||||
extends GSAISpecializedAgent
|
|
||||||
class_name GSAIRigidBody3DAgent
|
|
||||||
|
|
||||||
# The RigidBody to keep track of
|
# The RigidBody to keep track of
|
||||||
var body: RigidBody setget _set_body
|
var body: RigidBody setget _set_body
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
|
extends GSAISteeringAgent
|
||||||
|
class_name GSAISpecializedAgent
|
||||||
|
|
||||||
# A base class for a specialized steering agent that updates itself every frame
|
# 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.
|
# so the user does not have to. All other specialized agents derive from this.
|
||||||
# @category - Specialized agents
|
# @category - Specialized agents
|
||||||
# @tags - abstract
|
# @tags - abstract
|
||||||
extends GSAISteeringAgent
|
|
||||||
class_name GSAISpecializedAgent
|
|
||||||
|
|
||||||
# If `true`, calculates linear and angular velocities based on the previous
|
# If `true`, calculates linear and angular velocities based on the previous
|
||||||
# frame. When `false`, the user must keep those values updated.
|
# frame. When `false`, the user must keep those values updated.
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
class_name GSAIArrive
|
||||||
|
extends GSAISteeringBehavior
|
||||||
|
|
||||||
# Calculates acceleration to take an agent to its target's location. The
|
# Calculates acceleration to take an agent to its target's location. The
|
||||||
# calculation attempts to arrive with zero remaining velocity.
|
# calculation attempts to arrive with zero remaining velocity.
|
||||||
# @category - Individual behaviors
|
# @category - Individual behaviors
|
||||||
class_name GSAIArrive
|
|
||||||
extends GSAISteeringBehavior
|
|
||||||
|
|
||||||
# Target agent to arrive to.
|
# Target agent to arrive to.
|
||||||
var target : GSAIAgentLocation
|
var target : GSAIAgentLocation
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
class_name GSAIAvoidCollisions
|
||||||
|
extends GSAIGroupBehavior
|
||||||
|
|
||||||
# Steers the agent to avoid obstacles in its path. Approximates obstacles as
|
# Steers the agent to avoid obstacles in its path. Approximates obstacles as
|
||||||
# spheres.
|
# spheres.
|
||||||
# @category - Group behaviors
|
# @category - Group behaviors
|
||||||
class_name GSAIAvoidCollisions
|
|
||||||
extends GSAIGroupBehavior
|
|
||||||
|
|
||||||
var _first_neighbor: GSAISteeringAgent
|
var _first_neighbor: GSAISteeringAgent
|
||||||
var _shortest_time : float = 0.0
|
var _shortest_time : float = 0.0
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
class_name GSAIBlend
|
||||||
|
extends GSAISteeringBehavior
|
||||||
|
|
||||||
# Blends multiple steering behaviors into one, and returns a weighted
|
# Blends multiple steering behaviors into one, and returns a weighted
|
||||||
# acceleration from their calculations.
|
# acceleration from their calculations.
|
||||||
#
|
#
|
||||||
@ -7,8 +10,6 @@
|
|||||||
# weight : float
|
# weight : float
|
||||||
# }
|
# }
|
||||||
# @category - Combination behaviors
|
# @category - Combination behaviors
|
||||||
class_name GSAIBlend
|
|
||||||
extends GSAISteeringBehavior
|
|
||||||
|
|
||||||
var _behaviors : Array = Array()
|
var _behaviors : Array = Array()
|
||||||
var _accel : GSAITargetAcceleration = GSAITargetAcceleration.new()
|
var _accel : GSAITargetAcceleration = GSAITargetAcceleration.new()
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
class_name GSAICohesion
|
||||||
|
extends GSAIGroupBehavior
|
||||||
|
|
||||||
# Calculates an acceleration that attempts to move the agent towards the center
|
# Calculates an acceleration that attempts to move the agent towards the center
|
||||||
# of mass of the agents in the area defined by the `GSAIProximity`.
|
# of mass of the agents in the area defined by the `GSAIProximity`.
|
||||||
# @category - Group behaviors
|
# @category - Group behaviors
|
||||||
class_name GSAICohesion
|
|
||||||
extends GSAIGroupBehavior
|
|
||||||
|
|
||||||
var _center_of_mass: Vector3
|
var _center_of_mass: Vector3
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
# Calculates acceleration to take an agent away from where a target agent is
|
|
||||||
# moving.
|
|
||||||
# @category - Individual behaviors
|
|
||||||
class_name GSAIEvade
|
class_name GSAIEvade
|
||||||
extends GSAIPursue
|
extends GSAIPursue
|
||||||
|
|
||||||
|
# Calculates acceleration to take an agent away from where a target agent is
|
||||||
|
# moving.
|
||||||
|
# @category - Individual behaviors
|
||||||
|
|
||||||
func _get_modified_acceleration() -> float:
|
func _get_modified_acceleration() -> float:
|
||||||
return -agent.linear_acceleration_max
|
return -agent.linear_acceleration_max
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
class_name GSAIFace
|
||||||
|
extends GSAIMatchOrientation
|
||||||
|
|
||||||
# Calculates angular acceleration to rotate a target to face its target's
|
# Calculates angular acceleration to rotate a target to face its target's
|
||||||
# position. The behavior attemps to arrive with zero remaining angular velocity.
|
# position. The behavior attemps to arrive with zero remaining angular velocity.
|
||||||
# @category - Individual behaviors
|
# @category - Individual behaviors
|
||||||
class_name GSAIFace
|
|
||||||
extends GSAIMatchOrientation
|
|
||||||
|
|
||||||
func face(acceleration: GSAITargetAcceleration, target_position: Vector3) -> void:
|
func face(acceleration: GSAITargetAcceleration, target_position: Vector3) -> void:
|
||||||
call("_face", acceleration, target_position)
|
call("_face", acceleration, target_position)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
# Calculates acceleration to take an agent directly away from a target agent.
|
|
||||||
# @category - Individual behaviors
|
|
||||||
class_name GSAIFlee
|
class_name GSAIFlee
|
||||||
extends GSAISeek
|
extends GSAISeek
|
||||||
|
|
||||||
|
# Calculates acceleration to take an agent directly away from a target agent.
|
||||||
|
# @category - Individual behaviors
|
||||||
|
|
||||||
func _calculate_steering(acceleration: GSAITargetAcceleration) -> void:
|
func _calculate_steering(acceleration: GSAITargetAcceleration) -> void:
|
||||||
acceleration.linear = ((agent.position - target.position).normalized() * agent.linear_acceleration_max)
|
acceleration.linear = ((agent.position - target.position).normalized() * agent.linear_acceleration_max)
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
# Produces a linear acceleration that moves the agent along the specified path.
|
|
||||||
# @category - Individual behaviors
|
|
||||||
class_name GSAIFollowPath
|
class_name GSAIFollowPath
|
||||||
extends GSAIArrive
|
extends GSAIArrive
|
||||||
|
|
||||||
|
# Produces a linear acceleration that moves the agent along the specified path.
|
||||||
|
# @category - Individual behaviors
|
||||||
|
|
||||||
# The path to follow and travel along.
|
# The path to follow and travel along.
|
||||||
var path : GSAIPath
|
var path : GSAIPath
|
||||||
# The distance along the path to generate the next target position.
|
# The distance along the path to generate the next target position.
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
# Calculates an angular acceleration to match an agent's orientation to its
|
|
||||||
# direction of travel.
|
|
||||||
# @category - Individual behaviors
|
|
||||||
class_name GSAILookWhereYouGo
|
class_name GSAILookWhereYouGo
|
||||||
extends GSAIMatchOrientation
|
extends GSAIMatchOrientation
|
||||||
|
|
||||||
|
# Calculates an angular acceleration to match an agent's orientation to its
|
||||||
|
# direction of travel.
|
||||||
|
# @category - Individual behaviors
|
||||||
|
|
||||||
func _calculate_steering(accel: GSAITargetAcceleration) -> void:
|
func _calculate_steering(accel: GSAITargetAcceleration) -> void:
|
||||||
if agent.linear_velocity.length_squared() < agent.zero_linear_speed_threshold:
|
if agent.linear_velocity.length_squared() < agent.zero_linear_speed_threshold:
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
|
class_name GSAIMatchOrientation
|
||||||
|
extends GSAISteeringBehavior
|
||||||
|
|
||||||
# Calculates an angular acceleration to match an agent's orientation to that of
|
# 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
|
# its target. Attempts to make the agent arrive with zero remaining angular
|
||||||
# velocity.
|
# velocity.
|
||||||
# @category - Individual behaviors
|
# @category - Individual behaviors
|
||||||
class_name GSAIMatchOrientation
|
|
||||||
extends GSAISteeringBehavior
|
|
||||||
|
|
||||||
# The target orientation for the behavior to try and match rotations to.
|
# The target orientation for the behavior to try and match rotations to.
|
||||||
var target : GSAIAgentLocation
|
var target : GSAIAgentLocation
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
class_name GSAIPriority
|
||||||
|
extends GSAISteeringBehavior
|
||||||
|
|
||||||
# Container for multiple behaviors that returns the result of the first child
|
# Container for multiple behaviors that returns the result of the first child
|
||||||
# behavior with non-zero acceleration.
|
# behavior with non-zero acceleration.
|
||||||
# @category - Combination behaviors
|
# @category - Combination behaviors
|
||||||
class_name GSAIPriority
|
|
||||||
extends GSAISteeringBehavior
|
|
||||||
|
|
||||||
# If a behavior's acceleration is lower than this threshold, the container
|
# If a behavior's acceleration is lower than this threshold, the container
|
||||||
# considers it has an acceleration of zero.
|
# considers it has an acceleration of zero.
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
class_name GSAIPursue
|
||||||
|
extends GSAISteeringBehavior
|
||||||
|
|
||||||
# Calculates an acceleration to make an agent intercept another based on the
|
# Calculates an acceleration to make an agent intercept another based on the
|
||||||
# target agent's movement.
|
# target agent's movement.
|
||||||
# @category - Individual behaviors
|
# @category - Individual behaviors
|
||||||
class_name GSAIPursue
|
|
||||||
extends GSAISteeringBehavior
|
|
||||||
|
|
||||||
# The target agent that the behavior is trying to intercept.
|
# The target agent that the behavior is trying to intercept.
|
||||||
var target : GSAISteeringAgent
|
var target : GSAISteeringAgent
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
class_name GSAISeek
|
||||||
|
extends GSAISteeringBehavior
|
||||||
|
|
||||||
# Calculates an acceleration to take an agent to a target agent's position
|
# Calculates an acceleration to take an agent to a target agent's position
|
||||||
# directly.
|
# directly.
|
||||||
# @category - Individual behaviors
|
# @category - Individual behaviors
|
||||||
class_name GSAISeek
|
|
||||||
extends GSAISteeringBehavior
|
|
||||||
|
|
||||||
# The target that the behavior aims to move the agent to.
|
# The target that the behavior aims to move the agent to.
|
||||||
var target : GSAIAgentLocation
|
var target : GSAIAgentLocation
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
class_name GSAISeparation
|
||||||
|
extends GSAIGroupBehavior
|
||||||
|
|
||||||
# Calculates an acceleration that repels the agent from its neighbors in the
|
# Calculates an acceleration that repels the agent from its neighbors in the
|
||||||
# given `GSAIProximity`.
|
# given `GSAIProximity`.
|
||||||
#
|
#
|
||||||
@ -5,8 +8,6 @@
|
|||||||
# strength decreasing by the inverse square law in relation to distance, and it
|
# strength decreasing by the inverse square law in relation to distance, and it
|
||||||
# accumulates.
|
# accumulates.
|
||||||
# @category - Group behaviors
|
# @category - Group behaviors
|
||||||
class_name GSAISeparation
|
|
||||||
extends GSAIGroupBehavior
|
|
||||||
|
|
||||||
# The coefficient to calculate how fast the separation strength decays with distance.
|
# The coefficient to calculate how fast the separation strength decays with distance.
|
||||||
var decay_coefficient : float = 1.0
|
var decay_coefficient : float = 1.0
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
# Represents an agent with only a location and an orientation.
|
|
||||||
# @category - Base types
|
|
||||||
extends Reference
|
extends Reference
|
||||||
class_name GSAIAgentLocation
|
class_name GSAIAgentLocation
|
||||||
|
|
||||||
|
# Represents an agent with only a location and an orientation.
|
||||||
|
# @category - Base types
|
||||||
|
|
||||||
# The agent's position in space.
|
# The agent's position in space.
|
||||||
var position : Vector3 = Vector3.ZERO
|
var position : Vector3 = Vector3.ZERO
|
||||||
# The agent's orientation on its Y axis rotation.
|
# The agent's orientation on its Y axis rotation.
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
# Base type for group-based steering behaviors.
|
|
||||||
# @category - Base types
|
|
||||||
class_name GSAIGroupBehavior
|
class_name GSAIGroupBehavior
|
||||||
extends GSAISteeringBehavior
|
extends GSAISteeringBehavior
|
||||||
|
|
||||||
|
# Base type for group-based steering behaviors.
|
||||||
|
# @category - Base types
|
||||||
|
|
||||||
# Container to find neighbors of the agent and calculate group behavior.
|
# Container to find neighbors of the agent and calculate group behavior.
|
||||||
var proximity : GSAIProximity
|
var proximity : GSAIProximity
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
class_name GSAIPath
|
||||||
|
extends Reference
|
||||||
|
|
||||||
# Represents a path made up of Vector3 waypoints, split into segments path
|
# Represents a path made up of Vector3 waypoints, split into segments path
|
||||||
# follow behaviors can use.
|
# follow behaviors can use.
|
||||||
# @category - Base types
|
# @category - Base types
|
||||||
class_name GSAIPath
|
|
||||||
extends Reference
|
|
||||||
|
|
||||||
# If `false`, the path loops.
|
# If `false`, the path loops.
|
||||||
var is_open : bool
|
var is_open : bool
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
|
extends GSAIAgentLocation
|
||||||
|
class_name GSAISteeringAgent
|
||||||
|
|
||||||
# Adds velocity, speed, and size data to `GSAIAgentLocation`.
|
# Adds velocity, speed, and size data to `GSAIAgentLocation`.
|
||||||
#
|
#
|
||||||
# It is the character's responsibility to keep this information up to date for
|
# It is the character's responsibility to keep this information up to date for
|
||||||
# the steering toolkit to work correctly.
|
# the steering toolkit to work correctly.
|
||||||
# @category - Base types
|
# @category - Base types
|
||||||
extends GSAIAgentLocation
|
|
||||||
class_name GSAISteeringAgent
|
|
||||||
|
|
||||||
# The amount of velocity to be considered effectively not moving.
|
# The amount of velocity to be considered effectively not moving.
|
||||||
var zero_linear_speed_threshold : float = 0.01
|
var zero_linear_speed_threshold : float = 0.01
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
extends Reference
|
||||||
|
class_name GSAISteeringBehavior
|
||||||
|
|
||||||
# Base class for all steering behaviors.
|
# Base class for all steering behaviors.
|
||||||
#
|
#
|
||||||
# Steering behaviors calculate the linear and the angular acceleration to be
|
# Steering behaviors calculate the linear and the angular acceleration to be
|
||||||
@ -6,8 +9,6 @@
|
|||||||
# The `calculate_steering` function is the entry point for all behaviors.
|
# The `calculate_steering` function is the entry point for all behaviors.
|
||||||
# Individual steering behaviors encapsulate the steering logic.
|
# Individual steering behaviors encapsulate the steering logic.
|
||||||
# @category - Base types
|
# @category - Base types
|
||||||
extends Reference
|
|
||||||
class_name GSAISteeringBehavior
|
|
||||||
|
|
||||||
# If `false`, all calculations return zero amounts of acceleration.
|
# If `false`, all calculations return zero amounts of acceleration.
|
||||||
var is_enabled : bool = true
|
var is_enabled : bool = true
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
extends Reference
|
||||||
|
class_name GSAITargetAcceleration
|
||||||
|
|
||||||
# A desired linear and angular amount of acceleration requested by the steering
|
# A desired linear and angular amount of acceleration requested by the steering
|
||||||
# system.
|
# system.
|
||||||
# @category - Base types
|
# @category - Base types
|
||||||
extends Reference
|
|
||||||
class_name GSAITargetAcceleration
|
|
||||||
|
|
||||||
# Linear acceleration
|
# Linear acceleration
|
||||||
var linear : Vector3 = Vector3.ZERO
|
var linear : Vector3 = Vector3.ZERO
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
class_name GSAIUtils
|
||||||
|
|
||||||
# Math and vector utility functions.
|
# Math and vector utility functions.
|
||||||
# @Category - Utilities
|
# @Category - Utilities
|
||||||
class_name GSAIUtils
|
|
||||||
|
|
||||||
# Returns the `vector` with its length capped to `limit`.
|
# Returns the `vector` with its length capped to `limit`.
|
||||||
static func clampedv3(vector: Vector3, limit: float) -> Vector3:
|
static func clampedv3(vector: Vector3, limit: float) -> Vector3:
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
# Determines any agent that is in the specified list as being neighbors with the
|
|
||||||
# owner agent, regardless of distance.
|
|
||||||
# @category - Proximities
|
|
||||||
extends GSAIProximity
|
extends GSAIProximity
|
||||||
class_name GSAIInfiniteProximity
|
class_name GSAIInfiniteProximity
|
||||||
|
|
||||||
|
# Determines any agent that is in the specified list as being neighbors with the
|
||||||
|
# owner agent, regardless of distance.
|
||||||
|
# @category - Proximities
|
||||||
|
|
||||||
# Returns a number of neighbors based on a `callback` function.
|
# Returns a number of neighbors based on a `callback` function.
|
||||||
#
|
#
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
extends Reference
|
||||||
|
class_name GSAIProximity
|
||||||
|
|
||||||
# Base container type that stores data to find the neighbors of an agent.
|
# Base container type that stores data to find the neighbors of an agent.
|
||||||
# @category - Proximities
|
# @category - Proximities
|
||||||
# @tags - abstract
|
# @tags - abstract
|
||||||
extends Reference
|
|
||||||
class_name GSAIProximity
|
|
||||||
|
|
||||||
# The owning agent whose neighbors are found in the group
|
# The owning agent whose neighbors are found in the group
|
||||||
var agent : GSAISteeringAgent
|
var agent : GSAISteeringAgent
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
extends GSAIProximity
|
||||||
|
class_name GSAIRadiusProximity
|
||||||
|
|
||||||
# Determines any agent that is in the specified list as being neighbors with the owner agent if
|
# Determines any agent that is in the specified list as being neighbors with the owner agent if
|
||||||
# they lie within the specified radius.
|
# they lie within the specified radius.
|
||||||
# @category - Proximities
|
# @category - Proximities
|
||||||
extends GSAIProximity
|
|
||||||
class_name GSAIRadiusProximity
|
|
||||||
|
|
||||||
# The radius around the owning agent to find neighbors in
|
# The radius around the owning agent to find neighbors in
|
||||||
var radius : float = 0.0
|
var radius : float = 0.0
|
||||||
|
Loading…
Reference in New Issue
Block a user