mirror of
https://github.com/Relintai/godot-steering-ai-framework.git
synced 2024-11-14 04:57:19 +01:00
Move class docstring to top of class
For documentation purposes, current tools expect it there.
This commit is contained in:
parent
6276fc0413
commit
62ad172767
@ -1,7 +1,7 @@
|
||||
class_name GSTArrive
|
||||
extends GSTSteeringBehavior
|
||||
# Calculates acceleration to take an agent to its target's location.
|
||||
# The calculation will attempt to arrive with zero remaining velocity.
|
||||
class_name GSTArrive
|
||||
extends GSTSteeringBehavior
|
||||
|
||||
|
||||
# The target whose location the agent will be steered to arrive at
|
||||
@ -10,7 +10,7 @@ var target: GSTAgentLocation
|
||||
var arrival_tolerance: float
|
||||
# The distance from the target for the agent to begin slowing down
|
||||
var deceleration_radius: float
|
||||
# A constant that represents the time it takes to change acceleration
|
||||
# The amount of time to reach the target velocity
|
||||
var time_to_reach := 0.1
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Behavior that steers the agent to avoid obstacles lying in its path as approximated by spheres.
|
||||
class_name GSTAvoidCollisions
|
||||
extends GSTGroupBehavior
|
||||
# Behavior that steers the agent to avoid obstacles lying in its path as approximated by spheres.
|
||||
|
||||
|
||||
var first_neighbor: GSTSteeringAgent
|
||||
@ -39,6 +39,8 @@ func _calculate_steering(acceleration: GSTTargetAcceleration) -> GSTTargetAccele
|
||||
return acceleration
|
||||
|
||||
|
||||
# Callback for the proximity to call when finding neighbors. Keeps track of every `neighbor`
|
||||
# that was found but only keeps the one the owning agent will most likely collide with.
|
||||
func report_neighbor(neighbor: GSTSteeringAgent) -> bool:
|
||||
var relative_position := neighbor.position - agent.position
|
||||
var relative_velocity := neighbor.linear_velocity - agent.linear_velocity
|
||||
|
@ -1,5 +1,3 @@
|
||||
class_name GSTBlend
|
||||
extends GSTSteeringBehavior
|
||||
# Blends multiple steering behaviors into one, and returns acceleration combining all of them.
|
||||
#
|
||||
# Each behavior is associated with a weight - a modifier by which the result will be multiplied by,
|
||||
@ -7,6 +5,8 @@ extends GSTSteeringBehavior
|
||||
#
|
||||
# Each behavior is stored internally as a `Dictionary` with a `behavior` key with a value of type
|
||||
# `GSTSteeringBehavior` and a `weight` key with a value of type float.
|
||||
class_name GSTBlend
|
||||
extends GSTSteeringBehavior
|
||||
|
||||
|
||||
var _behaviors := []
|
||||
|
@ -1,7 +1,7 @@
|
||||
class_name GSTCohesion
|
||||
extends GSTGroupBehavior
|
||||
# Group behavior that produces linear acceleration that attempts to move the agent towards the
|
||||
# center of mass of the agents in the area defined by the Proximity.
|
||||
class_name GSTCohesion
|
||||
extends GSTGroupBehavior
|
||||
|
||||
|
||||
var center_of_mass: Vector3
|
||||
@ -21,6 +21,8 @@ func _calculate_steering(acceleration: GSTTargetAcceleration) -> GSTTargetAccele
|
||||
return acceleration
|
||||
|
||||
|
||||
# Callback for the proximity to call when finding neighbors. Adds `neighbor`'s position
|
||||
# to the center of mass of the group.
|
||||
func report_neighbor(neighbor: GSTSteeringAgent) -> bool:
|
||||
center_of_mass += neighbor.position
|
||||
return true
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Calculates acceleration to take an agent away from where a target agent will be.
|
||||
class_name GSTEvade
|
||||
extends GSTPursue
|
||||
# Calculates acceleration to take an agent away from where a target agent will be.
|
||||
|
||||
|
||||
func _init(
|
||||
|
@ -1,7 +1,7 @@
|
||||
class_name GSTFace
|
||||
extends GSTMatchOrientation
|
||||
# Calculates angular acceleration to rotate a target to face its target's position.
|
||||
# The acceleration will attempt to arrive with zero remaining angular velocity.
|
||||
class_name GSTFace
|
||||
extends GSTMatchOrientation
|
||||
|
||||
|
||||
func _init(agent: GSTSteeringAgent, target: GSTAgentLocation).(agent, target) -> void:
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Calculates acceleration to take an agent directly away from a target agent.
|
||||
class_name GSTFlee
|
||||
extends GSTSeek
|
||||
# Calculates acceleration to take an agent directly away from a target agent.
|
||||
|
||||
|
||||
func _init(agent: GSTSteeringAgent, target: GSTAgentLocation).(agent, target) -> void:
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Produces a linear acceleration that moves the agent along the specified path.
|
||||
class_name GSTFollowPath
|
||||
extends GSTArrive
|
||||
# Produces a linear acceleration that moves the agent along the specified path.
|
||||
|
||||
|
||||
# The path to follow and travel along
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Calculates an angular acceleration to match an agent's orientation to its direction of travel.
|
||||
class_name GSTLookWhereYouGo
|
||||
extends GSTMatchOrientation
|
||||
# Calculates an angular acceleration to match an agent's orientation to its direction of travel.
|
||||
|
||||
|
||||
func _init(agent: GSTSteeringAgent).(agent, null) -> void:
|
||||
|
@ -1,7 +1,7 @@
|
||||
class_name GSTMatchOrientation
|
||||
extends GSTSteeringBehavior
|
||||
# Calculates an angular acceleration to match an agent's orientation to its target's.
|
||||
# The calculation will attempt to arrive with zero remaining angular velocity.
|
||||
class_name GSTMatchOrientation
|
||||
extends GSTSteeringBehavior
|
||||
|
||||
|
||||
# The target orientation for the behavior to try and match rotations to
|
||||
@ -10,7 +10,7 @@ var target: GSTAgentLocation
|
||||
var alignment_tolerance: float
|
||||
# The amount of distance in radians from the goal to start slowing down
|
||||
var deceleration_radius: float
|
||||
# A constant to represent the time it takes to change angular accelerations
|
||||
# The amount of time to reach the target velocity
|
||||
var time_to_reach: float = 0.1
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Contains multiple behaviors and returns only the result of the first with non-zero acceleration.
|
||||
class_name GSTPriority
|
||||
extends GSTSteeringBehavior
|
||||
# Contains multiple behaviors and returns only the result of the first with non-zero acceleration.
|
||||
|
||||
|
||||
var _behaviors := []
|
||||
|
@ -1,7 +1,7 @@
|
||||
class_name GSTPursue
|
||||
extends GSTSteeringBehavior
|
||||
# Calculates acceleration to take an agent to intersect with where a target agent will be, instead
|
||||
# of where it currently is.
|
||||
class_name GSTPursue
|
||||
extends GSTSteeringBehavior
|
||||
|
||||
|
||||
# The target agent that the behavior is trying to intercept
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Calculates acceleration to take an agent to a target agent's position directly
|
||||
class_name GSTSeek
|
||||
extends GSTSteeringBehavior
|
||||
# Calculates acceleration to take an agent to a target agent's position directly
|
||||
|
||||
|
||||
# The target that the behavior aims to move the agent to
|
||||
|
@ -1,13 +1,13 @@
|
||||
class_name GSTSeparation
|
||||
extends GSTGroupBehavior
|
||||
# Group behavior that produces acceleration that repels the agent from the other neighbors that
|
||||
# are in the area defined by the given `GSTProximity`.
|
||||
#
|
||||
# The produced acceleration is an average of all agents under consideration, multiplied by a
|
||||
# strength decreasing by the inverse square law in relation to distance, and accumulated.
|
||||
class_name GSTSeparation
|
||||
extends GSTGroupBehavior
|
||||
|
||||
|
||||
# The constant 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 := 1.0
|
||||
|
||||
var acceleration: GSTTargetAcceleration
|
||||
@ -24,6 +24,8 @@ func _calculate_steering(acceleration: GSTTargetAcceleration) -> GSTTargetAccele
|
||||
return acceleration
|
||||
|
||||
|
||||
# Callback for the proximity to call when finding neighbors. Determines the amount of
|
||||
# acceleration that `neighbor` imposes based on its distance from the owner agent.
|
||||
func report_neighbor(neighbor: GSTSteeringAgent) -> bool:
|
||||
var to_agent := agent.position - neighbor.position
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
class_name GSTAgentLocation
|
||||
# Represents an agent with only a location and an orientation.
|
||||
class_name GSTAgentLocation
|
||||
|
||||
|
||||
# The agent's position in space.
|
||||
|
@ -1,9 +1,9 @@
|
||||
# Base type for group-based steering behaviors.
|
||||
extends GSTSteeringBehavior
|
||||
class_name GSTGroupBehavior
|
||||
# Base type for group-based steering behaviors.
|
||||
|
||||
|
||||
# Container to find neighbors of the agent and apply a group behavior.
|
||||
# Container to find neighbors of the agent and calculate group behavior.
|
||||
var proximity: GSTProximity
|
||||
|
||||
var _callback := funcref(self, "report_neighbor")
|
||||
|
@ -1,6 +1,6 @@
|
||||
extends Reference class_name GSTPath
|
||||
# Represents a path made up of Vector3 waypoints, split into segments path
|
||||
# follow behaviors can use.
|
||||
extends Reference class_name GSTPath
|
||||
|
||||
|
||||
# If `false`, the path loops.
|
||||
|
@ -1,9 +1,9 @@
|
||||
extends GSTAgentLocation
|
||||
class_name GSTSteeringAgent
|
||||
# Adds velocity, speed, and size data to `GSTAgentLocation`.
|
||||
#
|
||||
# It is the character's responsibility to keep this information up to date for
|
||||
# the steering toolkit to work correctly.
|
||||
extends GSTAgentLocation
|
||||
class_name GSTSteeringAgent
|
||||
|
||||
|
||||
# The amount of velocity to be considered effectively not moving.
|
||||
|
@ -1,4 +1,3 @@
|
||||
class_name GSTSteeringBehavior
|
||||
# Base class for all steering behaviors.
|
||||
#
|
||||
# Steering behaviors calculate the linear and the angular acceleration to be
|
||||
@ -6,6 +5,7 @@ class_name GSTSteeringBehavior
|
||||
#
|
||||
# The `calculate_steering` function is the entry point for all behaviors.
|
||||
# Individual steering behaviors encapsulate the steering logic.
|
||||
class_name GSTSteeringBehavior
|
||||
|
||||
|
||||
# If `false`, all calculations return zero amounts of acceleration.
|
||||
|
@ -1,6 +1,6 @@
|
||||
class_name GSTTargetAcceleration
|
||||
# A desired linear and angular amount of acceleration requested by the steering
|
||||
# system.
|
||||
class_name GSTTargetAcceleration
|
||||
|
||||
|
||||
# Linear acceleration
|
||||
|
@ -1,5 +1,5 @@
|
||||
class_name GSTUtils
|
||||
# Math and vector utility functions.
|
||||
class_name GSTUtils
|
||||
|
||||
|
||||
# Returns the `vector` with its length capped to `limit`.
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Determines any agent that is in the specified list as being neighbors with the
|
||||
# owner agent, regardless of distance.
|
||||
extends GSTProximity
|
||||
class_name GSTInfiniteProximity
|
||||
# Determines any agent that is in the specified list as being neighbors with the
|
||||
# owner agent.
|
||||
|
||||
|
||||
func _init(agent: GSTSteeringAgent, agents: Array).(agent, agents) -> void:
|
||||
@ -11,7 +11,7 @@ func _init(agent: GSTSteeringAgent, agents: Array).(agent, agents) -> void:
|
||||
# Returns a number of neighbors based on a `callback` function.
|
||||
#
|
||||
# `find_neighbors` calls `callback` for each agent in the `agents` array and
|
||||
# adds one to the count it if `callback` returns true.
|
||||
# adds one to the count if its `callback` returns true.
|
||||
func find_neighbors(callback: FuncRef) -> int:
|
||||
var neighbor_count := 0
|
||||
var agent_count := agents.size()
|
||||
|
@ -1,9 +1,11 @@
|
||||
# Base container type that stores data to find the neighbors of an agent.
|
||||
extends Reference
|
||||
class_name GSTProximity
|
||||
# Base container type that stores data to find the neighbors of an agent.
|
||||
|
||||
|
||||
# The owning agent whose neighbors are found in the group
|
||||
var agent: GSTSteeringAgent
|
||||
# The agents who are part of this group and could be potential neighbors
|
||||
var agents := []
|
||||
|
||||
|
||||
@ -12,5 +14,9 @@ func _init(agent: GSTSteeringAgent, agents: Array) -> void:
|
||||
self.agents = agents
|
||||
|
||||
|
||||
# Returns a number of neighbors based on a `callback` function.
|
||||
#
|
||||
# `find_neighbors` calls `callback` for each agent in the `agents` array and
|
||||
# adds one to the count if its `callback` returns true.
|
||||
func find_neighbors(callback: FuncRef) -> int:
|
||||
return 0
|
||||
|
@ -1,9 +1,10 @@
|
||||
extends GSTProximity
|
||||
class_name GSTRadiusProximity
|
||||
# Determines any agent that is in the specified list as being neighbors with the owner agent if
|
||||
# they lie within the specified radius.
|
||||
extends GSTProximity
|
||||
class_name GSTRadiusProximity
|
||||
|
||||
|
||||
# The radius around the owning agent to find neighbors in
|
||||
var radius := 0.0
|
||||
|
||||
var _last_frame := 0
|
||||
@ -15,6 +16,10 @@ func _init(agent: GSTSteeringAgent, agents: Array, radius: float).(agent, agents
|
||||
_scene_tree = Engine.get_main_loop()
|
||||
|
||||
|
||||
# Returns a number of neighbors based on a `callback` function.
|
||||
#
|
||||
# `find_neighbors` calls `callback` for each agent in the `agents` array that lie within
|
||||
# the radius around the owning agent and adds one to the count if its `callback` returns true.
|
||||
func find_neighbors(callback: FuncRef) -> int:
|
||||
var agent_count := agents.size()
|
||||
var neighbor_count := 0
|
||||
|
Loading…
Reference in New Issue
Block a user