godot-steering-ai-framework/project/src/GSTSteeringBehavior.gd
Nathan Lovato 0586878fcf Fix the style of booleans and virtual functions in the API
Made booleans start with a prefix, e.g. is_open
Added a leading underscore to two virtual functions
Added VIRTUAL comment above several virtual functions
Renamed accel -> acceleration in a function
2020-01-29 15:53:57 -06:00

34 lines
1011 B
GDScript

# Base class for all steering behaviors.
#
# Steering behaviors calculate the linear and the angular acceleration to be
# to the agent that owns them.
#
# 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.
var is_enabled := true
# The AI agent on which the steering behavior bases its calculations.
var agent: GSTSteeringAgent
func _init(agent: GSTSteeringAgent) -> void:
self.agent = agent
# Returns the `acceleration` modified with the behavior's desired amount of
# acceleration.
func calculate_steering(acceleration: GSTTargetAcceleration) -> GSTTargetAcceleration:
if is_enabled:
return _calculate_steering(acceleration)
else:
acceleration.set_zero()
return acceleration
func _calculate_steering(acceleration: GSTTargetAcceleration) -> GSTTargetAcceleration:
acceleration.set_zero()
return acceleration