27 lines
841 B
GDScript3
27 lines
841 B
GDScript3
|
extends Control
|
||
|
|
||
|
onready var scene = $"/root/scene" as GameInstance
|
||
|
|
||
|
func _physics_process(_delta):
|
||
|
if not visible:
|
||
|
return
|
||
|
var children = scene.systems.get_children()
|
||
|
var total_sink = 0
|
||
|
var total_source = 0
|
||
|
var total_alerts = 0
|
||
|
for child in children:
|
||
|
if child is PowerNetwork:
|
||
|
var network = child as PowerNetwork
|
||
|
total_sink += network.total_usage
|
||
|
total_source += network.total_source
|
||
|
total_alerts += network.unpowered
|
||
|
$Margin/Container/EnergyBox/CurrentSource/Value.text = str(round(total_source)) + " kW"
|
||
|
$Margin/Container/EnergyBox/CurrentSink/Value.text = str(round(total_sink)) + " kW"
|
||
|
$Margin/Container/EnergyBox/CurrentAlerts/Value.text = str(total_alerts)
|
||
|
|
||
|
func _map_button_pressed():
|
||
|
scene.ui.open_popup(GameUI.PopupName.EnergyUsage)
|
||
|
|
||
|
func force_close():
|
||
|
scene.ui.close_popup(GameUI.PopupName.EnergyUsage)
|