-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
serialize sound collection instances in unity
- Loading branch information
1 parent
00f9c6d
commit 34540ea
Showing
83 changed files
with
745 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace SCHIZO.Interop.Subnautica; | ||
|
||
partial class _FMODAsset : FMODAsset; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using Nautilus.Utility; | ||
|
||
namespace SCHIZO.Sounds; | ||
|
||
public static class BusPathsExtensions | ||
{ | ||
public static string GetBusName(this BusPaths bus) | ||
{ | ||
return bus switch | ||
{ | ||
BusPaths.PDAVoice => AudioUtils.BusPaths.PDAVoice, | ||
BusPaths.UnderwaterCreatures => AudioUtils.BusPaths.UnderwaterCreatures, | ||
BusPaths.IndoorSounds => "bus:/master/SFX_for_pause/PDA_pause/all/indoorsounds", | ||
BusPaths.SFX => "bus:/master/SFX_for_pause/PDA_pause/all/SFX", | ||
_ => throw new ArgumentOutOfRangeException(nameof(bus), bus, null) | ||
}; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using Nautilus.Utility; | ||
|
||
namespace SCHIZO.Sounds.Collections; | ||
|
||
public sealed class SoundCollectionInstance : SoundCollection | ||
partial class SoundCollectionInstance | ||
{ | ||
private FMODSoundCollection _fmodSounds; | ||
private string _bus; | ||
|
||
public static SoundCollectionInstance Create(SoundCollection soundCollection, string bus) | ||
private void OnEnable() | ||
{ | ||
SoundCollectionInstance instance = CreateInstance<SoundCollectionInstance>(); | ||
instance._fmodSounds = FMODSoundCollection.For(soundCollection, bus); | ||
instance._bus = bus; | ||
return instance; | ||
_fmodSounds = FMODSoundCollection.For(collection, bus.GetBusName()); | ||
path = id = new Guid().ToString(); | ||
} | ||
|
||
[Obsolete("SoundCollectionInstance does not need to be initialized", true)] | ||
public override SoundCollectionInstance Initialize(string bus) | ||
{ | ||
if (_bus != bus) throw new InvalidOperationException($"SoundCollection {this} is already initialized with a different bus ({_bus} != {bus})"); | ||
return this; | ||
} | ||
|
||
public override float LastPlay => _fmodSounds.LastPlay; | ||
public float LastPlay => _fmodSounds.LastPlay; | ||
|
||
public override void Play2D(float delay = 0) | ||
public void Play2D(float delay = 0) | ||
{ | ||
_fmodSounds.Play2D(delay); | ||
} | ||
|
||
public override void Play(FMOD_CustomEmitter emitter, float delay = 0) | ||
public void Play(FMOD_CustomEmitter emitter, float delay = 0) | ||
{ | ||
if (!emitter) throw new ArgumentNullException(nameof(emitter)); | ||
_fmodSounds.Play(emitter, delay); | ||
} | ||
|
||
public override void CancelAllDelayed() => _fmodSounds.CancelAllDelayed(); | ||
public void CancelAllDelayed() => _fmodSounds.CancelAllDelayed(); | ||
|
||
[Obsolete("SoundCollectionInstance does not support enumerating sounds", true)] | ||
public override IEnumerable<AudioClip> GetSounds() => throw new InvalidOperationException("SoundCollectionInstance does not support enumerating sounds"); | ||
public void Stop() => _fmodSounds.Stop(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,16 @@ | ||
using System; | ||
using SCHIZO.Helpers; | ||
|
||
namespace SCHIZO.Sounds.Players; | ||
|
||
partial class SoundPlayer | ||
{ | ||
protected virtual void Awake() | ||
public void Play(float delay = 0) | ||
{ | ||
string busOrFieldPath = string.IsNullOrEmpty(bus) ? DefaultBus : bus; | ||
if (string.IsNullOrEmpty(busOrFieldPath)) throw new InvalidOperationException($"No bus assigned to {this}"); | ||
// the string is most likely a field path, but we can also directly accept bus paths (and guids) | ||
string actualBus = busOrFieldPath.StartsWith("bus:/") || Guid.TryParse(busOrFieldPath, out _) | ||
? busOrFieldPath | ||
: StaticHelpers.GetValue<string>(busOrFieldPath); | ||
|
||
soundCollection = soundCollection.Initialize(actualBus); | ||
if (Is3D) sounds.Play(emitter, delay); | ||
else sounds.Play2D(delay); | ||
} | ||
|
||
public void Play(float delay = 0) | ||
public void Stop() | ||
{ | ||
if (Is3D) soundCollection.Play(emitter, delay); | ||
else soundCollection.Play2D(delay); | ||
if (Is3D) emitter.Stop(); | ||
else sounds.Stop(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.