59 lines
1.2 KiB
C#
59 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace DarkTonic.MasterAudio
|
|
{
|
|
[Serializable]
|
|
public class RealTimeParameterCommandTracker
|
|
{
|
|
public bool IsActive;
|
|
|
|
public ParameterCommand ParameterCommand;
|
|
|
|
public Transform Actor;
|
|
|
|
public List<PlaySoundResult> ElementResults = new List<PlaySoundResult>(2);
|
|
|
|
public Guid InstanceId = Guid.Empty;
|
|
|
|
public float? TimeInvoked;
|
|
|
|
public void Reset(bool stopElements = false)
|
|
{
|
|
if (stopElements)
|
|
{
|
|
for (int i = 0; i < ElementResults.Count; i++)
|
|
{
|
|
PlaySoundResult playSoundResult = ElementResults[i];
|
|
if (playSoundResult != null)
|
|
{
|
|
SoundGroupVariation actingVariation = playSoundResult.ActingVariation;
|
|
if (!(actingVariation == null))
|
|
{
|
|
actingVariation.Stop();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
IsActive = false;
|
|
ParameterCommand = null;
|
|
Actor = null;
|
|
ElementResults.Clear();
|
|
InstanceId = Guid.Empty;
|
|
TimeInvoked = null;
|
|
}
|
|
|
|
public Guid ActivateAndGetInstanceId(ParameterCommand cmd, Transform originObject)
|
|
{
|
|
IsActive = true;
|
|
ParameterCommand = cmd;
|
|
Actor = originObject;
|
|
InstanceId = Guid.NewGuid();
|
|
TimeInvoked = Time.realtimeSinceStartup;
|
|
cmd.NumberOfTimesInvoked++;
|
|
return InstanceId;
|
|
}
|
|
}
|
|
}
|