This repository has been archived on 2020-09-30. You can view files and clone it, but cannot push or open issues or pull requests.
odyssey-old/Actors/Objects/Computer/UI/EnergyComp.gd
2020-07-20 11:15:39 +02:00

26 lines
841 B
GDScript

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)