From 7eb91a61651c9f49c1d0fcf43396e49a37e05763 Mon Sep 17 00:00:00 2001 From: Nathan Lovato Date: Tue, 11 Feb 2020 11:33:25 -0600 Subject: [PATCH] Use GSAI as a class prefix instead of GST GSAI for Godot Steering AI --- README.md | 30 +-- project/demos/Arrive/Arriver.gd | 8 +- project/demos/Arrive/TargetDrawer.gd | 2 +- project/demos/AvoidCollisions/Avoider.gd | 14 +- project/demos/Face/Player.gd | 2 +- project/demos/Face/Turret.gd | 10 +- project/demos/FollowPath/PathFollower.gd | 8 +- project/demos/GroupBehaviors/Member.gd | 18 +- project/demos/PursueSeek/Player.gd | 2 +- project/demos/PursueSeek/Pursuer.gd | 26 +- project/demos/Quickstart/Agent.gd | 30 +-- project/demos/Quickstart/Player.gd | 10 +- project/demos/SeekFlee/Player.gd | 6 +- project/demos/SeekFlee/Seeker.gd | 10 +- project/project.godot | 222 +++++++++--------- ...2DAgent.gd => GSAIKinematicBody2DAgent.gd} | 26 +- ...BodyAgent.gd => GSAIKinematicBodyAgent.gd} | 14 +- ...Body2DAgent.gd => GSAIRigidBody2DAgent.gd} | 16 +- ...igidBodyAgent.gd => GSAIRigidBodyAgent.gd} | 6 +- ...alizedAgent.gd => GSAISpecializedAgent.gd} | 6 +- .../Behaviors/{GSTArrive.gd => GSAIArrive.gd} | 14 +- ...idCollisions.gd => GSAIAvoidCollisions.gd} | 12 +- .../Behaviors/{GSTBlend.gd => GSAIBlend.gd} | 16 +- .../{GSTCohesion.gd => GSAICohesion.gd} | 12 +- .../Behaviors/{GSTEvade.gd => GSAIEvade.gd} | 8 +- .../src/Behaviors/{GSTFace.gd => GSAIFace.gd} | 12 +- .../src/Behaviors/{GSTFlee.gd => GSAIFlee.gd} | 8 +- .../{GSTFollowPath.gd => GSAIFollowPath.gd} | 14 +- ...ookWhereYouGo.gd => GSAILookWhereYouGo.gd} | 10 +- ...Orientation.gd => GSAIMatchOrientation.gd} | 12 +- .../{GSTPriority.gd => GSAIPriority.gd} | 14 +- .../Behaviors/{GSTPursue.gd => GSAIPursue.gd} | 12 +- .../src/Behaviors/{GSTSeek.gd => GSAISeek.gd} | 10 +- .../{GSTSeparation.gd => GSAISeparation.gd} | 14 +- ...TAgentLocation.gd => GSAIAgentLocation.gd} | 2 +- ...TGroupBehavior.gd => GSAIGroupBehavior.gd} | 10 +- project/src/{GSTPath.gd => GSAIPath.gd} | 14 +- ...TSteeringAgent.gd => GSAISteeringAgent.gd} | 6 +- ...ingBehavior.gd => GSAISteeringBehavior.gd} | 10 +- ...eleration.gd => GSAITargetAcceleration.gd} | 4 +- project/src/{GSTUtils.gd => GSAIUtils.gd} | 2 +- ...eProximity.gd => GSAIInfiniteProximity.gd} | 8 +- .../{GSTProximity.gd => GSAIProximity.gd} | 6 +- ...iusProximity.gd => GSAIRadiusProximity.gd} | 10 +- 44 files changed, 353 insertions(+), 353 deletions(-) rename project/src/Agents/{GSTKinematicBody2DAgent.gd => GSAIKinematicBody2DAgent.gd} (79%) rename project/src/Agents/{GSTKinematicBodyAgent.gd => GSAIKinematicBodyAgent.gd} (88%) rename project/src/Agents/{GSTRigidBody2DAgent.gd => GSAIRigidBody2DAgent.gd} (72%) rename project/src/Agents/{GSTRigidBodyAgent.gd => GSAIRigidBodyAgent.gd} (90%) rename project/src/Agents/{GSTSpecializedAgent.gd => GSAISpecializedAgent.gd} (90%) rename project/src/Behaviors/{GSTArrive.gd => GSAIArrive.gd} (70%) rename project/src/Behaviors/{GSTAvoidCollisions.gd => GSAIAvoidCollisions.gd} (86%) rename project/src/Behaviors/{GSTBlend.gd => GSAIBlend.gd} (70%) rename project/src/Behaviors/{GSTCohesion.gd => GSAICohesion.gd} (63%) rename project/src/Behaviors/{GSTEvade.gd => GSAIEvade.gd} (72%) rename project/src/Behaviors/{GSTFace.gd => GSAIFace.gd} (56%) rename project/src/Behaviors/{GSTFlee.gd => GSAIFlee.gd} (52%) rename project/src/Behaviors/{GSTFollowPath.gd => GSAIFollowPath.gd} (86%) rename project/src/Behaviors/{GSTLookWhereYouGo.gd => GSAILookWhereYouGo.gd} (50%) rename project/src/Behaviors/{GSTMatchOrientation.gd => GSAIMatchOrientation.gd} (80%) rename project/src/Behaviors/{GSTPriority.gd => GSAIPriority.gd} (75%) rename project/src/Behaviors/{GSTPursue.gd => GSAIPursue.gd} (84%) rename project/src/Behaviors/{GSTSeek.gd => GSAISeek.gd} (57%) rename project/src/Behaviors/{GSTSeparation.gd => GSAISeparation.gd} (74%) rename project/src/{GSTAgentLocation.gd => GSAIAgentLocation.gd} (87%) rename project/src/{GSTGroupBehavior.gd => GSAIGroupBehavior.gd} (58%) rename project/src/{GSTPath.gd => GSAIPath.gd} (93%) rename project/src/{GSTSteeringAgent.gd => GSAISteeringAgent.gd} (89%) rename project/src/{GSTSteeringBehavior.gd => GSAISteeringBehavior.gd} (73%) rename project/src/{GSTTargetAcceleration.gd => GSAITargetAcceleration.gd} (87%) rename project/src/{GSTUtils.gd => GSAIUtils.gd} (98%) rename project/src/Proximities/{GSTInfiniteProximity.gd => GSAIInfiniteProximity.gd} (76%) rename project/src/Proximities/{GSTProximity.gd => GSAIProximity.gd} (83%) rename project/src/Proximities/{GSTRadiusProximity.gd => GSAIRadiusProximity.gd} (85%) diff --git a/README.md b/README.md index b6f3c0b..f72a9a9 100644 --- a/README.md +++ b/README.md @@ -74,32 +74,32 @@ var linear_drag := 0.1 var angular_drag := 0.1 # Holds the linear and angular components calculated by our steering behaviors. -var acceleration := GSTTargetAcceleration.new() +var acceleration := GSAITargetAcceleration.new() onready var current_health := health_max -# GSTSteeringAgent holds our agent's position, orientation, maximum speed and acceleration. -onready var agent := GSTSteeringAgent.new() +# GSAISteeringAgent holds our agent's position, orientation, maximum speed and acceleration. +onready var agent := GSAISteeringAgent.new() onready var player: Node = get_tree().get_nodes_in_group("Player")[0] # This assumes that our player class will keep its own agent updated. -onready var player_agent: GSTSteeringAgent = player.agent +onready var player_agent: GSAISteeringAgent = player.agent # Proximities represent an area with which an agent can identify where neighbors in its relevant # group are. In our case, the group will feature the player, which will be used to avoid a # collision with them. We use a radius proximity so the player is only relevant inside 100 pixels -onready var proximity := GSTRadiusProximity.new(agent, [player_agent], 100). +onready var proximity := GSAIRadiusProximity.new(agent, [player_agent], 100). -# GSTBlend combines behaviors together, calculating all of their acceleration together and adding +# GSAIBlend combines behaviors together, calculating all of their acceleration together and adding # them together, multiplied by a strength. We will have one for fleeing, and one for pursuing, # toggling them depending on the agent's health. Since we want the agent to rotate AND move, then # we aim to blend them together. -onready var flee_blend := GSTBlend.new(agent) -onready var pursue_blend := GSTBlend.new(agent) +onready var flee_blend := GSAIBlend.new(agent) +onready var pursue_blend := GSAIBlend.new(agent) -# GSTPriority will be the main steering behavior we use. It holds sub-behaviors and will pick the +# GSAIPriority will be the main steering behavior we use. It holds sub-behaviors and will pick the # first one that returns non-zero acceleration, ignoring any afterwards. -onready var priority := GSTPriority.new(agent) +onready var priority := GSAIPriority.new(agent) func _ready() -> void: @@ -114,20 +114,20 @@ func _ready() -> void: # ---------- Configuration for our behaviors ---------- # Pursue will happen while the player is in good health. It produces acceleration that takes # the agent on an intercept course with the target, predicting its position in the future. - var pursue := GSTPursue.new(agent, player_agent) + var pursue := GSAIPursue.new(agent, player_agent) pursue.predict_time_max = 1.5 # Flee will happen while the agent is in bad health, so will start disabled. It produces # acceleration that takes the agent directly away from the target with no prediction. - var flee := GSTFlee.new(agent, player_agent) + var flee := GSAIFlee.new(agent, player_agent) # AvoidCollision tries to keep the agent from running into any of the neighbors found in its # proximity group. In our case, this will be the player if they are close enough. - var avoid := GSTAvoidCollisions.new(agent, proximity) + var avoid := GSAIAvoidCollisions.new(agent, proximity) # Face turns the agent to keep looking towards its target. It will be enabled while the agent # is not fleeing due to low health. It tries to arrive 'on alignment' with 0 remaining velocity. - var face := GSTFace.new(agent, player_agent) + var face := GSAIFace.new(agent, player_agent) # We use deg2rad because the math in the toolkit assumes radians. # How close for the agent to be 'aligned', if not exact. @@ -137,7 +137,7 @@ func _ready() -> void: # LookWhereYouGo turns the agent to keep looking towards its direction of travel. It will only # be enabled while the agent is at low health. - var look := GSTLookWhereYouGo.new(agent) + var look := GSAILookWhereYouGo.new(agent) # How close for the agent to be 'aligned', if not exact. look.alignment_tolerance = deg2rad(5) # When to start slowing down. diff --git a/project/demos/Arrive/Arriver.gd b/project/demos/Arrive/Arriver.gd index 0d3b81d..84a8d5d 100644 --- a/project/demos/Arrive/Arriver.gd +++ b/project/demos/Arrive/Arriver.gd @@ -1,10 +1,10 @@ extends KinematicBody2D -var agent := GSTKinematicBody2DAgent.new(self) -var target := GSTAgentLocation.new() -var arrive := GSTArrive.new(agent, target) -var _accel := GSTTargetAcceleration.new() +var agent := GSAIKinematicBody2DAgent.new(self) +var target := GSAIAgentLocation.new() +var arrive := GSAIArrive.new(agent, target) +var _accel := GSAITargetAcceleration.new() var _velocity := Vector2() var _drag := 0.1 diff --git a/project/demos/Arrive/TargetDrawer.gd b/project/demos/Arrive/TargetDrawer.gd index 48322d0..f1aa0f1 100644 --- a/project/demos/Arrive/TargetDrawer.gd +++ b/project/demos/Arrive/TargetDrawer.gd @@ -15,6 +15,6 @@ func _ready() -> void: func _draw(): - var target_position := GSTUtils.to_vector2(arriver.target.position) + var target_position := GSAIUtils.to_vector2(arriver.target.position) draw_circle(target_position, owner.deceleration_radius, COLORS.deceleration_radius) draw_circle(target_position, owner.arrival_tolerance, COLORS.arrival_tolerance) diff --git a/project/demos/AvoidCollisions/Avoider.gd b/project/demos/AvoidCollisions/Avoider.gd index dfb8281..c47ff2b 100644 --- a/project/demos/AvoidCollisions/Avoider.gd +++ b/project/demos/AvoidCollisions/Avoider.gd @@ -6,19 +6,19 @@ var draw_proximity: bool var _boundary_right: float var _boundary_bottom: float var _radius: float -var _accel := GSTTargetAcceleration.new() +var _accel := GSAITargetAcceleration.new() var _velocity := Vector2.ZERO var _direction := Vector2() var _drag := 0.1 var _color := Color(0.4, 1.0, 0.89, 0.3) onready var collision := $CollisionShape2D -onready var agent := GSTKinematicBody2DAgent.new(self) -onready var proximity := GSTRadiusProximity.new(agent, [], 140) -onready var avoid := GSTAvoidCollisions.new(agent, proximity) -onready var target := GSTAgentLocation.new() -onready var seek := GSTSeek.new(agent, target) -onready var priority := GSTPriority.new(agent, 0.0001) +onready var agent := GSAIKinematicBody2DAgent.new(self) +onready var proximity := GSAIRadiusProximity.new(agent, [], 140) +onready var avoid := GSAIAvoidCollisions.new(agent, proximity) +onready var target := GSAIAgentLocation.new() +onready var seek := GSAISeek.new(agent, target) +onready var priority := GSAIPriority.new(agent, 0.0001) func _draw() -> void: diff --git a/project/demos/Face/Player.gd b/project/demos/Face/Player.gd index c93feb9..09d4576 100644 --- a/project/demos/Face/Player.gd +++ b/project/demos/Face/Player.gd @@ -3,7 +3,7 @@ extends KinematicBody2D var speed: float -onready var agent := GSTAgentLocation.new() +onready var agent := GSAIAgentLocation.new() func _physics_process(delta: float) -> void: diff --git a/project/demos/Face/Turret.gd b/project/demos/Face/Turret.gd index 8326837..e8b326b 100644 --- a/project/demos/Face/Turret.gd +++ b/project/demos/Face/Turret.gd @@ -1,10 +1,10 @@ extends KinematicBody2D -var face: GSTFace -var agent := GSTKinematicBody2DAgent.new(self) +var face: GSAIFace +var agent := GSAIKinematicBody2DAgent.new(self) -var _accel := GSTTargetAcceleration.new() +var _accel := GSAITargetAcceleration.new() var _angular_drag := 0.1 var _cannon: Rect2 var _color: Color @@ -28,13 +28,13 @@ func _draw() -> void: func setup( - player_agent: GSTAgentLocation, + player_agent: GSAIAgentLocation, align_tolerance: float, deceleration_radius: float, angular_accel_max: float, angular_speed_max: float ) -> void: - face = GSTFace.new(agent, player_agent) + face = GSAIFace.new(agent, player_agent) face.alignment_tolerance = align_tolerance face.deceleration_radius = deceleration_radius diff --git a/project/demos/FollowPath/PathFollower.gd b/project/demos/FollowPath/PathFollower.gd index 1777ea1..c403986 100644 --- a/project/demos/FollowPath/PathFollower.gd +++ b/project/demos/FollowPath/PathFollower.gd @@ -2,17 +2,17 @@ extends KinematicBody2D var _velocity := Vector2.ZERO -var _accel := GSTTargetAcceleration.new() +var _accel := GSAITargetAcceleration.new() var _valid := false var _drag := 0.1 -onready var agent := GSTKinematicBody2DAgent.new(self) -onready var path := GSTPath.new([ +onready var agent := GSAIKinematicBody2DAgent.new(self) +onready var path := GSAIPath.new([ Vector3(global_position.x, global_position.y, 0), Vector3(global_position.x, global_position.y, 0) ], true) -onready var follow := GSTFollowPath.new(agent, path, 0, 0) +onready var follow := GSAIFollowPath.new(agent, path, 0, 0) func setup( diff --git a/project/demos/GroupBehaviors/Member.gd b/project/demos/GroupBehaviors/Member.gd index 183a681..d858fbf 100644 --- a/project/demos/GroupBehaviors/Member.gd +++ b/project/demos/GroupBehaviors/Member.gd @@ -1,12 +1,12 @@ extends KinematicBody2D -var separation: GSTSeparation -var cohesion: GSTCohesion -var proximity: GSTRadiusProximity -var agent := GSTKinematicBody2DAgent.new(self) -var blend := GSTBlend.new(agent) -var acceleration := GSTTargetAcceleration.new() +var separation: GSAISeparation +var cohesion: GSAICohesion +var proximity: GSAIRadiusProximity +var agent := GSAIKinematicBody2DAgent.new(self) +var blend := GSAIBlend.new(agent) +var acceleration := GSAITargetAcceleration.new() var draw_proximity := false var _color := Color.red @@ -30,10 +30,10 @@ func setup( agent.linear_speed_max = linear_speed_max agent.linear_drag_percentage = 0.1 - proximity = GSTRadiusProximity.new(agent, [], proximity_radius) - separation = GSTSeparation.new(agent, proximity) + proximity = GSAIRadiusProximity.new(agent, [], proximity_radius) + separation = GSAISeparation.new(agent, proximity) separation.decay_coefficient = separation_decay_coefficient - cohesion = GSTCohesion.new(agent, proximity) + cohesion = GSAICohesion.new(agent, proximity) blend.add(separation, separation_strength) blend.add(cohesion, cohesion_strength) diff --git a/project/demos/PursueSeek/Player.gd b/project/demos/PursueSeek/Player.gd index 42f1ae8..a401e1c 100644 --- a/project/demos/PursueSeek/Player.gd +++ b/project/demos/PursueSeek/Player.gd @@ -12,7 +12,7 @@ export var linear_drag := 0.025 var _linear_velocity := Vector2() var _angular_velocity := 0.0 -onready var agent := GSTSteeringAgent.new() +onready var agent := GSAISteeringAgent.new() func _physics_process(delta: float) -> void: diff --git a/project/demos/PursueSeek/Pursuer.gd b/project/demos/PursueSeek/Pursuer.gd index cfe4884..9a6a0f4 100644 --- a/project/demos/PursueSeek/Pursuer.gd +++ b/project/demos/PursueSeek/Pursuer.gd @@ -4,15 +4,15 @@ extends KinematicBody2D export var use_seek: bool = false -var _blend: GSTBlend +var _blend: GSAIBlend var _linear_drag_coefficient := 0.025 var _angular_drag := 0.1 -var _direction_face := GSTAgentLocation.new() +var _direction_face := GSAIAgentLocation.new() -onready var agent := GSTKinematicBody2DAgent.new(self) -onready var accel := GSTTargetAcceleration.new() -onready var player_agent: GSTSteeringAgent = owner.find_node("Player", true, false).agent +onready var agent := GSAIKinematicBody2DAgent.new(self) +onready var accel := GSAITargetAcceleration.new() +onready var player_agent: GSAISteeringAgent = owner.find_node("Player", true, false).agent func _ready() -> void: @@ -35,8 +35,8 @@ func _physics_process(delta: float) -> void: rotation += agent.angular_velocity * delta var linear_velocity := ( - GSTUtils.to_vector2(agent.linear_velocity) + - (GSTUtils.angle_to_vector2(rotation) * -agent.linear_acceleration_max) + GSAIUtils.to_vector2(agent.linear_velocity) + + (GSAIUtils.angle_to_vector2(rotation) * -agent.linear_acceleration_max) ) linear_velocity = linear_velocity.clamped(agent.linear_speed_max) linear_velocity = linear_velocity.linear_interpolate( @@ -45,21 +45,21 @@ func _physics_process(delta: float) -> void: ) linear_velocity = move_and_slide(linear_velocity) - agent.linear_velocity = GSTUtils.to_vector3(linear_velocity) + agent.linear_velocity = GSAIUtils.to_vector3(linear_velocity) func setup(predict_time: float, linear_speed_max: float, linear_accel_max: float) -> void: - var behavior: GSTSteeringBehavior + var behavior: GSAISteeringBehavior if use_seek: - behavior = GSTSeek.new(agent, player_agent) + behavior = GSAISeek.new(agent, player_agent) else: - behavior = GSTPursue.new(agent, player_agent, predict_time) + behavior = GSAIPursue.new(agent, player_agent, predict_time) - var orient_behavior := GSTFace.new(agent, _direction_face) + var orient_behavior := GSAIFace.new(agent, _direction_face) orient_behavior.alignment_tolerance = deg2rad(5) orient_behavior.deceleration_radius = deg2rad(5) - _blend = GSTBlend.new(agent) + _blend = GSAIBlend.new(agent) _blend.add(behavior, 1) _blend.add(orient_behavior, 1) diff --git a/project/demos/Quickstart/Agent.gd b/project/demos/Quickstart/Agent.gd index 1731c32..d9b5456 100644 --- a/project/demos/Quickstart/Agent.gd +++ b/project/demos/Quickstart/Agent.gd @@ -19,32 +19,32 @@ var linear_drag := 0.1 var angular_drag := 0.1 # Holds the linear and angular components calculated by our steering behaviors. -var acceleration := GSTTargetAcceleration.new() +var acceleration := GSAITargetAcceleration.new() onready var current_health := health_max -# GSTSteeringAgent holds our agent's position, orientation, maximum speed and acceleration. -onready var agent := GSTSteeringAgent.new() +# GSAISteeringAgent holds our agent's position, orientation, maximum speed and acceleration. +onready var agent := GSAISteeringAgent.new() onready var player: Node = get_tree().get_nodes_in_group("Player")[0] # This assumes that our player class will keep its own agent updated. -onready var player_agent: GSTSteeringAgent = player.agent +onready var player_agent: GSAISteeringAgent = player.agent # Proximities represent an area with which an agent can identify where neighbors in its relevant # group are. In our case, the group will feature the player, which will be used to avoid a # collision with them. We use a radius proximity so the player is only relevant inside 100 pixels. -onready var proximity := GSTRadiusProximity.new(agent, [player_agent], 100) +onready var proximity := GSAIRadiusProximity.new(agent, [player_agent], 100) -# GSTBlend combines behaviors together, calculating all of their acceleration together and adding +# GSAIBlend combines behaviors together, calculating all of their acceleration together and adding # them together, multiplied by a strength. We will have one for fleeing, and one for pursuing, # toggling them depending on the agent's health. Since we want the agent to rotate AND move, then # we aim to blend them together. -onready var flee_blend := GSTBlend.new(agent) -onready var pursue_blend := GSTBlend.new(agent) +onready var flee_blend := GSAIBlend.new(agent) +onready var pursue_blend := GSAIBlend.new(agent) -# GSTPriority will be the main steering behavior we use. It holds sub-behaviors and will pick the +# GSAIPriority will be the main steering behavior we use. It holds sub-behaviors and will pick the # first one that returns non-zero acceleration, ignoring any afterwards. -onready var priority := GSTPriority.new(agent) +onready var priority := GSAIPriority.new(agent) func _ready() -> void: @@ -59,20 +59,20 @@ func _ready() -> void: # ---------- Configuration for our behaviors ---------- # Pursue will happen while the agent is in good health. It produces acceleration that takes # the agent on an intercept course with the target, predicting its position in the future. - var pursue := GSTPursue.new(agent, player_agent) + var pursue := GSAIPursue.new(agent, player_agent) pursue.predict_time_max = 1.5 # Flee will happen while the agent is in bad health, so will start disabled. It produces # acceleration that takes the agent directly away from the target with no prediction. - var flee := GSTFlee.new(agent, player_agent) + var flee := GSAIFlee.new(agent, player_agent) # AvoidCollision tries to keep the agent from running into any of the neighbors found in its # proximity group. In our case, this will be the player, if they are close enough. - var avoid := GSTAvoidCollisions.new(agent, proximity) + var avoid := GSAIAvoidCollisions.new(agent, proximity) # Face turns the agent to keep looking towards its target. It will be enabled while the agent # is not fleeing due to low health. It tries to arrive 'on alignment' with 0 remaining velocity. - var face := GSTFace.new(agent, player_agent) + var face := GSAIFace.new(agent, player_agent) # We use deg2rad because the math in the toolkit assumes radians. # How close for the agent to be 'aligned', if not exact. @@ -82,7 +82,7 @@ func _ready() -> void: # LookWhereYouGo turns the agent to keep looking towards its direction of travel. It will only # be enabled while the agent is at low health. - var look := GSTLookWhereYouGo.new(agent) + var look := GSAILookWhereYouGo.new(agent) # How close for the agent to be 'aligned', if not exact look.alignment_tolerance = deg2rad(5) # When to start slowing down. diff --git a/project/demos/Quickstart/Player.gd b/project/demos/Quickstart/Player.gd index 8aed2b3..90b5aeb 100644 --- a/project/demos/Quickstart/Player.gd +++ b/project/demos/Quickstart/Player.gd @@ -11,10 +11,10 @@ var velocity := Vector2.ZERO var angular_velocity := 0.0 var direction := Vector2.RIGHT -onready var agent := GSTSteeringAgent.new() -onready var proxy_target := GSTAgentLocation.new() -onready var face := GSTFace.new(agent, proxy_target) -onready var accel := GSTTargetAcceleration.new() +onready var agent := GSAISteeringAgent.new() +onready var proxy_target := GSAIAgentLocation.new() +onready var face := GSAIFace.new(agent, proxy_target) +onready var accel := GSAITargetAcceleration.new() onready var bullets := owner.get_node("Bullets") @@ -39,7 +39,7 @@ func _physics_process(delta: float) -> void: var movement := get_movement() - direction = GSTUtils.angle_to_vector2(rotation) + direction = GSAIUtils.angle_to_vector2(rotation) velocity += direction * acceleration_max * movement velocity = velocity.clamped(speed_max) diff --git a/project/demos/SeekFlee/Player.gd b/project/demos/SeekFlee/Player.gd index 6581933..4ee19a2 100644 --- a/project/demos/SeekFlee/Player.gd +++ b/project/demos/SeekFlee/Player.gd @@ -3,11 +3,11 @@ extends KinematicBody2D var speed: float -onready var agent := GSTAgentLocation.new() +onready var agent := GSAIAgentLocation.new() func _ready() -> void: - agent.position = GSTUtils.to_vector3(global_position) + agent.position = GSAIUtils.to_vector3(global_position) func _physics_process(delta: float) -> void: @@ -16,7 +16,7 @@ func _physics_process(delta: float) -> void: return move_and_slide(movement * speed) - agent.position = GSTUtils.to_vector3(global_position) + agent.position = GSAIUtils.to_vector3(global_position) func _get_movement() -> Vector2: diff --git a/project/demos/SeekFlee/Seeker.gd b/project/demos/SeekFlee/Seeker.gd index a18d111..36f4f78 100644 --- a/project/demos/SeekFlee/Seeker.gd +++ b/project/demos/SeekFlee/Seeker.gd @@ -1,16 +1,16 @@ extends KinematicBody2D -var player_agent: GSTAgentLocation +var player_agent: GSAIAgentLocation var velocity := Vector2.ZERO var start_speed: float var start_accel: float var use_seek := true -onready var agent := GSTKinematicBody2DAgent.new(self) -onready var accel := GSTTargetAcceleration.new() -onready var seek := GSTSeek.new(agent, player_agent) -onready var flee := GSTFlee.new(agent, player_agent) +onready var agent := GSAIKinematicBody2DAgent.new(self) +onready var accel := GSAITargetAcceleration.new() +onready var seek := GSAISeek.new(agent, player_agent) +onready var flee := GSAIFlee.new(agent, player_agent) func _ready() -> void: diff --git a/project/project.godot b/project/project.godot index 9179fbd..c47e3b9 100644 --- a/project/project.godot +++ b/project/project.godot @@ -9,187 +9,187 @@ config_version=4 _global_script_classes=[ { -"base": "CenterContainer", +"base": "Control", "class": "DemoPickerUI", "language": "GDScript", "path": "res://demos/DemoPickerUI.gd" }, { "base": "Reference", -"class": "GSTAgentLocation", +"class": "GSAIAgentLocation", "language": "GDScript", -"path": "res://src/GSTAgentLocation.gd" +"path": "res://src/GSAIAgentLocation.gd" }, { -"base": "GSTSteeringBehavior", -"class": "GSTArrive", +"base": "GSAISteeringBehavior", +"class": "GSAIArrive", "language": "GDScript", -"path": "res://src/Behaviors/GSTArrive.gd" +"path": "res://src/Behaviors/GSAIArrive.gd" }, { -"base": "GSTGroupBehavior", -"class": "GSTAvoidCollisions", +"base": "GSAIGroupBehavior", +"class": "GSAIAvoidCollisions", "language": "GDScript", -"path": "res://src/Behaviors/GSTAvoidCollisions.gd" +"path": "res://src/Behaviors/GSAIAvoidCollisions.gd" }, { -"base": "GSTSteeringBehavior", -"class": "GSTBlend", +"base": "GSAISteeringBehavior", +"class": "GSAIBlend", "language": "GDScript", -"path": "res://src/Behaviors/GSTBlend.gd" +"path": "res://src/Behaviors/GSAIBlend.gd" }, { -"base": "GSTGroupBehavior", -"class": "GSTCohesion", +"base": "GSAIGroupBehavior", +"class": "GSAICohesion", "language": "GDScript", -"path": "res://src/Behaviors/GSTCohesion.gd" +"path": "res://src/Behaviors/GSAICohesion.gd" }, { -"base": "GSTPursue", -"class": "GSTEvade", +"base": "GSAIPursue", +"class": "GSAIEvade", "language": "GDScript", -"path": "res://src/Behaviors/GSTEvade.gd" +"path": "res://src/Behaviors/GSAIEvade.gd" }, { -"base": "GSTMatchOrientation", -"class": "GSTFace", +"base": "GSAIMatchOrientation", +"class": "GSAIFace", "language": "GDScript", -"path": "res://src/Behaviors/GSTFace.gd" +"path": "res://src/Behaviors/GSAIFace.gd" }, { -"base": "GSTSeek", -"class": "GSTFlee", +"base": "GSAISeek", +"class": "GSAIFlee", "language": "GDScript", -"path": "res://src/Behaviors/GSTFlee.gd" +"path": "res://src/Behaviors/GSAIFlee.gd" }, { -"base": "GSTArrive", -"class": "GSTFollowPath", +"base": "GSAIArrive", +"class": "GSAIFollowPath", "language": "GDScript", -"path": "res://src/Behaviors/GSTFollowPath.gd" +"path": "res://src/Behaviors/GSAIFollowPath.gd" }, { -"base": "GSTSteeringBehavior", -"class": "GSTGroupBehavior", +"base": "GSAISteeringBehavior", +"class": "GSAIGroupBehavior", "language": "GDScript", -"path": "res://src/GSTGroupBehavior.gd" +"path": "res://src/GSAIGroupBehavior.gd" }, { -"base": "GSTProximity", -"class": "GSTInfiniteProximity", +"base": "GSAIProximity", +"class": "GSAIInfiniteProximity", "language": "GDScript", -"path": "res://src/Proximities/GSTInfiniteProximity.gd" +"path": "res://src/Proximities/GSAIInfiniteProximity.gd" }, { -"base": "GSTSpecializedAgent", -"class": "GSTKinematicBody2DAgent", +"base": "GSAISpecializedAgent", +"class": "GSAIKinematicBody2DAgent", "language": "GDScript", -"path": "res://src/Agents/GSTKinematicBody2DAgent.gd" +"path": "res://src/Agents/GSAIKinematicBody2DAgent.gd" }, { -"base": "GSTSpecializedAgent", -"class": "GSTKinematicBodyAgent", +"base": "GSAISpecializedAgent", +"class": "GSAIKinematicBodyAgent", "language": "GDScript", -"path": "res://src/Agents/GSTKinematicBodyAgent.gd" +"path": "res://src/Agents/GSAIKinematicBodyAgent.gd" }, { -"base": "GSTMatchOrientation", -"class": "GSTLookWhereYouGo", +"base": "GSAIMatchOrientation", +"class": "GSAILookWhereYouGo", "language": "GDScript", -"path": "res://src/Behaviors/GSTLookWhereYouGo.gd" +"path": "res://src/Behaviors/GSAILookWhereYouGo.gd" }, { -"base": "GSTSteeringBehavior", -"class": "GSTMatchOrientation", +"base": "GSAISteeringBehavior", +"class": "GSAIMatchOrientation", "language": "GDScript", -"path": "res://src/Behaviors/GSTMatchOrientation.gd" +"path": "res://src/Behaviors/GSAIMatchOrientation.gd" }, { "base": "Reference", -"class": "GSTPath", +"class": "GSAIPath", "language": "GDScript", -"path": "res://src/GSTPath.gd" +"path": "res://src/GSAIPath.gd" }, { -"base": "GSTSteeringBehavior", -"class": "GSTPriority", +"base": "GSAISteeringBehavior", +"class": "GSAIPriority", "language": "GDScript", -"path": "res://src/Behaviors/GSTPriority.gd" +"path": "res://src/Behaviors/GSAIPriority.gd" }, { "base": "Reference", -"class": "GSTProximity", +"class": "GSAIProximity", "language": "GDScript", -"path": "res://src/Proximities/GSTProximity.gd" +"path": "res://src/Proximities/GSAIProximity.gd" }, { -"base": "GSTSteeringBehavior", -"class": "GSTPursue", +"base": "GSAISteeringBehavior", +"class": "GSAIPursue", "language": "GDScript", -"path": "res://src/Behaviors/GSTPursue.gd" +"path": "res://src/Behaviors/GSAIPursue.gd" }, { -"base": "GSTProximity", -"class": "GSTRadiusProximity", +"base": "GSAIProximity", +"class": "GSAIRadiusProximity", "language": "GDScript", -"path": "res://src/Proximities/GSTRadiusProximity.gd" +"path": "res://src/Proximities/GSAIRadiusProximity.gd" }, { -"base": "GSTSpecializedAgent", -"class": "GSTRigidBody2DAgent", +"base": "GSAISpecializedAgent", +"class": "GSAIRigidBody2DAgent", "language": "GDScript", -"path": "res://src/Agents/GSTRigidBody2DAgent.gd" +"path": "res://src/Agents/GSAIRigidBody2DAgent.gd" }, { -"base": "GSTSpecializedAgent", -"class": "GSTRigidBodyAgent", +"base": "GSAISpecializedAgent", +"class": "GSAIRigidBodyAgent", "language": "GDScript", -"path": "res://src/Agents/GSTRigidBodyAgent.gd" +"path": "res://src/Agents/GSAIRigidBodyAgent.gd" }, { -"base": "GSTSteeringBehavior", -"class": "GSTSeek", +"base": "GSAISteeringBehavior", +"class": "GSAISeek", "language": "GDScript", -"path": "res://src/Behaviors/GSTSeek.gd" +"path": "res://src/Behaviors/GSAISeek.gd" }, { -"base": "GSTGroupBehavior", -"class": "GSTSeparation", +"base": "GSAIGroupBehavior", +"class": "GSAISeparation", "language": "GDScript", -"path": "res://src/Behaviors/GSTSeparation.gd" +"path": "res://src/Behaviors/GSAISeparation.gd" }, { -"base": "GSTSteeringAgent", -"class": "GSTSpecializedAgent", +"base": "GSAISteeringAgent", +"class": "GSAISpecializedAgent", "language": "GDScript", -"path": "res://src/Agents/GSTSpecializedAgent.gd" +"path": "res://src/Agents/GSAISpecializedAgent.gd" }, { -"base": "GSTAgentLocation", -"class": "GSTSteeringAgent", +"base": "GSAIAgentLocation", +"class": "GSAISteeringAgent", "language": "GDScript", -"path": "res://src/GSTSteeringAgent.gd" +"path": "res://src/GSAISteeringAgent.gd" }, { "base": "Reference", -"class": "GSTSteeringBehavior", +"class": "GSAISteeringBehavior", "language": "GDScript", -"path": "res://src/GSTSteeringBehavior.gd" +"path": "res://src/GSAISteeringBehavior.gd" }, { "base": "Reference", -"class": "GSTTargetAcceleration", +"class": "GSAITargetAcceleration", "language": "GDScript", -"path": "res://src/GSTTargetAcceleration.gd" +"path": "res://src/GSAITargetAcceleration.gd" }, { "base": "Reference", -"class": "GSTUtils", +"class": "GSAIUtils", "language": "GDScript", -"path": "res://src/GSTUtils.gd" +"path": "res://src/GSAIUtils.gd" } ] _global_script_class_icons={ "DemoPickerUI": "", -"GSTAgentLocation": "", -"GSTArrive": "", -"GSTAvoidCollisions": "", -"GSTBlend": "", -"GSTCohesion": "", -"GSTEvade": "", -"GSTFace": "", -"GSTFlee": "", -"GSTFollowPath": "", -"GSTGroupBehavior": "", -"GSTInfiniteProximity": "", -"GSTKinematicBody2DAgent": "", -"GSTKinematicBodyAgent": "", -"GSTLookWhereYouGo": "", -"GSTMatchOrientation": "", -"GSTPath": "", -"GSTPriority": "", -"GSTProximity": "", -"GSTPursue": "", -"GSTRadiusProximity": "", -"GSTRigidBody2DAgent": "", -"GSTRigidBodyAgent": "", -"GSTSeek": "", -"GSTSeparation": "", -"GSTSpecializedAgent": "", -"GSTSteeringAgent": "", -"GSTSteeringBehavior": "", -"GSTTargetAcceleration": "", -"GSTUtils": "" +"GSAIAgentLocation": "", +"GSAIArrive": "", +"GSAIAvoidCollisions": "", +"GSAIBlend": "", +"GSAICohesion": "", +"GSAIEvade": "", +"GSAIFace": "", +"GSAIFlee": "", +"GSAIFollowPath": "", +"GSAIGroupBehavior": "", +"GSAIInfiniteProximity": "", +"GSAIKinematicBody2DAgent": "", +"GSAIKinematicBodyAgent": "", +"GSAILookWhereYouGo": "", +"GSAIMatchOrientation": "", +"GSAIPath": "", +"GSAIPriority": "", +"GSAIProximity": "", +"GSAIPursue": "", +"GSAIRadiusProximity": "", +"GSAIRigidBody2DAgent": "", +"GSAIRigidBodyAgent": "", +"GSAISeek": "", +"GSAISeparation": "", +"GSAISpecializedAgent": "", +"GSAISteeringAgent": "", +"GSAISteeringBehavior": "", +"GSAITargetAcceleration": "", +"GSAIUtils": "" } [application] diff --git a/project/src/Agents/GSTKinematicBody2DAgent.gd b/project/src/Agents/GSAIKinematicBody2DAgent.gd similarity index 79% rename from project/src/Agents/GSTKinematicBody2DAgent.gd rename to project/src/Agents/GSAIKinematicBody2DAgent.gd index 4e01ba9..80500fa 100644 --- a/project/src/Agents/GSTKinematicBody2DAgent.gd +++ b/project/src/Agents/GSAIKinematicBody2DAgent.gd @@ -1,7 +1,7 @@ # A specialized steering agent that updates itself every frame so the user does # not have to using a KinematicBody2D -extends GSTSpecializedAgent -class_name GSTKinematicBody2DAgent +extends GSAISpecializedAgent +class_name GSAIKinematicBody2DAgent # SLIDE uses `move_and_slide` @@ -31,7 +31,7 @@ func _init(body: KinematicBody2D, movement_type: int = MovementType.SLIDE) -> vo # Moves the agent's `body` by target `acceleration`. # tags: virtual -func _apply_steering(acceleration: GSTTargetAcceleration, delta: float) -> void: +func _apply_steering(acceleration: GSAITargetAcceleration, delta: float) -> void: _applied_steering = true match movement_type: MovementType.COLLIDE: @@ -45,34 +45,34 @@ func _apply_steering(acceleration: GSTTargetAcceleration, delta: float) -> void: func _apply_sliding_steering(accel: Vector3) -> void: - var velocity := GSTUtils.to_vector2(linear_velocity + accel).clamped(linear_speed_max) + var velocity := GSAIUtils.to_vector2(linear_velocity + accel).clamped(linear_speed_max) if apply_linear_drag: velocity = velocity.linear_interpolate(Vector2.ZERO, linear_drag_percentage) velocity = body.move_and_slide(velocity) if calculate_velocities: - linear_velocity = GSTUtils.to_vector3(velocity) + linear_velocity = GSAIUtils.to_vector3(velocity) func _apply_collide_steering(accel: Vector3, delta: float) -> void: - var velocity := GSTUtils.clampedv3(linear_velocity + accel, linear_speed_max) + var velocity := GSAIUtils.clampedv3(linear_velocity + accel, linear_speed_max) if apply_linear_drag: velocity = velocity.linear_interpolate( Vector3.ZERO, linear_drag_percentage ) - body.move_and_collide(GSTUtils.to_vector2(velocity) * delta) + body.move_and_collide(GSAIUtils.to_vector2(velocity) * delta) if calculate_velocities: linear_velocity = velocity func _apply_position_steering(accel: Vector3, delta: float) -> void: - var velocity := GSTUtils.clampedv3(linear_velocity + accel, linear_speed_max) + var velocity := GSAIUtils.clampedv3(linear_velocity + accel, linear_speed_max) if apply_linear_drag: velocity = velocity.linear_interpolate( Vector3.ZERO, linear_drag_percentage ) - body.global_position += GSTUtils.to_vector2(velocity) * delta + body.global_position += GSAIUtils.to_vector2(velocity) * delta if calculate_velocities: linear_velocity = velocity @@ -92,7 +92,7 @@ func _set_body(value: KinematicBody2D) -> void: _last_position = body.global_position _last_orientation = body.rotation - position = GSTUtils.to_vector3(_last_position) + position = GSAIUtils.to_vector3(_last_position) orientation = _last_orientation @@ -100,15 +100,15 @@ func _on_SceneTree_physics_frame() -> void: var current_position: Vector2 = body.global_position var current_orientation: float = body.rotation - position = GSTUtils.to_vector3(current_position) + position = GSAIUtils.to_vector3(current_position) orientation = current_orientation if calculate_velocities: if _applied_steering: _applied_steering = false else: - linear_velocity = GSTUtils.clampedv3( - GSTUtils.to_vector3(_last_position - current_position), + linear_velocity = GSAIUtils.clampedv3( + GSAIUtils.to_vector3(_last_position - current_position), linear_speed_max ) if apply_linear_drag: diff --git a/project/src/Agents/GSTKinematicBodyAgent.gd b/project/src/Agents/GSAIKinematicBodyAgent.gd similarity index 88% rename from project/src/Agents/GSTKinematicBodyAgent.gd rename to project/src/Agents/GSAIKinematicBodyAgent.gd index da84d23..7113174 100644 --- a/project/src/Agents/GSTKinematicBodyAgent.gd +++ b/project/src/Agents/GSAIKinematicBodyAgent.gd @@ -1,7 +1,7 @@ # A specialized steering agent that updates itself every frame so the user does # not have to using a KinematicBody -extends GSTSpecializedAgent -class_name GSTKinematicBodyAgent +extends GSAISpecializedAgent +class_name GSAIKinematicBodyAgent # SLIDE uses `move_and_slide` # COLLIDE uses `move_and_collide` @@ -30,7 +30,7 @@ func _init(body: KinematicBody, movement_type: int = MovementType.SLIDE) -> void # Moves the agent's `body` by target `acceleration`. # tags: virtual -func _apply_steering(acceleration: GSTTargetAcceleration, delta: float) -> void: +func _apply_steering(acceleration: GSAITargetAcceleration, delta: float) -> void: _applied_steering = true match movement_type: MovementType.COLLIDE: @@ -44,7 +44,7 @@ func _apply_steering(acceleration: GSTTargetAcceleration, delta: float) -> void: func _apply_sliding_steering(accel: Vector3) -> void: - var velocity := GSTUtils.clampedv3(linear_velocity + accel, linear_speed_max) + var velocity := GSAIUtils.clampedv3(linear_velocity + accel, linear_speed_max) if apply_linear_drag: velocity = velocity.linear_interpolate(Vector3.ZERO, linear_drag_percentage) velocity = body.move_and_slide(velocity) @@ -53,7 +53,7 @@ func _apply_sliding_steering(accel: Vector3) -> void: func _apply_collide_steering(accel: Vector3, delta: float) -> void: - var velocity := GSTUtils.clampedv3(linear_velocity + accel, linear_speed_max) + var velocity := GSAIUtils.clampedv3(linear_velocity + accel, linear_speed_max) if apply_linear_drag: velocity = velocity.linear_interpolate( Vector3.ZERO, @@ -65,7 +65,7 @@ func _apply_collide_steering(accel: Vector3, delta: float) -> void: func _apply_position_steering(accel: Vector3, delta: float) -> void: - var velocity := GSTUtils.clampedv3(linear_velocity + accel, linear_speed_max) + var velocity := GSAIUtils.clampedv3(linear_velocity + accel, linear_speed_max) if apply_linear_drag: velocity = velocity.linear_interpolate( Vector3.ZERO, @@ -106,7 +106,7 @@ func _on_SceneTree_physics_frame() -> void: if _applied_steering: _applied_steering = false else: - linear_velocity = GSTUtils.clampedv3( + linear_velocity = GSAIUtils.clampedv3( _last_position - current_position, linear_speed_max ) diff --git a/project/src/Agents/GSTRigidBody2DAgent.gd b/project/src/Agents/GSAIRigidBody2DAgent.gd similarity index 72% rename from project/src/Agents/GSTRigidBody2DAgent.gd rename to project/src/Agents/GSAIRigidBody2DAgent.gd index 43e2a6b..890ffb1 100644 --- a/project/src/Agents/GSTRigidBody2DAgent.gd +++ b/project/src/Agents/GSAIRigidBody2DAgent.gd @@ -1,7 +1,7 @@ # A specialized steering agent that updates itself every frame so the user does # not have to using a RigidBody2D -extends GSTSpecializedAgent -class_name GSTRigidBody2DAgent +extends GSAISpecializedAgent +class_name GSAIRigidBody2DAgent # The RigidBody2D to keep track of @@ -19,12 +19,12 @@ func _init(body: RigidBody2D) -> void: # Moves the agent's `body` by target `acceleration`. # tags: virtual -func _apply_steering(acceleration: GSTTargetAcceleration, delta: float) -> void: +func _apply_steering(acceleration: GSAITargetAcceleration, delta: float) -> void: _applied_steering = true - body.apply_central_impulse(GSTUtils.to_vector2(acceleration.linear)) + body.apply_central_impulse(GSAIUtils.to_vector2(acceleration.linear)) body.apply_torque_impulse(acceleration.angular) if calculate_velocities: - linear_velocity = GSTUtils.to_vector3(body.linear_velocity) + linear_velocity = GSAIUtils.to_vector3(body.linear_velocity) angular_velocity = body.angular_velocity @@ -34,7 +34,7 @@ func _set_body(value: RigidBody2D) -> void: _last_position = body.global_position _last_orientation = body.rotation - position = GSTUtils.to_vector3(_last_position) + position = GSAIUtils.to_vector3(_last_position) orientation = _last_orientation @@ -47,12 +47,12 @@ func _on_SceneTree_frame() -> void: var current_position: Vector2 = body.global_position var current_orientation: float = body.rotation - position = GSTUtils.to_vector3(current_position) + position = GSAIUtils.to_vector3(current_position) orientation = current_orientation if calculate_velocities: if _applied_steering: _applied_steering = false else: - linear_velocity = GSTUtils.to_vector3(body.linear_velocity) + linear_velocity = GSAIUtils.to_vector3(body.linear_velocity) angular_velocity = body.angular_velocity diff --git a/project/src/Agents/GSTRigidBodyAgent.gd b/project/src/Agents/GSAIRigidBodyAgent.gd similarity index 90% rename from project/src/Agents/GSTRigidBodyAgent.gd rename to project/src/Agents/GSAIRigidBodyAgent.gd index c3d189c..f8f8505 100644 --- a/project/src/Agents/GSTRigidBodyAgent.gd +++ b/project/src/Agents/GSAIRigidBodyAgent.gd @@ -1,7 +1,7 @@ # A specialized steering agent that updates itself every frame so the user does # not have to using a RigidBody -extends GSTSpecializedAgent -class_name GSTRigidBodyAgent +extends GSAISpecializedAgent +class_name GSAIRigidBodyAgent # The RigidBody to keep track of @@ -21,7 +21,7 @@ func _init(body: RigidBody) -> void: # Moves the agent's `body` by target `acceleration`. # tags: virtual -func _apply_steering(acceleration: GSTTargetAcceleration, delta: float) -> void: +func _apply_steering(acceleration: GSAITargetAcceleration, delta: float) -> void: _applied_steering = true body.apply_central_impulse(acceleration.linear) body.apply_torque_impulse(Vector3.UP * acceleration.angular) diff --git a/project/src/Agents/GSTSpecializedAgent.gd b/project/src/Agents/GSAISpecializedAgent.gd similarity index 90% rename from project/src/Agents/GSTSpecializedAgent.gd rename to project/src/Agents/GSAISpecializedAgent.gd index 80daa7e..f6389b9 100644 --- a/project/src/Agents/GSTSpecializedAgent.gd +++ b/project/src/Agents/GSAISpecializedAgent.gd @@ -1,8 +1,8 @@ # 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. # tags: abstract -extends GSTSteeringAgent -class_name GSTSpecializedAgent +extends GSAISteeringAgent +class_name GSAISpecializedAgent # If `true`, calculates linear and angular velocities based on the previous @@ -36,5 +36,5 @@ var _applied_steering := false # Moves the agent's body by target `acceleration`. # tags: virtual -func _apply_steering(acceleration: GSTTargetAcceleration, delta: float) -> void: +func _apply_steering(acceleration: GSAITargetAcceleration, delta: float) -> void: pass diff --git a/project/src/Behaviors/GSTArrive.gd b/project/src/Behaviors/GSAIArrive.gd similarity index 70% rename from project/src/Behaviors/GSTArrive.gd rename to project/src/Behaviors/GSAIArrive.gd index 17083be..f171068 100644 --- a/project/src/Behaviors/GSTArrive.gd +++ b/project/src/Behaviors/GSAIArrive.gd @@ -1,11 +1,11 @@ # Calculates acceleration to take an agent to its target's location. The # calculation attempts to arrive with zero remaining velocity. -class_name GSTArrive -extends GSTSteeringBehavior +class_name GSAIArrive +extends GSAISteeringBehavior # Target agent to arrive to. -var target: GSTAgentLocation +var target: GSAIAgentLocation # Distance from the target for the agent to be considered successfully # arrived. var arrival_tolerance: float @@ -15,11 +15,11 @@ var deceleration_radius: float var time_to_reach := 0.1 -func _init(agent: GSTSteeringAgent, target: GSTAgentLocation).(agent) -> void: +func _init(agent: GSAISteeringAgent, target: GSAIAgentLocation).(agent) -> void: self.target = target -func _arrive(acceleration: GSTTargetAcceleration, target_position: Vector3) -> void: +func _arrive(acceleration: GSAITargetAcceleration, target_position: Vector3) -> void: var to_target := target_position - agent.position var distance := to_target.length() @@ -35,9 +35,9 @@ func _arrive(acceleration: GSTTargetAcceleration, target_position: Vector3) -> v desired_velocity = (desired_velocity - agent.linear_velocity) * 1.0 / time_to_reach - acceleration.linear = GSTUtils.clampedv3(desired_velocity, agent.linear_acceleration_max) + acceleration.linear = GSAIUtils.clampedv3(desired_velocity, agent.linear_acceleration_max) acceleration.angular = 0 -func _calculate_steering(acceleration: GSTTargetAcceleration) -> void: +func _calculate_steering(acceleration: GSAITargetAcceleration) -> void: _arrive(acceleration, target.position) diff --git a/project/src/Behaviors/GSTAvoidCollisions.gd b/project/src/Behaviors/GSAIAvoidCollisions.gd similarity index 86% rename from project/src/Behaviors/GSTAvoidCollisions.gd rename to project/src/Behaviors/GSAIAvoidCollisions.gd index 711b744..b510c58 100644 --- a/project/src/Behaviors/GSTAvoidCollisions.gd +++ b/project/src/Behaviors/GSAIAvoidCollisions.gd @@ -1,10 +1,10 @@ # Steers the agent to avoid obstacles in its path. Approximates obstacles as # spheres. -class_name GSTAvoidCollisions -extends GSTGroupBehavior +class_name GSAIAvoidCollisions +extends GSAIGroupBehavior -var _first_neighbor: GSTSteeringAgent +var _first_neighbor: GSAISteeringAgent var _shortest_time: float var _first_minimum_separation: float var _first_distance: float @@ -12,11 +12,11 @@ var _first_relative_position: Vector3 var _first_relative_velocity: Vector3 -func _init(agent: GSTSteeringAgent, proximity: GSTProximity).(agent, proximity) -> void: +func _init(agent: GSAISteeringAgent, proximity: GSAIProximity).(agent, proximity) -> void: pass -func _calculate_steering(acceleration: GSTTargetAcceleration) -> void: +func _calculate_steering(acceleration: GSAITargetAcceleration) -> void: _shortest_time = INF _first_neighbor = null _first_minimum_separation = 0 @@ -41,7 +41,7 @@ func _calculate_steering(acceleration: GSTTargetAcceleration) -> void: # 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. # tags: virtual -func _report_neighbor(neighbor: GSTSteeringAgent) -> bool: +func _report_neighbor(neighbor: GSAISteeringAgent) -> bool: var relative_position := neighbor.position - agent.position var relative_velocity := neighbor.linear_velocity - agent.linear_velocity var relative_speed_squared := relative_velocity.length_squared() diff --git a/project/src/Behaviors/GSTBlend.gd b/project/src/Behaviors/GSAIBlend.gd similarity index 70% rename from project/src/Behaviors/GSTBlend.gd rename to project/src/Behaviors/GSAIBlend.gd index db20eab..f8bf00f 100644 --- a/project/src/Behaviors/GSTBlend.gd +++ b/project/src/Behaviors/GSAIBlend.gd @@ -3,23 +3,23 @@ # # Stores the behaviors internally as dictionaries of the form # { -# behavior : GSTSteeringBehavior, +# behavior : GSAISteeringBehavior, # weight : float # } -class_name GSTBlend -extends GSTSteeringBehavior +class_name GSAIBlend +extends GSAISteeringBehavior var _behaviors := [] -var _accel := GSTTargetAcceleration.new() +var _accel := GSAITargetAcceleration.new() -func _init(agent: GSTSteeringAgent).(agent) -> void: +func _init(agent: GSAISteeringAgent).(agent) -> void: pass # Appends a behavior to the internal array along with its `weight`. -func add(behavior: GSTSteeringBehavior, weight: float) -> void: +func add(behavior: GSAISteeringBehavior, weight: float) -> void: behavior.agent = agent _behaviors.append({behavior = behavior, weight = weight}) @@ -33,7 +33,7 @@ func get_behavior_at(index: int) -> Dictionary: return {} -func _calculate_steering(blended_accel: GSTTargetAcceleration) -> void: +func _calculate_steering(blended_accel: GSAITargetAcceleration) -> void: blended_accel.set_zero() for i in range(_behaviors.size()): @@ -42,7 +42,7 @@ func _calculate_steering(blended_accel: GSTTargetAcceleration) -> void: blended_accel.add_scaled_accel(_accel, bw.weight) - blended_accel.linear = GSTUtils.clampedv3(blended_accel.linear, agent.linear_acceleration_max) + blended_accel.linear = GSAIUtils.clampedv3(blended_accel.linear, agent.linear_acceleration_max) blended_accel.angular = clamp( blended_accel.angular, -agent.angular_acceleration_max, diff --git a/project/src/Behaviors/GSTCohesion.gd b/project/src/Behaviors/GSAICohesion.gd similarity index 63% rename from project/src/Behaviors/GSTCohesion.gd rename to project/src/Behaviors/GSAICohesion.gd index eb2c816..6117e03 100644 --- a/project/src/Behaviors/GSTCohesion.gd +++ b/project/src/Behaviors/GSAICohesion.gd @@ -1,17 +1,17 @@ # Calculates an acceleration that attempts to move the agent towards the center -# of mass of the agents in the area defined by the `GSTProximity`. -class_name GSTCohesion -extends GSTGroupBehavior +# of mass of the agents in the area defined by the `GSAIProximity`. +class_name GSAICohesion +extends GSAIGroupBehavior var _center_of_mass: Vector3 -func _init(agent: GSTSteeringAgent, proximity: GSTProximity).(agent, proximity) -> void: +func _init(agent: GSAISteeringAgent, proximity: GSAIProximity).(agent, proximity) -> void: pass -func _calculate_steering(acceleration: GSTTargetAcceleration) -> void: +func _calculate_steering(acceleration: GSAITargetAcceleration) -> void: acceleration.set_zero() _center_of_mass = Vector3.ZERO var neighbor_count = proximity._find_neighbors(_callback) @@ -23,6 +23,6 @@ func _calculate_steering(acceleration: GSTTargetAcceleration) -> void: # Callback for the proximity to call when finding neighbors. Adds `neighbor`'s position # to the center of mass of the group. # tags: virtual -func _report_neighbor(neighbor: GSTSteeringAgent) -> bool: +func _report_neighbor(neighbor: GSAISteeringAgent) -> bool: _center_of_mass += neighbor.position return true diff --git a/project/src/Behaviors/GSTEvade.gd b/project/src/Behaviors/GSAIEvade.gd similarity index 72% rename from project/src/Behaviors/GSTEvade.gd rename to project/src/Behaviors/GSAIEvade.gd index 7b0e12f..c722e3e 100644 --- a/project/src/Behaviors/GSTEvade.gd +++ b/project/src/Behaviors/GSAIEvade.gd @@ -1,12 +1,12 @@ # Calculates acceleration to take an agent away from where a target agent is # moving. -class_name GSTEvade -extends GSTPursue +class_name GSAIEvade +extends GSAIPursue func _init( - agent: GSTSteeringAgent, - target: GSTSteeringAgent, + agent: GSAISteeringAgent, + target: GSAISteeringAgent, predict_time_max := 1.0).(agent, target, predict_time_max): pass diff --git a/project/src/Behaviors/GSTFace.gd b/project/src/Behaviors/GSAIFace.gd similarity index 56% rename from project/src/Behaviors/GSTFace.gd rename to project/src/Behaviors/GSAIFace.gd index 8a97e0b..62ba90e 100644 --- a/project/src/Behaviors/GSTFace.gd +++ b/project/src/Behaviors/GSAIFace.gd @@ -1,23 +1,23 @@ # Calculates angular acceleration to rotate a target to face its target's # position. The behavior attemps to arrive with zero remaining angular velocity. -class_name GSTFace -extends GSTMatchOrientation +class_name GSAIFace +extends GSAIMatchOrientation -func _init(agent: GSTSteeringAgent, target: GSTAgentLocation).(agent, target) -> void: +func _init(agent: GSAISteeringAgent, target: GSAIAgentLocation).(agent, target) -> void: pass -func _face(acceleration: GSTTargetAcceleration, target_position: Vector3) -> void: +func _face(acceleration: GSAITargetAcceleration, target_position: Vector3) -> void: var to_target := target_position - agent.position var distance_squared := to_target.length_squared() if distance_squared < agent.zero_linear_speed_threshold: acceleration.set_zero() else: - var orientation = GSTUtils.vector3_to_angle(to_target) + var orientation = GSAIUtils.vector3_to_angle(to_target) _match_orientation(acceleration, orientation) -func _calculate_steering(acceleration: GSTTargetAcceleration) -> void: +func _calculate_steering(acceleration: GSAITargetAcceleration) -> void: _face(acceleration, target.position) diff --git a/project/src/Behaviors/GSTFlee.gd b/project/src/Behaviors/GSAIFlee.gd similarity index 52% rename from project/src/Behaviors/GSTFlee.gd rename to project/src/Behaviors/GSAIFlee.gd index 86c071b..51fc3e9 100644 --- a/project/src/Behaviors/GSTFlee.gd +++ b/project/src/Behaviors/GSAIFlee.gd @@ -1,13 +1,13 @@ # Calculates acceleration to take an agent directly away from a target agent. -class_name GSTFlee -extends GSTSeek +class_name GSAIFlee +extends GSAISeek -func _init(agent: GSTSteeringAgent, target: GSTAgentLocation).(agent, target) -> void: +func _init(agent: GSAISteeringAgent, target: GSAIAgentLocation).(agent, target) -> void: pass -func _calculate_steering(acceleration: GSTTargetAcceleration) -> void: +func _calculate_steering(acceleration: GSAITargetAcceleration) -> void: acceleration.linear = ( (agent.position - target.position).normalized() * agent.linear_acceleration_max) acceleration.angular = 0 diff --git a/project/src/Behaviors/GSTFollowPath.gd b/project/src/Behaviors/GSAIFollowPath.gd similarity index 86% rename from project/src/Behaviors/GSTFollowPath.gd rename to project/src/Behaviors/GSAIFollowPath.gd index c269831..21206e0 100644 --- a/project/src/Behaviors/GSTFollowPath.gd +++ b/project/src/Behaviors/GSAIFollowPath.gd @@ -1,14 +1,14 @@ # Produces a linear acceleration that moves the agent along the specified path. -class_name GSTFollowPath -extends GSTArrive +class_name GSAIFollowPath +extends GSAIArrive # The path to follow and travel along. -var path: GSTPath +var path: GSAIPath # The distance along the path to generate the next target position. var path_offset := 0.0 -# Whether to use `GSTArrive` behavior on an open path. +# Whether to use `GSAIArrive` behavior on an open path. var is_arrive_enabled := true # The amount of time in the future to predict the owning agent's position along # the path. Setting it to 0.0 will force non-predictive path following. @@ -16,8 +16,8 @@ var prediction_time := 0.0 func _init( - agent: GSTSteeringAgent, - path: GSTPath, + agent: GSAISteeringAgent, + path: GSAIPath, path_offset := 0.0, prediction_time := 0.0).(agent, null) -> void: self.path = path @@ -25,7 +25,7 @@ func _init( self.prediction_time = prediction_time -func _calculate_steering(acceleration: GSTTargetAcceleration) -> void: +func _calculate_steering(acceleration: GSAITargetAcceleration) -> void: var location := ( agent.position if prediction_time == 0 else agent.position + (agent.linear_velocity * prediction_time)) diff --git a/project/src/Behaviors/GSTLookWhereYouGo.gd b/project/src/Behaviors/GSAILookWhereYouGo.gd similarity index 50% rename from project/src/Behaviors/GSTLookWhereYouGo.gd rename to project/src/Behaviors/GSAILookWhereYouGo.gd index 9e254f3..42800f3 100644 --- a/project/src/Behaviors/GSTLookWhereYouGo.gd +++ b/project/src/Behaviors/GSAILookWhereYouGo.gd @@ -1,16 +1,16 @@ # Calculates an angular acceleration to match an agent's orientation to its # direction of travel. -class_name GSTLookWhereYouGo -extends GSTMatchOrientation +class_name GSAILookWhereYouGo +extends GSAIMatchOrientation -func _init(agent: GSTSteeringAgent).(agent, null) -> void: +func _init(agent: GSAISteeringAgent).(agent, null) -> void: pass -func _calculate_steering(accel: GSTTargetAcceleration) -> void: +func _calculate_steering(accel: GSAITargetAcceleration) -> void: if agent.linear_velocity.length_squared() < agent.zero_linear_speed_threshold: accel.set_zero() else: - var orientation := GSTUtils.vector3_to_angle(agent.linear_velocity) + var orientation := GSAIUtils.vector3_to_angle(agent.linear_velocity) _match_orientation(accel, orientation) diff --git a/project/src/Behaviors/GSTMatchOrientation.gd b/project/src/Behaviors/GSAIMatchOrientation.gd similarity index 80% rename from project/src/Behaviors/GSTMatchOrientation.gd rename to project/src/Behaviors/GSAIMatchOrientation.gd index a682d70..0a151f8 100644 --- a/project/src/Behaviors/GSTMatchOrientation.gd +++ b/project/src/Behaviors/GSAIMatchOrientation.gd @@ -1,12 +1,12 @@ # 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. -class_name GSTMatchOrientation -extends GSTSteeringBehavior +class_name GSAIMatchOrientation +extends GSAISteeringBehavior # The target orientation for the behavior to try and match rotations to. -var target: GSTAgentLocation +var target: GSAIAgentLocation # The amount of distance in radians for the behavior to consider itself close # enough to be matching the target agent's rotation. var alignment_tolerance: float @@ -16,11 +16,11 @@ var deceleration_radius: float var time_to_reach: float = 0.1 -func _init(agent: GSTSteeringAgent, target: GSTAgentLocation).(agent) -> void: +func _init(agent: GSAISteeringAgent, target: GSAIAgentLocation).(agent) -> void: self.target = target -func _match_orientation(acceleration: GSTTargetAcceleration, desired_orientation: float) -> void: +func _match_orientation(acceleration: GSAITargetAcceleration, desired_orientation: float) -> void: var rotation := wrapf(desired_orientation - agent.orientation, -PI, PI) var rotation_size := abs(rotation) @@ -44,5 +44,5 @@ func _match_orientation(acceleration: GSTTargetAcceleration, desired_orientation acceleration.linear = Vector3.ZERO -func _calculate_steering(acceleration: GSTTargetAcceleration) -> void: +func _calculate_steering(acceleration: GSAITargetAcceleration) -> void: _match_orientation(acceleration, target.orientation) diff --git a/project/src/Behaviors/GSTPriority.gd b/project/src/Behaviors/GSAIPriority.gd similarity index 75% rename from project/src/Behaviors/GSTPriority.gd rename to project/src/Behaviors/GSAIPriority.gd index f352461..144f6ce 100644 --- a/project/src/Behaviors/GSTPriority.gd +++ b/project/src/Behaviors/GSAIPriority.gd @@ -1,7 +1,7 @@ # Container for multiple behaviors that returns the result of the first child # behavior with non-zero acceleration. -class_name GSTPriority -extends GSTSteeringBehavior +class_name GSAIPriority +extends GSAISteeringBehavior var _behaviors := [] @@ -13,25 +13,25 @@ var last_selected_index: int var zero_threshold: float -func _init(agent: GSTSteeringAgent, zero_threshold := 0.001).(agent) -> void: +func _init(agent: GSAISteeringAgent, zero_threshold := 0.001).(agent) -> void: self.zero_threshold = zero_threshold # Appends a steering behavior as a child of this container. -func add(behavior: GSTSteeringBehavior) -> void: +func add(behavior: GSAISteeringBehavior) -> void: _behaviors.append(behavior) # Returns the behavior at the position in the pool referred to by `index`, or # `null` if no behavior was found. -func get_behavior_at(index: int) -> GSTSteeringBehavior: +func get_behavior_at(index: int) -> GSAISteeringBehavior: if _behaviors.size() > index: return _behaviors[index] printerr("Tried to get index " + str(index) + " in array of size " + str(_behaviors.size())) return null -func _calculate_steering(accel: GSTTargetAcceleration) -> void: +func _calculate_steering(accel: GSAITargetAcceleration) -> void: var threshold_squared := zero_threshold * zero_threshold last_selected_index = -1 @@ -41,7 +41,7 @@ func _calculate_steering(accel: GSTTargetAcceleration) -> void: if size > 0: for i in range(size): last_selected_index = i - var behavior: GSTSteeringBehavior = _behaviors[i] + var behavior: GSAISteeringBehavior = _behaviors[i] behavior.calculate_steering(accel) if accel.get_magnitude_squared() > threshold_squared: diff --git a/project/src/Behaviors/GSTPursue.gd b/project/src/Behaviors/GSAIPursue.gd similarity index 84% rename from project/src/Behaviors/GSTPursue.gd rename to project/src/Behaviors/GSAIPursue.gd index 301bdd7..2018b14 100644 --- a/project/src/Behaviors/GSTPursue.gd +++ b/project/src/Behaviors/GSAIPursue.gd @@ -1,25 +1,25 @@ # Calculates an acceleration to make an agent intercept another based on the # target agent's movement. -class_name GSTPursue -extends GSTSteeringBehavior +class_name GSAIPursue +extends GSAISteeringBehavior # The target agent that the behavior is trying to intercept. -var target: GSTSteeringAgent +var target: GSAISteeringAgent # The maximum amount of time in the future the behavior predicts the target's # location. var predict_time_max: float func _init( - agent: GSTSteeringAgent, - target: GSTSteeringAgent, + agent: GSAISteeringAgent, + target: GSAISteeringAgent, predict_time_max := 1.0).(agent) -> void: self.target = target self.predict_time_max = predict_time_max -func _calculate_steering(acceleration: GSTTargetAcceleration) -> void: +func _calculate_steering(acceleration: GSAITargetAcceleration) -> void: var target_position := target.position var distance_squared := (target_position - agent.position).length_squared() diff --git a/project/src/Behaviors/GSTSeek.gd b/project/src/Behaviors/GSAISeek.gd similarity index 57% rename from project/src/Behaviors/GSTSeek.gd rename to project/src/Behaviors/GSAISeek.gd index 61229e4..e958d9e 100644 --- a/project/src/Behaviors/GSTSeek.gd +++ b/project/src/Behaviors/GSAISeek.gd @@ -1,18 +1,18 @@ # Calculates an acceleration to take an agent to a target agent's position # directly. -class_name GSTSeek -extends GSTSteeringBehavior +class_name GSAISeek +extends GSAISteeringBehavior # The target that the behavior aims to move the agent to. -var target: GSTAgentLocation +var target: GSAIAgentLocation -func _init(agent: GSTSteeringAgent, target: GSTAgentLocation).(agent) -> void: +func _init(agent: GSAISteeringAgent, target: GSAIAgentLocation).(agent) -> void: self.target = target -func _calculate_steering(acceleration: GSTTargetAcceleration) -> void: +func _calculate_steering(acceleration: GSAITargetAcceleration) -> void: acceleration.linear = ( (target.position - agent.position).normalized() * agent.linear_acceleration_max) acceleration.angular = 0 diff --git a/project/src/Behaviors/GSTSeparation.gd b/project/src/Behaviors/GSAISeparation.gd similarity index 74% rename from project/src/Behaviors/GSTSeparation.gd rename to project/src/Behaviors/GSAISeparation.gd index 87bec2a..a919a6e 100644 --- a/project/src/Behaviors/GSTSeparation.gd +++ b/project/src/Behaviors/GSAISeparation.gd @@ -1,24 +1,24 @@ # Calculates an acceleration that repels the agent from its neighbors in the -# given `GSTProximity`. +# given `GSAIProximity`. # # The acceleration is an average based on all neighbors, multiplied by a # strength decreasing by the inverse square law in relation to distance, and it # accumulates. -class_name GSTSeparation -extends GSTGroupBehavior +class_name GSAISeparation +extends GSAIGroupBehavior # The coefficient to calculate how fast the separation strength decays with distance. var decay_coefficient := 1.0 -var _acceleration: GSTTargetAcceleration +var _acceleration: GSAITargetAcceleration -func _init(agent: GSTSteeringAgent, proximity: GSTProximity).(agent, proximity) -> void: +func _init(agent: GSAISteeringAgent, proximity: GSAIProximity).(agent, proximity) -> void: pass -func _calculate_steering(acceleration: GSTTargetAcceleration) -> void: +func _calculate_steering(acceleration: GSAITargetAcceleration) -> void: acceleration.set_zero() self._acceleration = acceleration proximity._find_neighbors(_callback) @@ -27,7 +27,7 @@ func _calculate_steering(acceleration: GSTTargetAcceleration) -> void: # 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. # tags: virtual -func _report_neighbor(neighbor: GSTSteeringAgent) -> bool: +func _report_neighbor(neighbor: GSAISteeringAgent) -> bool: var to_agent := agent.position - neighbor.position var distance_squared := to_agent.length_squared() diff --git a/project/src/GSTAgentLocation.gd b/project/src/GSAIAgentLocation.gd similarity index 87% rename from project/src/GSTAgentLocation.gd rename to project/src/GSAIAgentLocation.gd index fba8a8d..aac7408 100644 --- a/project/src/GSTAgentLocation.gd +++ b/project/src/GSAIAgentLocation.gd @@ -1,5 +1,5 @@ # Represents an agent with only a location and an orientation. -class_name GSTAgentLocation +class_name GSAIAgentLocation # The agent's position in space. diff --git a/project/src/GSTGroupBehavior.gd b/project/src/GSAIGroupBehavior.gd similarity index 58% rename from project/src/GSTGroupBehavior.gd rename to project/src/GSAIGroupBehavior.gd index 404be8d..d45a4f6 100644 --- a/project/src/GSTGroupBehavior.gd +++ b/project/src/GSAIGroupBehavior.gd @@ -1,20 +1,20 @@ # Base type for group-based steering behaviors. -class_name GSTGroupBehavior -extends GSTSteeringBehavior +class_name GSAIGroupBehavior +extends GSAISteeringBehavior # Container to find neighbors of the agent and calculate group behavior. -var proximity: GSTProximity +var proximity: GSAIProximity var _callback := funcref(self, "_report_neighbor") -func _init(agent: GSTSteeringAgent, proximity: GSTProximity).(agent) -> void: +func _init(agent: GSAISteeringAgent, proximity: GSAIProximity).(agent) -> void: self.proximity = proximity # Internal callback for the behavior to define whether or not a member is # relevant # tags: virtual -func _report_neighbor(neighbor: GSTSteeringAgent) -> bool: +func _report_neighbor(neighbor: GSAISteeringAgent) -> bool: return false diff --git a/project/src/GSTPath.gd b/project/src/GSAIPath.gd similarity index 93% rename from project/src/GSTPath.gd rename to project/src/GSAIPath.gd index 62b0ac8..d29c159 100644 --- a/project/src/GSTPath.gd +++ b/project/src/GSAIPath.gd @@ -1,6 +1,6 @@ # Represents a path made up of Vector3 waypoints, split into segments path # follow behaviors can use. -class_name GSTPath +class_name GSAIPath extends Reference @@ -41,7 +41,7 @@ func create_path(waypoints: Array) -> void: break else: current = waypoints[0] - var segment := GSTSegment.new(previous, current) + var segment := GSAISegment.new(previous, current) length += segment.length segment.cumulative_length = length _segments.append(segment) @@ -52,9 +52,9 @@ func calculate_distance(agent_current_position: Vector3) -> float: if _segments.size() == 0: return 0.0 var smallest_distance_squared: float = INF - var nearest_segment: GSTSegment + var nearest_segment: GSAISegment for i in range(_segments.size()): - var segment: GSTSegment = _segments[i] + var segment: GSAISegment = _segments[i] var distance_squared := _calculate_point_segment_distance_squared( segment.begin, segment.end, @@ -83,9 +83,9 @@ func calculate_target_position(target_distance: float) -> Vector3: elif target_distance > length: target_distance = fmod(target_distance, length) - var desired_segment: GSTSegment + var desired_segment: GSAISegment for i in range(_segments.size()): - var segment: GSTSegment = _segments[i] + var segment: GSAISegment = _segments[i] if segment.cumulative_length >= target_distance: desired_segment = segment break @@ -121,7 +121,7 @@ func _calculate_point_segment_distance_squared(start: Vector3, end: Vector3, pos return _nearest_point_on_segment.distance_squared_to(position) -class GSTSegment: +class GSAISegment: var begin: Vector3 var end: Vector3 var length: float diff --git a/project/src/GSTSteeringAgent.gd b/project/src/GSAISteeringAgent.gd similarity index 89% rename from project/src/GSTSteeringAgent.gd rename to project/src/GSAISteeringAgent.gd index 7302f5f..74c150f 100644 --- a/project/src/GSTSteeringAgent.gd +++ b/project/src/GSAISteeringAgent.gd @@ -1,9 +1,9 @@ -# Adds velocity, speed, and size data to `GSTAgentLocation`. +# Adds velocity, speed, and size data to `GSAIAgentLocation`. # # 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 +extends GSAIAgentLocation +class_name GSAISteeringAgent # The amount of velocity to be considered effectively not moving. diff --git a/project/src/GSTSteeringBehavior.gd b/project/src/GSAISteeringBehavior.gd similarity index 73% rename from project/src/GSTSteeringBehavior.gd rename to project/src/GSAISteeringBehavior.gd index b503d15..5920f00 100644 --- a/project/src/GSTSteeringBehavior.gd +++ b/project/src/GSAISteeringBehavior.gd @@ -5,26 +5,26 @@ # # The `calculate_steering` function is the entry point for all behaviors. # Individual steering behaviors encapsulate the steering logic. -class_name GSTSteeringBehavior +class_name GSAISteeringBehavior # 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 +var agent: GSAISteeringAgent -func _init(agent: GSTSteeringAgent) -> void: +func _init(agent: GSAISteeringAgent) -> void: self.agent = agent # Sets the `acceleration` with the behavior's desired amount of acceleration. -func calculate_steering(acceleration: GSTTargetAcceleration) -> void: +func calculate_steering(acceleration: GSAITargetAcceleration) -> void: if is_enabled: _calculate_steering(acceleration) else: acceleration.set_zero() -func _calculate_steering(acceleration: GSTTargetAcceleration) -> void: +func _calculate_steering(acceleration: GSAITargetAcceleration) -> void: acceleration.set_zero() diff --git a/project/src/GSTTargetAcceleration.gd b/project/src/GSAITargetAcceleration.gd similarity index 87% rename from project/src/GSTTargetAcceleration.gd rename to project/src/GSAITargetAcceleration.gd index b03c11f..9a6563e 100644 --- a/project/src/GSTTargetAcceleration.gd +++ b/project/src/GSAITargetAcceleration.gd @@ -1,6 +1,6 @@ # A desired linear and angular amount of acceleration requested by the steering # system. -class_name GSTTargetAcceleration +class_name GSAITargetAcceleration # Linear acceleration @@ -18,7 +18,7 @@ func set_zero() -> void: # Adds `accel`'s components, multiplied by `scalar`, to this one. -func add_scaled_accel(accel: GSTTargetAcceleration, scalar: float) -> void: +func add_scaled_accel(accel: GSAITargetAcceleration, scalar: float) -> void: linear += accel.linear * scalar angular += accel.angular * scalar diff --git a/project/src/GSTUtils.gd b/project/src/GSAIUtils.gd similarity index 98% rename from project/src/GSTUtils.gd rename to project/src/GSAIUtils.gd index bbe5e34..c299351 100644 --- a/project/src/GSTUtils.gd +++ b/project/src/GSAIUtils.gd @@ -1,5 +1,5 @@ # Math and vector utility functions. -class_name GSTUtils +class_name GSAIUtils # Returns the `vector` with its length capped to `limit`. diff --git a/project/src/Proximities/GSTInfiniteProximity.gd b/project/src/Proximities/GSAIInfiniteProximity.gd similarity index 76% rename from project/src/Proximities/GSTInfiniteProximity.gd rename to project/src/Proximities/GSAIInfiniteProximity.gd index 4453250..5c93bf2 100644 --- a/project/src/Proximities/GSTInfiniteProximity.gd +++ b/project/src/Proximities/GSAIInfiniteProximity.gd @@ -1,10 +1,10 @@ # Determines any agent that is in the specified list as being neighbors with the # owner agent, regardless of distance. -extends GSTProximity -class_name GSTInfiniteProximity +extends GSAIProximity +class_name GSAIInfiniteProximity -func _init(agent: GSTSteeringAgent, agents: Array).(agent, agents) -> void: +func _init(agent: GSAISteeringAgent, agents: Array).(agent, agents) -> void: pass @@ -17,7 +17,7 @@ func _find_neighbors(callback: FuncRef) -> int: var neighbor_count := 0 var agent_count := agents.size() for i in range(agent_count): - var current_agent := agents[i] as GSTSteeringAgent + var current_agent := agents[i] as GSAISteeringAgent if current_agent != agent: if callback.call_func(current_agent): diff --git a/project/src/Proximities/GSTProximity.gd b/project/src/Proximities/GSAIProximity.gd similarity index 83% rename from project/src/Proximities/GSTProximity.gd rename to project/src/Proximities/GSAIProximity.gd index 9125537..f7ccfae 100644 --- a/project/src/Proximities/GSTProximity.gd +++ b/project/src/Proximities/GSAIProximity.gd @@ -1,15 +1,15 @@ # Base container type that stores data to find the neighbors of an agent. extends Reference -class_name GSTProximity +class_name GSAIProximity # The owning agent whose neighbors are found in the group -var agent: GSTSteeringAgent +var agent: GSAISteeringAgent # The agents who are part of this group and could be potential neighbors var agents := [] -func _init(agent: GSTSteeringAgent, agents: Array) -> void: +func _init(agent: GSAISteeringAgent, agents: Array) -> void: self.agent = agent self.agents = agents diff --git a/project/src/Proximities/GSTRadiusProximity.gd b/project/src/Proximities/GSAIRadiusProximity.gd similarity index 85% rename from project/src/Proximities/GSTRadiusProximity.gd rename to project/src/Proximities/GSAIRadiusProximity.gd index 5e457f5..348e205 100644 --- a/project/src/Proximities/GSTRadiusProximity.gd +++ b/project/src/Proximities/GSAIRadiusProximity.gd @@ -1,7 +1,7 @@ # 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 +extends GSAIProximity +class_name GSAIRadiusProximity # The radius around the owning agent to find neighbors in @@ -11,7 +11,7 @@ var _last_frame := 0 var _scene_tree: SceneTree -func _init(agent: GSTSteeringAgent, agents: Array, radius: float).(agent, agents) -> void: +func _init(agent: GSAISteeringAgent, agents: Array, radius: float).(agent, agents) -> void: self.radius = radius _scene_tree = Engine.get_main_loop() @@ -32,7 +32,7 @@ func _find_neighbors(callback: FuncRef) -> int: var owner_position := agent.position for i in range(agent_count): - var current_agent := agents[i] as GSTSteeringAgent + var current_agent := agents[i] as GSAISteeringAgent if current_agent != agent: var distance_squared := owner_position.distance_squared_to(current_agent.position) @@ -48,7 +48,7 @@ func _find_neighbors(callback: FuncRef) -> int: current_agent.is_tagged = false else: for i in range(agent_count): - var current_agent = agents[i] as GSTSteeringAgent + var current_agent = agents[i] as GSAISteeringAgent if current_agent != agent and current_agent.is_tagged: if callback.call_func(current_agent):