1
Fork 0
mirror of https://github.com/Steffo99/hella-farm.git synced 2024-11-24 17:14:23 +00:00

Add TimerStddev

This commit is contained in:
Steffo 2024-04-17 05:45:34 +02:00
parent 8278a55069
commit 8142f399bd
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0
3 changed files with 41 additions and 3 deletions

View file

@ -0,0 +1,23 @@
extends Timer
class_name TimerStddev
## A [Timer] which randomizes its [field wait_time] at each timeout.
@export_range(0, 10, 0.1, "or_greater") var mean_secs: float = 1.0
@export var deviation: float = 1.0
@export_range(0, 10, 0.1, "or_greater") var min_secs: float = 0.0
@export_range(0, 10, 0.1, "or_greater") var max_secs: float = 2.0
func randomize_wait_time() -> void:
wait_time = clampf(
min_secs,
Random.rng.randfn(mean_secs, deviation),
max_secs
)
func _ready() -> void:
randomize_wait_time()

View file

@ -0,0 +1,8 @@
[gd_scene load_steps=2 format=3 uid="uid://g8t6dt0ye6n3"]
[ext_resource type="Script" path="res://behaviours/timer_stddev.gd" id="1_rvemn"]
[node name="TimerStddev" type="Timer"]
script = ExtResource("1_rvemn")
[connection signal="timeout" from="." to="." method="randomize_wait_time"]

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=21 format=3 uid="uid://bc2bm8lbol18w"] [gd_scene load_steps=22 format=3 uid="uid://bc2bm8lbol18w"]
[ext_resource type="Script" path="res://entities/sheep.gd" id="1_4dmll"] [ext_resource type="Script" path="res://entities/sheep.gd" id="1_4dmll"]
[ext_resource type="Texture2D" uid="uid://iljp5yn3ehfk" path="res://entities/sheep_left.png" id="2_t13f5"] [ext_resource type="Texture2D" uid="uid://iljp5yn3ehfk" path="res://entities/sheep_left.png" id="2_t13f5"]
@ -11,6 +11,7 @@
[ext_resource type="PackedScene" uid="uid://djcwis8ycrq85" path="res://behaviours/sampler_priority.tscn" id="9_s5lod"] [ext_resource type="PackedScene" uid="uid://djcwis8ycrq85" path="res://behaviours/sampler_priority.tscn" id="9_s5lod"]
[ext_resource type="PackedScene" uid="uid://dk1ipq7dhkhf3" path="res://behaviours/move_straight.tscn" id="10_05kcd"] [ext_resource type="PackedScene" uid="uid://dk1ipq7dhkhf3" path="res://behaviours/move_straight.tscn" id="10_05kcd"]
[ext_resource type="PackedScene" uid="uid://cm67ko1k6kn4u" path="res://behaviours/priority.tscn" id="11_0jlmk"] [ext_resource type="PackedScene" uid="uid://cm67ko1k6kn4u" path="res://behaviours/priority.tscn" id="11_0jlmk"]
[ext_resource type="PackedScene" uid="uid://g8t6dt0ye6n3" path="res://behaviours/timer_stddev.tscn" id="12_c45uk"]
[ext_resource type="PackedScene" uid="uid://cml7rqvyfuagx" path="res://behaviours/move_towards.tscn" id="12_x2g3x"] [ext_resource type="PackedScene" uid="uid://cml7rqvyfuagx" path="res://behaviours/move_towards.tscn" id="12_x2g3x"]
[ext_resource type="PackedScene" uid="uid://cbg5kgwxusvxf" path="res://behaviours/cursor_detector.tscn" id="13_5fkdr"] [ext_resource type="PackedScene" uid="uid://cbg5kgwxusvxf" path="res://behaviours/cursor_detector.tscn" id="13_5fkdr"]
[ext_resource type="PackedScene" uid="uid://c5pyp5hvthdof" path="res://behaviours/tracker_tracker.tscn" id="14_eqowb"] [ext_resource type="PackedScene" uid="uid://c5pyp5hvthdof" path="res://behaviours/tracker_tracker.tscn" id="14_eqowb"]
@ -123,8 +124,12 @@ enabled = false
[node name="IdlePriority" parent="MovementIdle" instance=ExtResource("11_0jlmk")] [node name="IdlePriority" parent="MovementIdle" instance=ExtResource("11_0jlmk")]
priority = 10 priority = 10
[node name="BoredTimer" type="Timer" parent="MovementIdle"] [node name="BoredTimer" parent="MovementIdle" instance=ExtResource("12_c45uk")]
one_shot = true one_shot = true
autostart = true
mean_secs = 3.0
min_secs = 1.0
max_secs = 5.0
[node name="MovementWander" parent="." instance=ExtResource("10_05kcd")] [node name="MovementWander" parent="." instance=ExtResource("10_05kcd")]
speed = 66.0 speed = 66.0
@ -132,8 +137,10 @@ enabled = false
[node name="WanderPriority" parent="MovementWander" instance=ExtResource("11_0jlmk")] [node name="WanderPriority" parent="MovementWander" instance=ExtResource("11_0jlmk")]
[node name="TiredTimer" type="Timer" parent="MovementWander"] [node name="TiredTimer" parent="MovementWander" instance=ExtResource("12_c45uk")]
one_shot = true one_shot = true
min_secs = 0.3
max_secs = 1.5
[node name="MovementRunFromMouse" parent="." instance=ExtResource("12_x2g3x")] [node name="MovementRunFromMouse" parent="." instance=ExtResource("12_x2g3x")]
speed = -100.0 speed = -100.0