2019-12-20 19:17:27 +01:00
|
|
|
extends Node2D
|
|
|
|
|
|
|
|
|
|
|
|
onready var player: = $Player
|
2019-12-23 17:38:27 +01:00
|
|
|
onready var gui: = $GUI
|
|
|
|
onready var turret: = $Turret
|
2019-12-22 20:08:53 +01:00
|
|
|
|
2020-01-15 20:15:31 +01:00
|
|
|
export(int, 0, 359, 1) var max_angular_speed: = 90 setget set_max_angular_speed
|
|
|
|
export(int, 0, 359, 1) var max_angular_accel: = 5 setget set_max_angular_accel
|
|
|
|
export(int, 0, 180, 1) var align_tolerance: = 5 setget set_align_tolerance
|
|
|
|
export(int, 0, 359, 1) var deceleration_radius: = 45 setget set_deceleration_radius
|
|
|
|
|
2019-12-22 20:08:53 +01:00
|
|
|
|
|
|
|
func _ready() -> void:
|
2020-01-15 20:15:31 +01:00
|
|
|
turret.setup(
|
|
|
|
deg2rad(align_tolerance),
|
|
|
|
deg2rad(deceleration_radius),
|
|
|
|
deg2rad(max_angular_accel),
|
|
|
|
deg2rad(max_angular_speed)
|
|
|
|
)
|
2019-12-22 20:08:53 +01:00
|
|
|
|
|
|
|
|
2020-01-15 20:15:31 +01:00
|
|
|
func set_align_tolerance(value: int) -> void:
|
|
|
|
align_tolerance = value
|
|
|
|
if turret:
|
|
|
|
turret._face.alignment_tolerance = deg2rad(value)
|
2019-12-22 20:08:53 +01:00
|
|
|
|
|
|
|
|
2020-01-15 20:15:31 +01:00
|
|
|
func set_deceleration_radius(value: int) -> void:
|
|
|
|
deceleration_radius = value
|
|
|
|
if turret:
|
|
|
|
turret._face.deceleration_radius = deg2rad(value)
|
2019-12-22 20:08:53 +01:00
|
|
|
|
|
|
|
|
2020-01-15 20:15:31 +01:00
|
|
|
func set_max_angular_accel(value: int) -> void:
|
|
|
|
max_angular_accel = value
|
|
|
|
if turret:
|
|
|
|
turret._agent.max_angular_acceleration = deg2rad(value)
|
2019-12-22 20:08:53 +01:00
|
|
|
|
|
|
|
|
2020-01-15 20:15:31 +01:00
|
|
|
func set_max_angular_speed(value: int) -> void:
|
|
|
|
max_angular_speed = value
|
|
|
|
if turret:
|
|
|
|
turret._agent.max_angular_speed = deg2rad(value)
|