mirror of
https://github.com/Relintai/godot-steering-ai-framework.git
synced 2024-11-14 04:57:19 +01:00
Handle all warnings in GSAI* classes and demos
This commit is contained in:
parent
04468a7d60
commit
36f2dcb522
@ -17,6 +17,10 @@ We decided to make this change as soon as possible, as the framework was release
|
||||
- There is now a main scene with a demo picker, so you can select and play any demo on the fly.
|
||||
- The demo projects now support resizing and toggling fullscreen with <kbd>F11</kbd>.
|
||||
|
||||
### Improvements ###
|
||||
|
||||
- We handled all warnings in the framework, so using it won't add warnings to your projects.
|
||||
|
||||
### Changes ###
|
||||
|
||||
- Renamed all classes from `GST*` (Godot Steering Toolkit) to `GSAI*` (Godot Steering AI).
|
||||
|
@ -40,7 +40,7 @@ func setup(
|
||||
proximity_radius: float,
|
||||
boundary_right: float,
|
||||
boundary_bottom: float,
|
||||
draw_proximity: bool,
|
||||
_draw_proximity: bool,
|
||||
rng: RandomNumberGenerator
|
||||
) -> void:
|
||||
rng.randomize()
|
||||
@ -58,7 +58,7 @@ func setup(
|
||||
|
||||
agent.linear_drag_percentage = _drag
|
||||
|
||||
self.draw_proximity = draw_proximity
|
||||
self.draw_proximity = _draw_proximity
|
||||
|
||||
priority.add(avoid)
|
||||
priority.add(seek)
|
||||
|
@ -12,8 +12,11 @@ onready var button: Button = $VBoxContainer/Button
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
# warning-ignore:return_value_discarded
|
||||
list.connect("demo_selected", self, "set_demo_path")
|
||||
# warning-ignore:return_value_discarded
|
||||
list.connect("item_activated", self, "emit_signal", ["demo_requested"])
|
||||
# warning-ignore:return_value_discarded
|
||||
button.connect("pressed", self, "emit_signal", ["demo_requested"])
|
||||
demo_path = list.file_paths[0]
|
||||
|
||||
|
@ -18,6 +18,9 @@ anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
theme = ExtResource( 2 )
|
||||
script = ExtResource( 4 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="DemoPickerUI"]
|
||||
anchor_right = 1.0
|
||||
|
@ -7,7 +7,9 @@ onready var button_go_back: Button = $ButtonGoBack
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
# warning-ignore:return_value_discarded
|
||||
demo_picker.connect("demo_requested", self, "_on_DemoPickerUI_demo_requested")
|
||||
# warning-ignore:return_value_discarded
|
||||
button_go_back.connect("pressed", self, "_on_ButtonGoBack_pressed")
|
||||
|
||||
|
||||
|
@ -8,7 +8,6 @@ export(int, 0, 359, 2) var deceleration_radius := 45 setget set_deceleration_rad
|
||||
export(float, 0, 1000, 40) var player_speed := 600.0 setget set_player_speed
|
||||
|
||||
onready var player := $Player
|
||||
onready var gui := $GUI
|
||||
onready var turret := $Turret
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@ var speed: float
|
||||
onready var agent := GSAIAgentLocation.new()
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
func _physics_process(_delta: float) -> void:
|
||||
var movement := _get_movement()
|
||||
move_and_slide(movement * speed)
|
||||
agent.position = Vector3(global_position.x, global_position.y, 0)
|
||||
|
@ -7,6 +7,7 @@ var file_paths := PoolStringArray()
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
# warning-ignore:return_value_discarded
|
||||
self.connect("item_selected", self, "_on_item_selected")
|
||||
|
||||
var this_directory: String = get_tree().current_scene.filename.rsplit("/", false, 1)[0]
|
||||
|
@ -12,6 +12,6 @@ func _ready() -> void:
|
||||
)
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
func _physics_process(_delta: float) -> void:
|
||||
for ship in get_children():
|
||||
ship.position = ship.position.posmodv(_world_bounds)
|
||||
|
@ -44,15 +44,15 @@ func _physics_process(delta: float) -> void:
|
||||
func _calculate_angular_velocity(
|
||||
horizontal_movement: float,
|
||||
current_velocity: float,
|
||||
thruster_strength: float,
|
||||
velocity_max: float,
|
||||
_thruster_strength: float,
|
||||
_velocity_max: float,
|
||||
ship_drag: float,
|
||||
delta: float
|
||||
) -> float:
|
||||
var velocity := clamp(
|
||||
current_velocity + thruster_strength * horizontal_movement * delta,
|
||||
-velocity_max,
|
||||
velocity_max
|
||||
current_velocity + _thruster_strength * horizontal_movement * delta,
|
||||
-_velocity_max,
|
||||
_velocity_max
|
||||
)
|
||||
|
||||
velocity = lerp(velocity, 0, ship_drag)
|
||||
|
@ -10,11 +10,12 @@ func _ready() -> void:
|
||||
agent.position = GSAIUtils.to_vector3(global_position)
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
func _physics_process(_delta: float) -> void:
|
||||
var movement := _get_movement()
|
||||
if movement.length_squared() < 0.01:
|
||||
return
|
||||
|
||||
# warning-ignore:return_value_discarded
|
||||
move_and_slide(movement * speed)
|
||||
agent.position = GSAIUtils.to_vector3(global_position)
|
||||
|
||||
|
@ -198,10 +198,6 @@ config/name="SteeringToolkit"
|
||||
run/main_scene="res://demos/DemoSelector.tscn"
|
||||
config/icon="res://icon.png"
|
||||
|
||||
[debug]
|
||||
|
||||
gdscript/warnings/return_value_discarded=false
|
||||
|
||||
[display]
|
||||
|
||||
window/size/width=1920
|
||||
|
@ -19,13 +19,14 @@ var movement_type: int
|
||||
var _last_position: Vector2
|
||||
|
||||
|
||||
func _init(body: KinematicBody2D, movement_type: int = MovementType.SLIDE) -> void:
|
||||
if not body.is_inside_tree():
|
||||
yield(body, "ready")
|
||||
func _init(_body: KinematicBody2D, _movement_type: int = MovementType.SLIDE) -> void:
|
||||
if not _body.is_inside_tree():
|
||||
yield(_body, "ready")
|
||||
|
||||
self.body = body
|
||||
self.movement_type = movement_type
|
||||
self.body = _body
|
||||
self.movement_type = _movement_type
|
||||
|
||||
# warning-ignore:return_value_discarded
|
||||
body.get_tree().connect("physics_frame", self, "_on_SceneTree_physics_frame")
|
||||
|
||||
|
||||
@ -60,6 +61,7 @@ func _apply_collide_steering(accel: Vector3, delta: float) -> void:
|
||||
Vector3.ZERO,
|
||||
linear_drag_percentage
|
||||
)
|
||||
# warning-ignore:return_value_discarded
|
||||
body.move_and_collide(GSAIUtils.to_vector2(velocity) * delta)
|
||||
if calculate_velocities:
|
||||
linear_velocity = velocity
|
||||
|
@ -18,14 +18,15 @@ var movement_type: int
|
||||
var _last_position: Vector3
|
||||
|
||||
|
||||
func _init(body: KinematicBody, movement_type: int = MovementType.SLIDE) -> void:
|
||||
if not body.is_inside_tree():
|
||||
yield(body, "ready")
|
||||
func _init(_body: KinematicBody, _movement_type: int = MovementType.SLIDE) -> void:
|
||||
if not _body.is_inside_tree():
|
||||
yield(_body, "ready")
|
||||
|
||||
self.body = body
|
||||
self.movement_type = movement_type
|
||||
self.body = _body
|
||||
self.movement_type = _movement_type
|
||||
|
||||
body.get_tree().connect("physics_frame", self, "_on_SceneTree_physics_frame")
|
||||
# warning-ignore:return_value_discarded
|
||||
self.body.get_tree().connect("physics_frame", self, "_on_SceneTree_physics_frame")
|
||||
|
||||
|
||||
# Moves the agent's `body` by target `acceleration`.
|
||||
@ -59,6 +60,7 @@ func _apply_collide_steering(accel: Vector3, delta: float) -> void:
|
||||
Vector3.ZERO,
|
||||
linear_drag_percentage
|
||||
)
|
||||
# warning-ignore:return_value_discarded
|
||||
body.move_and_collide(velocity * delta)
|
||||
if calculate_velocities:
|
||||
linear_velocity = velocity
|
||||
|
@ -10,16 +10,16 @@ var body: RigidBody2D setget _set_body
|
||||
var _last_position: Vector2
|
||||
|
||||
|
||||
func _init(body: RigidBody2D) -> void:
|
||||
if not body.is_inside_tree():
|
||||
yield(body, "ready")
|
||||
func _init(_body: RigidBody2D) -> void:
|
||||
if not _body.is_inside_tree():
|
||||
yield(_body, "ready")
|
||||
|
||||
self.body = body
|
||||
self.body = _body
|
||||
|
||||
|
||||
# Moves the agent's `body` by target `acceleration`.
|
||||
# tags: virtual
|
||||
func _apply_steering(acceleration: GSAITargetAcceleration, delta: float) -> void:
|
||||
func _apply_steering(acceleration: GSAITargetAcceleration, _delta: float) -> void:
|
||||
_applied_steering = true
|
||||
body.apply_central_impulse(GSAIUtils.to_vector2(acceleration.linear))
|
||||
body.apply_torque_impulse(acceleration.angular)
|
||||
@ -39,6 +39,7 @@ func _set_body(value: RigidBody2D) -> void:
|
||||
|
||||
|
||||
func _on_body_ready() -> void:
|
||||
# warning-ignore:return_value_discarded
|
||||
body.get_tree().connect("physics_frame", self, "_on_SceneTree_frame")
|
||||
_set_body(body)
|
||||
|
||||
|
@ -10,18 +10,19 @@ var body: RigidBody setget _set_body
|
||||
var _last_position: Vector3
|
||||
|
||||
|
||||
func _init(body: RigidBody) -> void:
|
||||
if not body.is_inside_tree():
|
||||
yield(body, "ready")
|
||||
func _init(_body: RigidBody) -> void:
|
||||
if not _body.is_inside_tree():
|
||||
yield(_body, "ready")
|
||||
|
||||
self.body = body
|
||||
body.get_tree().connect("physics_frame", self, "_on_SceneTree_frame")
|
||||
self.body = _body
|
||||
# warning-ignore:return_value_discarded
|
||||
self.body.get_tree().connect("physics_frame", self, "_on_SceneTree_frame")
|
||||
|
||||
|
||||
|
||||
# Moves the agent's `body` by target `acceleration`.
|
||||
# tags: virtual
|
||||
func _apply_steering(acceleration: GSAITargetAcceleration, 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)
|
||||
@ -41,6 +42,7 @@ func _set_body(value: RigidBody) -> void:
|
||||
|
||||
|
||||
func _on_body_ready() -> void:
|
||||
# warning-ignore:return_value_discarded
|
||||
body.get_tree().connect("physics_frame", self, "_on_SceneTree_frame")
|
||||
_set_body(body)
|
||||
|
||||
|
@ -15,8 +15,8 @@ var deceleration_radius: float
|
||||
var time_to_reach := 0.1
|
||||
|
||||
|
||||
func _init(agent: GSAISteeringAgent, target: GSAIAgentLocation).(agent) -> void:
|
||||
self.target = target
|
||||
func _init(agent: GSAISteeringAgent, _target: GSAIAgentLocation).(agent) -> void:
|
||||
self.target = _target
|
||||
|
||||
|
||||
func _arrive(acceleration: GSAITargetAcceleration, target_position: Vector3) -> void:
|
||||
|
@ -17,12 +17,12 @@ var prediction_time := 0.0
|
||||
|
||||
func _init(
|
||||
agent: GSAISteeringAgent,
|
||||
path: GSAIPath,
|
||||
path_offset := 0.0,
|
||||
prediction_time := 0.0).(agent, null) -> void:
|
||||
self.path = path
|
||||
self.path_offset = path_offset
|
||||
self.prediction_time = prediction_time
|
||||
_path: GSAIPath,
|
||||
_path_offset := 0.0,
|
||||
_prediction_time := 0.0).(agent, null) -> void:
|
||||
self.path = _path
|
||||
self.path_offset = _path_offset
|
||||
self.prediction_time = _prediction_time
|
||||
|
||||
|
||||
func _calculate_steering(acceleration: GSAITargetAcceleration) -> void:
|
||||
|
@ -16,8 +16,8 @@ var deceleration_radius: float
|
||||
var time_to_reach: float = 0.1
|
||||
|
||||
|
||||
func _init(agent: GSAISteeringAgent, target: GSAIAgentLocation).(agent) -> void:
|
||||
self.target = target
|
||||
func _init(agent: GSAISteeringAgent, _target: GSAIAgentLocation).(agent) -> void:
|
||||
self.target = _target
|
||||
|
||||
|
||||
func _match_orientation(acceleration: GSAITargetAcceleration, desired_orientation: float) -> void:
|
||||
|
@ -13,8 +13,8 @@ var last_selected_index: int
|
||||
var zero_threshold: float
|
||||
|
||||
|
||||
func _init(agent: GSAISteeringAgent, zero_threshold := 0.001).(agent) -> void:
|
||||
self.zero_threshold = zero_threshold
|
||||
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.
|
||||
|
@ -13,10 +13,10 @@ var predict_time_max: float
|
||||
|
||||
func _init(
|
||||
agent: GSAISteeringAgent,
|
||||
target: GSAISteeringAgent,
|
||||
predict_time_max := 1.0).(agent) -> void:
|
||||
self.target = target
|
||||
self.predict_time_max = predict_time_max
|
||||
_target: GSAISteeringAgent,
|
||||
_predict_time_max := 1.0).(agent) -> void:
|
||||
self.target = _target
|
||||
self.predict_time_max = _predict_time_max
|
||||
|
||||
|
||||
func _calculate_steering(acceleration: GSAITargetAcceleration) -> void:
|
||||
|
@ -8,8 +8,8 @@ extends GSAISteeringBehavior
|
||||
var target: GSAIAgentLocation
|
||||
|
||||
|
||||
func _init(agent: GSAISteeringAgent, target: GSAIAgentLocation).(agent) -> void:
|
||||
self.target = target
|
||||
func _init(agent: GSAISteeringAgent, _target: GSAIAgentLocation).(agent) -> void:
|
||||
self.target = _target
|
||||
|
||||
|
||||
func _calculate_steering(acceleration: GSAITargetAcceleration) -> void:
|
||||
|
@ -21,6 +21,7 @@ func _init(agent: GSAISteeringAgent, proximity: GSAIProximity).(agent, proximity
|
||||
func _calculate_steering(acceleration: GSAITargetAcceleration) -> void:
|
||||
acceleration.set_zero()
|
||||
self._acceleration = acceleration
|
||||
# warning-ignore:return_value_discarded
|
||||
proximity._find_neighbors(_callback)
|
||||
|
||||
|
||||
|
@ -9,8 +9,8 @@ var proximity: GSAIProximity
|
||||
var _callback := funcref(self, "_report_neighbor")
|
||||
|
||||
|
||||
func _init(agent: GSAISteeringAgent, proximity: GSAIProximity).(agent) -> void:
|
||||
self.proximity = proximity
|
||||
func _init(agent: GSAISteeringAgent, _proximity: GSAIProximity).(agent) -> void:
|
||||
self.proximity = _proximity
|
||||
|
||||
|
||||
# Internal callback for the behavior to define whether or not a member is
|
||||
|
@ -15,8 +15,8 @@ var _nearest_point_on_segment: Vector3
|
||||
var _nearest_point_on_path: Vector3
|
||||
|
||||
|
||||
func _init(waypoints: Array, is_open := false) -> void:
|
||||
self.is_open = is_open
|
||||
func _init(waypoints: Array, _is_open := false) -> void:
|
||||
self.is_open = _is_open
|
||||
create_path(waypoints)
|
||||
_nearest_point_on_segment = waypoints[0]
|
||||
_nearest_point_on_path = waypoints[0]
|
||||
@ -128,7 +128,7 @@ class GSAISegment:
|
||||
var cumulative_length: float
|
||||
|
||||
|
||||
func _init(begin: Vector3, end: Vector3) -> void:
|
||||
self.begin = begin
|
||||
self.end = end
|
||||
length = begin.distance_to(end)
|
||||
func _init(_begin: Vector3, _end: Vector3) -> void:
|
||||
self.begin = _begin
|
||||
self.end = _end
|
||||
length = _begin.distance_to(_end)
|
||||
|
@ -9,9 +9,9 @@ var agent: GSAISteeringAgent
|
||||
var agents := []
|
||||
|
||||
|
||||
func _init(agent: GSAISteeringAgent, agents: Array) -> void:
|
||||
self.agent = agent
|
||||
self.agents = agents
|
||||
func _init(_agent: GSAISteeringAgent, _agents: Array) -> void:
|
||||
self.agent = _agent
|
||||
self.agents = _agents
|
||||
|
||||
|
||||
# Returns a number of neighbors based on a `callback` function.
|
||||
|
@ -11,8 +11,8 @@ var _last_frame := 0
|
||||
var _scene_tree: SceneTree
|
||||
|
||||
|
||||
func _init(agent: GSAISteeringAgent, agents: Array, radius: float).(agent, agents) -> void:
|
||||
self.radius = radius
|
||||
func _init(agent: GSAISteeringAgent, agents: Array, _radius: float).(agent, agents) -> void:
|
||||
self.radius = _radius
|
||||
_scene_tree = Engine.get_main_loop()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user