retrace/Global/Daytime.gd

29 lines
477 B
GDScript3
Raw Normal View History

2020-01-17 20:56:36 +01:00
extends Node
2020-01-25 19:07:51 +01:00
const _increase_per_second: float = 0.0 #0.5
2020-01-17 20:56:36 +01:00
const _max: int = 1440 # 24 hour + 60 mins
var _time: float setget _set_time, get_time
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)
if _time >= _max:
2020-01-17 21:29:33 +01:00
_time = 0
emit_signal("respawn")