potato mine not exploding fix

This commit is contained in:
Rendo 2025-07-17 13:11:19 +05:00
commit 2987fc2604
2 changed files with 21 additions and 10 deletions

View file

@ -65,17 +65,17 @@ nodes/Tree/node = SubResource("AnimationNodeStateMachine_nfn7b")
nodes/Tree/position = Vector2(-260, 140) nodes/Tree/position = Vector2(-260, 140)
node_connections = [&"TimeScale", 0, &"Tree", &"output", 0, &"TimeScale"] node_connections = [&"TimeScale", 0, &"Tree", &"output", 0, &"TimeScale"]
[sub_resource type="CircleShape2D" id="CircleShape2D_v0g5b"] [sub_resource type="CircleShape2D" id="CircleShape2D_824aq"]
radius = 19.0263 radius = 17.0
[sub_resource type="CircleShape2D" id="CircleShape2D_wvns6"] [sub_resource type="CircleShape2D" id="CircleShape2D_wvns6"]
radius = 19.0263 radius = 25.0
[sub_resource type="RectangleShape2D" id="RectangleShape2D_qfqko"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_qfqko"]
size = Vector2(15, 27) size = Vector2(15, 27)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ti2g4"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_ti2g4"]
size = Vector2(34, 19) size = Vector2(22, 19)
[node name="Potato mine" instance=ExtResource("1_dj7ul")] [node name="Potato mine" instance=ExtResource("1_dj7ul")]
MaxHP = 20.0 MaxHP = 20.0
@ -84,7 +84,7 @@ MaxHP = 20.0
texture = ExtResource("2_sneas") texture = ExtResource("2_sneas")
hframes = 7 hframes = 7
vframes = 4 vframes = 4
frame = 7 frame = 8
[node name="AnimationPlayer" parent="." index="1"] [node name="AnimationPlayer" parent="." index="1"]
libraries = { libraries = {
@ -104,7 +104,7 @@ collision_mask = 8
[node name="CollisionShape2D" type="CollisionShape2D" parent="Detectionbox" index="0"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Detectionbox" index="0"]
position = Vector2(0, 9) position = Vector2(0, 9)
shape = SubResource("CircleShape2D_v0g5b") shape = SubResource("CircleShape2D_824aq")
[node name="ExplosionBox" type="Area2D" parent="." index="4"] [node name="ExplosionBox" type="Area2D" parent="." index="4"]
collision_layer = 0 collision_layer = 0
@ -130,9 +130,10 @@ autostart = true
script = ExtResource("8_824aq") script = ExtResource("8_824aq")
entity = NodePath("..") 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") script = ExtResource("4_twx65")
_hitbox = NodePath("../Hitbox") _hitbox = NodePath("../Hitbox")
detectionBox = NodePath("../Detectionbox")
_unprimedShape = NodePath("../Hitbox/Unprimed") _unprimedShape = NodePath("../Hitbox/Unprimed")
_primedShape = NodePath("../Hitbox/Primed") _primedShape = NodePath("../Hitbox/Primed")

View file

@ -5,24 +5,34 @@ namespace Newlon.Components.Plants.Behaviours;
public partial class PotatomineBehaviour : BaseBehaviour public partial class PotatomineBehaviour : BaseBehaviour
{ {
[Export] private Area2D _hitbox; [Export] private Area2D _hitbox;
[Export] private Area2D detectionBox;
[Export] private CollisionShape2D _unprimedShape; [Export] private CollisionShape2D _unprimedShape;
[Export] private CollisionShape2D _primedShape; [Export] private CollisionShape2D _primedShape;
private bool _primed = false; private bool _primed = false;
public void Prime() public void Prime()
{ {
_tree.Set("parameters/Tree/conditions/primed",true); _tree.Set("parameters/Tree/conditions/primed", true);
_hitbox.Monitorable = false; _hitbox.Monitorable = false;
_primed = true; _primed = true;
_unprimedShape.Disabled = true; _unprimedShape.Disabled = true;
_primedShape.Disabled = false; _primedShape.Disabled = false;
if (detectionBox.HasOverlappingAreas())
{
SetupExplosion();
}
} }
public void OnAreaEntered(Area2D area) public void OnAreaEntered(Area2D area)
{ {
if (_primed == false) return; if (_primed == false) return;
_tree.Set("parameters/Tree/conditions/explode",true); SetupExplosion();
}
private void SetupExplosion()
{
_tree.Set("parameters/Tree/conditions/explode", true);
_primed = false; _primed = false;
} }
} }