Initial Commit
This commit is contained in:
28
Scripts/Logic/cNight.gd
Normal file
28
Scripts/Logic/cNight.gd
Normal file
@@ -0,0 +1,28 @@
|
||||
class_name cNight
|
||||
extends Node
|
||||
|
||||
signal hour_changed(new_hour)
|
||||
signal night_completed
|
||||
|
||||
@export var seconds_per_hour := 10.0
|
||||
@export var start_hour := 12
|
||||
@export var end_hour := 6
|
||||
|
||||
var current_hour := start_hour
|
||||
var hour_timer := 0.0
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
hour_timer += delta
|
||||
if hour_timer >= seconds_per_hour:
|
||||
hour_timer = 0.0
|
||||
_advance_hour()
|
||||
|
||||
func _advance_hour() -> void:
|
||||
if current_hour == 12:
|
||||
current_hour = 1
|
||||
else:
|
||||
current_hour += 1
|
||||
emit_signal("hour_changed", current_hour)
|
||||
|
||||
if current_hour >= end_hour:
|
||||
emit_signal("night_completed")
|
||||
Reference in New Issue
Block a user