Wwise Audio Integration
This commit is contained in:
parent
e7e305e6a0
commit
7d67d7ec2c
72 changed files with 4551 additions and 11819 deletions
|
|
@ -1033,6 +1033,7 @@ public class EquippedItem
|
|||
|
||||
private bool _thermalOnline;
|
||||
private bool _durabilityOnline;
|
||||
public WwiseMetaSoundBank SoundBank;
|
||||
|
||||
public Behavior[] Behaviors { get; }
|
||||
public Dictionary<int, BehaviorGroup> BehaviorGroups { get; }
|
||||
|
|
@ -1053,6 +1054,10 @@ public class EquippedItem
|
|||
public ReadOnlyReactiveProperty<bool> Active { get; }
|
||||
public ItemManager ItemManager { get; }
|
||||
|
||||
public Subject<uint> AudioEvents { get; } = new Subject<uint>();
|
||||
public Subject<(uint id, float v)> AudioParameters { get; } = new Subject<(uint id, float v)>();
|
||||
public Dictionary<uint, float> AudioParameterValues { get; } = new Dictionary<uint, float>();
|
||||
|
||||
public float Temperature
|
||||
{
|
||||
get
|
||||
|
|
@ -1062,8 +1067,77 @@ public class EquippedItem
|
|||
return sum/InsetShape.Coordinates.Length;
|
||||
}
|
||||
}
|
||||
|
||||
//private bool _online;
|
||||
|
||||
public void FireAudioEvent(uint eventId, bool skipVerify = false)
|
||||
{
|
||||
if(SoundBank != null && (skipVerify || SoundBank.IncludedEvents.Any(o => o.Id == eventId)))
|
||||
AudioEvents.OnNext(eventId);
|
||||
}
|
||||
|
||||
public void FireAudioEvent(WwiseSoundBinding soundBinding)
|
||||
{
|
||||
FireAudioEvent(soundBinding.PlayEvent);
|
||||
}
|
||||
|
||||
public void PlaySound(WwiseLoopingSoundBinding soundBinding)
|
||||
{
|
||||
FireAudioEvent(soundBinding.PlayEvent);
|
||||
}
|
||||
|
||||
public void StopSound(WwiseLoopingSoundBinding soundBinding)
|
||||
{
|
||||
FireAudioEvent(soundBinding.StopEvent);
|
||||
}
|
||||
|
||||
public void FireAudioEvent(WeaponAudioEvent weaponAudioEvent)
|
||||
{
|
||||
if (SoundBank == null) return;
|
||||
var eventObject = SoundBank.GetEvent(weaponAudioEvent);
|
||||
if (eventObject == null)
|
||||
{
|
||||
ItemManager.Log($"Attempted to trigger {Enum.GetName(typeof(WeaponAudioEvent), weaponAudioEvent)} weapon audio event, but the soundbank doesn't support it!");
|
||||
return;
|
||||
}
|
||||
FireAudioEvent(eventObject.Id, true);
|
||||
}
|
||||
|
||||
public void FireAudioEvent(ChargedWeaponAudioEvent weaponAudioEvent)
|
||||
{
|
||||
if (SoundBank == null) return;
|
||||
var eventObject = SoundBank.GetEvent(weaponAudioEvent);
|
||||
if (eventObject == null)
|
||||
{
|
||||
ItemManager.Log($"Attempted to trigger {Enum.GetName(typeof(ChargedWeaponAudioEvent), weaponAudioEvent)} weapon audio event, but the soundbank doesn't support it!");
|
||||
return;
|
||||
}
|
||||
FireAudioEvent(eventObject.Id, true);
|
||||
}
|
||||
|
||||
public void SetAudioParameter(uint id, float v, bool skipVerify = false)
|
||||
{
|
||||
if (SoundBank != null && (skipVerify || SoundBank.GameParameters.Any(o => o.Id == id)))
|
||||
{
|
||||
AudioParameterValues[id] = v;
|
||||
AudioParameters.OnNext((id, v));
|
||||
}
|
||||
}
|
||||
|
||||
// public void SetAudioParameter(WwiseParameterBinding binding)
|
||||
// {
|
||||
// FireAudioEvent(binding.Parameter);
|
||||
// }
|
||||
|
||||
public void SetAudioParameter(SpecialAudioParameter p, float v)
|
||||
{
|
||||
if (SoundBank == null) return;
|
||||
var metaObject = SoundBank.GetParameter(p);
|
||||
if (metaObject == null)
|
||||
{
|
||||
ItemManager.Log($"Attempted to set {Enum.GetName(typeof(ChargedWeaponAudioEvent), p)} audio parameter, but the soundbank doesn't support it!");
|
||||
return;
|
||||
}
|
||||
SetAudioParameter(metaObject.Id, v, true);
|
||||
}
|
||||
|
||||
public EquippedItem(ItemManager itemManager, EquippableItem item, int2 position, Entity entity)
|
||||
{
|
||||
|
|
@ -1152,6 +1226,11 @@ public class EquippedItem
|
|||
|
||||
public void Update(float delta)
|
||||
{
|
||||
foreach (var audioStat in Data.AudioStats)
|
||||
{
|
||||
SetAudioParameter(audioStat.Parameter, Evaluate(audioStat.Stat));
|
||||
}
|
||||
|
||||
if (Active.Value)
|
||||
{
|
||||
foreach (var group in BehaviorGroups.Values)
|
||||
|
|
|
|||
Loading…
Reference in a new issue