Audio Fixes

Reactor load RTPC wasn't being set correctly
Turns out you actually have to assign audio emitter positions manually, wow
This commit is contained in:
Reinier Vens 2021-03-16 18:17:38 +00:00
commit c0494ee3d8
11 changed files with 107 additions and 61 deletions

View file

@ -464,6 +464,7 @@ public class EntityInstance : MonoBehaviour
foreach (var r in _radiatorSfx)
{
r.Value.SetActive(r.Key.Item.Online.Value);
AkSoundEngine.SetObjectPosition(r.Value, r.Value.transform);
AkSoundEngine.SetRTPCValue("performance_durability", r.Key.Item.DurabilityPerformance, r.Value);
AkSoundEngine.SetRTPCValue("performance_thermal", r.Key.Item.ThermalPerformance, r.Value);
AkSoundEngine.SetRTPCValue("performance_quality", r.Key.Item.ItemManager.CompoundQuality(r.Key.Item.EquippableItem), r.Value);
@ -472,6 +473,7 @@ public class EntityInstance : MonoBehaviour
if (_reactor.reactor != null)
{
_reactor.sfxSource.SetActive(_reactor.reactor.Item.Online.Value);
AkSoundEngine.SetObjectPosition(_reactor.sfxSource, _reactor.sfxSource.transform);
AkSoundEngine.SetRTPCValue("reactor_load", _reactor.reactor.CurrentLoadRatio, _reactor.sfxSource);
AkSoundEngine.SetRTPCValue("performance_durability", _reactor.reactor.Item.DurabilityPerformance, _reactor.sfxSource);
AkSoundEngine.SetRTPCValue("performance_thermal", _reactor.reactor.Item.ThermalPerformance, _reactor.sfxSource);

View file

@ -92,6 +92,7 @@ public class ShipInstance : EntityInstance
var throttle = 0f;
if (thrusterInstance.System.particleCount > 0)
throttle = (float) thrusterInstance.System.particleCount / thrusterInstance.MaxParticleCount;
AkSoundEngine.SetObjectPosition(thrusterInstance.SfxSource, thrusterInstance.SfxSource.transform);
AkSoundEngine.SetRTPCValue("thruster_throttle", throttle, thrusterInstance.SfxSource);
AkSoundEngine.SetRTPCValue("performance_durability", thrusterInstance.Thruster.Item.DurabilityPerformance, thrusterInstance.SfxSource);
AkSoundEngine.SetRTPCValue("performance_thermal", thrusterInstance.Thruster.Item.ThermalPerformance, thrusterInstance.SfxSource);

View file

@ -80,7 +80,6 @@ public class Reactor : IBehavior, IOrderedBehavior
// This behavior executes last, so any components drawing power have already done so
CurrentLoadRatio = Draw / max(charge, .01f);
// Subtract the baseline charge from draw
Draw -= charge;
@ -90,6 +89,7 @@ public class Reactor : IBehavior, IOrderedBehavior
// We have an energy deficit, have to overload the reactor
if (Draw > .01f)
{
CurrentLoadRatio = (Draw + charge) / max(charge, .01f);
var overloadEfficiency = Item.Evaluate(_data.OverloadEfficiency);
// Generate heat using overload efficiency, usually much less efficient!
@ -122,9 +122,14 @@ public class Reactor : IBehavior, IOrderedBehavior
// We still have an energy surplus, try to throttle the reactor to reduce heat generation
if (Draw < -.01f)
{
CurrentLoadRatio = (Draw + charge) / max(charge, .01f);
heat -= Draw / efficiency * (1 - 1 / Item.Evaluate(_data.ThrottlingFactor));
Draw = 0;
}
else
{
CurrentLoadRatio = 1;
}
Item.AddHeat(heat);
return true;