2020-01-28 00:31:10 +01:00
|
|
|
# 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.
|
2020-04-03 02:31:59 +02:00
|
|
|
# @category - Base types
|
2023-01-13 13:09:18 +01:00
|
|
|
extends Reference
|
2020-02-11 18:33:25 +01:00
|
|
|
class_name GSAISteeringBehavior
|
2019-12-19 20:04:08 +01:00
|
|
|
|
2020-01-28 00:31:10 +01:00
|
|
|
# If `false`, all calculations return zero amounts of acceleration.
|
2023-01-13 13:09:18 +01:00
|
|
|
var is_enabled : bool = true
|
2020-01-28 00:31:10 +01:00
|
|
|
# The AI agent on which the steering behavior bases its calculations.
|
2023-01-13 13:09:18 +01:00
|
|
|
var agent : GSAISteeringAgent
|
2019-12-19 20:04:08 +01:00
|
|
|
|
|
|
|
|
2020-02-11 20:18:22 +01:00
|
|
|
func _init(_agent: GSAISteeringAgent) -> void:
|
2023-01-13 13:09:18 +01:00
|
|
|
agent = _agent
|
2019-12-19 20:04:08 +01:00
|
|
|
|
|
|
|
|
2020-02-06 20:46:21 +01:00
|
|
|
# Sets the `acceleration` with the behavior's desired amount of acceleration.
|
2020-02-11 18:33:25 +01:00
|
|
|
func calculate_steering(acceleration: GSAITargetAcceleration) -> void:
|
2020-01-29 22:53:57 +01:00
|
|
|
if is_enabled:
|
2020-02-06 20:46:21 +01:00
|
|
|
_calculate_steering(acceleration)
|
2019-12-19 20:04:08 +01:00
|
|
|
else:
|
|
|
|
acceleration.set_zero()
|
|
|
|
|
|
|
|
|
2020-02-11 18:33:25 +01:00
|
|
|
func _calculate_steering(acceleration: GSAITargetAcceleration) -> void:
|
2019-12-19 20:04:08 +01:00
|
|
|
acceleration.set_zero()
|