cirnogodot/Scripts/Weapons/WeaponSoundModule.cs

40 lines
895 B
C#
Raw Normal View History

2025-04-08 17:59:20 +02:00
using Godot;
namespace Cirno.Scripts.Weapons;
2025-06-18 15:16:43 +02:00
public partial class WeaponSoundModule : Node
2025-04-08 17:59:20 +02:00
{
[Export]
public Weapon Weapon { get; private set; }
[Export]
2025-06-18 15:16:43 +02:00
public AudioStreamPlayer ShootSound { get; private set; }
2025-04-08 17:59:20 +02:00
[Export]
2025-06-18 15:16:43 +02:00
public AudioStreamPlayer ReloadSound { get; private set; }
2025-04-08 17:59:20 +02:00
[Export]
2025-06-18 15:16:43 +02:00
public AudioStreamPlayer EmptySound { get; private set; }
2025-04-08 17:59:20 +02:00
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();
}
}