Done with Audio Implementation via C# #347

Merged
mushgunAX merged 14 commits from AudioImplementation into main 2023-02-04 10:18:26 +08:00
6 changed files with 57 additions and 12 deletions
Showing only changes of commit 1d0522e334 - Show all commits

View File

@ -0,0 +1,16 @@
using SHADE;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SHADE_Scripting.Audio
{
public static class AudioHandler
{
public static Dictionary<string, AudioClipHandler> audioClipHandlers = new Dictionary<string, AudioClipHandler>();
//Functions here, maybe
}
}

View File

@ -0,0 +1,3 @@
Name: AudioHandler
ID: 159235425
Type: 9

View File

@ -14,6 +14,7 @@
using SHADE;
using SHADE_Scripting.AIBehaviour.BehaviourTree;
using SHADE_Scripting.Audio;
using System;
using System.Collections.Generic;
using System.Linq;
@ -99,6 +100,23 @@ public partial class Homeowner1 : BehaviourTree
SetData("turningSpeed", turningSpeed);
SetData("distanceToCapture", distanceToCapture);
SetData("baseCaptureTime", captureTime);*/
//These should be somewhere else
AudioHandler.audioClipHandlers["BGMUnalert"] = Audio.CreateAudioClip("event:/Music/player_undetected");
Audio.AddAudioClipToBGMChannelGroup(AudioHandler.audioClipHandlers["BGMUnalert"]);
AudioHandler.audioClipHandlers["BGMAlert"] = Audio.CreateAudioClip("event:/Music/player_detected");
Audio.AddAudioClipToBGMChannelGroup(AudioHandler.audioClipHandlers["BGMAlert"]);
AudioHandler.audioClipHandlers["SFXHumming"] = Audio.CreateAudioClip("event:/Homeowner/homeowner_humming");
Audio.AddAudioClipToSFXChannelGroup(AudioHandler.audioClipHandlers["SFXHumming"]);
AudioHandler.audioClipHandlers["SFXFootstep"] = Audio.CreateAudioClip("event:/Homeowner/homeowner_footsteps");
Audio.AddAudioClipToSFXChannelGroup(AudioHandler.audioClipHandlers["SFXFootstep"]);
AudioHandler.audioClipHandlers["SFXDetectAh"] = Audio.CreateAudioClip("event:/Homeowner/homeowner_detect_raccoon");
Audio.AddAudioClipToSFXChannelGroup(AudioHandler.audioClipHandlers["SFXDetectAh"]);
AudioHandler.audioClipHandlers["SFXDetectSting"] = Audio.CreateAudioClip("event:/Music/stingers/player_detected");
Audio.AddAudioClipToSFXChannelGroup(AudioHandler.audioClipHandlers["SFXDetectSting"]);
}
//Called every tick
@ -132,7 +150,6 @@ public partial class Homeowner1 : BehaviourTree
if (GetData("baseCaptureTime") == null || (float)GetData("baseCaptureTime") != captureTime)
SetData("baseCaptureTime", captureTime);
events.Tick();
//Footsteps SFX, move them somewhere else soon
@ -142,6 +159,7 @@ public partial class Homeowner1 : BehaviourTree
if (footstepTimeRemaining < 0.0f)
{
Audio.PlaySFXOnce2D("event:/Homeowner/homeowner_footsteps");
AudioHandler.audioClipHandlers["SFXFootstep"].Play();
footstepTimeRemaining = footstepSFXIntervalMultiplier;
}
//Debug.Log("Ticked");

View File

@ -11,6 +11,7 @@
using SHADE;
using SHADE_Scripting.AIBehaviour.BehaviourTree;
using SHADE_Scripting.Audio;
using System;
using System.Collections.Generic;
using System.Linq;
@ -111,7 +112,7 @@ public partial class LeafChase : BehaviourTreeNode
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == true)
{
Audio.PlaySFXOnce2D("event:/Homeowner/humming");
AudioHandler.audioClipHandlers["SFXHumming"].Play();
}
SetNodeData("isAlert", false);

View File

@ -11,6 +11,7 @@
using SHADE;
using SHADE_Scripting.AIBehaviour.BehaviourTree;
using SHADE_Scripting.Audio;
using System;
using System.Collections.Generic;
using System.Linq;
@ -239,9 +240,10 @@ public partial class LeafPatrol : BehaviourTreeNode
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert"))
{
//Debug.Log("Unalert");
Audio.PlaySFXOnce2D("event:/Homeowner/humming");
Audio.StopAllSounds();
Audio.PlayBGMOnce2D("event:/Music/player_undetected");
AudioHandler.audioClipHandlers["BGMAlert"].Stop(true);
//Audio.PlaySFXOnce2D("event:/Homeowner/humming");
AudioHandler.audioClipHandlers["SFXHumming"].Play();
AudioHandler.audioClipHandlers["BGMUnalert"].Play();
}
SetNodeData("isAlert", false);
}

View File

@ -11,6 +11,7 @@
using SHADE;
using SHADE_Scripting.AIBehaviour.BehaviourTree;
using SHADE_Scripting.Audio;
using System;
using System.Collections.Generic;
using System.Linq;
@ -65,7 +66,7 @@ public partial class LeafSearch : BehaviourTreeNode
{
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == true)
{
Audio.PlaySFXOnce2D("event:/Homeowner/humming");
AudioHandler.audioClipHandlers["SFXHumming"].Play();
reevaluateWaypoint();
}
SetNodeData("isAlert", false);
@ -185,19 +186,23 @@ public partial class LeafSearch : BehaviourTreeNode
if (GetNodeData("isAlert") == null)
{
SetNodeData("isAlert", true);
Audio.PlaySFXOnce2D("event:/Homeowner/homeowner_detect_raccoon");
Audio.PlaySFXOnce2D("event:/Music/stingers/player_detected");
Audio.StopAllSounds();
Audio.PlayBGMOnce2D("event:/Music/player_detected");
AudioHandler.audioClipHandlers["SFXDetectAh"].Play();
AudioHandler.audioClipHandlers["SFXDetectSting"].Play();
AudioHandler.audioClipHandlers["BGMAlert"].Play();
AudioHandler.audioClipHandlers["SFXHumming"].Stop(false);
AudioHandler.audioClipHandlers["BGMUnalert"].Stop(true);
}
else
{
if (GetNodeData("isAlert") != null && (bool)GetNodeData("isAlert") == false)
{
Audio.PlaySFXOnce2D("event:/Homeowner/homeowner_detect_raccoon");
Audio.PlaySFXOnce2D("event:/Music/stingers/player_detected");
Audio.StopAllSounds();
Audio.PlayBGMOnce2D("event:/Music/player_detected");
AudioHandler.audioClipHandlers["SFXDetectAh"].Play();
AudioHandler.audioClipHandlers["SFXDetectSting"].Play();
AudioHandler.audioClipHandlers["BGMAlert"].Play();
AudioHandler.audioClipHandlers["SFXHumming"].Stop(false);
AudioHandler.audioClipHandlers["BGMUnalert"].Stop(true);
}
SetNodeData("isAlert", true);
}