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/Components/PowerManager.gd

29 lines
561 B
GDScript3
Raw Normal View History

2020-07-08 12:30:46 +00:00
extends Node
class_name PowerManager
signal power_connected()
signal power_disconnected()
2020-07-09 07:19:17 +00:00
var socket = false
var working = false
var wired setget , get_wired
export var power_usage = 0.0
export var power_source = 0.0
2020-07-08 12:30:46 +00:00
2020-07-09 14:50:34 +00:00
var power_load = 0.0
var available = 0.0
var powered = false setget set_powered
2020-07-09 07:19:17 +00:00
func get_wired() -> bool:
return socket != null
remotesync func set_powered(val: bool) -> void:
2020-07-09 14:50:34 +00:00
var current = powered
powered = val
if current and not val:
emit_signal("power_disconnected")
elif not current and val:
emit_signal("power_connected")