1
Fork 0
mirror of https://github.com/Steffo99/hella-farm.git synced 2024-11-25 01:24:23 +00:00
hella-farm/behaviours/timer_stddev.gd

26 lines
493 B
GDScript3
Raw Normal View History

2024-04-17 03:45:34 +00:00
extends Timer
class_name TimerStddev
## A [Timer] which randomizes its [field wait_time] at each timeout.
@export var mean_secs: float = 1.0
2024-04-17 03:45:34 +00:00
@export var deviation: float = 1.0
@export var min_secs: float = 0.0
@export var max_secs: float = 2.0
@export var randomize_on_ready: bool = true
2024-04-17 03:45:34 +00:00
func randomize_wait_time() -> void:
wait_time = clampf(
Random.rng.randfn(mean_secs, deviation),
2024-05-02 23:37:20 +00:00
min_secs,
2024-04-17 03:45:34 +00:00
max_secs
)
func _ready() -> void:
if randomize_on_ready:
randomize_wait_time()