mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-24 09:04:22 +00:00
Make chupacabra a menace
This commit is contained in:
parent
cfacba4f89
commit
229fc6f992
6 changed files with 73 additions and 56 deletions
|
@ -20,12 +20,20 @@ signal changed_direction(new: Vector2)
|
|||
func set_direction(value: Vector2) -> void:
|
||||
direction = value
|
||||
|
||||
func steer_direction_towards(node: Node2D) -> void:
|
||||
if node != null:
|
||||
direction = global_position.direction_to(node.global_position)
|
||||
|
||||
func clear_direction() -> void:
|
||||
direction = Vector2.ZERO
|
||||
|
||||
func randomize_direction() -> void:
|
||||
direction = Vector2.from_angle(Random.rng.randf_range(0, 2*PI))
|
||||
|
||||
func randomize_direction_if_zero() -> void:
|
||||
if direction == Vector2.ZERO:
|
||||
randomize_direction()
|
||||
|
||||
func log_state() -> void:
|
||||
Log.p(self, "Direction: %s | Speed: %s" % [direction, speed])
|
||||
|
||||
|
|
|
@ -45,4 +45,4 @@ func sample_target_if_null() -> void:
|
|||
|
||||
|
||||
func log_target() -> void:
|
||||
pass # Replace with function body.
|
||||
Log.p(self, "Target: %s" % target)
|
||||
|
|
|
@ -6,15 +6,12 @@ class_name Chupacabra
|
|||
|
||||
|
||||
@onready var sprite: SpriteLeftRight = %"Sprite"
|
||||
@onready var movement_skitter: MoveStraight = %"MovementSkitter"
|
||||
@onready var movement_wander: MoveStraight = %"MovementWander"
|
||||
@onready var movement_wander_tp: TargetPicker = movement_wander.get_node("TrackerMeat/TargetPicker")
|
||||
@onready var animator: AnimationPlayer = %"Animator"
|
||||
@onready var eater: Eater = %"Eater"
|
||||
|
||||
|
||||
func _on_cursor_detected(_cursor: Cursor) -> void:
|
||||
var direction = Random.sample(skitter_directions)
|
||||
movement_skitter.set_direction(direction)
|
||||
|
||||
func _on_move(movement: Vector2) -> void:
|
||||
move_and_collide(movement)
|
||||
sprite.handle_move(movement)
|
||||
|
@ -45,3 +42,9 @@ func _on_trapped() -> void:
|
|||
func _on_freed() -> void:
|
||||
z_index = Enums.ZIndex.EntityGround
|
||||
y_sort_enabled = true
|
||||
|
||||
func _on_wander_enabled() -> void:
|
||||
if movement_wander_tp.target:
|
||||
movement_wander.steer_direction_towards(movement_wander_tp.target)
|
||||
else:
|
||||
movement_wander.randomize_direction()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=33 format=3 uid="uid://cmemgijh6nfmk"]
|
||||
[gd_scene load_steps=34 format=3 uid="uid://cmemgijh6nfmk"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bxbjfev0lhwws" path="res://behaviours/sprite_left_right.tscn" id="1_11voy"]
|
||||
[ext_resource type="Script" path="res://entities/chupacabra.gd" id="1_s4qg1"]
|
||||
|
@ -342,6 +342,9 @@ _data = {
|
|||
"sit": SubResource("Animation_fsmcn")
|
||||
}
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_wya3j"]
|
||||
radius = 320.0
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_dcrcb"]
|
||||
radius = 48.0
|
||||
|
||||
|
@ -388,51 +391,53 @@ kind = &"Chupacabra"
|
|||
|
||||
[node name="MovementSampler" parent="." instance=ExtResource("7_nq78n")]
|
||||
|
||||
[node name="MovementWander" parent="." instance=ExtResource("8_7fxrt")]
|
||||
speed = 300.0
|
||||
[node name="MovementIdle" parent="." instance=ExtResource("8_7fxrt")]
|
||||
speed = 0.0
|
||||
enabled = false
|
||||
|
||||
[node name="WanderPriority" parent="MovementWander" instance=ExtResource("9_7i81t")]
|
||||
[node name="IdlePriority" parent="MovementIdle" instance=ExtResource("9_7i81t")]
|
||||
default_priority = 10
|
||||
alternative_priority = 10
|
||||
|
||||
[node name="StartMovingTimer" parent="MovementWander" instance=ExtResource("6_qsds3")]
|
||||
[node name="BoredTimer" parent="MovementIdle" instance=ExtResource("6_qsds3")]
|
||||
one_shot = true
|
||||
autostart = true
|
||||
mean_secs = 3.0
|
||||
deviation = 2.0
|
||||
mean_secs = 5.0
|
||||
min_secs = 1.0
|
||||
max_secs = 5.0
|
||||
max_secs = 9.0
|
||||
|
||||
[node name="StopMovingTimer" parent="MovementWander" instance=ExtResource("6_qsds3")]
|
||||
one_shot = true
|
||||
mean_secs = 0.5
|
||||
deviation = 0.5
|
||||
min_secs = 0.1
|
||||
max_secs = 1.0
|
||||
|
||||
[node name="MovementSkitter" parent="." instance=ExtResource("8_7fxrt")]
|
||||
[node name="MovementWander" parent="." instance=ExtResource("8_7fxrt")]
|
||||
unique_name_in_owner = true
|
||||
speed = 600.0
|
||||
speed = 333.0
|
||||
enabled = false
|
||||
|
||||
[node name="SkitterPriority" parent="MovementSkitter" instance=ExtResource("9_7i81t")]
|
||||
[node name="WanderPriority" parent="MovementWander" instance=ExtResource("9_7i81t")]
|
||||
alternative_priority = 20
|
||||
|
||||
[node name="CursorSense" parent="MovementSkitter" instance=ExtResource("10_3wu3x")]
|
||||
[node name="TiredTimer" parent="MovementWander" instance=ExtResource("6_qsds3")]
|
||||
one_shot = true
|
||||
mean_secs = 0.6
|
||||
deviation = 0.5
|
||||
min_secs = 0.3
|
||||
max_secs = 1.2
|
||||
|
||||
[node name="Shape" type="CollisionShape2D" parent="MovementSkitter/CursorSense"]
|
||||
[node name="TrackerMeat" parent="MovementWander" instance=ExtResource("14_mk76g")]
|
||||
collision_mask = 8
|
||||
acceptable_diets = Array[StringName]([&"Meat"])
|
||||
|
||||
[node name="Shape" type="CollisionShape2D" parent="MovementWander/TrackerMeat"]
|
||||
shape = SubResource("CircleShape2D_wya3j")
|
||||
debug_color = Color(1, 0.498039, 0, 0)
|
||||
|
||||
[node name="TargetPicker" parent="MovementWander/TrackerMeat" node_paths=PackedStringArray("tracker") instance=ExtResource("15_xay6p")]
|
||||
tracker = NodePath("..")
|
||||
|
||||
[node name="CursorSense" parent="MovementWander" instance=ExtResource("10_3wu3x")]
|
||||
|
||||
[node name="Shape" type="CollisionShape2D" parent="MovementWander/CursorSense"]
|
||||
shape = SubResource("CircleShape2D_dcrcb")
|
||||
debug_color = Color(1, 1, 0, 0)
|
||||
|
||||
[node name="CalmTimer" parent="MovementSkitter" instance=ExtResource("6_qsds3")]
|
||||
wait_time = 0.2
|
||||
one_shot = true
|
||||
mean_secs = 0.1
|
||||
deviation = 0.2
|
||||
min_secs = 0.1
|
||||
max_secs = 0.3
|
||||
|
||||
[node name="MovementTrap" parent="." instance=ExtResource("13_vh42q")]
|
||||
speed = 600.0
|
||||
enabled = false
|
||||
|
@ -484,24 +489,25 @@ stream = ExtResource("17_ccla5")
|
|||
bus = &"KillSounds"
|
||||
|
||||
[connection signal="sacrificed" from="Sacrificable" to="." method="queue_free"]
|
||||
[connection signal="changed_direction" from="MovementWander" to="MovementWander/WanderPriority" method="priority_conditional"]
|
||||
[connection signal="move" from="MovementIdle" to="." method="_on_move"]
|
||||
[connection signal="move_disabled" from="MovementIdle" to="MovementIdle/BoredTimer" method="stop"]
|
||||
[connection signal="move_enabled" from="MovementIdle" to="MovementIdle/BoredTimer" method="start"]
|
||||
[connection signal="move_enabled" from="MovementIdle" to="Animator" method="play" binds= [&"sit"]]
|
||||
[connection signal="timeout" from="MovementIdle/BoredTimer" to="MovementIdle/BoredTimer" method="randomize_wait_time"]
|
||||
[connection signal="timeout" from="MovementIdle/BoredTimer" to="MovementWander/WanderPriority" method="priority_alternative"]
|
||||
[connection signal="move" from="MovementWander" to="." method="_on_move"]
|
||||
[connection signal="move_disabled" from="MovementWander" to="MovementWander" method="clear_direction"]
|
||||
[connection signal="move_disabled" from="MovementWander" to="MovementWander/StartMovingTimer" method="stop"]
|
||||
[connection signal="move_disabled" from="MovementWander" to="MovementWander/StopMovingTimer" method="stop"]
|
||||
[connection signal="move_enabled" from="MovementWander" to="MovementWander/StartMovingTimer" method="start"]
|
||||
[connection signal="move_enabled" from="MovementWander" to="Animator" method="play" binds= [&"sit"]]
|
||||
[connection signal="timeout" from="MovementWander/StartMovingTimer" to="MovementWander" method="randomize_direction"]
|
||||
[connection signal="timeout" from="MovementWander/StartMovingTimer" to="MovementWander/StopMovingTimer" method="start"]
|
||||
[connection signal="timeout" from="MovementWander/StartMovingTimer" to="Animator" method="play" binds= [&"run"]]
|
||||
[connection signal="timeout" from="MovementWander/StopMovingTimer" to="MovementWander" method="clear_direction"]
|
||||
[connection signal="timeout" from="MovementWander/StopMovingTimer" to="MovementWander/StartMovingTimer" method="start"]
|
||||
[connection signal="timeout" from="MovementWander/StopMovingTimer" to="Animator" method="play" binds= [&"sit"]]
|
||||
[connection signal="changed_direction" from="MovementSkitter" to="MovementSkitter/SkitterPriority" method="priority_conditional"]
|
||||
[connection signal="changed_direction" from="MovementSkitter" to="MovementSkitter/CalmTimer" method="start" unbinds=1]
|
||||
[connection signal="move" from="MovementSkitter" to="." method="_on_move"]
|
||||
[connection signal="cursor_entered" from="MovementSkitter/CursorSense" to="." method="_on_cursor_detected"]
|
||||
[connection signal="timeout" from="MovementSkitter/CalmTimer" to="MovementSkitter" method="clear_direction"]
|
||||
[connection signal="move_disabled" from="MovementWander" to="MovementWander/TiredTimer" method="stop"]
|
||||
[connection signal="move_enabled" from="MovementWander" to="." method="_on_wander_enabled"]
|
||||
[connection signal="move_enabled" from="MovementWander" to="MovementWander/TiredTimer" method="start"]
|
||||
[connection signal="move_enabled" from="MovementWander" to="Animator" method="play" binds= [&"run"]]
|
||||
[connection signal="timeout" from="MovementWander/TiredTimer" to="MovementWander/WanderPriority" method="priority_default"]
|
||||
[connection signal="timeout" from="MovementWander/TiredTimer" to="MovementWander/TiredTimer" method="randomize_wait_time"]
|
||||
[connection signal="area_entered" from="MovementWander/TrackerMeat" to="MovementWander/TrackerMeat" method="check_diet_then_track"]
|
||||
[connection signal="area_exited" from="MovementWander/TrackerMeat" to="MovementWander/TrackerMeat" method="untrack"]
|
||||
[connection signal="tracked" from="MovementWander/TrackerMeat" to="MovementWander/TrackerMeat/TargetPicker" method="sample_target_if_null" unbinds=1]
|
||||
[connection signal="untracked" from="MovementWander/TrackerMeat" to="MovementWander/TrackerMeat/TargetPicker" method="clear_if_target"]
|
||||
[connection signal="target_changed" from="MovementWander/TrackerMeat/TargetPicker" to="MovementWander/TrackerMeat/TargetPicker" method="sample_target_if_null" unbinds=2]
|
||||
[connection signal="cursor_entered" from="MovementWander/CursorSense" to="MovementWander/WanderPriority" method="priority_alternative" unbinds=1]
|
||||
[connection signal="changed_target" from="MovementTrap" to="MovementTrap/TrapPriority" method="priority_conditional"]
|
||||
[connection signal="move" from="MovementTrap" to="." method="_on_move"]
|
||||
[connection signal="move_disabled" from="MovementTrap" to="." method="_on_freed"]
|
||||
|
|
|
@ -281,7 +281,7 @@ min_secs = 0.6
|
|||
max_secs = 3.0
|
||||
|
||||
[node name="MovementHunt" parent="." instance=ExtResource("11_4ra22")]
|
||||
speed = 140.0
|
||||
speed = 110.0
|
||||
enabled = false
|
||||
|
||||
[node name="HuntPriority" parent="MovementHunt" instance=ExtResource("9_2wb1b")]
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
[ext_resource type="PackedScene" uid="uid://bc2bm8lbol18w" path="res://entities/sheep.tscn" id="4_7isfg"]
|
||||
[ext_resource type="PackedScene" uid="uid://8jkesanu4hrn" path="res://behaviours/tracker.tscn" id="5_ewy4o"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_j2mj5"]
|
||||
radius = 48.0
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_6ky4x"]
|
||||
radius = 8.0
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_dc2ul"]
|
||||
radius = 8.0
|
||||
|
@ -19,7 +19,7 @@ collision_mask = 56
|
|||
script = ExtResource("1_1og6v")
|
||||
|
||||
[node name="Shape" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_j2mj5")
|
||||
shape = SubResource("CircleShape2D_6ky4x")
|
||||
debug_color = Color(0, 0.411765, 0, 0)
|
||||
|
||||
[node name="GoldDisplay" parent="." instance=ExtResource("2_5c4iq")]
|
||||
|
|
Loading…
Reference in a new issue