Add more volumes (#332)

I added a ton of volumes.
This commit is contained in:
Nick 2022-09-04 22:53:22 -04:00 committed by GitHub
commit 58e12a23c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 519 additions and 95 deletions

View File

@ -41,7 +41,22 @@ namespace NewHorizons.Builder.ShipLog
GameObject revealTriggerVolume = new GameObject("Reveal Volume (" + info.revealOn + ")"); GameObject revealTriggerVolume = new GameObject("Reveal Volume (" + info.revealOn + ")");
revealTriggerVolume.SetActive(false); revealTriggerVolume.SetActive(false);
revealTriggerVolume.transform.parent = sector?.transform ?? planetGO.transform; revealTriggerVolume.transform.parent = sector?.transform ?? planetGO.transform;
if (!string.IsNullOrEmpty(info.parentPath))
{
var newParent = planetGO.transform.Find(info.parentPath);
if (newParent != null)
{
revealTriggerVolume.transform.parent = newParent;
}
else
{
Logger.LogWarning($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}");
}
}
revealTriggerVolume.transform.position = planetGO.transform.TransformPoint(info.position ?? Vector3.zero); revealTriggerVolume.transform.position = planetGO.transform.TransformPoint(info.position ?? Vector3.zero);
return revealTriggerVolume; return revealTriggerVolume;
} }

View File

@ -19,6 +19,20 @@ namespace NewHorizons.Builder.Volumes
go.SetActive(false); go.SetActive(false);
go.transform.parent = sector?.transform ?? planetGO.transform; go.transform.parent = sector?.transform ?? planetGO.transform;
if (!string.IsNullOrEmpty(info.parentPath))
{
var newParent = planetGO.transform.Find(info.parentPath);
if (newParent != null)
{
go.transform.parent = newParent;
}
else
{
Logger.LogWarning($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}");
}
}
go.transform.position = planetGO.transform.TransformPoint(info.position != null ? (Vector3)info.position : Vector3.zero); go.transform.position = planetGO.transform.TransformPoint(info.position != null ? (Vector3)info.position : Vector3.zero);
go.layer = LayerMask.NameToLayer("AdvancedEffectVolume"); go.layer = LayerMask.NameToLayer("AdvancedEffectVolume");

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Builder.Volumes namespace NewHorizons.Builder.Volumes
{ {
@ -16,6 +17,20 @@ namespace NewHorizons.Builder.Volumes
go.SetActive(false); go.SetActive(false);
go.transform.parent = sector?.transform ?? planetGO.transform; go.transform.parent = sector?.transform ?? planetGO.transform;
if (!string.IsNullOrEmpty(info.parentPath))
{
var newParent = planetGO.transform.Find(info.parentPath);
if (newParent != null)
{
go.transform.parent = newParent;
}
else
{
Logger.LogWarning($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}");
}
}
go.transform.position = planetGO.transform.TransformPoint(info.position != null ? (Vector3)info.position : Vector3.zero); go.transform.position = planetGO.transform.TransformPoint(info.position != null ? (Vector3)info.position : Vector3.zero);
go.layer = LayerMask.NameToLayer("BasicEffectVolume"); go.layer = LayerMask.NameToLayer("BasicEffectVolume");

View File

@ -21,6 +21,20 @@ namespace NewHorizons.Builder.Volumes
go.SetActive(false); go.SetActive(false);
go.transform.parent = sector?.transform ?? planetGO.transform; go.transform.parent = sector?.transform ?? planetGO.transform;
if (!string.IsNullOrEmpty(info.parentPath))
{
var newParent = planetGO.transform.Find(info.parentPath);
if (newParent != null)
{
go.transform.parent = newParent;
}
else
{
Logger.LogWarning($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}");
}
}
go.transform.position = planetGO.transform.TransformPoint(info.position != null ? (Vector3)info.position : Vector3.zero); go.transform.position = planetGO.transform.TransformPoint(info.position != null ? (Vector3)info.position : Vector3.zero);
go.layer = LayerMask.NameToLayer("BasicEffectVolume"); go.layer = LayerMask.NameToLayer("BasicEffectVolume");

View File

@ -0,0 +1,46 @@
using NewHorizons.Components;
using NewHorizons.External.Modules;
using UnityEngine;
using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Builder.Volumes
{
public static class VolumeBuilder
{
public static TVolume Make<TVolume>(GameObject planetGO, Sector sector, VolumesModule.VolumeInfo info) where TVolume : MonoBehaviour //Could be BaseVolume but I need to create vanilla volumes too.
{
var go = new GameObject(typeof(TVolume).Name);
go.SetActive(false);
go.transform.parent = sector?.transform ?? planetGO.transform;
if (!string.IsNullOrEmpty(info.parentPath))
{
var newParent = planetGO.transform.Find(info.parentPath);
if (newParent != null)
{
go.transform.parent = newParent;
}
else
{
Logger.LogWarning($"Cannot find parent object at path: {planetGO.name}/{info.parentPath}");
}
}
go.transform.position = planetGO.transform.TransformPoint(info.position != null ? (Vector3)info.position : Vector3.zero);
go.layer = LayerMask.NameToLayer("BasicEffectVolume");
var shape = go.AddComponent<SphereShape>();
shape.radius = info.radius;
var owTriggerVolume = go.AddComponent<OWTriggerVolume>();
owTriggerVolume._shape = shape;
var volume = go.AddComponent<TVolume>();
go.SetActive(true);
return volume;
}
}
}

View File

@ -1,6 +1,7 @@
using NewHorizons.Builder.Body; using NewHorizons.Builder.Body;
using NewHorizons.Builder.ShipLog; using NewHorizons.Builder.ShipLog;
using NewHorizons.Builder.Volumes; using NewHorizons.Builder.Volumes;
using NewHorizons.Components;
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using OWML.Common; using OWML.Common;
using System; using System;
@ -49,6 +50,34 @@ namespace NewHorizons.Builder.Volumes
HazardVolumeBuilder.Make(go, sector, planetBody, hazardVolume, mod); HazardVolumeBuilder.Make(go, sector, planetBody, hazardVolume, mod);
} }
} }
if (config.Volumes.mapRestrictionVolumes != null)
{
foreach (var mapRestrictionVolume in config.Volumes.mapRestrictionVolumes)
{
VolumeBuilder.Make<MapRestrictionVolume>(go, sector, mapRestrictionVolume);
}
}
if (config.Volumes.interferenceVolumes != null)
{
foreach (var interferenceVolume in config.Volumes.interferenceVolumes)
{
VolumeBuilder.Make<Components.InterferenceVolume>(go, sector, interferenceVolume);
}
}
if (config.Volumes.reverbVolumes != null)
{
foreach (var reverbVolume in config.Volumes.reverbVolumes)
{
VolumeBuilder.Make<ReverbTriggerVolume>(go, sector, reverbVolume);
}
}
if (config.Volumes.insulatingVolumes != null)
{
foreach (var insulatingVolume in config.Volumes.insulatingVolumes)
{
VolumeBuilder.Make<InsulatingVolume>(go, sector, insulatingVolume);
}
}
} }
} }
} }

