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

27 lines
825 B
GDScript3
Raw Normal View History

2020-07-20 09:15:39 +00:00
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 = "%.0f kW" % total_source
$Margin/Container/EnergyBox/CurrentSink/Value.text = "%.0f kW" % total_sink
2020-07-20 09:15:39 +00:00
$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)