28 lines
561 B
GDScript
28 lines
561 B
GDScript
extends Node
|
|
|
|
class_name PowerManager
|
|
|
|
signal power_connected()
|
|
signal power_disconnected()
|
|
|
|
var socket = false
|
|
var working = false
|
|
var wired setget , get_wired
|
|
|
|
export var power_usage = 0.0
|
|
export var power_source = 0.0
|
|
|
|
var power_load = 0.0
|
|
var available = 0.0
|
|
var powered = false setget set_powered
|
|
|
|
func get_wired() -> bool:
|
|
return socket != null
|
|
|
|
remotesync func set_powered(val: bool) -> void:
|
|
var current = powered
|
|
powered = val
|
|
if current and not val:
|
|
emit_signal("power_disconnected")
|
|
elif not current and val:
|
|
emit_signal("power_connected")
|