Рефакторинг.
This commit is contained in:
@@ -21,13 +21,13 @@ func set_strob_band(val: float): $строб.set_instance_shader_parameter('
|
||||
func set_strob_radius(val: float): $строб.set_instance_shader_parameter('radius', sv(val))
|
||||
func set_strob_color(val: Color): $строб.set_instance_shader_parameter('color', val)
|
||||
|
||||
func get_strob_center() -> Vector2: return $строб.position
|
||||
func get_strob_visible() -> bool: return $строб.visible
|
||||
func get_strob_dir() -> float: return $строб.get_instance_shader_parameter('dir')
|
||||
func get_strob_width() -> float: return $строб.get_instance_shader_parameter('width')
|
||||
func get_strob_band() -> float: return $строб.get_instance_shader_parameter('band') * 125.0
|
||||
func get_strob_radius() -> float: return $строб.get_instance_shader_parameter('radius') * 125.0
|
||||
func get_strob_color() -> float: return $строб.get_instance_shader_parameter('color')
|
||||
func get_strob_center() -> Vector2: return $строб.position
|
||||
func get_strob_visible() -> bool: return $строб.visible
|
||||
func get_strob_dir() -> float: return $строб.get_instance_shader_parameter('dir')
|
||||
func get_strob_width() -> float: return $строб.get_instance_shader_parameter('width')
|
||||
func get_strob_band() -> float: return $строб.get_instance_shader_parameter('band') * 125.0
|
||||
func get_strob_radius() -> float: return $строб.get_instance_shader_parameter('radius') * 125.0
|
||||
func get_strob_color() -> float: return $строб.get_instance_shader_parameter('color')
|
||||
|
||||
func get_radius_outter() -> float: return material.get('shader_parameter/radius_outter')
|
||||
func get_radius_inner_0() -> float: return material.get('shader_parameter/radius_inner_0')
|
||||
|
||||
@@ -18,12 +18,12 @@ func _on_request_completed(result, _response_code, headers, body: PackedByteArra
|
||||
log.error('\"%s\"' % rs)
|
||||
return
|
||||
|
||||
var json_str: String = body.get_string_from_utf8()
|
||||
var json_str: = body.get_string_from_utf8()
|
||||
if not json_str:
|
||||
push_error('не удаётся получить строку из utf8-данных (%s)' % headers)
|
||||
return
|
||||
|
||||
var rc = json_conv.parse(json_str)
|
||||
var rc: = json_conv.parse(json_str)
|
||||
if rc != Error.OK:
|
||||
var err = json_conv.get_error_message()
|
||||
push_error('разбор json прерван - \"%s\" (%s)' % [err, headers])
|
||||
|
||||
@@ -46,5 +46,5 @@ func _on_request_timer():
|
||||
var rc = request(addr)
|
||||
if rc != Error.OK:
|
||||
var s: String = '%s: %s' % [error_string(rc), addr]
|
||||
log.error('ошибка: %s' % s)
|
||||
log.error('%s' % s)
|
||||
i_bort = (i_bort + 1) % 2
|
||||
|
||||
@@ -177,10 +177,10 @@ func _ready() -> void:
|
||||
signaller.connect('interfer_prinuditelno', Callable(self, 'on_interfer_prinuditelno'))
|
||||
signaller.connect('emit_changed', Callable(self, 'on_emit_changed').bind(ecms))
|
||||
threats.connect('threat_lost', Callable(self, 'on_threats_lost').bind(ecms, unit_caps))
|
||||
var unit_nav = network.get_unit_instance('навигация')
|
||||
unit_nav.connect('data_received', on_nav_data_received.bind(unit_caps))
|
||||
threats.connect('threats_resized', Callable(self, 'on_threats_resized'))
|
||||
threats.connect('threat_update', Callable(self, 'on_threats_update').bind(ecms, unit_caps))
|
||||
var unit_nav = network.get_unit_instance('навигация')
|
||||
unit_nav.connect('data_received', on_nav_data_received.bind(unit_caps))
|
||||
|
||||
|
||||
func on_nav_data_received(coords: Dictionary, unit_caps):
|
||||
@@ -250,10 +250,9 @@ func on_data_capsrpb_received(unit_instance: capsrpb.CapsRpb, ecms: Dictionary)
|
||||
func map_msvk_to_ecms(unit_instance: unit.Unit, ecms: Dictionary):
|
||||
var json_dic = unit_instance.json_dic
|
||||
if not json_dic.has('msvk'): return
|
||||
var msvk = unit_instance.json_dic['msvk']
|
||||
if msvk is not Array: return
|
||||
var msvk = unit_instance.json_dic.get('msvk', [])
|
||||
for dic_msvk in msvk:
|
||||
if not (dic_msvk is Dictionary): continue
|
||||
if dic_msvk is not Dictionary: continue
|
||||
if not dic_msvk.has('ispp'): continue
|
||||
var ispp = int(dic_msvk['ispp'])
|
||||
var errmsg = dic_msvk.get('errmsg', '')
|
||||
|
||||
@@ -45,13 +45,13 @@ signal threats_resized(th: Dictionary)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
var threats = {} ## Список целей. Индекс - <номер цели>
|
||||
var unit_caps = network.get_unit_instance('уарэп-капсрпб')
|
||||
var unit_5p28 = network.get_unit_instance('уарэп-5п28')
|
||||
var timer_check_lost: = Timer.new()
|
||||
var timer_aoa_update: = Timer.new()
|
||||
add_child(timer_check_lost)
|
||||
add_child(timer_aoa_update)
|
||||
var threats = {} ## Список целей. Индекс - <номер цели>
|
||||
unit_caps.connect('data_received', Callable(self, 'on_data_capsrpb_received').bind(threats))
|
||||
unit_5p28.connect('get_threats', Callable(self, 'on_get_threats').bind(unit_5p28, threats))
|
||||
timer_check_lost.connect('timeout', Callable(self, 'on_timer_check_lost').bind(settings.ThreatParams.time_lost, threats))
|
||||
@@ -69,7 +69,7 @@ func _ready() -> void:
|
||||
|
||||
## Периодически удаляет устаревшие цели.
|
||||
func on_timer_check_lost(time_lost: int, threats: Dictionary):
|
||||
var tick = Time.get_ticks_msec()
|
||||
var tick: = Time.get_ticks_msec()
|
||||
var sz: = threats.size()
|
||||
for th in threats.values():
|
||||
if (tick - th.tick_rx) >= time_lost:
|
||||
@@ -115,7 +115,7 @@ func on_interfer_init(interfer_name, fs_arr, power, threats):
|
||||
sel_threats.append(threat)
|
||||
if threat.auto_selected:
|
||||
sel_threats.append(threat)
|
||||
if len(sel_threats) or (len(fs_arr)):
|
||||
if len(sel_threats) or len(fs_arr):
|
||||
signaller.emit_signal('interfer_create', interfer_name, sel_threats, fs_arr, power)
|
||||
|
||||
|
||||
@@ -128,20 +128,22 @@ func on_data_capsrpb_received(unit: capsrpb.CapsRpb, threats: Dictionary):
|
||||
var mis = unit.json_dic['mis']
|
||||
var sz: = threats.size()
|
||||
for dic_th in mis:
|
||||
if dic_th is Dictionary:
|
||||
if dic_th.has('id'):
|
||||
var id = int(dic_th['id'])
|
||||
if threats.has(id):
|
||||
var th = threats[id]
|
||||
th.clear_fflags()
|
||||
th.set_from_dic(dic_th)
|
||||
th.tick_rx = unit.tick
|
||||
call_deferred('emit_signal', 'threat_update', th)
|
||||
else:
|
||||
var th = Threat.new()
|
||||
th.set_from_dic(dic_th)
|
||||
threats[id] = th
|
||||
th.tick_rx = unit.tick
|
||||
call_deferred('emit_signal', 'threat_new', th)
|
||||
if dic_th is not Dictionary:
|
||||
continue
|
||||
if not dic_th.has('id'):
|
||||
continue
|
||||
var id = int(dic_th['id'])
|
||||
if threats.has(id):
|
||||
var th = threats[id]
|
||||
th.clear_fflags()
|
||||
th.set_from_dic(dic_th)
|
||||
th.tick_rx = unit.tick
|
||||
call_deferred('emit_signal', 'threat_update', th)
|
||||
else:
|
||||
var th: = Threat.new()
|
||||
th.set_from_dic(dic_th)
|
||||
threats[id] = th
|
||||
th.tick_rx = unit.tick
|
||||
call_deferred('emit_signal', 'threat_new', th)
|
||||
if sz != threats.size():
|
||||
call_deferred('emit_signal', 'threats_resized', threats)
|
||||
|
||||
@@ -33,7 +33,7 @@ func is_overlap(x1, x2, y1, y2) -> bool: return max(x1, y1) <= min(x2, y2)
|
||||
## [param msg] - сообщение об ошибке
|
||||
func allways(val: bool, msg: String = '<не указано>'):
|
||||
if val: return
|
||||
push_error('ошибка: %s\n' % msg)
|
||||
push_error('%s\n' % msg)
|
||||
get_tree().quit(Error.FAILED)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user