using UnityEngine;
using ORKFramework;
using ORKFramework.Menu;
using ORKFramework.Reflection;
using ORKFramework.Behaviours;
using System.Collections.Generic;
using DarkTonic.MasterAudio;
namespace ORKFramework.Events.Steps
{
[ORKEditorHelp("MasterAudio PlaySound", "PlaysMaster Audio Sounds", "")]
[ORKEventStep(typeof(BaseEvent))]
[ORKNodeInfo("MasterAudio")]
public class MasterAudioPlaySoundStep : BaseEventStep
{
[ORKEditorHelp("SoundGroup Name", "The name of the MasterAudio SoundGroup to Play.\n", "")]
[ORKEditorInfo(expandWidth = true, labelText = "SoundGroup Name")]
public StringValue SoundGroupName = new StringValue();
[ORKEditorHelp("Play Once and Forget", "Same as PlaySound, but does not return a PlaySoundResult object so it has 0 bytes of GC Allocation.\n", "")]
[ORKEditorInfo(labelText = "Play Once and Forget")]
public bool OnceAndForget;
[ORKEditorHelp("Play At Vector3Position", "Plays Sound at defined Vector3 position", "")]
[ORKEditorInfo(labelText = "Play At Vector3Position")]
public bool PlayAtVector3Position;
[ORKEditorLayout("PlayAtVector3Position", true, endCheckGroup = true, autoInit = true)]
[ORKEditorInfo(labelText = "Vector3 Position")]
public Vector3Value Vector3 = new Vector3Value();
[ORKEditorHelp("PlayAtTransformPosition", "Plays Sound at defined Transform position", "")]
[ORKEditorInfo(expandWidth = true, labelText = "Play at Transform Position")]
public bool PlayAtTransformPosition;
[ORKEditorLayout("PlayAtTransformPosition", true, endCheckGroup = true, autoInit = true)]
[ORKEditorInfo(labelText = "Transform")]
public EventObjectSetting Transform = new EventObjectSetting();
[ORKEditorLayout("PlayAtTransformPosition", true, endCheckGroup = true, autoInit = true)]
[ORKEditorInfo(labelText = "Follow Transform With Sound")]
public bool Follow = false;
[ORKEditorHelp("SetParameters", "", "")]
public bool SetParameters = false;
[ORKEditorLayout("SetParameters", true, endCheckGroup = true, autoInit = true)]
[ORKEditorInfo(labelText = "Volume Percentage")]
public EventFloat VolumePercentage = new EventFloat();
[ORKEditorLayout("SetParameters", true, endCheckGroup = true, autoInit = true)]
[ORKEditorInfo(labelText = "Pitch")]
public EventFloat Pitch = new EventFloat();
[ORKEditorLayout("SetParameters", true, endCheckGroup = true, autoInit = true)]
[ORKEditorInfo(labelText = "DelaySoundTime")]
public EventFloat DelaySoundTime = new EventFloat();
[ORKEditorLayout("SetParameters", true, endCheckGroup = true, autoInit = true)]
[ORKEditorInfo(labelText = "VariationName")]
public StringValue VariationName = new StringValue();
private List<GameObject> TransformsList;
public MasterAudioPlaySoundStep()
{
}
public override void Execute(BaseEvent baseEvent)
{
this.TransformsList = this.Transform.GetObject(baseEvent);
if (PlayAtVector3Position)
{
if (OnceAndForget)
{
if (SetParameters)
MasterAudio.PlaySound3DAtVector3AndForget(SoundGroupName.GetValue(), Vector3.GetValue(), VolumePercentage.GetValue(baseEvent), Pitch.GetValue(baseEvent), DelaySoundTime.GetValue(baseEvent), VariationName.GetValue());
else
MasterAudio.PlaySound3DAtVector3AndForget(SoundGroupName.GetValue(), Vector3.GetValue());
}
else
{
if (SetParameters)
MasterAudio.PlaySound3DAtVector3(SoundGroupName.GetValue(), Vector3.GetValue(), VolumePercentage.GetValue(baseEvent), Pitch.GetValue(baseEvent), DelaySoundTime.GetValue(baseEvent), VariationName.GetValue());
else
MasterAudio.PlaySound3DAtVector3(SoundGroupName.GetValue(), Vector3.GetValue());
}
}
if (PlayAtTransformPosition)
{
for (int i = 0; i < TransformsList.Count; i++)
{
if (OnceAndForget)
{
if (SetParameters)
{
if (Follow)
MasterAudio.PlaySound3DFollowTransformAndForget(SoundGroupName.GetValue(), TransformsList[i].transform, VolumePercentage.GetValue(baseEvent), Pitch.GetValue(baseEvent), DelaySoundTime.GetValue(baseEvent), VariationName.GetValue());
else
MasterAudio.PlaySound3DAtTransformAndForget(SoundGroupName.GetValue(), TransformsList[i].transform, VolumePercentage.GetValue(baseEvent), Pitch.GetValue(baseEvent), DelaySoundTime.GetValue(baseEvent), VariationName.GetValue());
}
else
{
if (Follow)
MasterAudio.PlaySound3DFollowTransformAndForget(SoundGroupName.GetValue(), TransformsList[i].transform);
else
MasterAudio.PlaySound3DAtTransformAndForget(SoundGroupName.GetValue(), TransformsList[i].transform);
}
}
else
{
if (SetParameters)
{
if (Follow)
MasterAudio.PlaySound3DFollowTransform(SoundGroupName.GetValue(), TransformsList[i].transform, VolumePercentage.GetValue(baseEvent), Pitch.GetValue(baseEvent), DelaySoundTime.GetValue(baseEvent), VariationName.GetValue());
else
MasterAudio.PlaySound3DAtTransform(SoundGroupName.GetValue(), TransformsList[i].transform, VolumePercentage.GetValue(baseEvent), Pitch.GetValue(baseEvent), DelaySoundTime.GetValue(baseEvent), VariationName.GetValue());
}
else
{
if (Follow)
MasterAudio.PlaySound3DFollowTransform(SoundGroupName.GetValue(), TransformsList[i].transform);
else
MasterAudio.PlaySound3DAtTransform(SoundGroupName.GetValue(), TransformsList[i].transform);
}
}
}
}
if (!PlayAtVector3Position && !PlayAtTransformPosition)
{
if (OnceAndForget)
{
if (SetParameters)
MasterAudio.PlaySoundAndForget(SoundGroupName.GetValue(), VolumePercentage.GetValue(baseEvent), Pitch.GetValue(baseEvent), DelaySoundTime.GetValue(baseEvent), VariationName.GetValue());
else
MasterAudio.PlaySoundAndForget(SoundGroupName.GetValue());
}
else
{
if (SetParameters)
MasterAudio.PlaySound(SoundGroupName.GetValue(), VolumePercentage.GetValue(baseEvent), Pitch.GetValue(baseEvent), DelaySoundTime.GetValue(baseEvent), VariationName.GetValue());
else
MasterAudio.PlaySound(SoundGroupName.GetValue());
}
}
baseEvent.StepFinished(this.next);
}
/*
============================================================================
Node name functions
============================================================================
*/
public override string GetNodeDetails()
{
return "";
}
}
}
It looks like you're new here. If you want to get involved, click one of these buttons!
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!