dash hits enemies now

This commit is contained in:
Lilith Schier 2026-07-20 21:06:35 +02:00
parent 26c0c2c9a7
commit 1ba24d1faf
3 changed files with 36 additions and 17 deletions

View file

@ -26,7 +26,6 @@ public sealed partial class Hitbox : Area2D
{
BodyEntered += OnEntered;
BodyExited += OnLeft;
SetPhysicsProcess(true);
}
public void OnResolved() => HitboxOwner.OnHitboxAdded(this);
@ -68,14 +67,15 @@ public sealed partial class Hitbox : Area2D
{
if (Engine.IsEditorHint()) Visible = true;
_checkingForHits = true;
foreach (var immunityEntry in _immunityEntries.Values)
immunityEntry.HitCount = 0;
SetPhysicsProcess(true);
}
public void StopAttack()
{
if (Engine.IsEditorHint()) Visible = false;
_checkingForHits = false;
_immunityEntries.Clear();
SetPhysicsProcess(false);
}
private sealed class ImmunityEntry

View file

@ -88,6 +88,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
[Node] private AnimationTree AnimationTree { get; set; } = null!;
[Node] private Area2D SubmersedSensor { get; set; } = null!;
[Node] private Hitbox DashHitbox { get; set; } = null!;
public void OnReady()
{
@ -140,7 +141,11 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
if (CanTurn) AdjustFacing();
if (DashTicker.HasFinishedLastTick) velocity *= 0.6f;
if (DashTicker.HasFinishedLastTick)
{
velocity *= 0.6f;
DashHitbox.StopAttack();
}
if (DashTicker.IsRunning)
{
@ -230,9 +235,9 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
if (IsOnCeiling()) JumpTicker.Reset();
}
public void EnteredWater(Node2D body) => IsInWater = true;
public void OnEnteredWater(Node2D body) => IsInWater = true;
public void LeftWater(Node2D body)
public void OnLeftWater(Node2D body)
{
if (!IsInWater || SubmersedSensor.HasOverlappingBodies()) return;
IsInWater = false;
@ -406,6 +411,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
? FacingVector
: _currentDirection
).Normalized();
DashHitbox.StartAttack();
}
private static Vector2 To8DirectionVector(Vector2 input)

View file

@ -12,7 +12,7 @@ size = Vector2(8, 28)
size = Vector2(8, 12)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_244u8"]
size = Vector2(27.5, 20)
size = Vector2(14, 32)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_5f2sf"]
size = Vector2(13.59375, 20)
@ -48,7 +48,7 @@ tracks/1/keys = {
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("Body/FrontKickHitBox/CollisionShape2D:disabled")
tracks/2/path = NodePath("Body/FrontKickHitbox/CollisionShape2D:disabled")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
@ -60,7 +60,7 @@ tracks/2/keys = {
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("Body/FrontKickHitBox/CollisionShape2D2:disabled")
tracks/3/path = NodePath("Body/FrontKickHitbox/CollisionShape2D2:disabled")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
@ -101,7 +101,7 @@ tracks/1/keys = {
tracks/2/type = "method"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("Body/FrontKickHitBox")
tracks/2/path = NodePath("Body/FrontKickHitbox")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
@ -118,7 +118,7 @@ tracks/2/keys = {
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("Body/FrontKickHitBox/CollisionShape2D:disabled")
tracks/3/path = NodePath("Body/FrontKickHitbox/CollisionShape2D:disabled")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
@ -130,7 +130,7 @@ tracks/3/keys = {
tracks/4/type = "value"
tracks/4/imported = false
tracks/4/enabled = true
tracks/4/path = NodePath("Body/FrontKickHitBox/CollisionShape2D2:disabled")
tracks/4/path = NodePath("Body/FrontKickHitbox/CollisionShape2D2:disabled")
tracks/4/interp = 1
tracks/4/loop_wrap = true
tracks/4/keys = {
@ -350,23 +350,36 @@ metadata/_aseprite_wizard_source_file_hash_ = "61168df4a163c039cfaab97f4fccb905"
unique_name_in_owner = true
position = Vector2(0, -14)
[node name="FrontKickHitBox" type="Area2D" parent="Body" unique_id=1918418417]
[node name="FrontKickHitbox" type="Area2D" parent="Body" unique_id=1918418417]
visible = false
position = Vector2(0, -16)
collision_layer = 8
collision_mask = 4
script = ExtResource("4_244u8")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Body/FrontKickHitBox" unique_id=2048987579]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Body/FrontKickHitbox" unique_id=2048987579]
position = Vector2(5, 7)
shape = SubResource("RectangleShape2D_244u8")
debug_color = Color(0.99430805, 0, 0.2314094, 0.41960785)
[node name="CollisionShape2D2" type="CollisionShape2D" parent="Body/FrontKickHitBox" unique_id=734742131]
[node name="CollisionShape2D2" type="CollisionShape2D" parent="Body/FrontKickHitbox" unique_id=734742131]
position = Vector2(16, -2)
shape = SubResource("RectangleShape2D_5f2sf")
debug_color = Color(0.99430805, 0, 0.2314094, 0.41960785)
[node name="DashHitbox" type="Area2D" parent="Body" unique_id=45996338]
unique_name_in_owner = true
visible = false
position = Vector2(0, -16)
collision_layer = 8
collision_mask = 4
script = ExtResource("4_244u8")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Body/DashHitbox" unique_id=2040304054]
position = Vector2(5, 0)
shape = SubResource("RectangleShape2D_244u8")
debug_color = Color(0.99430805, 0, 0.2314094, 0.41960785)
[node name="AnimationPlayer" type="AnimationPlayer" parent="." unique_id=1251324400]
libraries/ = SubResource("AnimationLibrary_rgyib")
@ -378,5 +391,5 @@ tree_root = SubResource("AnimationNodeStateMachine_yllr7")
advance_expression_base_node = NodePath("../..")
anim_player = NodePath("..")
[connection signal="body_entered" from="SubmersedSensor" to="." method="EnteredWater"]
[connection signal="body_exited" from="SubmersedSensor" to="." method="LeftWater"]
[connection signal="body_entered" from="SubmersedSensor" to="." method="OnEnteredWater"]
[connection signal="body_exited" from="SubmersedSensor" to="." method="OnLeftWater"]