32 lines
537 B
GDScript
32 lines
537 B
GDScript
extends Node
|
|
|
|
const _increase_per_second: float = 5.0 #0.5
|
|
const _max: int = 1440 # 24 hour + 60 mins
|
|
|
|
const WORK_TIME = _max * 0.3
|
|
const SLEEP_TIME = _max * 0.6
|
|
|
|
var _time: float setget _set_time, get_time
|
|
|
|
signal respawn
|
|
|
|
|
|
func _set_time (new_time: float):
|
|
_time = new_time
|
|
|
|
|
|
func get_time () -> float:
|
|
return _time
|
|
|
|
|
|
func get_max () -> int:
|
|
return _max
|
|
|
|
|
|
func _process (delta: float) -> void:
|
|
# continually increases daytime
|
|
_set_time(_time + _increase_per_second * delta)
|
|
if _time >= _max:
|
|
_time = 0
|
|
emit_signal("respawn")
|