cirnogodot/Scripts/Weapons/WeaponSoundModule.cs
2025-04-08 17:59:20 +02:00

40 lines
No EOL
903 B
C#

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();
}
}