2020-02-08 22:40:43 +01:00
|
|
|
extends Node
|
2020-01-16 09:44:44 +01:00
|
|
|
|
2020-02-14 17:35:18 +01:00
|
|
|
export (int, 0, 359, 2) var angular_speed_max := 120 setget set_angular_speed_max
|
|
|
|
export (int, 0, 359, 2) var angular_accel_max := 10 setget set_angular_accel_max
|
|
|
|
export (int, 0, 180, 2) var align_tolerance := 5 setget set_align_tolerance
|
|
|
|
export (int, 0, 359, 2) var deceleration_radius := 45 setget set_deceleration_radius
|
|
|
|
export (float, 0, 1000, 40) var player_speed := 600.0 setget set_player_speed
|
2020-01-16 09:44:44 +01:00
|
|
|
|
2020-01-22 17:55:49 +01:00
|
|
|
onready var player := $Player
|
|
|
|
onready var turret := $Turret
|
|
|
|
|
2020-01-16 09:44:44 +01:00
|
|
|
|
|
|
|
func _ready() -> void:
|
|
|
|
player.speed = player_speed
|
|
|
|
turret.setup(
|
|
|
|
player.agent,
|
|
|
|
deg2rad(align_tolerance),
|
|
|
|
deg2rad(deceleration_radius),
|
2020-01-22 17:55:49 +01:00
|
|
|
deg2rad(angular_accel_max),
|
|
|
|
deg2rad(angular_speed_max)
|
2020-01-16 09:44:44 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func set_align_tolerance(value: int) -> void:
|
2020-01-16 18:31:02 +01:00
|
|
|
align_tolerance = value
|
2020-01-16 09:44:44 +01:00
|
|
|
if not is_inside_tree():
|
|
|
|
return
|
2020-02-14 17:35:18 +01:00
|
|
|
|
2020-01-16 09:44:44 +01:00
|
|
|
turret.face.alignment_tolerance = deg2rad(value)
|
|
|
|
|
|
|
|
|
|
|
|
func set_deceleration_radius(value: int) -> void:
|
2020-01-16 18:31:02 +01:00
|
|
|
deceleration_radius = value
|
2020-01-16 09:44:44 +01:00
|
|
|
if not is_inside_tree():
|
|
|
|
return
|
2020-02-14 17:35:18 +01:00
|
|
|
|
2020-01-16 09:44:44 +01:00
|
|
|
turret.face.deceleration_radius = deg2rad(value)
|
|
|
|
|
|
|
|
|
2020-01-22 17:55:49 +01:00
|
|
|
func set_angular_accel_max(value: int) -> void:
|
|
|
|
angular_accel_max = value
|
2020-01-16 09:44:44 +01:00
|
|
|
if not is_inside_tree():
|
|
|
|
return
|
2020-02-14 17:35:18 +01:00
|
|
|
|
2020-01-22 17:55:49 +01:00
|
|
|
turret.agent.angular_acceleration_max = deg2rad(value)
|
2020-01-16 09:44:44 +01:00
|
|
|
|
|
|
|
|
2020-01-22 17:55:49 +01:00
|
|
|
func set_angular_speed_max(value: int) -> void:
|
|
|
|
angular_speed_max = value
|
2020-01-16 09:44:44 +01:00
|
|
|
if not is_inside_tree():
|
|
|
|
return
|
2020-02-14 17:35:18 +01:00
|
|
|
|
2020-01-22 17:55:49 +01:00
|
|
|
turret.agent.angular_speed_max = deg2rad(value)
|
2020-01-16 09:44:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
func set_player_speed(value: float) -> void:
|
2020-01-16 18:31:02 +01:00
|
|
|
player_speed = value
|
2020-01-16 09:44:44 +01:00
|
|
|
if not is_inside_tree():
|
|
|
|
return
|
2020-02-14 17:35:18 +01:00
|
|
|
|
2020-01-16 09:44:44 +01:00
|
|
|
player.speed = player_speed
|