23 lines
540 B
GDScript
23 lines
540 B
GDScript
class_name BatterySnapshot
|
|
extends RefCounted
|
|
|
|
var remaining_kwh: float
|
|
var maximum_kwh: float
|
|
var ratio: float
|
|
var current_power_kw: float
|
|
var endurance_minutes: float
|
|
|
|
|
|
func _init(
|
|
p_remaining_kwh: float,
|
|
p_maximum_kwh: float,
|
|
p_current_power_kw: float
|
|
) -> void:
|
|
remaining_kwh = p_remaining_kwh
|
|
maximum_kwh = p_maximum_kwh
|
|
ratio = remaining_kwh / maximum_kwh if maximum_kwh > 0.0 else 0.0
|
|
current_power_kw = p_current_power_kw
|
|
endurance_minutes = (
|
|
remaining_kwh / current_power_kw * 60.0 if current_power_kw > 0.0 else INF
|
|
)
|