View File

@ -0,0 +1,28 @@
using UnityEngine;
namespace NewHorizons.Components
{
[RequireComponent(typeof(OWTriggerVolume))]
public abstract class BaseVolume : MonoBehaviour
{
private OWTriggerVolume _triggerVolume;
public virtual void Awake()
{
_triggerVolume = this.GetRequiredComponent<OWTriggerVolume>();
_triggerVolume.OnEntry += OnTriggerVolumeEntry;
_triggerVolume.OnExit += OnTriggerVolumeExit;
}
public virtual void OnDestroy()
{
if (_triggerVolume == null) return;
_triggerVolume.OnEntry -= OnTriggerVolumeEntry;
_triggerVolume.OnExit -= OnTriggerVolumeExit;
}
public abstract void OnTriggerVolumeEntry(GameObject hitObj);
public abstract void OnTriggerVolumeExit(GameObject hitObj);
}
}

View File

@ -0,0 +1,54 @@
using NewHorizons.Handlers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace NewHorizons.Components
{
public class InterferenceVolume : BaseVolume
{
public override void OnTriggerVolumeEntry(GameObject hitObj)
{
if (hitObj.CompareTag("PlayerDetector"))
{
OnPlayerEnter();
}
else if (hitObj.CompareTag("ProbeDetector"))
{
OnProbeEnter();
}
else if (hitObj.CompareTag("ShipDetector"))
{
OnShipEnter();
}
}
public override void OnTriggerVolumeExit(GameObject hitObj)
{
if (hitObj.CompareTag("PlayerDetector"))
{
OnPlayerExit();
}
else if (hitObj.CompareTag("ProbeDetector"))
{
OnProbeExit();
}
else if (hitObj.CompareTag("ShipDetector"))
{
OnShipExit();
}
}
public void OnPlayerEnter() => InterferenceHandler.OnPlayerEnterInterferenceVolume(this);
public void OnPlayerExit() => InterferenceHandler.OnPlayerExitInterferenceVolume(this);
public void OnProbeEnter() => InterferenceHandler.OnProbeEnterInterferenceVolume(this);
public void OnProbeExit() => InterferenceHandler.OnProbeExitInterferenceVolume(this);
public void OnShipEnter() => InterferenceHandler.OnShipEnterInterferenceVolume(this);
public void OnShipExit() => InterferenceHandler.OnShipExitInterferenceVolume(this);
}
}

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace NewHorizons.Components
{
public class MapRestrictionVolume : BaseVolume
{
public override void OnTriggerVolumeEntry(GameObject hitObj)
{
if (hitObj.CompareTag("PlayerDetector"))
{
Locator.GetMapController()?.OnPlayerEnterMapRestriction();
}
}
public override void OnTriggerVolumeExit(GameObject hitObj)
{
if (hitObj.CompareTag("PlayerDetector"))
{
Locator.GetMapController()?.OnPlayerExitMapRestriction();
}
}
}
}

