mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Fix audio bug
This commit is contained in:
parent
2b988257e0
commit
f5f347080b
@ -54,6 +54,10 @@ namespace NewHorizons.Builder.Body
|
||||
sunAudio.transform.localPosition = Vector3.zero;
|
||||
sunAudio.transform.localScale = Vector3.one;
|
||||
sunAudio.transform.Find("SurfaceAudio_Sun").GetComponent<AudioSource>().maxDistance = starModule.Size * 2f;
|
||||
var surfaceAudio = sunAudio.GetComponentInChildren<SunSurfaceAudioController>();
|
||||
surfaceAudio.SetSector(sector);
|
||||
surfaceAudio._sunController = null;
|
||||
|
||||
sunAudio.name = "Audio_Star";
|
||||
|
||||
var sunAtmosphere = GameObject.Instantiate(GameObject.Find("Sun_Body/Atmosphere_SUN"), starGO.transform);
|
||||
|
||||
@ -94,6 +94,26 @@ namespace NewHorizons.Builder.General
|
||||
var starController = ao.gameObject.GetComponent<StarController>();
|
||||
Main.Instance.StarLightController.RemoveStar(starController);
|
||||
GameObject.Destroy(starController);
|
||||
|
||||
var audio = ao.GetComponentInChildren<SunSurfaceAudioController>();
|
||||
GameObject.Destroy(audio);
|
||||
|
||||
foreach(var owAudioSource in ao.GetComponentsInChildren<OWAudioSource>())
|
||||
{
|
||||
owAudioSource.Stop();
|
||||
GameObject.Destroy(owAudioSource);
|
||||
}
|
||||
|
||||
foreach (var audioSource in ao.GetComponentsInChildren<AudioSource>())
|
||||
{
|
||||
audioSource.Stop();
|
||||
GameObject.Destroy(audioSource);
|
||||
}
|
||||
}
|
||||
else if(ao.GetAstroObjectName() == AstroObject.Name.DreamWorld)
|
||||
{
|
||||
GameObject.Find("BackRaft_Body").SetActive(false);
|
||||
GameObject.Find("SealRaft_Body").SetActive(false);
|
||||
}
|
||||
|
||||
// Deal with proxies
|
||||
|
||||
@ -22,6 +22,20 @@ namespace NewHorizons.Utility
|
||||
{
|
||||
if (Keyboard.current != null && Keyboard.current[Key.P].wasReleasedThisFrame)
|
||||
{
|
||||
/*
|
||||
var soundSources = GameObject.FindObjectsOfType<AudioSource>();
|
||||
foreach(var s in soundSources)
|
||||
{
|
||||
if (s.isPlaying)
|
||||
{
|
||||
Logger.Log($"{s.name}, {s.gameObject.name}");
|
||||
Logger.LogPath(s.gameObject);
|
||||
s.loop = false;
|
||||
s.Stop();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Raycast
|
||||
_rb.DisableCollisionDetection();
|
||||
int layerMask = OWLayerMask.physicalMask;
|
||||
|
||||
@ -16,6 +16,7 @@ namespace NewHorizons.Utility
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<ReferenceFrame>("GetHUDDisplayName", typeof(Patches), nameof(Patches.GetHUDDisplayName));
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<PlayerState>("CheckShipOutsideSolarSystem", typeof(Patches), nameof(Patches.CheckShipOutersideSolarSystem));
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<SunLightParamUpdater>("LateUpdate", typeof(Patches), nameof(Patches.OnSunLightParamUpdaterLateUpdate));
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<SunSurfaceAudioController>("Update", typeof(Patches), nameof(Patches.OnSunSurfaceAudioControllerUpdate));
|
||||
|
||||
// Postfixes
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<EllipticOrbitLine>("Start", typeof(Patches), nameof(Patches.OnEllipticOrbitLineStart));
|
||||
@ -81,5 +82,16 @@ namespace NewHorizons.Utility
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool OnSunSurfaceAudioControllerUpdate(SunSurfaceAudioController __instance)
|
||||
{
|
||||
if (__instance._sunController != null) return true;
|
||||
|
||||
var surfaceRadius = __instance.transform.parent.parent.localScale.magnitude;
|
||||
float value = Mathf.Max(0f, Vector3.Distance(Locator.GetPlayerCamera().transform.position, __instance.transform.position) - surfaceRadius);
|
||||
float num = Mathf.InverseLerp(1600f, 100f, value);
|
||||
__instance._audioSource.SetLocalVolume(num * num * __instance._fade);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,6 @@
|
||||
"author": "xen",
|
||||
"name": "New Horizons",
|
||||
"uniqueName": "xen.NewHorizons",
|
||||
"version": "0.1.5",
|
||||
"version": "0.2.0",
|
||||
"owmlVersion": "2.1.0"
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user