Movement refactor

This commit is contained in:
2025-08-30 23:06:12 +02:00
committed by GitHub
parent d786ef4c22
commit 88c7a0a055
41 changed files with 656 additions and 122 deletions

View File

@@ -0,0 +1,29 @@
using Godot;
namespace Mr.BrickAdventures.scripts.components;
[GlobalClass]
public partial class PlayerSfxComponent : Node
{
[Export] public AudioStreamPlayer2D JumpSfx { get; set; }
private PlayerController _controller;
public override void _Ready()
{
_controller = GetOwner<PlayerController>();
if (_controller == null)
{
GD.PrintErr("PlayerSfxComponent must be a child of a PlayerController.");
SetProcess(false);
}
_controller.JumpInitiated += OnJumpInitiated;
}
private void OnJumpInitiated()
{
if (JumpSfx is { Playing: false })
JumpSfx.Play();
}
}