43 lines
683 B
C#
43 lines
683 B
C#
|
|
using System;
|
|
using Godot;
|
|
|
|
|
|
namespace Rokojori;
|
|
|
|
[Tool]
|
|
[GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Tween.svg")]
|
|
public partial class ScheduleMusic:SequenceAction
|
|
{
|
|
[Export]
|
|
public float duration = 0;
|
|
|
|
[Export]
|
|
public MusicData musicData;
|
|
|
|
[Export]
|
|
public MusicChannel channel;
|
|
|
|
|
|
protected override void _OnTrigger()
|
|
{
|
|
this.LogInfo( "Scheduling:", musicData );
|
|
var id = DispatchStart();
|
|
|
|
var audioManager = Unique<AudioManager>.Get();
|
|
var player = audioManager.GetPlayer( channel );
|
|
|
|
player.SchedulePlayer(
|
|
musicData, Mathf.Max( 0.0f, duration), ()=>
|
|
{
|
|
DispatchEnd( id );
|
|
}
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|