Weapon sounds

This commit is contained in:
Marco 2025-04-08 17:59:20 +02:00
commit 3c531bbe04
14 changed files with 174 additions and 52 deletions

View file

@ -0,0 +1,40 @@
using Godot;
namespace Cirno.Scripts.Weapons;
public partial class WeaponSoundModule : Node2D
{
[Export]
public Weapon Weapon { get; private set; }
[Export]
public AudioStreamPlayer2D ShootSound { get; private set; }
[Export]
public AudioStreamPlayer2D ReloadSound { get; private set; }
[Export]
public AudioStreamPlayer2D EmptySound { get; private set; }
public override void _Ready()
{
if (Weapon?.WeaponData is null) return;
ShootSound.Stream = Weapon.WeaponData.ShootSound;
ReloadSound.Stream = Weapon.WeaponData.ReloadSound;
EmptySound.Stream = Weapon.WeaponData.EmptySound;
}
public void PlayReloadSound()
{
ReloadSound?.Play();
}
public void PlayShootSound()
{
ShootSound?.Play();
}
public void PlayEmptySound()
{
EmptySound?.Play();
}
}