mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Cloak Entry Audio
This commit is contained in:
parent
855a4caa2f
commit
0fe3ed06ac
@ -1,14 +1,30 @@
|
|||||||
using NewHorizons.Components;
|
using NewHorizons.Components;
|
||||||
using NewHorizons.External.Modules;
|
using NewHorizons.External.Modules;
|
||||||
using NewHorizons.Utility;
|
using NewHorizons.Utility;
|
||||||
|
using OWML.Common;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
namespace NewHorizons.Builder.Body
|
namespace NewHorizons.Builder.Body
|
||||||
{
|
{
|
||||||
public static class CloakBuilder
|
public static class CloakBuilder
|
||||||
{
|
{
|
||||||
public static void Make(GameObject planetGO, Sector sector, OWRigidbody OWRB, CloakModule module, bool keepReferenceFrame)
|
public static void Make(GameObject planetGO, Sector sector, OWRigidbody OWRB, CloakModule module, bool keepReferenceFrame, IModBehaviour mod)
|
||||||
{
|
{
|
||||||
var radius = module.radius;
|
var radius = module.radius;
|
||||||
|
|
||||||
|
AudioClip clip = null;
|
||||||
|
if (module.audioClip != null) clip = SearchUtilities.FindResourceOfTypeAndName<AudioClip>(module.audioClip);
|
||||||
|
else if (module.audioFilePath != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
clip = AudioUtilities.LoadAudio(mod.ModHelper.Manifest.ModFolderPath + "/" + module.audioFilePath);
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
Utility.Logger.LogError($"Couldn't load audio file {module.audioFilePath} : {e.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var cloak = SearchUtilities.Find("RingWorld_Body/CloakingField_IP");
|
var cloak = SearchUtilities.Find("RingWorld_Body/CloakingField_IP");
|
||||||
|
|
||||||
var newCloak = GameObject.Instantiate(cloak, sector?.transform ?? planetGO.transform);
|
var newCloak = GameObject.Instantiate(cloak, sector?.transform ?? planetGO.transform);
|
||||||
@ -31,6 +47,14 @@ namespace NewHorizons.Builder.Body
|
|||||||
var cloakSectorController = newCloak.AddComponent<CloakSectorController>();
|
var cloakSectorController = newCloak.AddComponent<CloakSectorController>();
|
||||||
cloakSectorController.Init(newCloak.GetComponent<CloakFieldController>(), planetGO);
|
cloakSectorController.Init(newCloak.GetComponent<CloakFieldController>(), planetGO);
|
||||||
|
|
||||||
|
var cloakAudioSource = newCloak.GetComponentInChildren<OWAudioSource>();
|
||||||
|
cloakAudioSource._audioSource = cloakAudioSource.GetComponent<AudioSource>();
|
||||||
|
cloakAudioSource._audioLibraryClip = AudioType.None;
|
||||||
|
cloakAudioSource._clipArrayIndex = 0;
|
||||||
|
cloakAudioSource._clipArrayLength = 0;
|
||||||
|
cloakAudioSource._clipSelectionOnPlay = OWAudioSource.ClipSelectionOnPlay.MANUAL;
|
||||||
|
cloakAudioSource.clip = clip;
|
||||||
|
|
||||||
newCloak.SetActive(true);
|
newCloak.SetActive(true);
|
||||||
cloakFieldController.enabled = true;
|
cloakFieldController.enabled = true;
|
||||||
|
|
||||||
@ -38,6 +62,7 @@ namespace NewHorizons.Builder.Body
|
|||||||
|
|
||||||
// To cloak from the start
|
// To cloak from the start
|
||||||
Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(cloakSectorController.OnPlayerExit);
|
Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(cloakSectorController.OnPlayerExit);
|
||||||
|
Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(clip != null ? cloakSectorController.TurnOnMusic : cloakSectorController.TurnOffMusic);
|
||||||
Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(keepReferenceFrame ? cloakSectorController.EnableReferenceFrameVolume : cloakSectorController.DisableReferenceFrameVolume);
|
Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(keepReferenceFrame ? cloakSectorController.EnableReferenceFrameVolume : cloakSectorController.DisableReferenceFrameVolume);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,5 +80,8 @@ namespace NewHorizons.Components
|
|||||||
public void SetReferenceFrameVolumeActive(bool active) => _cloak._referenceFrameVolume.gameObject.SetActive(active);
|
public void SetReferenceFrameVolumeActive(bool active) => _cloak._referenceFrameVolume.gameObject.SetActive(active);
|
||||||
public void EnableReferenceFrameVolume() => SetReferenceFrameVolumeActive(true);
|
public void EnableReferenceFrameVolume() => SetReferenceFrameVolumeActive(true);
|
||||||
public void DisableReferenceFrameVolume() => SetReferenceFrameVolumeActive(false);
|
public void DisableReferenceFrameVolume() => SetReferenceFrameVolumeActive(false);
|
||||||
|
|
||||||
|
public void TurnOnMusic() => _cloak._hasTriggeredMusic = false;
|
||||||
|
public void TurnOffMusic() => _cloak._hasTriggeredMusic = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
10
NewHorizons/External/Modules/CloakModule.cs
vendored
10
NewHorizons/External/Modules/CloakModule.cs
vendored
@ -15,5 +15,15 @@ namespace NewHorizons.External.Modules
|
|||||||
/// don't want a cloak, leave this as 0.
|
/// don't want a cloak, leave this as 0.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float radius;
|
public float radius;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Name of an existing AudioClip in the game that will play when entering the cloaking field.
|
||||||
|
/// </summary>
|
||||||
|
public string audioClip;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Relative filepath to the .wav file to use as the audio. Mutually exclusive with audioClip.
|
||||||
|
/// </summary>
|
||||||
|
public string audioFilePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -482,7 +482,7 @@ namespace NewHorizons.Handlers
|
|||||||
// Has to go last probably
|
// Has to go last probably
|
||||||
if (body.Config.Cloak != null && body.Config.Cloak.radius != 0f)
|
if (body.Config.Cloak != null && body.Config.Cloak.radius != 0f)
|
||||||
{
|
{
|
||||||
CloakBuilder.Make(go, sector, rb, body.Config.Cloak, body.Config.Base.hasReferenceFrame);
|
CloakBuilder.Make(go, sector, rb, body.Config.Cloak, body.Config.Base.hasReferenceFrame, body.Mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
return go;
|
return go;
|
||||||
|
|||||||
@ -297,6 +297,14 @@
|
|||||||
"type": "number",
|
"type": "number",
|
||||||
"description": "Radius of the cloaking field around the planet. It's a bit finicky so experiment with different values. If you\ndon't want a cloak, leave this as 0.",
|
"description": "Radius of the cloaking field around the planet. It's a bit finicky so experiment with different values. If you\ndon't want a cloak, leave this as 0.",
|
||||||
"format": "float"
|
"format": "float"
|
||||||
|
},
|
||||||
|
"audioClip": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Name of an existing AudioClip in the game that will play when entering the cloaking field."
|
||||||
|
},
|
||||||
|
"audioFilePath": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Relative filepath to the .wav file to use as the audio. Mutually exclusive with audioClip."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user