rokojori_action_library/Runtime/Actions/Audio/PlayMusic.cs

51 lines
909 B
C#
Raw Normal View History

2025-07-22 14:08:22 +00:00
using Godot;
using System.Collections.Generic;
namespace Rokojori
{
[Tool][GlobalClass]
public partial class PlayMusic:Action
{
[Export]
public AudioStreamPlayer music;
2025-12-18 10:29:54 +00:00
[ExportToolButton( "Set Reference Name" )]
public Callable setReferencedNameButton => Callable.From(
()=>
{
if ( music == null )
{
this.Name = "Play (nothing)";
}
else
{
this.Name = "Play " + music.Name;
}
}
);
2025-07-22 14:08:22 +00:00
[Export]
public bool stopSiblingPlayers = false;
protected override void _OnTrigger()
{
if ( stopSiblingPlayers )
{
2025-12-11 14:47:57 +00:00
music.GetParent().ForEachDirectChild<AudioStreamPlayer>(
2025-07-22 14:08:22 +00:00
( p )=>
{
if ( p == music )
{
return;
}
p.Stop();
}
);
}
music.Play();
}
}
}