View File

@ -7,29 +7,13 @@ using UnityEngine;
namespace NewHorizons.Components namespace NewHorizons.Components
{ {
[RequireComponent(typeof(OWTriggerVolume))] public class NotificationVolume : BaseVolume
public class NotificationVolume : MonoBehaviour
{ {
private NotificationTarget _target = NotificationTarget.All; private NotificationTarget _target = NotificationTarget.All;
private bool _pin = false; private bool _pin = false;
private OWTriggerVolume _triggerVolume;
private NotificationData _entryNotification; private NotificationData _entryNotification;
private NotificationData _exitNotification; private NotificationData _exitNotification;
public void Awake()
{
_triggerVolume = this.GetRequiredComponent<OWTriggerVolume>();
_triggerVolume.OnEntry += OnTriggerVolumeEntry;
_triggerVolume.OnExit += OnTriggerVolumeExit;
}
public void OnDestroy()
{
if (_triggerVolume == null) return;
_triggerVolume.OnEntry -= OnTriggerVolumeEntry;
_triggerVolume.OnExit -= OnTriggerVolumeExit;
}
public void SetPinned(bool pin) => _pin = pin; public void SetPinned(bool pin) => _pin = pin;
public void SetTarget(External.Modules.VolumesModule.NotificationVolumeInfo.NotificationTarget target) => SetTarget(EnumUtils.Parse<NotificationTarget>(target.ToString(), NotificationTarget.All)); public void SetTarget(External.Modules.VolumesModule.NotificationVolumeInfo.NotificationTarget target) => SetTarget(EnumUtils.Parse<NotificationTarget>(target.ToString(), NotificationTarget.All));
@ -46,7 +30,7 @@ namespace NewHorizons.Components
_exitNotification = new NotificationData(_target, TranslationHandler.GetTranslation(displayMessage, TranslationHandler.TextType.UI), duration); _exitNotification = new NotificationData(_target, TranslationHandler.GetTranslation(displayMessage, TranslationHandler.TextType.UI), duration);
} }
public void OnTriggerVolumeEntry(GameObject hitObj) public override void OnTriggerVolumeEntry(GameObject hitObj)
{ {
if (_target == NotificationTarget.All) if (_target == NotificationTarget.All)
{ {
@ -71,7 +55,7 @@ namespace NewHorizons.Components
} }
} }
public void OnTriggerVolumeExit(GameObject hitObj) public override void OnTriggerVolumeExit(GameObject hitObj)
{ {
if (_target == NotificationTarget.All) if (_target == NotificationTarget.All)
{ {

View File

@ -15,27 +15,66 @@ namespace NewHorizons.External.Modules
public class VolumesModule public class VolumesModule
{ {
/// <summary> /// <summary>
/// Add audio volumes to this planet /// Add audio volumes to this planet.
/// </summary> /// </summary>
public AudioVolumeInfo[] audioVolumes; public AudioVolumeInfo[] audioVolumes;
/// <summary> /// <summary>
/// Add hazard volumes to this planet /// Add hazard volumes to this planet.
/// </summary> /// </summary>
public HazardVolumeInfo[] hazardVolumes; public HazardVolumeInfo[] hazardVolumes;
/// <summary> /// <summary>
/// Add notification volumes to this planet /// Add interference volumes to this planet.
/// </summary>
public VolumeInfo[] interferenceVolumes;
/// <summary>
/// Add insulating volumes to this planet. These will stop electricty hazard volumes from affecting you (just like the jellyfish).
/// </summary>
public VolumeInfo[] insulatingVolumes;
/// <summary>
/// Add map restriction volumes to this planet.
/// </summary>
public VolumeInfo[] mapRestrictionVolumes;
/// <summary>
/// Add notification volumes to this planet.
/// </summary> /// </summary>
public NotificationVolumeInfo[] notificationVolumes; public NotificationVolumeInfo[] notificationVolumes;
/// <summary> /// <summary>
/// Add triggers that reveal parts of the ship log on this planet /// Add triggers that reveal parts of the ship log on this planet.
/// </summary> /// </summary>
public RevealVolumeInfo[] revealVolumes; public RevealVolumeInfo[] revealVolumes;
/// <summary>
/// Add reverb volumes to this planet. Great for echoes in caves.
/// </summary>
public VolumeInfo[] reverbVolumes;
[JsonObject] [JsonObject]
public class RevealVolumeInfo public class VolumeInfo
{
/// <summary>
/// The location of this volume. Optional (will default to 0,0,0).
/// </summary>
public MVector3 position;
/// <summary>
/// The radius of this volume.
/// </summary>
public float radius = 1f;
/// <summary>
/// The relative path from the planet to the parent of this object. Optional (will default to the root sector).
/// </summary>
public string parentPath;
}
[JsonObject]
public class RevealVolumeInfo : VolumeInfo
{ {
[JsonConverter(typeof(StringEnumConverter))] [JsonConverter(typeof(StringEnumConverter))]
public enum RevealVolumeType public enum RevealVolumeType
@ -57,16 +96,6 @@ namespace NewHorizons.External.Modules
/// </summary> /// </summary>
public float maxDistance = -1f; // Snapshot & Observe Only public float maxDistance = -1f; // Snapshot & Observe Only
/// <summary>
/// The position to place this volume at
/// </summary>
public MVector3 position;
/// <summary>
/// The radius of this reveal volume
/// </summary>
public float radius = 1f;
/// <summary> /// <summary>
/// What needs to be done to the volume to unlock the facts /// What needs to be done to the volume to unlock the facts
/// </summary> /// </summary>
@ -84,18 +113,8 @@ namespace NewHorizons.External.Modules
} }
[JsonObject] [JsonObject]
public class AudioVolumeInfo public class AudioVolumeInfo : VolumeInfo
{ {
/// <summary>
/// The location of this audio volume. Optional (will default to 0,0,0).
/// </summary>
public MVector3 position;
/// <summary>
/// The radius of this audio volume
/// </summary>
public float radius;
/// <summary> /// <summary>
/// The audio to use. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list. /// The audio to use. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
/// </summary> /// </summary>
@ -113,23 +132,13 @@ namespace NewHorizons.External.Modules
} }
[JsonObject] [JsonObject]
public class NotificationVolumeInfo public class NotificationVolumeInfo : VolumeInfo
{ {
/// <summary> /// <summary>
/// What the notification will show for. /// What the notification will show for.
/// </summary> /// </summary>
[DefaultValue("all")] public NotificationTarget target = NotificationTarget.All; [DefaultValue("all")] public NotificationTarget target = NotificationTarget.All;
/// <summary>
/// The location of this notification volume. Optional (will default to 0,0,0).
/// </summary>
public MVector3 position;
/// <summary>
/// The radius of this notification volume.
/// </summary>
public float radius;
/// <summary> /// <summary>
/// The notification that will play when you enter this volume. /// The notification that will play when you enter this volume.
/// </summary> /// </summary>
@ -165,18 +174,8 @@ namespace NewHorizons.External.Modules
} }
[JsonObject] [JsonObject]
public class HazardVolumeInfo public class HazardVolumeInfo : VolumeInfo
{ {
/// <summary>
/// The location of this hazard volume. Optional (will default to 0,0,0).
/// </summary>
public MVector3 position;
/// <summary>
/// The radius of this hazard volume.
/// </summary>
public float radius;
/// <summary> /// <summary>
/// The type of hazard for this volume. /// The type of hazard for this volume.
/// </summary> /// </summary>
@ -202,7 +201,7 @@ namespace NewHorizons.External.Modules
{ {
[EnumMember(Value = @"none")] NONE = 0, [EnumMember(Value = @"none")] NONE = 0,
[EnumMember(Value = @"general")] GENERAL = 1, [EnumMember(Value = @"general")] GENERAL = 1,
[EnumMember(Value = @"darkMatter")] DARKMATTER = 2, [EnumMember(Value = @"ghostMatter")] DARKMATTER = 2,
[EnumMember(Value = @"heat")] HEAT = 4, [EnumMember(Value = @"heat")] HEAT = 4,
[EnumMember(Value = @"fire")] FIRE = 8, [EnumMember(Value = @"fire")] FIRE = 8,
[EnumMember(Value = @"sandfall")] SANDFALL = 16, [EnumMember(Value = @"sandfall")] SANDFALL = 16,

View File

@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NewHorizons.Handlers
{
using InterferenceVolume = NewHorizons.Components.InterferenceVolume;
public static class InterferenceHandler
{
private static List<InterferenceVolume> _playerInterference;
private static List<InterferenceVolume> _probeInterference;
private static List<InterferenceVolume> _shipInterference;
public static void Init()
{
_playerInterference = new List<InterferenceVolume>();
_probeInterference = new List<InterferenceVolume>();
_shipInterference = new List<InterferenceVolume>();
}
public static bool PlayerHasInterference() => _playerInterference.Any(volume => volume != null);
public static bool ProbeHasInterference() => _probeInterference.Any(volume => volume != null);
public static bool ShipHasInterference() => _shipInterference.Any(volume => volume != null);
public static bool IsPlayerSameAsProbe()
{
_playerInterference.RemoveAll(volume => volume == null);
return _playerInterference.All(_probeInterference.Contains) && _playerInterference.Count == _probeInterference.Count;
}
public static bool IsPlayerSameAsShip()
{
_playerInterference.RemoveAll(volume => volume == null);
return _playerInterference.All(_shipInterference.Contains) && _playerInterference.Count == _shipInterference.Count;
}
public static void OnPlayerEnterInterferenceVolume(InterferenceVolume interferenceVolume)
{
_playerInterference.SafeAdd(interferenceVolume);
GlobalMessenger.FireEvent("RefreshHUDVisibility");
}
public static void OnPlayerExitInterferenceVolume(InterferenceVolume interferenceVolume)
{
_playerInterference.Remove(interferenceVolume);
GlobalMessenger.FireEvent("RefreshHUDVisibility");
}
public static void OnProbeEnterInterferenceVolume(InterferenceVolume interferenceVolume)
{
_probeInterference.SafeAdd(interferenceVolume);
GlobalMessenger.FireEvent("RefreshHUDVisibility");
}
public static void OnProbeExitInterferenceVolume(InterferenceVolume interferenceVolume)
{
_probeInterference.Remove(interferenceVolume);
GlobalMessenger.FireEvent("RefreshHUDVisibility");
}
public static void OnShipEnterInterferenceVolume(InterferenceVolume interferenceVolume)
{
_shipInterference.SafeAdd(interferenceVolume);
GlobalMessenger.FireEvent("RefreshHUDVisibility");
}
public static void OnShipExitInterferenceVolume(InterferenceVolume interferenceVolume)
{
_shipInterference.Remove(interferenceVolume);
GlobalMessenger.FireEvent("RefreshHUDVisibility");
}
}
}

View File

@ -305,6 +305,7 @@ namespace NewHorizons
AstroObjectLocator.Init(); AstroObjectLocator.Init();
StreamingHandler.Init(); StreamingHandler.Init();
AudioTypeHandler.Init(); AudioTypeHandler.Init();
InterferenceHandler.Init();
RemoteHandler.Init(); RemoteHandler.Init();
AtmosphereBuilder.Init(); AtmosphereBuilder.Init();
BrambleNodeBuilder.Init(BodyDict[CurrentStarSystem].Select(x => x.Config).Where(x => x.Bramble?.dimension != null).ToArray()); BrambleNodeBuilder.Init(BodyDict[CurrentStarSystem].Select(x => x.Config).Where(x => x.Bramble?.dimension != null).ToArray());

View File

@ -1,4 +1,5 @@
using HarmonyLib; using HarmonyLib;
using NewHorizons.Handlers;
namespace NewHorizons.Patches namespace NewHorizons.Patches
{ {
@ -9,6 +10,8 @@ namespace NewHorizons.Patches
[HarmonyPatch(typeof(HUDMarker), nameof(HUDMarker.Awake))] [HarmonyPatch(typeof(HUDMarker), nameof(HUDMarker.Awake))]
public static void HUDMarker_Awake(HUDMarker __instance) public static void HUDMarker_Awake(HUDMarker __instance)
{ {
GlobalMessenger.AddListener("RefreshHUDVisibility", __instance.RefreshOwnVisibility);
GlobalMessenger.AddListener("RefreshHUDVisibility", __instance.RefreshOwnVisibility);
GlobalMessenger.AddListener("PlayerEnterCloakField", __instance.OnPlayerEnterCloakField); GlobalMessenger.AddListener("PlayerEnterCloakField", __instance.OnPlayerEnterCloakField);
GlobalMessenger.AddListener("PlayerExitCloakField", __instance.OnPlayerExitCloakField); GlobalMessenger.AddListener("PlayerExitCloakField", __instance.OnPlayerExitCloakField);
} }
@ -17,6 +20,8 @@ namespace NewHorizons.Patches
[HarmonyPatch(typeof(HUDMarker), nameof(HUDMarker.OnDestroy))] [HarmonyPatch(typeof(HUDMarker), nameof(HUDMarker.OnDestroy))]
public static void HUDMarker_OnDestroy(HUDMarker __instance) public static void HUDMarker_OnDestroy(HUDMarker __instance)
{ {
GlobalMessenger.RemoveListener("RefreshHUDVisibility", __instance.RefreshOwnVisibility);
GlobalMessenger.RemoveListener("RefreshHUDVisibility", __instance.RefreshOwnVisibility);
GlobalMessenger.RemoveListener("PlayerEnterCloakField", __instance.OnPlayerEnterCloakField); GlobalMessenger.RemoveListener("PlayerEnterCloakField", __instance.OnPlayerEnterCloakField);
GlobalMessenger.RemoveListener("PlayerExitCloakField", __instance.OnPlayerExitCloakField); GlobalMessenger.RemoveListener("PlayerExitCloakField", __instance.OnPlayerExitCloakField);
} }
@ -53,11 +58,67 @@ namespace NewHorizons.Patches
GlobalMessenger.RemoveListener("ShipExitCloakField", __instance.RefreshOwnVisibility); GlobalMessenger.RemoveListener("ShipExitCloakField", __instance.RefreshOwnVisibility);
} }
[HarmonyPrefix]
[HarmonyPatch(typeof(ProbeHUDMarker), nameof(ProbeHUDMarker.RefreshOwnVisibility))]
public static bool ProbeHUDMarker_RefreshOwnVisibility(ProbeHUDMarker __instance)
{
bool insideEYE = Locator.GetEyeStateManager() != null && Locator.GetEyeStateManager().IsInsideTheEye();
bool insideQM = __instance._quantumMoon != null && (__instance._quantumMoon.IsPlayerInside() || __instance._quantumMoon.IsProbeInside());
bool insideRW = Locator.GetRingWorldController() != null && Locator.GetRingWorldController().isPlayerInside == Locator.GetRingWorldController().isProbeInside;
bool insideIP = Locator.GetCloakFieldController() != null && Locator.GetCloakFieldController().isPlayerInsideCloak == Locator.GetCloakFieldController().isProbeInsideCloak;
bool insideCloak = Components.CloakSectorController.isPlayerInside == Components.CloakSectorController.isProbeInside;
bool sameInterference = InterferenceHandler.IsPlayerSameAsProbe();
bool isActive = __instance.gameObject.activeInHierarchy || __instance._isTLCDuplicate;
__instance._isVisible = isActive && !insideEYE && !insideQM && !__instance._translatorEquipped && !__instance._inConversation && __instance._launched && (__instance._isWearingHelmet || __instance._atFlightConsole) && insideRW && insideIP && insideCloak && sameInterference;
if (__instance._canvasMarker != null) __instance._canvasMarker.SetVisibility(__instance._isVisible);
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(ShipHUDMarker), nameof(ShipHUDMarker.RefreshOwnVisibility))]
public static bool ShipHUDMarker_RefreshOwnVisibility(ShipHUDMarker __instance)
{
bool insideEYE = Locator.GetEyeStateManager() != null && Locator.GetEyeStateManager().IsInsideTheEye();
bool insideQM = __instance._quantumMoon != null && (__instance._quantumMoon.IsPlayerInside() || __instance._quantumMoon.IsShipInside());
bool insideRW = Locator.GetRingWorldController() != null && Locator.GetRingWorldController().isPlayerInside;
bool insideIP = Locator.GetCloakFieldController() != null ? true : Locator.GetCloakFieldController().isPlayerInsideCloak == Locator.GetCloakFieldController().isShipInsideCloak;
bool insideCloak = Components.CloakSectorController.isPlayerInside == Components.CloakSectorController.isShipInside;
bool sameInterference = InterferenceHandler.IsPlayerSameAsShip();
__instance._isVisible = !insideEYE && !insideQM && !insideRW && !__instance._translatorEquipped && !__instance._inConversation && !__instance._shipDestroyed && !__instance._playerInShip && PlayerState.HasPlayerEnteredShip() && __instance._isWearingHelmet && insideIP && insideCloak && sameInterference;
if (__instance._canvasMarker != null) __instance._canvasMarker.SetVisibility(__instance._isVisible);
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(ShipLogEntryHUDMarker), nameof(ShipLogEntryHUDMarker.RefreshOwnVisibility))]
public static bool ShipLogEntryHUDMarker_RefreshOwnVisibility(ShipLogEntryHUDMarker __instance)
{
bool hasEntryLocation = ShipLogEntryHUDMarker.s_entryLocation != null;
bool insideEYE = Locator.GetEyeStateManager() != null && Locator.GetEyeStateManager().IsInsideTheEye();
bool insideQM = __instance._quantumMoon != null && __instance._quantumMoon.IsPlayerInside();
bool insideRW = Locator.GetRingWorldController() != null && Locator.GetRingWorldController().isPlayerInside && ShipLogEntryHUDMarker.s_entryLocationID == "IP_RING_WORLD";
bool insideIP = (hasEntryLocation && ShipLogEntryHUDMarker.s_entryLocation.IsWithinCloakField()) || !(Locator.GetCloakFieldController() != null && Locator.GetCloakFieldController().isPlayerInsideCloak);
bool insideCloak = (hasEntryLocation && ShipLogEntryHUDMarker.s_entryLocation.IsWithinCloakField()) || !Components.CloakSectorController.isPlayerInside;
__instance._isVisible = (!insideEYE && !insideQM && !insideRW && !__instance._translatorEquipped && !__instance._inConversation && hasEntryLocation && (__instance._isWearingHelmet || __instance._atFlightConsole) && insideIP && insideCloak);
if (__instance._canvasMarker != null) __instance._canvasMarker.SetVisibility(__instance._isVisible);
return false;
}
[HarmonyPostfix] [HarmonyPostfix]
[HarmonyPatch(typeof(ProbeCamera), nameof(ProbeCamera.HasInterference))] [HarmonyPatch(typeof(ProbeCamera), nameof(ProbeCamera.HasInterference))]
public static void ProbeCamera_HasInterference(ProbeCamera __instance, ref bool __result) public static void ProbeCamera_HasInterference(ProbeCamera __instance, ref bool __result)
{ {
__result = __result || Components.CloakSectorController.isPlayerInside != Components.CloakSectorController.isProbeInside; __result = __result || (__instance._id != ProbeCamera.ID.PreLaunch && (Components.CloakSectorController.isPlayerInside != Components.CloakSectorController.isProbeInside || !InterferenceHandler.IsPlayerSameAsProbe()));
} }
} }
} }

View File

@ -2395,31 +2395,59 @@
"properties": { "properties": {
"audioVolumes": { "audioVolumes": {
"type": "array", "type": "array",
"description": "Add audio volumes to this planet", "description": "Add audio volumes to this planet.",
"items": { "items": {
"$ref": "#/definitions/AudioVolumeInfo" "$ref": "#/definitions/AudioVolumeInfo"
} }
}, },
"hazardVolumes": { "hazardVolumes": {
"type": "array", "type": "array",
"description": "Add hazard volumes to this planet", "description": "Add hazard volumes to this planet.",
"items": { "items": {
"$ref": "#/definitions/HazardVolumeInfo" "$ref": "#/definitions/HazardVolumeInfo"
} }
}, },
"interferenceVolumes": {
"type": "array",
"description": "Add interference volumes to this planet.",
"items": {
"$ref": "#/definitions/VolumeInfo"
}
},
"insulatingVolumes": {
"type": "array",
"description": "Add insulating volumes to this planet. These will stop electricty hazard volumes from affecting you (just like the jellyfish).",
"items": {
"$ref": "#/definitions/VolumeInfo"
}
},
"mapRestrictionVolumes": {
"type": "array",
"description": "Add map restriction volumes to this planet.",
"items": {
"$ref": "#/definitions/VolumeInfo"
}
},
"notificationVolumes": { "notificationVolumes": {
"type": "array", "type": "array",
"description": "Add notification volumes to this planet", "description": "Add notification volumes to this planet.",
"items": { "items": {
"$ref": "#/definitions/NotificationVolumeInfo" "$ref": "#/definitions/NotificationVolumeInfo"
} }
}, },
"revealVolumes": { "revealVolumes": {
"type": "array", "type": "array",
"description": "Add triggers that reveal parts of the ship log on this planet", "description": "Add triggers that reveal parts of the ship log on this planet.",
"items": { "items": {
"$ref": "#/definitions/RevealVolumeInfo" "$ref": "#/definitions/RevealVolumeInfo"
} }
},
"reverbVolumes": {
"type": "array",
"description": "Add reverb volumes to this planet. Great for echoes in caves.",
"items": {
"$ref": "#/definitions/VolumeInfo"
}
} }
} }
}, },
@ -2428,14 +2456,18 @@
"additionalProperties": false, "additionalProperties": false,
"properties": { "properties": {
"position": { "position": {
"description": "The location of this audio volume. Optional (will default to 0,0,0).", "description": "The location of this volume. Optional (will default to 0,0,0).",
"$ref": "#/definitions/MVector3" "$ref": "#/definitions/MVector3"
}, },
"radius": { "radius": {
"type": "number", "type": "number",
"description": "The radius of this audio volume", "description": "The radius of this volume.",
"format": "float" "format": "float"
}, },
"parentPath": {
"type": "string",
"description": "The relative path from the planet to the parent of this object. Optional (will default to the root sector)."
},
"audio": { "audio": {
"type": "string", "type": "string",
"description": "The audio to use. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list." "description": "The audio to use. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list."
@ -2497,14 +2529,18 @@
"additionalProperties": false, "additionalProperties": false,
"properties": { "properties": {
"position": { "position": {
"description": "The location of this hazard volume. Optional (will default to 0,0,0).", "description": "The location of this volume. Optional (will default to 0,0,0).",
"$ref": "#/definitions/MVector3" "$ref": "#/definitions/MVector3"
}, },
"radius": { "radius": {
"type": "number", "type": "number",
"description": "The radius of this hazard volume.", "description": "The radius of this volume.",
"format": "float" "format": "float"
}, },
"parentPath": {
"type": "string",
"description": "The relative path from the planet to the parent of this object. Optional (will default to the root sector)."
},
"type": { "type": {
"description": "The type of hazard for this volume.", "description": "The type of hazard for this volume.",
"default": "general", "default": "general",
@ -2544,7 +2580,7 @@
"enum": [ "enum": [
"none", "none",
"general", "general",
"darkMatter", "ghostMatter",
"heat", "heat",
"fire", "fire",
"sandfall", "sandfall",
@ -2566,24 +2602,47 @@
"electrical" "electrical"
] ]
}, },
"NotificationVolumeInfo": { "VolumeInfo": {
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
"properties": { "properties": {
"target": {
"description": "What the notification will show for.",
"default": "all",
"$ref": "#/definitions/NotificationTarget"
},
"position": { "position": {
"description": "The location of this notification volume. Optional (will default to 0,0,0).", "description": "The location of this volume. Optional (will default to 0,0,0).",
"$ref": "#/definitions/MVector3" "$ref": "#/definitions/MVector3"
}, },
"radius": { "radius": {
"type": "number", "type": "number",
"description": "The radius of this notification volume.", "description": "The radius of this volume.",
"format": "float" "format": "float"
}, },
"parentPath": {
"type": "string",
"description": "The relative path from the planet to the parent of this object. Optional (will default to the root sector)."
}
}
},
"NotificationVolumeInfo": {
"type": "object",
"additionalProperties": false,
"properties": {
"position": {
"description": "The location of this volume. Optional (will default to 0,0,0).",
"$ref": "#/definitions/MVector3"
},
"radius": {
"type": "number",
"description": "The radius of this volume.",
"format": "float"
},
"parentPath": {
"type": "string",
"description": "The relative path from the planet to the parent of this object. Optional (will default to the root sector)."
},
"target": {
"description": "What the notification will show for.",
"default": "all",
"$ref": "#/definitions/NotificationTarget"
},
"entryNotification": { "entryNotification": {
"description": "The notification that will play when you enter this volume.", "description": "The notification that will play when you enter this volume.",
"$ref": "#/definitions/NotificationInfo" "$ref": "#/definitions/NotificationInfo"
@ -2628,6 +2687,19 @@
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
"properties": { "properties": {
"position": {
"description": "The location of this volume. Optional (will default to 0,0,0).",
"$ref": "#/definitions/MVector3"
},
"radius": {
"type": "number",
"description": "The radius of this volume.",
"format": "float"
},
"parentPath": {
"type": "string",
"description": "The relative path from the planet to the parent of this object. Optional (will default to the root sector)."
},
"maxAngle": { "maxAngle": {
"type": "number", "type": "number",
"description": "The max view angle (in degrees) the player can see the volume with to unlock the fact (`observe` only)", "description": "The max view angle (in degrees) the player can see the volume with to unlock the fact (`observe` only)",
@ -2638,15 +2710,6 @@
"description": "The max distance the user can be away from the volume to reveal the fact (`snapshot` and `observe` only)", "description": "The max distance the user can be away from the volume to reveal the fact (`snapshot` and `observe` only)",
"format": "float" "format": "float"
}, },
"position": {
"description": "The position to place this volume at",
"$ref": "#/definitions/MVector3"
},
"radius": {
"type": "number",
"description": "The radius of this reveal volume",
"format": "float"
},
"revealOn": { "revealOn": {
"description": "What needs to be done to the volume to unlock the facts", "description": "What needs to be done to the volume to unlock the facts",
"default": "enter", "default": "enter",