diff --git a/scenes/entities/plants/potato_mine.tscn b/scenes/entities/plants/potato_mine.tscn index d7d3e1f..228901e 100644 --- a/scenes/entities/plants/potato_mine.tscn +++ b/scenes/entities/plants/potato_mine.tscn @@ -65,17 +65,17 @@ nodes/Tree/node = SubResource("AnimationNodeStateMachine_nfn7b") nodes/Tree/position = Vector2(-260, 140) node_connections = [&"TimeScale", 0, &"Tree", &"output", 0, &"TimeScale"] -[sub_resource type="CircleShape2D" id="CircleShape2D_v0g5b"] -radius = 19.0263 +[sub_resource type="CircleShape2D" id="CircleShape2D_824aq"] +radius = 17.0 [sub_resource type="CircleShape2D" id="CircleShape2D_wvns6"] -radius = 19.0263 +radius = 25.0 [sub_resource type="RectangleShape2D" id="RectangleShape2D_qfqko"] size = Vector2(15, 27) [sub_resource type="RectangleShape2D" id="RectangleShape2D_ti2g4"] -size = Vector2(34, 19) +size = Vector2(22, 19) [node name="Potato mine" instance=ExtResource("1_dj7ul")] MaxHP = 20.0 @@ -84,7 +84,7 @@ MaxHP = 20.0 texture = ExtResource("2_sneas") hframes = 7 vframes = 4 -frame = 7 +frame = 8 [node name="AnimationPlayer" parent="." index="1"] libraries = { @@ -104,7 +104,7 @@ collision_mask = 8 [node name="CollisionShape2D" type="CollisionShape2D" parent="Detectionbox" index="0"] position = Vector2(0, 9) -shape = SubResource("CircleShape2D_v0g5b") +shape = SubResource("CircleShape2D_824aq") [node name="ExplosionBox" type="Area2D" parent="." index="4"] collision_layer = 0 @@ -130,9 +130,10 @@ autostart = true script = ExtResource("8_824aq") entity = NodePath("..") -[node name="Behaviour" type="Node" parent="." index="6" node_paths=PackedStringArray("_hitbox", "_unprimedShape", "_primedShape")] +[node name="Behaviour" type="Node" parent="." index="6" node_paths=PackedStringArray("_hitbox", "detectionBox", "_unprimedShape", "_primedShape")] script = ExtResource("4_twx65") _hitbox = NodePath("../Hitbox") +detectionBox = NodePath("../Detectionbox") _unprimedShape = NodePath("../Hitbox/Unprimed") _primedShape = NodePath("../Hitbox/Primed") diff --git a/scripts/plants/behaviours/PotatomineBehaviour.cs b/scripts/plants/behaviours/PotatomineBehaviour.cs index 8f16553..fd28cc8 100644 --- a/scripts/plants/behaviours/PotatomineBehaviour.cs +++ b/scripts/plants/behaviours/PotatomineBehaviour.cs @@ -5,24 +5,34 @@ namespace Newlon.Components.Plants.Behaviours; public partial class PotatomineBehaviour : BaseBehaviour { [Export] private Area2D _hitbox; + [Export] private Area2D detectionBox; [Export] private CollisionShape2D _unprimedShape; [Export] private CollisionShape2D _primedShape; private bool _primed = false; public void Prime() { - _tree.Set("parameters/Tree/conditions/primed",true); + _tree.Set("parameters/Tree/conditions/primed", true); _hitbox.Monitorable = false; _primed = true; _unprimedShape.Disabled = true; _primedShape.Disabled = false; + + if (detectionBox.HasOverlappingAreas()) + { + SetupExplosion(); + } } - + public void OnAreaEntered(Area2D area) { if (_primed == false) return; - _tree.Set("parameters/Tree/conditions/explode",true); + SetupExplosion(); + } + private void SetupExplosion() + { + _tree.Set("parameters/Tree/conditions/explode", true); _primed = false; } }