Рефакторинг

This commit is contained in:
sasha80
2023-08-10 11:55:22 +03:00
parent 1a410593da
commit 0908185d41
2 changed files with 9 additions and 9 deletions

View File

@@ -33,7 +33,7 @@ signal full_screen ## Вызывается при смене режима о
## Состояние перетаскивания
enum DRAG_FSM {
enum DragFSM {
DRAG, ## В процессе
IDLE, ## Не активно, ожидание
OFF ## Выключено
@@ -54,7 +54,7 @@ func _ready():
$btn_off.set_pressed(true)
strob_center = $canvas.get_strob_center()
on_button_strobe_pressed()
drag_fsm = DRAG_FSM.OFF
drag_fsm = DragFSM.OFF
var nodes: = get_tree().get_nodes_in_group('группа-режим-помехи')
nodes.any(func(btn): btn.button_connect('pressed', Callable(self, 'on_button_pressed').bind(btn, nodes)))
Threats.connect('threat_lost', Callable(self, 'on_threat_lost'))
@@ -101,10 +101,10 @@ func on_threat_lost(threats: Dictionary, th: Object):
func on_button_strobe_pressed():
if $btn_strobe.is_pressed():
$canvas.set_strob_visible(true)
drag_fsm = DRAG_FSM.IDLE
drag_fsm = DragFSM.IDLE
else:
$canvas.set_strob_visible(false)
drag_fsm = DRAG_FSM.OFF
drag_fsm = DragFSM.OFF
## Поведение радиокнопок в группе. Управляет состоянием кнопок в радиогруппе
@@ -160,16 +160,16 @@ func _on_drag_begin(event):
## Обработчик событий вввода. Вызывается godot
func _input(event):
if event is InputEventMouseMotion:
if drag_fsm == DRAG_FSM.DRAG:
if drag_fsm == DragFSM.DRAG:
emit_signal('drag_continue', event)
elif event is InputEventMouseButton:
drag_button = event.button_index
if event.pressed:
if drag_fsm == DRAG_FSM.IDLE:
drag_fsm = DRAG_FSM.DRAG
if drag_fsm == DragFSM.IDLE:
drag_fsm = DragFSM.DRAG
emit_signal('drag_begin', event)
else:
drag_fsm = DRAG_FSM.IDLE
drag_fsm = DragFSM.IDLE
emit_signal('drag_end', event)
elif event is InputEventKey:
if event.pressed and event.physical_keycode == KEY_F11:

View File

@@ -46,9 +46,9 @@ func _ready() -> void:
Log.info('Модуль обработки целей готов')
var unit_key = REPSettings.get_unit_key('уарэп-капсрпб-отп')
var unit = REPNetwork.units[unit_key]
unit.connect('data_received', Callable(self, 'on_data_capsrpb_received'))
var timer_check_lost: = Timer.new()
add_child(timer_check_lost)
unit.connect('data_received', Callable(self, 'on_data_capsrpb_received'))
timer_check_lost.connect('timeout', Callable(self, 'on_timer_check_lost').bind(unit, REPSettings.ThreatParams.time_lost[0]))
timer_check_lost.start(REPSettings.ThreatParams.time_lost[0] / 2.0)