diff --git a/core/ai/agents/cow/ai_cow.tscn b/core/ai/agents/cow/ai_cow.tscn index 8abd4e3..fdff44f 100644 --- a/core/ai/agents/cow/ai_cow.tscn +++ b/core/ai/agents/cow/ai_cow.tscn @@ -2,6 +2,8 @@ [ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_p2hpa"] [ext_resource type="PackedScene" uid="uid://bjp8wbrtfl4v2" path="res://core/ai/agents/cow/cow_mannequin.tscn" id="2_6gadt"] +[ext_resource type="Script" uid="uid://d3hy70ec8vqo5" path="res://core/ai/framework/run_animation_state.gd" id="2_vlvvc"] +[ext_resource type="Script" uid="uid://bngfthvt04ivv" path="res://core/ai/framework/patrol_state.gd" id="3_su7en"] [sub_resource type="BoxShape3D" id="BoxShape3D_6gadt"] size = Vector3(1, 1.4033203, 2.201294) @@ -16,38 +18,23 @@ visible = false transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.20166016, 0.24859619) shape = SubResource("BoxShape3D_6gadt") +[node name="StateMachine" parent="." index="3" unique_id=1286404264 node_paths=PackedStringArray("initial_state")] +initial_state = NodePath("IdleState") + +[node name="IdleState" type="Node" parent="StateMachine" index="0" unique_id=2033863310] +script = ExtResource("2_vlvvc") +state_id = &"idle" +next_state_id = &"patrol" +animation_name = "custom/idle" + +[node name="PatrolState" type="Node" parent="StateMachine" index="1" unique_id=2076820654] +script = ExtResource("3_su7en") +state_id = &"patrol" +next_state_id = &"idle" +animation_name = "custom/walking" +exit_on_action_finished = true + [node name="CowMannequin" parent="." index="5" unique_id=1390675137 instance=ExtResource("2_6gadt")] transform = Transform3D(0.25, 0, 0, 0, 0.25, 0, 0, 0, 0.25, 0, -0.9, 0) -[node name="Skeleton3D" parent="CowMannequin/Armature" parent_id_path=PackedInt32Array(1390675137, 698629112) index="0" unique_id=1122133347] -bones/1/position = Vector3(-0.00911771, 0.0010000349, 0.006467142) -bones/3/position = Vector3(0.0017672703, 0.020791268, -0.0029404918) -bones/4/position = Vector3(-0.0032468068, 0.0023884464, 0.01873094) -bones/4/rotation = Quaternion(0.10042217, -0.10042243, 0.69993955, 0.69993955) -bones/5/rotation = Quaternion(0.67686933, -0.7237772, -0.07669845, 0.11005373) -bones/6/rotation = Quaternion(0.2912588, -0.018159404, 0.0055299345, 0.95645595) -bones/8/position = Vector3(-0.0032468068, 0.003527336, -0.02178527) -bones/8/rotation = Quaternion(-0.13840333, 0.13840266, 0.6934296, 0.6934297) -bones/9/rotation = Quaternion(0.63873273, -0.71572495, 0.1725141, -0.22360067) -bones/10/rotation = Quaternion(-0.5624951, 0.015998652, 0.010887203, 0.82657415) -bones/12/position = Vector3(0.0026304817, 0.0015686632, 0.01873094) -bones/12/rotation = Quaternion(0.69003975, 0.6900398, -0.15441875, 0.15441847) -bones/13/rotation = Quaternion(-0.06197851, -0.1282304, 0.73018706, 0.6682384) -bones/14/rotation = Quaternion(0.1410681, 0.051763278, -0.0073862504, 0.9886182) -bones/16/position = Vector3(0.0026304817, 0.005057063, -0.02178527) -bones/16/rotation = Quaternion(0.70645297, 0.7064531, 0.030399354, -0.030400336) -bones/17/rotation = Quaternion(0.198508, 0.20028433, 0.69889957, 0.65728253) -bones/18/rotation = Quaternion(-0.4085358, -0.008673466, -0.0038824743, 0.9126928) -bones/20/position = Vector3(-0.0003228268, 0.009853916, -0.026626632) -bones/26/position = Vector3(-0.00072195934, 0.0076745725, 0.016512236) -bones/26/rotation = Quaternion(0.0042201285, 0.8477673, 0.5299017, -0.021842854) -bones/27/rotation = Quaternion(0.1513493, -0.04170839, -0.04666066, 0.9864972) -bones/28/rotation = Quaternion(-0.6312453, -0.17917253, 0.17600863, 0.73378986) -bones/30/position = Vector3(-0.0003228271, 0.011335416, -0.01734586) -bones/33/position = Vector3(-0.008358625, 0.004613471, -0.013200058) -bones/33/rotation = Quaternion(0.76341635, -5.672201e-07, -6.704141e-07, 0.6459068) -bones/35/position = Vector3(0.008608938, 0.0010000349, 0.028441517) -bones/35/rotation = Quaternion(0.7071068, -6.866289e-07, -1.22965e-06, 0.7071067) -bones/37/position = Vector3(0.007849856, 0.0010000349, -0.02901155) - [editable path="CowMannequin"] diff --git a/core/ai/agents/cow/idle.res b/core/ai/agents/cow/idle.res index b461930..7c9ee39 100644 Binary files a/core/ai/agents/cow/idle.res and b/core/ai/agents/cow/idle.res differ diff --git a/core/ai/agents/cow/walking.res b/core/ai/agents/cow/walking.res index c432560..d2eb7a1 100644 Binary files a/core/ai/agents/cow/walking.res and b/core/ai/agents/cow/walking.res differ diff --git a/core/ai/agents/horse/ai_horse.tscn b/core/ai/agents/horse/ai_horse.tscn index 1f81be5..8710cec 100644 --- a/core/ai/agents/horse/ai_horse.tscn +++ b/core/ai/agents/horse/ai_horse.tscn @@ -2,6 +2,8 @@ [ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_e5v3h"] [ext_resource type="PackedScene" uid="uid://dqhueybnlrrqx" path="res://core/ai/agents/horse/horse_mannequin.tscn" id="2_4t6jw"] +[ext_resource type="Script" uid="uid://d3hy70ec8vqo5" path="res://core/ai/framework/run_animation_state.gd" id="2_or6xs"] +[ext_resource type="Script" uid="uid://bngfthvt04ivv" path="res://core/ai/framework/patrol_state.gd" id="3_n63jb"] [ext_resource type="Animation" uid="uid://doyi6etqvy4n2" path="res://core/ai/agents/horse/idle.res" id="3_qe4rt"] [ext_resource type="Animation" uid="uid://hotr7r3fd1sq" path="res://core/ai/agents/horse/walking.res" id="4_q8m0v"] @@ -24,10 +26,26 @@ visible = false transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.2074585, 0.14794922) shape = SubResource("BoxShape3D_4t6jw") +[node name="StateMachine" parent="." index="3" unique_id=1286404264 node_paths=PackedStringArray("initial_state")] +initial_state = NodePath("IdleState") + +[node name="IdleState" type="Node" parent="StateMachine" index="0" unique_id=734754793] +script = ExtResource("2_or6xs") +state_id = &"idle" +next_state_id = &"patrol" +animation_name = "custom/idle" + +[node name="PatrolState" type="Node" parent="StateMachine" index="1" unique_id=1748382252] +script = ExtResource("3_n63jb") +state_id = &"patrol" +next_state_id = &"idle" +animation_name = "custom/walking" +exit_on_action_finished = true + [node name="HorseMannequin" parent="." index="5" unique_id=1289880358 instance=ExtResource("2_4t6jw")] transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, -0.9, 0) -[node name="Skeleton3D" parent="HorseMannequin/Armature" parent_id_path=PackedInt32Array(1289880358, 502167939) index="0" unique_id=972507008] +[node name="Skeleton3D" parent="HorseMannequin/Armature" parent_id_path=PackedInt32Array(1289880358, 245823720) index="0" unique_id=494955820] bones/1/rotation = Quaternion(0.7071068, -6.209646e-07, -6.209645e-07, 0.7071067) bones/4/rotation = Quaternion(0.0012952884, -0.0012955684, 0.7071056, 0.7071057) bones/5/rotation = Quaternion(0.70685357, -0.70227593, -0.04508998, 0.07164877) @@ -55,7 +73,7 @@ bones/33/rotation = Quaternion(0.7071068, -6.209646e-07, -6.209645e-07, 0.707106 bones/35/rotation = Quaternion(0.7071068, -9.581396e-07, -9.581394e-07, 0.7071067) bones/37/rotation = Quaternion(0.7071068, -9.581396e-07, -9.581394e-07, 0.7071067) -[node name="AnimationPlayer" parent="HorseMannequin" index="1" unique_id=868895357] +[node name="AnimationPlayer" parent="HorseMannequin" index="1" unique_id=272680130] libraries/custom = SubResource("AnimationLibrary_or6xs") [editable path="HorseMannequin"] diff --git a/core/ai/agents/horse/idle.res b/core/ai/agents/horse/idle.res index eaab330..2f231d7 100644 Binary files a/core/ai/agents/horse/idle.res and b/core/ai/agents/horse/idle.res differ diff --git a/core/ai/agents/horse/walking.res b/core/ai/agents/horse/walking.res index bda900b..b3b738d 100644 Binary files a/core/ai/agents/horse/walking.res and b/core/ai/agents/horse/walking.res differ diff --git a/core/ai/agents/human/ai_citizen_walker.tscn b/core/ai/agents/human/ai_citizen_walker.tscn index e769cb7..a143b51 100644 --- a/core/ai/agents/human/ai_citizen_walker.tscn +++ b/core/ai/agents/human/ai_citizen_walker.tscn @@ -20,6 +20,6 @@ script = ExtResource("3_8d0tj") state_id = &"patrol" next_state_id = &"idle" animation_name = "custom/walking" -wait_time = 0.0 +exit_on_action_finished = true [editable path="HumanMannequin"] diff --git a/core/ai/agents/human/ai_farmer.tscn b/core/ai/agents/human/ai_farmer.tscn index d56e2a8..1ac71a3 100644 --- a/core/ai/agents/human/ai_farmer.tscn +++ b/core/ai/agents/human/ai_farmer.tscn @@ -14,7 +14,7 @@ script = ExtResource("3_2oda6") state_id = &"patrol" next_state_id = &"gather" animation_name = "custom/walking" -wait_time = 0.0 +exit_on_action_finished = true [node name="GatherState" type="Node" parent="StateMachine" index="1" unique_id=48091671] script = ExtResource("4_2oda6") @@ -22,6 +22,5 @@ state_id = &"gather" next_state_id = &"patrol" animation_name = "custom/gather" exit_on_animation_finished = true -wait_time = 1.0 [editable path="HumanMannequin"] diff --git a/core/ai/agents/human/idle.res b/core/ai/agents/human/idle.res index 2a57fcb..46ec99f 100644 Binary files a/core/ai/agents/human/idle.res and b/core/ai/agents/human/idle.res differ diff --git a/core/ai/agents/human/sit.res b/core/ai/agents/human/sit.res index 4497c3c..4565c03 100644 Binary files a/core/ai/agents/human/sit.res and b/core/ai/agents/human/sit.res differ diff --git a/core/ai/agents/human/walking.res b/core/ai/agents/human/walking.res index b230219..b910ccc 100644 Binary files a/core/ai/agents/human/walking.res and b/core/ai/agents/human/walking.res differ diff --git a/core/ai/agents/pig/ai_pig.tscn b/core/ai/agents/pig/ai_pig.tscn index 0d35f54..8f78b7a 100644 --- a/core/ai/agents/pig/ai_pig.tscn +++ b/core/ai/agents/pig/ai_pig.tscn @@ -1,8 +1,10 @@ [gd_scene format=3 uid="uid://c2hg6hu2y5srb"] [ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_j8spt"] +[ext_resource type="Script" uid="uid://d3hy70ec8vqo5" path="res://core/ai/framework/run_animation_state.gd" id="2_acc6o"] [ext_resource type="PackedScene" uid="uid://b0xb7kl4rjd66" path="res://core/ai/agents/pig/pig_mannequin.tscn" id="2_qmc2e"] -[ext_resource type="Animation" uid="uid://cneiflmpalcg5" path="res://core/ai/agents/pig/idle.res" id="3_lvpc5"] +[ext_resource type="Script" uid="uid://bngfthvt04ivv" path="res://core/ai/framework/patrol_state.gd" id="3_3n8ak"] +[ext_resource type="Animation" uid="uid://c4ingpw0co8v2" path="res://core/ai/agents/pig/idle.res" id="3_lvpc5"] [ext_resource type="Animation" uid="uid://0563r715lmw1" path="res://core/ai/agents/pig/walking.res" id="4_3f3hl"] [sub_resource type="BoxShape3D" id="BoxShape3D_lvpc5"] @@ -24,10 +26,26 @@ visible = false transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.24243164, 0.10699463) shape = SubResource("BoxShape3D_lvpc5") +[node name="StateMachine" parent="." index="3" unique_id=1286404264 node_paths=PackedStringArray("initial_state")] +initial_state = NodePath("IdleState") + +[node name="IdleState" type="Node" parent="StateMachine" index="0" unique_id=403305255] +script = ExtResource("2_acc6o") +state_id = &"idle" +next_state_id = &"patrol" +animation_name = "custom/idle" + +[node name="PatrolState" type="Node" parent="StateMachine" index="1" unique_id=1237150984] +script = ExtResource("3_3n8ak") +state_id = &"patrol" +next_state_id = &"idle" +animation_name = "custom/walking" +exit_on_action_finished = true + [node name="PigMannequin" parent="." index="5" unique_id=926755470 instance=ExtResource("2_qmc2e")] transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, -0.9, 0) -[node name="Skeleton3D" parent="PigMannequin/Armature" parent_id_path=PackedInt32Array(926755470, 1135672511) index="0" unique_id=689596368] +[node name="Skeleton3D" parent="PigMannequin/Armature" parent_id_path=PackedInt32Array(926755470, 695496535) index="0" unique_id=725647261] bones/1/rotation = Quaternion(0.7071068, -7.052583e-07, -7.052583e-07, 0.7071067) bones/3/position = Vector3(5.37765e-05, 0.017809996, -0.007695386) bones/3/rotation = Quaternion(-0.027121998, 0, 0, 0.99963224) @@ -62,7 +80,7 @@ bones/31/rotation = Quaternion(0.7071068, -1.0424332e-06, -1.0424329e-06, 0.7071 bones/33/position = Vector3(0.010670463, 0.0010000349, -0.03166372) bones/33/rotation = Quaternion(0.70755845, -7.1388774e-07, -1.0355643e-06, 0.7066547) -[node name="AnimationPlayer" parent="PigMannequin" index="1" unique_id=1348500176] +[node name="AnimationPlayer" parent="PigMannequin" index="1" unique_id=904091745] libraries/custom = SubResource("AnimationLibrary_lvpc5") [editable path="PigMannequin"] diff --git a/core/ai/agents/pig/idle.res b/core/ai/agents/pig/idle.res index cfaae36..8a44096 100644 Binary files a/core/ai/agents/pig/idle.res and b/core/ai/agents/pig/idle.res differ diff --git a/core/ai/agents/pug/ai_pug.tscn b/core/ai/agents/pug/ai_pug.tscn index bf7cc34..6439381 100644 --- a/core/ai/agents/pug/ai_pug.tscn +++ b/core/ai/agents/pug/ai_pug.tscn @@ -1,9 +1,11 @@ [gd_scene format=3 uid="uid://2md4l83fy8kr"] [ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_0bu1i"] +[ext_resource type="Script" uid="uid://d3hy70ec8vqo5" path="res://core/ai/framework/run_animation_state.gd" id="2_iapui"] [ext_resource type="PackedScene" uid="uid://c16j3umhplew4" path="res://core/ai/agents/pug/pug_mannequin.tscn" id="2_n0mit"] -[ext_resource type="Animation" uid="uid://cwrfo6h44qghm" path="res://core/ai/agents/pug/idle.res" id="3_hv1px"] -[ext_resource type="Animation" uid="uid://dbv2ikwa8h4nb" path="res://core/ai/agents/pug/walking.res" id="4_cjq2y"] +[ext_resource type="Animation" uid="uid://c8hy2tftqb7su" path="res://core/ai/agents/pug/idle.res" id="3_hv1px"] +[ext_resource type="Script" uid="uid://bngfthvt04ivv" path="res://core/ai/framework/patrol_state.gd" id="3_xc1yq"] +[ext_resource type="Animation" uid="uid://bqrhidcnublea" path="res://core/ai/agents/pug/walking.res" id="4_cjq2y"] [sub_resource type="AnimationLibrary" id="AnimationLibrary_iapui"] _data = { @@ -17,10 +19,26 @@ anim_player = NodePath("PugMannequin/AnimationPlayer") [node name="MeshInstance3D" parent="." index="0" unique_id=214482161] visible = false +[node name="StateMachine" parent="." index="3" unique_id=1286404264 node_paths=PackedStringArray("initial_state")] +initial_state = NodePath("IdleState") + +[node name="IdleState" type="Node" parent="StateMachine" index="0" unique_id=1079848975] +script = ExtResource("2_iapui") +state_id = &"idle" +next_state_id = &"patrol" +animation_name = "custom/idle" + +[node name="PatrolState" type="Node" parent="StateMachine" index="1" unique_id=1573670396] +script = ExtResource("3_xc1yq") +state_id = &"patrol" +next_state_id = &"idle" +animation_name = "custom/walking" +exit_on_action_finished = true + [node name="PugMannequin" parent="." index="5" unique_id=1732134047 instance=ExtResource("2_n0mit")] transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, -0.9, 0) -[node name="Skeleton3D" parent="PugMannequin/Armature" parent_id_path=PackedInt32Array(1732134047, 251322627) index="0" unique_id=1067550931] +[node name="Skeleton3D" parent="PugMannequin/Armature" parent_id_path=PackedInt32Array(1732134047, 199608791) index="0" unique_id=33809722] bones/8/position = Vector3(-0.0054483665, 0.008346455, -0.020266803) bones/8/rotation = Quaternion(-0.007561639, 0.007561228, 0.70706636, 0.70706636) bones/9/rotation = Quaternion(0.6665347, -0.6790185, 0.20055033, -0.23333457) @@ -34,7 +52,7 @@ bones/20/rotation = Quaternion(0.6013276, -0.007656022, 0.017799761, 0.79876757) bones/24/rotation = Quaternion(-0.45064288, -0.22904137, 0.090387635, 0.858074) bones/27/rotation = Quaternion(0.05229574, 5.703821e-05, -0.025155801, 0.99831474) -[node name="AnimationPlayer" parent="PugMannequin" index="1" unique_id=2146190163] +[node name="AnimationPlayer" parent="PugMannequin" index="1" unique_id=1653203922] libraries/custom = SubResource("AnimationLibrary_iapui") [editable path="PugMannequin"] diff --git a/core/ai/agents/pug/idle.res b/core/ai/agents/pug/idle.res index df85ee3..ebe7ddb 100644 Binary files a/core/ai/agents/pug/idle.res and b/core/ai/agents/pug/idle.res differ diff --git a/core/ai/agents/pug/walking.res b/core/ai/agents/pug/walking.res index 8bcff79..fd4bf30 100644 Binary files a/core/ai/agents/pug/walking.res and b/core/ai/agents/pug/walking.res differ diff --git a/core/ai/agents/sheep/ai_sheep.tscn b/core/ai/agents/sheep/ai_sheep.tscn index 42b8636..1d00def 100644 --- a/core/ai/agents/sheep/ai_sheep.tscn +++ b/core/ai/agents/sheep/ai_sheep.tscn @@ -2,8 +2,10 @@ [ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_smbiq"] [ext_resource type="PackedScene" uid="uid://58u6viv3qd63" path="res://core/ai/agents/sheep/sheep_mannequin.tscn" id="2_hnenk"] -[ext_resource type="Animation" uid="uid://ifn4akvcgaua" path="res://core/ai/agents/sheep/idle.res" id="3_i3d22"] -[ext_resource type="Animation" uid="uid://52eg4664eik0" path="res://core/ai/agents/sheep/walking.res" id="4_hxh1r"] +[ext_resource type="Script" uid="uid://d3hy70ec8vqo5" path="res://core/ai/framework/run_animation_state.gd" id="2_vlyix"] +[ext_resource type="Animation" uid="uid://bjvoxmyf4vdy8" path="res://core/ai/agents/sheep/idle.res" id="3_i3d22"] +[ext_resource type="Script" uid="uid://bngfthvt04ivv" path="res://core/ai/framework/patrol_state.gd" id="3_uqv5v"] +[ext_resource type="Animation" uid="uid://8r05h8e7nmic" path="res://core/ai/agents/sheep/walking.res" id="4_hxh1r"] [sub_resource type="BoxShape3D" id="BoxShape3D_hnenk"] size = Vector3(1, 1.4770508, 1.3725281) @@ -24,13 +26,29 @@ visible = false transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.23852539, 0.11299133) shape = SubResource("BoxShape3D_hnenk") +[node name="StateMachine" parent="." index="3" unique_id=1286404264 node_paths=PackedStringArray("initial_state")] +initial_state = NodePath("IdleState") + +[node name="IdleState" type="Node" parent="StateMachine" index="0" unique_id=190711451] +script = ExtResource("2_vlyix") +state_id = &"idle" +next_state_id = &"patrol" +animation_name = "custom/idle" + +[node name="PatrolState" type="Node" parent="StateMachine" index="1" unique_id=431976868] +script = ExtResource("3_uqv5v") +state_id = &"patrol" +next_state_id = &"idle" +animation_name = "custom/walking" +exit_on_action_finished = true + [node name="SheepMannequin" parent="." index="5" unique_id=1153770042 instance=ExtResource("2_hnenk")] transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, -0.9, 0) -[node name="Armature" parent="SheepMannequin" index="0" unique_id=1644576745] +[node name="Armature" parent="SheepMannequin" index="0" unique_id=62421163] transform = Transform3D(100, 0, 0, 0, -4.3711384e-06, 99.99999, 0, -99.99999, -4.3711384e-06, 0, 0, 0) -[node name="AnimationPlayer" parent="SheepMannequin" index="1" unique_id=770197846] +[node name="AnimationPlayer" parent="SheepMannequin" index="1" unique_id=676833932] libraries/custom = SubResource("AnimationLibrary_vlyix") [editable path="SheepMannequin"] diff --git a/core/ai/agents/sheep/idle.res b/core/ai/agents/sheep/idle.res index 8c89cad..94e7ca8 100644 Binary files a/core/ai/agents/sheep/idle.res and b/core/ai/agents/sheep/idle.res differ diff --git a/core/ai/agents/sheep/walking.res b/core/ai/agents/sheep/walking.res index 9499ab6..3a167fa 100644 Binary files a/core/ai/agents/sheep/walking.res and b/core/ai/agents/sheep/walking.res differ diff --git a/core/ai/framework/state.gd b/core/ai/framework/state.gd index dffd4b9..7681095 100644 --- a/core/ai/framework/state.gd +++ b/core/ai/framework/state.gd @@ -5,8 +5,10 @@ class_name State @export var state_id: StringName = &"" @export var next_state_id: StringName @export var animation_name: String +@export var exit_on_action_finished: bool @export var exit_on_animation_finished: bool -@export var wait_time: float = 3.0 +@export var min_wait_time: float = 3.0 +@export var max_wait_time: float = 10 var runtime_timer: Timer @@ -15,7 +17,7 @@ var runtime_timer: Timer signal transitioned(state: State, new_state_id: StringName) func _ready() -> void: - if wait_time > 0: + if min_wait_time > 0 and !exit_on_action_finished: runtime_timer = Timer.new() runtime_timer.name = "IdleTimer" runtime_timer.one_shot = true @@ -26,7 +28,8 @@ func enter() -> void: if exit_on_animation_finished: if not agent.anim_player.animation_finished.is_connected(_on_animation_finished): agent.anim_player.animation_finished.connect(_on_animation_finished) - elif wait_time > 0: + elif min_wait_time > 0 and !exit_on_action_finished: + var wait_time:= randf_range(min_wait_time, max_wait_time) runtime_timer.start(wait_time) func exit() -> void: @@ -48,7 +51,10 @@ func run_animation() -> void: func _on_animation_finished(anim_name: StringName) -> void: if animation_name == anim_name: - if wait_time > 0: + if exit_on_action_finished: + return + elif min_wait_time > 0: + var wait_time := randf_range(min_wait_time, max_wait_time) runtime_timer.start(wait_time) else: transitioned.emit(self, next_state_id) diff --git a/docs/gyms/ai/gym_ai.tscn b/docs/gyms/ai/gym_ai.tscn index 31de6ff..479a4f1 100644 --- a/docs/gyms/ai/gym_ai.tscn +++ b/docs/gyms/ai/gym_ai.tscn @@ -3,6 +3,11 @@ [ext_resource type="PackedScene" uid="uid://bnnuke5e7e1yr" path="res://core/ai/agents/human/ai_citizen_walker.tscn" id="1_a2xtd"] [ext_resource type="PackedScene" uid="uid://ceqxsqfiotm5j" path="res://core/ai/agents/human/ai_farmer.tscn" id="2_n3ssi"] [ext_resource type="PackedScene" uid="uid://bbseno7clbepx" path="res://core/ai/agents/human/ai_citizen_sitter.tscn" id="3_fdj8t"] +[ext_resource type="PackedScene" uid="uid://dd8wn62anbts8" path="res://core/ai/agents/cow/ai_cow.tscn" id="4_wr508"] +[ext_resource type="PackedScene" uid="uid://cayakdk7gmlyg" path="res://core/ai/agents/horse/ai_horse.tscn" id="5_7kg15"] +[ext_resource type="PackedScene" uid="uid://c2hg6hu2y5srb" path="res://core/ai/agents/pig/ai_pig.tscn" id="6_hw7u7"] +[ext_resource type="PackedScene" uid="uid://2md4l83fy8kr" path="res://core/ai/agents/pug/ai_pug.tscn" id="7_s6v14"] +[ext_resource type="PackedScene" uid="uid://bs1bdtm7jdtgb" path="res://core/ai/agents/sheep/ai_sheep.tscn" id="8_amn6p"] [sub_resource type="NavigationMesh" id="NavigationMesh_optuv"] vertices = PackedVector3Array(10.984741, 0.25012434, -1.0140381, 11.234741, 0.25012434, 0.23596191, 19.484741, 0.25012434, 0.23596191, 19.484741, 0.25012434, -19.514038, 9.234741, 0.25012434, -1.0140381, -19.515259, 0.25012434, -19.514038, -19.515259, 0.25012434, -0.014038086, 8.984741, 0.25012434, -0.014038086, 10.984741, 0.25012434, 1.2359619, 19.484741, 0.25012434, 19.235962, 9.234741, 0.25012434, 1.2359619, -19.515259, 0.25012434, 19.235962) @@ -98,3 +103,18 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.2447205, 0.94226265, 2.9251 [node name="AiCitizenSitter" parent="." unique_id=127569260 instance=ExtResource("3_fdj8t")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -10.074956, 1.3552468, 11.883549) + +[node name="AiCow" parent="." unique_id=1021070481 instance=ExtResource("4_wr508")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.4981034, 0.94226265, 15.013644) + +[node name="AiHorse" parent="." unique_id=71046494 instance=ExtResource("5_7kg15")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 7.385908, 0.94226265, 14.142443) + +[node name="AiPig" parent="." unique_id=430569938 instance=ExtResource("6_hw7u7")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -9.327689, 0.94226265, 6.6309185) + +[node name="AiPug" parent="." unique_id=1284695236 instance=ExtResource("7_s6v14")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.4858246, 0.9422617, 9.294181) + +[node name="AiSheep" parent="." unique_id=806542551 instance=ExtResource("8_amn6p")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -6.740941, 1.1779783, 16.328548)