retrace/Global/Daytime.gd

32 lines
528 B
GDScript3
Raw Normal View History

2020-01-17 20:56:36 +01:00
extends Node
const _max: int = 1440 # 24 hour + 60 mins
2020-01-26 00:48:08 +01:00
const WORK_TIME = _max * 0.3
const SLEEP_TIME = _max * 0.6
2020-01-17 20:56:36 +01:00
var _time: float setget _set_time, get_time
var increase_per_second: float = 5.0
2020-01-17 20:56:36 +01:00
2020-01-17 21:29:33 +01:00
signal respawn
2020-01-17 20:56:36 +01:00
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)
2020-01-17 20:56:36 +01:00
if _time >= _max:
2020-01-17 21:29:33 +01:00
_time = 0
emit_signal("respawn")