mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 09:45:33 +00:00
55 lines
No EOL
1.3 KiB
C#
55 lines
No EOL
1.3 KiB
C#
using Godot;
|
|
|
|
namespace Cirno.Scripts.Weapons;
|
|
|
|
public partial class WeaponSoundModule3D : Node
|
|
{
|
|
[Export] public Weapon3D Weapon { get; private set; }
|
|
|
|
[Export] public AudioStreamPlayer3D ShootSound { get; private set; }
|
|
[Export] public AudioStreamPlayer3D ReloadSound { get; private set; }
|
|
[Export] public AudioStreamPlayer3D EmptySound { get; private set; }
|
|
|
|
public override void _Ready()
|
|
{
|
|
Weapon.Initialized += WeaponOnInitialized;
|
|
}
|
|
|
|
private void WeaponOnInitialized()
|
|
{
|
|
if (Weapon?.WeaponData is null) return;
|
|
|
|
if (Weapon.WeaponData.ShootSound is not null)
|
|
{
|
|
ShootSound.Stream = Weapon.WeaponData.ShootSound;
|
|
Weapon.Shooting += WeaponOnShooting;
|
|
}
|
|
|
|
if (Weapon.WeaponData.ReloadSound is not null)
|
|
{
|
|
ReloadSound.Stream = Weapon.WeaponData.ReloadSound;
|
|
Weapon.Reloading += WeaponOnReloading;
|
|
}
|
|
|
|
if (Weapon.WeaponData.EmptySound is not null)
|
|
{
|
|
EmptySound.Stream = Weapon.WeaponData.EmptySound;
|
|
Weapon.Empty += WeaponOnEmpty;
|
|
}
|
|
}
|
|
|
|
private void WeaponOnEmpty()
|
|
{
|
|
EmptySound.Play();
|
|
}
|
|
|
|
private void WeaponOnReloading()
|
|
{
|
|
ReloadSound.Play();
|
|
}
|
|
|
|
private void WeaponOnShooting()
|
|
{
|
|
ShootSound.Play();
|
|
}
|
|
} |