Merge branch 'main' into profiler

This commit is contained in:
JohnCorby 2025-07-21 18:07:30 -07:00
commit b0bcba9e6d
117 changed files with 4222 additions and 428 deletions

View File

@ -66,4 +66,4 @@ jobs:
uses: tj-actions/verify-changed-files@v20
id: changed_files
with:
files: NewHorizons/Schemas/**
files: NewHorizons/Schemas/**

View File

@ -6,6 +6,7 @@
"NEW_HORIZONS_WARP_DRIVE_DIALOGUE_3": "之后只需要系好安全带并启动自动驾驶即可进行跃迁!"
},
"UIDictionary": {
"INSTALL_OUTER_WILDS_CHINESE_FONT_FIX": "在享受故事之前建议安装Outer Wilds Chinese Fix这个Mod来解决缺字问题。",
"INTERSTELLAR_MODE": "恒星际模式",
"FREQ_STATUE": "挪麦雕像",
"FREQ_WARP_CORE": "反引力推进",

View File

@ -6,6 +6,7 @@
"NEW_HORIZONS_WARP_DRIVE_DIALOGUE_3": "Then just buckle up and engage the autopilot to warp there!"
},
"UIDictionary": {
"INSTALL_OUTER_WILDS_CHINESE_FONT_FIX": "What why is this message being shown when the language is not set to Chinese go report this bug!",
"INTERSTELLAR_MODE": "Interstellar Mode",
"FREQ_STATUE": "Nomai Statue",
"FREQ_WARP_CORE": "Anti-Graviton Flux",

View File

@ -100,6 +100,15 @@ namespace NewHorizons.Builder.Atmosphere
atmoGO.transform.position = planetGO.transform.TransformPoint(Vector3.zero);
atmoGO.SetActive(true);
// CullGroups have already set up their renderers when this is done so we need to add ourself to it
// TODO: There are probably other builders where this is relevant
// This in particular was a bug affecting hazy dreams
if (sector != null && sector.gameObject.GetComponent<CullGroup>() is CullGroup cullGroup)
{
cullGroup.RecursivelyAddRenderers(atmoGO.transform, true);
cullGroup.SetVisible(cullGroup.IsVisible());
}
return atmoGO;
}
}

View File

@ -5,6 +5,7 @@ using NewHorizons.External;
using NewHorizons.External.Modules;
using NewHorizons.External.Modules.Props;
using NewHorizons.Utility;
using NewHorizons.Utility.DebugTools;
using NewHorizons.Utility.Files;
using NewHorizons.Utility.OWML;
using OWML.Common;
@ -189,6 +190,7 @@ namespace NewHorizons.Builder.Body
outerFogWarpVolume._linkedInnerWarpVolume = null;
outerFogWarpVolume._name = OuterFogWarpVolume.Name.None;
outerFogWarpVolume._sector = sector;
exitWarps.GetAddComponent<DebugFogWarp>().fogWarpVolume = outerFogWarpVolume;
PairExit(config.linksTo, outerFogWarpVolume);

View File

@ -60,14 +60,22 @@ namespace NewHorizons.Builder.Body
}
}
public static void Make(GameObject planetGO, Sector sector, CometTailModule cometTailModule, PlanetConfig config)
public static void Make(GameObject planetGO, Sector sector, CometTailModule cometTailModule, PlanetConfig config, AstroObject ao)
{
if (config.Orbit.primaryBody == null)
var primaryBody = ao.GetPrimaryBody();
if (!string.IsNullOrEmpty(config.Orbit.primaryBody)) primaryBody = AstroObjectLocator.GetAstroObject(config.Orbit.primaryBody);
if (primaryBody == null)
{
NHLogger.LogError($"Comet {planetGO.name} does not orbit anything. That makes no sense");
return;
}
if (string.IsNullOrEmpty(cometTailModule.primaryBody))
cometTailModule.primaryBody = !string.IsNullOrEmpty(config.Orbit.primaryBody) ? config.Orbit.primaryBody
: primaryBody.GetKey();
var rootObj = new GameObject("CometRoot");
rootObj.SetActive(false);
rootObj.transform.parent = sector?.transform ?? planetGO.transform;
@ -79,13 +87,11 @@ namespace NewHorizons.Builder.Body
if (cometTailModule.rotationOverride != null) controller.SetRotationOverride(cometTailModule.rotationOverride);
if (string.IsNullOrEmpty(cometTailModule.primaryBody)) cometTailModule.primaryBody = config.Orbit.primaryBody;
Delay.FireOnNextUpdate(() =>
{
controller.SetPrimaryBody(
AstroObjectLocator.GetAstroObject(cometTailModule.primaryBody).transform,
AstroObjectLocator.GetAstroObject(config.Orbit.primaryBody).GetAttachedOWRigidbody()
AstroObjectLocator.GetAstroObject(cometTailModule.primaryBody).transform,
primaryBody.GetAttachedOWRigidbody()
);
});

View File

@ -203,7 +203,7 @@ namespace NewHorizons.Builder.Body
if (body.Config.CometTail != null)
{
CometTailBuilder.Make(proxy, null, body.Config.CometTail, body.Config);
CometTailBuilder.Make(proxy, null, body.Config.CometTail, body.Config, planetGO.GetComponent<AstroObject>());
}
if (body.Config.Props?.proxyDetails != null)

View File

@ -150,6 +150,7 @@ namespace NewHorizons.Builder.Body
streamingVolume.streamingGroup = streamingGroup;
streamingVolume.transform.parent = blackHoleVolume.transform;
streamingVolume.transform.localPosition = Vector3.zero;
streamingVolume.gameObject.SetActive(true);
}
}
catch (Exception e)

View File

@ -25,5 +25,8 @@ public static class GroupsBuilder
go.GetAddComponent<SectorCullGroup>()._sector = sector;
go.GetAddComponent<SectorCollisionGroup>()._sector = sector;
go.GetAddComponent<SectorLightsCullGroup>()._sector = sector;
// SectorCollisionGroup is unique among the sector groups because it only attaches its event listener on Start() instead of Awake(), so if the detail gets immediately deactivated then it never gets attached. To avoid this, we'll attach the event listener manually (even if it means getting attached twice).
sector.OnSectorOccupantsUpdated += go.GetComponent<SectorCollisionGroup>().OnSectorOccupantsUpdated;
}
}

View File

@ -15,7 +15,7 @@ namespace NewHorizons.Builder.General
{
var module = config.MapMarker;
NHMapMarker mapMarker = body.AddComponent<NHMapMarker>();
mapMarker._labelID = (UITextType)TranslationHandler.AddUI(config.name);
mapMarker._labelID = (UITextType)TranslationHandler.AddUI(config.name, true);
var markerType = MapMarker.MarkerType.Planet;

View File

@ -69,6 +69,8 @@ namespace NewHorizons.Builder.General
PlayerSpawn = playerSpawn;
PlayerSpawnInfo = point;
}
spawnGO.SetActive(true);
}
}
@ -77,7 +79,6 @@ namespace NewHorizons.Builder.General
foreach (var point in module.shipSpawnPoints)
{
var spawnGO = GeneralPropBuilder.MakeNew("ShipSpawnPoint", planetGO, null, point);
spawnGO.SetActive(false);
spawnGO.layer = Layer.PlayerSafetyCollider;
var shipSpawn = spawnGO.AddComponent<SpawnPoint>();

View File

@ -4,6 +4,7 @@ using NewHorizons.External.Configs;
using NewHorizons.External.Modules.Props.Audio;
using NewHorizons.Handlers;
using NewHorizons.Utility;
using NewHorizons.Utility.DebugTools;
using NewHorizons.Utility.OuterWilds;
using NewHorizons.Utility.OWML;
using Newtonsoft.Json;
@ -12,7 +13,6 @@ using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using static NewHorizons.External.Modules.BrambleModule;
using static NewHorizons.External.Modules.SignalModule;
namespace NewHorizons.Builder.Props
{
@ -204,6 +204,10 @@ namespace NewHorizons.Builder.Props
foreach (var fogWarpVolume in brambleNode.GetComponentsInChildren<FogWarpVolume>(true).Append(brambleNode.GetComponent<FogWarpVolume>()))
{
_nhFogWarpVolumes.Add(fogWarpVolume);
if (fogWarpVolume is SphericalFogWarpVolume sphericalFogWarpVolume)
{
fogWarpVolume.gameObject.GetAddComponent<DebugFogWarp>().fogWarpVolume = sphericalFogWarpVolume;
}
}
var innerFogWarpVolume = brambleNode.GetComponent<InnerFogWarpVolume>();

View File

@ -356,7 +356,10 @@ namespace NewHorizons.Builder.Props
singleLightSensor._sector.OnSectorOccupantsUpdated -= singleLightSensor.OnSectorOccupantsUpdated;
}
singleLightSensor._sector = sector;
singleLightSensor._sector.OnSectorOccupantsUpdated += singleLightSensor.OnSectorOccupantsUpdated;
if (singleLightSensor._sector != null)
{
singleLightSensor._sector.OnSectorOccupantsUpdated += singleLightSensor.OnSectorOccupantsUpdated;
}
}
}
@ -470,10 +473,14 @@ namespace NewHorizons.Builder.Props
{
// These flood toggles are to disable flooded docks on the Stranger
// Presumably the user isn't making one of those
foreach (var toggle in dock.GetComponents<FloodToggle>())
foreach (var toggle in dock.GetComponentsInChildren<FloodToggle>())
{
Component.DestroyImmediate(toggle);
}
foreach (var floodSensor in dock.GetComponentsInChildren<RingRiverFloodSensor>())
{
Component.DestroyImmediate(floodSensor);
}
}
}

View File

@ -290,6 +290,10 @@ namespace NewHorizons.Builder.Props
interact._interactRange = info.range;
// If a dialogue is on the ship, make sure its usable
// Assumes these are inside the ship and not outside, not sure if thats an issue
interact._usableInShip = planetGO.name == "Ship_Body";
if (info.radius <= 0)
{
sphere.enabled = false;

View File

@ -1,3 +1,4 @@
using NewHorizons.Components.EOTE;
using NewHorizons.External.Modules.Props;
using NewHorizons.External.Modules.Props.EchoesOfTheEye;
using NewHorizons.Handlers;
@ -70,6 +71,12 @@ namespace NewHorizons.Builder.Props.EchoesOfTheEye
dreamCandle._startLit = info.startLit;
dreamCandle.SetLit(info.startLit, false, true);
if (info.condition != null)
{
var conditionController = dreamCandle.gameObject.AddComponent<DreamLightConditionController>();
conditionController.SetFromInfo(info.condition);
}
return candleObj;
}
}

View File

@ -1,3 +1,4 @@
using NewHorizons.Components.EOTE;
using NewHorizons.External.Modules.Props;
using NewHorizons.External.Modules.Props.EchoesOfTheEye;
using NewHorizons.Handlers;
@ -116,6 +117,13 @@ namespace NewHorizons.Builder.Props.EchoesOfTheEye
projector._lit = info.startLit;
projector._startLit = info.startLit;
projector._extinguishOnly = info.extinguishOnly;
if (info.condition != null)
{
var conditionController = projector.gameObject.AddComponent<DreamLightConditionController>();
conditionController.SetFromInfo(info.condition);
}
/*
Delay.FireOnNextUpdate(() =>
{

View File

@ -0,0 +1,180 @@
using NewHorizons.Components.Props;
using NewHorizons.External.Modules.Props.EchoesOfTheEye;
using NewHorizons.Handlers;
using NewHorizons.Utility;
using NewHorizons.Utility.OWML;
using System.Collections.Generic;
using UnityEngine;
namespace NewHorizons.Builder.Props.EchoesOfTheEye
{
public static class RaftBuilder
{
private static GameObject _prefab;
private static GameObject _cleanPrefab;
internal static void InitPrefab()
{
if (_prefab == null)
{
_prefab = Object.FindObjectOfType<RaftController>()?.gameObject?.InstantiateInactive()?.Rename("Raft_Body_Prefab")?.DontDestroyOnLoad();
if (_prefab == null)
{
NHLogger.LogWarning($"Tried to make a raft but couldn't. Do you have the DLC installed?");
return;
}
else
{
_prefab.AddComponent<DestroyOnDLC>()._destroyOnDLCNotOwned = true;
var raftController = _prefab.GetComponent<RaftController>();
if (raftController._sector != null)
{
// Since awake already ran we have to unhook these events
raftController._sector.OnOccupantEnterSector -= raftController.OnOccupantEnterSector;
raftController._sector.OnOccupantExitSector -= raftController.OnOccupantExitSector;
raftController._sector = null;
}
raftController._riverFluid = null;
foreach (var lightSensor in _prefab.GetComponentsInChildren<SingleLightSensor>())
{
if (lightSensor._sector != null)
{
lightSensor._sector.OnSectorOccupantsUpdated -= lightSensor.OnSectorOccupantsUpdated;
lightSensor._sector = null;
}
lightSensor._detectDreamLanterns = true;
lightSensor._lanternFocusThreshold = 0.9f;
lightSensor._illuminatingDreamLanternList = new List<DreamLanternController>();
lightSensor._lightSourceMask |= LightSourceType.DREAM_LANTERN;
}
// TODO: Change to one mesh
var twRaftRoot = new GameObject("Effects_IP_SIM_Raft");
twRaftRoot.transform.SetParent(_prefab.transform, false);
var twRaft = SearchUtilities.Find("DreamWorld_Body/Sector_DreamWorld/Interactibles_Dreamworld/DreamRaft_Body/Effects_IP_SIM_Raft_1Way")
.Instantiate(Vector3.zero, Quaternion.identity, twRaftRoot.transform).Rename("Effects_IP_SIM_Raft_1Way");
twRaft.Instantiate(Vector3.zero, Quaternion.Euler(0, 180, 0), twRaftRoot.transform).Rename(twRaft.name);
twRaft.Instantiate(Vector3.zero, Quaternion.Euler(0, 90, 0), twRaftRoot.transform).Rename(twRaft.name);
twRaft.Instantiate(Vector3.zero, Quaternion.Euler(0, -90, 0), twRaftRoot.transform).Rename(twRaft.name);
}
}
if (_cleanPrefab == null && _prefab != null)
{
_cleanPrefab = _prefab?.InstantiateInactive()?.Rename("Raft_Body_Prefab_Clean")?.DontDestroyOnLoad();
if (_cleanPrefab == null)
{
NHLogger.LogWarning($"Tried to make a raft but couldn't. Do you have the DLC installed?");
return;
}
else
{
var raftController = _cleanPrefab.GetComponent<RaftController>();
var rwRaft = _cleanPrefab.FindChild("Structure_IP_Raft");
var rwRaftAnimator = rwRaft.GetComponent<Animator>();
var rac = rwRaftAnimator.runtimeAnimatorController;
Object.DestroyImmediate(rwRaft);
var dwRaft = SearchUtilities.Find("DreamWorld_Body/Sector_DreamWorld/Interactibles_Dreamworld/DreamRaft_Body/Structure_IP_Raft")
.Instantiate(Vector3.zero, Quaternion.identity, _cleanPrefab.transform).Rename("Structure_IP_DreamRaft");
dwRaft.transform.SetSiblingIndex(3);
foreach (var child in dwRaft.GetAllChildren())
{
child.SetActive(true);
}
var dwRaftAnimator = dwRaft.AddComponent<Animator>();
dwRaftAnimator.runtimeAnimatorController = rac;
raftController._railingAnimator = dwRaftAnimator;
var dwLightSensorForward = SearchUtilities.Find("DreamWorld_Body/Sector_DreamWorld/Interactibles_Dreamworld/DreamRaft_Body/LightSensor_Forward");
var dwLightSensorOrigMaterial = dwLightSensorForward.GetComponent<LightSensorEffects>()._origMaterial;
var dwLightSensor = dwLightSensorForward.FindChild("Structure_IP_Raft_Sensor");
ChangeSensor(_cleanPrefab.FindChild("LightSensorRoot/LightSensor_Forward"), dwLightSensorOrigMaterial, dwLightSensor);
ChangeSensor(_cleanPrefab.FindChild("LightSensorRoot/LightSensor_Right"), dwLightSensorOrigMaterial, dwLightSensor);
ChangeSensor(_cleanPrefab.FindChild("LightSensorRoot/LightSensor_Rear"), dwLightSensorOrigMaterial, dwLightSensor, true);
ChangeSensor(_cleanPrefab.FindChild("LightSensorRoot/LightSensor_Left"), dwLightSensorOrigMaterial, dwLightSensor);
}
}
}
private static void ChangeSensor(GameObject lightSensor, Material origMaterial, GameObject newLightSensor, bool reverse = false)
{
var singleLightSensor = lightSensor.GetComponent<SingleLightSensor>();
var lightSensorEffects = lightSensor.GetComponent<LightSensorEffects>();
lightSensorEffects._lightSensor = singleLightSensor;
Object.DestroyImmediate(lightSensor.FindChild("Structure_IP_Raft_Sensor"));
lightSensorEffects._origMaterial = origMaterial;
var copiedLightSensor = newLightSensor
.Instantiate(reverse ? new Vector3(0, -1.5f, -0.1303f) : new Vector3(0, -1.5f, -0.0297f),
reverse ? Quaternion.identity : Quaternion.Euler(0, 180, 0),
lightSensor.transform).Rename("Structure_IP_DreamRaft_Sensor");
var bulb = copiedLightSensor.FindChild("Props_IP_Raft_Lamp_geoBulb");
lightSensorEffects._renderer = bulb.GetComponent<MeshRenderer>();
lightSensorEffects._lightRenderer = bulb.GetComponent<OWRenderer>();
}
public static GameObject Make(GameObject planetGO, Sector sector, RaftInfo info, OWRigidbody planetBody)
{
InitPrefab();
if (_prefab == null || _cleanPrefab == null || sector == null) return null;
GameObject raftObject = GeneralPropBuilder.MakeFromPrefab(info.pristine ? _cleanPrefab : _prefab, "Raft_Body", planetGO, sector, info);
StreamingHandler.SetUpStreaming(raftObject, sector);
var raftController = raftObject.GetComponent<RaftController>();
raftController._sector = sector;
raftController._acceleration = info.acceleration;
sector.OnOccupantEnterSector += raftController.OnOccupantEnterSector;
sector.OnOccupantExitSector += raftController.OnOccupantExitSector;
// Detectors
var fluidDetector = raftObject.transform.Find("Detector_Raft").GetComponent<RaftFluidDetector>();
var waterVolume = planetGO.GetComponentInChildren<RadialFluidVolume>();
fluidDetector._alignmentFluid = waterVolume;
fluidDetector._buoyancy.checkAgainstWaves = true;
// Rafts were unable to trigger docks because these were disabled for some reason
fluidDetector.GetComponent<BoxShape>().enabled = true;
fluidDetector.GetComponent<OWCollider>().enabled = true;
// Light sensors
foreach (var lightSensor in raftObject.GetComponentsInChildren<SingleLightSensor>())
{
lightSensor._sector = sector;
sector.OnSectorOccupantsUpdated += lightSensor.OnSectorOccupantsUpdated;
}
var nhRaftController = raftObject.AddComponent<NHRaftController>();
var achievementObject = new GameObject("AchievementVolume");
achievementObject.transform.SetParent(raftObject.transform, false);
var shape = achievementObject.AddComponent<SphereShape>();
shape.radius = 3;
shape.SetCollisionMode(Shape.CollisionMode.Volume);
achievementObject.AddComponent<OWTriggerVolume>()._shape = shape;
achievementObject.AddComponent<OtherMods.AchievementsPlus.NH.RaftingAchievement>();
raftObject.SetActive(true);
if (planetGO != null && !string.IsNullOrEmpty(info.dockPath))
{
var dockTransform = planetGO.transform.Find(info.dockPath);
if (dockTransform != null && dockTransform.TryGetComponent(out RaftDock raftDock))
{
raftController.SkipSuspendOnStart();
raftDock._startRaft = raftController;
raftDock._raft = raftController;
}
else
{
NHLogger.LogError($"Cannot find raft dock object at path: {planetGO.name}/{info.dockPath}");
}
}
return raftObject;
}
}
}

View File

@ -0,0 +1,55 @@
using NewHorizons.Components.Props;
using NewHorizons.External.Modules.Props;
using NewHorizons.External.Modules.Props.EchoesOfTheEye;
using NewHorizons.Handlers;
using NewHorizons.Utility;
using NewHorizons.Utility.OWML;
using OWML.Common;
using UnityEngine;
namespace NewHorizons.Builder.Props.EchoesOfTheEye
{
public static class RaftDockBuilder
{
private static GameObject _prefab;
internal static void InitPrefab()
{
if (_prefab == null)
{
_prefab = SearchUtilities.Find("RingWorld_Body/Sector_RingInterior/Sector_Zone1/Structures_Zone1/RaftHouse_ArrivalPatio_Zone1/Interactables_RaftHouse_ArrivalPatio_Zone1/Prefab_IP_RaftDock").InstantiateInactive().Rename("Prefab_RaftDock").DontDestroyOnLoad();
if (_prefab == null)
{
NHLogger.LogWarning($"Tried to make a raft dock but couldn't. Do you have the DLC installed?");
return;
}
else
{
_prefab.AddComponent<DestroyOnDLC>()._destroyOnDLCNotOwned = true;
var raftDock = _prefab.GetComponent<RaftDock>();
raftDock._startRaft = null;
raftDock._floodSensor = null;
foreach (var floodToggle in _prefab.GetComponents<FloodToggle>())
{
Component.DestroyImmediate(floodToggle);
}
Object.DestroyImmediate(_prefab.FindChild("FloodSensor"));
Object.DestroyImmediate(_prefab.FindChild("FloodSensor_RaftHouseArrivalPatio_NoDelay"));
}
}
}
public static GameObject Make(GameObject planetGO, Sector sector, RaftDockInfo info, IModBehaviour mod)
{
InitPrefab();
if (_prefab == null || sector == null) return null;
var dockObject = DetailBuilder.Make(planetGO, sector, mod, _prefab, new DetailInfo(info));
//var raftDock = dockObject.GetComponent<RaftDock>();
return dockObject;
}
}
}

View File

@ -1,6 +1,7 @@
using NewHorizons.Components.Props;
using NewHorizons.External.Modules.Props.Item;
using NewHorizons.Handlers;
using NewHorizons.Utility.OuterWilds;
using NewHorizons.Utility.OWML;
using OWML.Common;
using OWML.Utils;
@ -15,18 +16,13 @@ namespace NewHorizons.Builder.Props
internal static void Init()
{
if (_itemTypes != null)
{
foreach (var value in _itemTypes.Values)
{
EnumUtils.Remove<ItemType>(value);
}
}
_itemTypes = new Dictionary<string, ItemType>();
}
public static NHItem MakeItem(GameObject go, GameObject planetGO, Sector sector, ItemInfo info, IModBehaviour mod)
{
go.layer = Layer.Interactible;
var itemName = info.name;
if (string.IsNullOrEmpty(itemName))
{
@ -93,10 +89,13 @@ namespace NewHorizons.Builder.Props
if (info.colliderRadius > 0f)
{
go.AddComponent<SphereCollider>().radius = info.colliderRadius;
var col = go.AddComponent<SphereCollider>();
col.radius = info.colliderRadius;
col.isTrigger = info.colliderIsTrigger;
go.GetAddComponent<OWCollider>();
}
// Wait until next frame when all objects are built before trying to socket the item if it has an initial socket
Delay.FireOnNextUpdate(() =>
{
if (item != null && !string.IsNullOrEmpty(info.pathToInitialSocket))
@ -133,11 +132,9 @@ namespace NewHorizons.Builder.Props
public static NHItemSocket MakeSocket(GameObject go, GameObject planetGO, Sector sector, ItemSocketInfo info)
{
var itemType = EnumUtils.TryParse(info.itemType, true, out ItemType result) ? result : ItemType.Invalid;
if (itemType == ItemType.Invalid && !string.IsNullOrEmpty(info.itemType))
{
itemType = EnumUtilities.Create<ItemType>(info.itemType);
}
go.layer = Layer.Interactible;
var itemType = GetOrCreateItemType(info.itemType);
var socket = go.GetAddComponent<NHItemSocket>();
socket._sector = sector;
@ -151,15 +148,18 @@ namespace NewHorizons.Builder.Props
if (socket._socketTransform == null)
{
var socketGO = GeneralPropBuilder.MakeNew("Socket", planetGO, sector, info, defaultParent: go.transform);
if (info.colliderRadius > 0f)
{
go.AddComponent<SphereCollider>().radius = info.colliderRadius;
go.GetAddComponent<OWCollider>();
}
socketGO.SetActive(true);
socket._socketTransform = socketGO.transform;
}
if (info.colliderRadius > 0f)
{
var col = go.AddComponent<SphereCollider>();
col.radius = info.colliderRadius;
col.isTrigger = info.colliderIsTrigger;
go.GetAddComponent<OWCollider>();
}
socket.ItemType = itemType;
socket.UseGiveTakePrompts = info.useGiveTakePrompts;
socket.InsertCondition = info.insertCondition;
@ -169,6 +169,7 @@ namespace NewHorizons.Builder.Props
socket.ClearRemovalConditionOnInsert = info.clearRemovalConditionOnInsert;
socket.RemovalFact = info.removalFact;
// Wait until initial item socketing is done before considering the socket empty
Delay.FireInNUpdates(() =>
{
if (socket != null && !socket._socketedItem)
@ -193,7 +194,7 @@ namespace NewHorizons.Builder.Props
}
else if (!string.IsNullOrEmpty(name))
{
itemType = EnumUtils.Create<ItemType>(name);
itemType = EnumUtilities.Create<ItemType>(name);
_itemTypes.Add(name, itemType);
}
return itemType;

View File

@ -312,7 +312,7 @@ namespace NewHorizons.Builder.Props
scrollItem._nomaiWallText = nomaiWallText;
scrollItem.SetSector(sector);
customScroll.transform.Find("Props_NOM_Scroll/Props_NOM_Scroll_Geo").GetComponent<MeshRenderer>().enabled = true;
customScroll.transform.Find("Props_NOM_Scroll/Props_NOM_Scroll_Collider").gameObject.SetActive(true);
customScroll.transform.Find("Props_NOM_Scroll/Props_NOM_Scroll_Collider").gameObject.SetActive(false);
nomaiWallText.gameObject.GetComponent<Collider>().enabled = false;
customScroll.GetComponent<CapsuleCollider>().enabled = true;
}

View File

@ -43,6 +43,7 @@ namespace NewHorizons.Builder.Props
private static GameObject _autoPrefab;
private static GameObject _visionTorchDetectorPrefab;
private static GameObject _standingVisionTorchPrefab;
private static GameObject _standingVisionTorchCleanPrefab;
private static readonly int EmissionMap = Shader.PropertyToID("_EmissionMap");
private static bool _isInit;
@ -90,13 +91,28 @@ namespace NewHorizons.Builder.Props
_visionTorchDetectorPrefab.AddComponent<DestroyOnDLC>()._destroyOnDLCNotOwned = true;
}
if (_standingVisionTorchCleanPrefab == null)
{
_standingVisionTorchCleanPrefab = SearchUtilities.Find("DreamWorld_Body/Sector_DreamWorld/Sector_DreamZone_4/Interactibles_DreamZone_4_Upper/Prefab_IP_VisionTorchProjector")?.gameObject?.InstantiateInactive()?.Rename("Prefab_DW_VisionTorchProjector")?.DontDestroyOnLoad();
if (_standingVisionTorchCleanPrefab == null)
NHLogger.LogWarning($"Tried to make standing vision torch prefab but couldn't. Do you have the DLC installed?");
else
{
_standingVisionTorchCleanPrefab.AddComponent<DestroyOnDLC>()._destroyOnDLCNotOwned = true;
GameObject.DestroyImmediate(_standingVisionTorchCleanPrefab.FindChild("Prefab_IP_Reel_PrisonPeephole_Vision"));
}
}
if (_standingVisionTorchPrefab == null)
{
_standingVisionTorchPrefab = SearchUtilities.Find("RingWorld_Body/Sector_RingWorld/Sector_SecretEntrance/Interactibles_SecretEntrance/Experiment_1/VisionTorchApparatus/VisionTorchRoot/Prefab_IP_VisionTorchProjector")?.gameObject?.InstantiateInactive()?.Rename("Prefab_IP_VisionTorchProjector")?.DontDestroyOnLoad();
if (_standingVisionTorchPrefab == null)
NHLogger.LogWarning($"Tried to make standing vision torch prefab but couldn't. Do you have the DLC installed?");
else
{
_standingVisionTorchPrefab.AddComponent<DestroyOnDLC>()._destroyOnDLCNotOwned = true;
GameObject.Instantiate(_standingVisionTorchCleanPrefab.FindChild("Effects_IP_SIM_VisionTorch"), _standingVisionTorchPrefab.transform, false).Rename("Effects_IP_SIM_VisionTorch");
}
}
}
@ -446,10 +462,11 @@ namespace NewHorizons.Builder.Props
{
InitPrefabs();
if (_standingVisionTorchPrefab == null) return null;
if (_standingVisionTorchPrefab == null || _standingVisionTorchCleanPrefab == null) return null;
// Spawn the torch itself
var standingTorch = DetailBuilder.Make(planetGO, sector, mod, _standingVisionTorchPrefab, new DetailInfo(info));
var prefab = info.reelCondition == ProjectionInfo.SlideReelCondition.Pristine ? _standingVisionTorchCleanPrefab : _standingVisionTorchPrefab;
var standingTorch = DetailBuilder.Make(planetGO, sector, mod, prefab, new DetailInfo(info));
if (standingTorch == null)
{

View File

@ -114,6 +114,7 @@ namespace NewHorizons.Builder.Props
MakeGeneralProps(go, config.Props.grappleTotems, (totem) => GrappleTotemBuilder.Make(go, sector, totem, mod));
MakeGeneralProps(go, config.Props.dreamCampfires, (campfire) => DreamCampfireBuilder.Make(go, sector, campfire, mod), (campfire) => campfire.id);
MakeGeneralProps(go, config.Props.dreamArrivalPoints, (point) => DreamArrivalPointBuilder.Make(go, sector, point, mod), (point) => point.id);
MakeGeneralProps(go, config.Props.raftDocks, (dock) => RaftDockBuilder.Make(go, sector, dock, mod));
MakeGeneralProps(go, config.Props.rafts, (raft) => RaftBuilder.Make(go, sector, raft, planetBody));
}
MakeGeneralProps(go, config.Props.tornados, (tornado) => TornadoBuilder.Make(go, sector, tornado, config.Atmosphere?.clouds != null));

View File

@ -69,13 +69,17 @@ namespace NewHorizons.Builder.Props
{
(GameObject go, QuantumDetailInfo detail)[] propsInGroup = quantumGroup.details.Select(x => (DetailBuilder.GetGameObjectFromDetailInfo(x), x)).ToArray();
GameObject specialProp = null;
QuantumDetailInfo specialInfo = null;
if (propsInGroup.Length == quantumGroup.sockets.Length)
{
// Special case!
specialProp = propsInGroup.Last().go;
propsInGroup.Last().go.SetActive(false);
// Will be manually positioned on the sockets anyway
specialInfo = propsInGroup.Last().detail;
specialInfo.parentPath = string.Empty;
specialInfo.isRelativeToParent = false;
var propsInGroupList = propsInGroup.ToList();
propsInGroupList.RemoveAt(propsInGroup.Length - 1);
propsInGroup = propsInGroupList.ToArray();
@ -117,13 +121,13 @@ namespace NewHorizons.Builder.Props
prop.go.SetActive(true);
}
if (specialProp != null)
if (specialInfo != null)
{
// Can't have 4 objects in 4 slots
// Instead we have a duplicate of the final object for each slot, which appears when that slot is "empty"
for (int i = 0; i < sockets.Length; i++)
{
var emptySocketObject = DetailBuilder.Make(planetGO, sector, mod, specialProp, new DetailInfo());
{
var emptySocketObject = DetailBuilder.Make(planetGO, sector, mod, new DetailInfo(specialInfo));
var socket = sockets[i];
socket._emptySocketObject = emptySocketObject;
emptySocketObject.SetActive(socket._quantumObject == null);

View File

@ -1,97 +0,0 @@
using NewHorizons.Components.Props;
using NewHorizons.External.Modules.Props.EchoesOfTheEye;
using NewHorizons.Handlers;
using NewHorizons.Utility;
using NewHorizons.Utility.OWML;
using UnityEngine;
namespace NewHorizons.Builder.Props
{
public static class RaftBuilder
{
private static GameObject _prefab;
internal static void InitPrefab()
{
if (_prefab == null)
{
_prefab = Object.FindObjectOfType<RaftController>()?.gameObject?.InstantiateInactive()?.Rename("Raft_Body_Prefab")?.DontDestroyOnLoad();
if (_prefab == null)
{
NHLogger.LogWarning($"Tried to make a raft but couldn't. Do you have the DLC installed?");
return;
}
else
{
_prefab.AddComponent<DestroyOnDLC>()._destroyOnDLCNotOwned = true;
var raftController = _prefab.GetComponent<RaftController>();
if (raftController._sector != null)
{
// Since awake already ran we have to unhook these events
raftController._sector.OnOccupantEnterSector -= raftController.OnOccupantEnterSector;
raftController._sector.OnOccupantExitSector -= raftController.OnOccupantExitSector;
raftController._sector = null;
}
raftController._riverFluid = null;
foreach (var lightSensor in _prefab.GetComponentsInChildren<SingleLightSensor>())
{
if (lightSensor._sector != null)
{
lightSensor._sector.OnSectorOccupantsUpdated -= lightSensor.OnSectorOccupantsUpdated;
lightSensor._sector = null;
}
}
}
}
}
public static GameObject Make(GameObject planetGO, Sector sector, RaftInfo info, OWRigidbody planetBody)
{
InitPrefab();
if (_prefab == null || sector == null) return null;
GameObject raftObject = GeneralPropBuilder.MakeFromPrefab(_prefab, "Raft_Body", planetGO, sector, info);
StreamingHandler.SetUpStreaming(raftObject, sector);
var raftController = raftObject.GetComponent<RaftController>();
raftController._sector = sector;
raftController._acceleration = info.acceleration;
sector.OnOccupantEnterSector += raftController.OnOccupantEnterSector;
sector.OnOccupantExitSector += raftController.OnOccupantExitSector;
// Detectors
var fluidDetector = raftObject.transform.Find("Detector_Raft").GetComponent<RaftFluidDetector>();
var waterVolume = planetGO.GetComponentInChildren<RadialFluidVolume>();
fluidDetector._alignmentFluid = waterVolume;
fluidDetector._buoyancy.checkAgainstWaves = true;
// Rafts were unable to trigger docks because these were disabled for some reason
fluidDetector.GetComponent<BoxShape>().enabled = true;
fluidDetector.GetComponent<OWCollider>().enabled = true;
// Light sensors
foreach (var lightSensor in raftObject.GetComponentsInChildren<SingleLightSensor>())
{
lightSensor._sector = sector;
sector.OnSectorOccupantsUpdated += lightSensor.OnSectorOccupantsUpdated;
}
var nhRaftController = raftObject.AddComponent<NHRaftController>();
var achievementObject = new GameObject("AchievementVolume");
achievementObject.transform.SetParent(raftObject.transform, false);
var shape = achievementObject.AddComponent<SphereShape>();
shape.radius = 3;
shape.SetCollisionMode(Shape.CollisionMode.Volume);
achievementObject.AddComponent<OWTriggerVolume>()._shape = shape;
achievementObject.AddComponent<OtherMods.AchievementsPlus.NH.RaftingAchievement>();
raftObject.SetActive(true);
return raftObject;
}
}
}

View File

@ -0,0 +1,183 @@
using NewHorizons.Components;
using NewHorizons.External.Modules.Props;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace NewHorizons.Builder.Props
{
public static class ShapeBuilder
{
public static OWTriggerVolume AddTriggerVolume(GameObject go, ShapeInfo info, float defaultRadius)
{
var owTriggerVolume = go.AddComponent<OWTriggerVolume>();
if (info != null)
{
var shapeOrCol = AddShapeOrCollider(go, info);
if (shapeOrCol is Shape shape)
{
owTriggerVolume._shape = shape;
}
else if (shapeOrCol is Collider col)
{
owTriggerVolume._owCollider = col.GetComponent<OWCollider>();
}
}
else
{
var shape = go.AddComponent<SphereShape>();
shape.radius = defaultRadius;
owTriggerVolume._shape = shape;
}
return owTriggerVolume;
}
public static Component AddShapeOrCollider(GameObject go, ShapeInfo info)
{
if (info.useShape.HasValue)
{
// Explicitly add either a shape or collider if specified
if (info.useShape.Value)
{
return AddShape(go, info);
}
else
{
return AddCollider(go, info);
}
}
else
{
// Prefer shapes over colliders if no preference is specified and not using collision
// This is required for backwards compat (previously it defaulted to shapes)
// A common-ish puzzle is to put an insulating volume on a held item. Held items disabled all colliders when held, but don't disable shapes.
// Changing the default from shapes to colliders broke these puzzles
// The reason OWItem disables all colliders (even those that are just triggers) is presumably for scrolls which have nomai text as a trigger collider
if (info.hasCollision)
{
return AddCollider(go, info);
}
else
{
return AddShape(go, info);
}
}
}
public static Shape AddShape(GameObject go, ShapeInfo info)
{
if (info.hasCollision)
{
throw new NotSupportedException($"Shapes do not support collision; set {nameof(info.hasCollision)} to false or use a supported collider type (sphere, box, or capsule).");
}
if (info.useShape.HasValue && !info.useShape.Value)
{
throw new NotSupportedException($"{info.useShape} was explicitly set to false but a shape is required here.");
}
switch (info.type)
{
case ShapeType.Sphere:
var sphereShape = go.AddComponent<SphereShape>();
sphereShape._radius = info.radius;
sphereShape._center = info.offset ?? Vector3.zero;
return sphereShape;
case ShapeType.Box:
var boxShape = go.AddComponent<BoxShape>();
boxShape._size = info.size ?? Vector3.one;
boxShape._center = info.offset ?? Vector3.zero;
return boxShape;
case ShapeType.Capsule:
var capsuleShape = go.AddComponent<CapsuleShape>();
capsuleShape._radius = info.radius;
capsuleShape._direction = (int)info.direction;
capsuleShape._height = info.height;
capsuleShape._center = info.offset ?? Vector3.zero;
return capsuleShape;
case ShapeType.Cylinder:
var cylinderShape = go.AddComponent<CylinderShape>();
cylinderShape._radius = info.radius;
cylinderShape._height = info.height;
cylinderShape._center = info.offset ?? Vector3.zero;
cylinderShape._pointChecksOnly = true;
return cylinderShape;
case ShapeType.Cone:
var coneShape = go.AddComponent<ConeShape>();
coneShape._topRadius = info.innerRadius;
coneShape._bottomRadius = info.outerRadius;
coneShape._direction = (int)info.direction;
coneShape._height = info.height;
coneShape._center = info.offset ?? Vector3.zero;
coneShape._pointChecksOnly = true;
return coneShape;
case ShapeType.Hemisphere:
var hemisphereShape = go.AddComponent<HemisphereShape>();
hemisphereShape._radius = info.radius;
hemisphereShape._direction = (int)info.direction;
hemisphereShape._cap = info.cap;
hemisphereShape._center = info.offset ?? Vector3.zero;
hemisphereShape._pointChecksOnly = true;
return hemisphereShape;
case ShapeType.Hemicapsule:
var hemicapsuleShape = go.AddComponent<HemicapsuleShape>();
hemicapsuleShape._radius = info.radius;
hemicapsuleShape._direction = (int)info.direction;
hemicapsuleShape._height = info.height;
hemicapsuleShape._cap = info.cap;
hemicapsuleShape._center = info.offset ?? Vector3.zero;
hemicapsuleShape._pointChecksOnly = true;
return hemicapsuleShape;
case ShapeType.Ring:
var ringShape = go.AddComponent<RingShape>();
ringShape.innerRadius = info.innerRadius;
ringShape.outerRadius = info.outerRadius;
ringShape.height = info.height;
ringShape.center = info.offset ?? Vector3.zero;
ringShape._pointChecksOnly = true;
return ringShape;
default:
throw new ArgumentOutOfRangeException(nameof(info.type), info.type, $"Unsupported shape type");
}
}
public static Collider AddCollider(GameObject go, ShapeInfo info)
{
if (info.useShape.HasValue && info.useShape.Value)
{
throw new NotSupportedException($"{info.useShape} was explicitly set to true but a non-shape collider is required here.");
}
switch (info.type)
{
case ShapeType.Sphere:
var sphereCollider = go.AddComponent<SphereCollider>();
sphereCollider.radius = info.radius;
sphereCollider.center = info.offset ?? Vector3.zero;
sphereCollider.isTrigger = !info.hasCollision;
go.GetAddComponent<OWCollider>();
return sphereCollider;
case ShapeType.Box:
var boxCollider = go.AddComponent<BoxCollider>();
boxCollider.size = info.size ?? Vector3.one;
boxCollider.center = info.offset ?? Vector3.zero;
boxCollider.isTrigger = !info.hasCollision;
go.GetAddComponent<OWCollider>();
return boxCollider;
case ShapeType.Capsule:
var capsuleCollider = go.AddComponent<CapsuleCollider>();
capsuleCollider.radius = info.radius;
capsuleCollider.direction = (int)info.direction;
capsuleCollider.height = info.height;
capsuleCollider.center = info.offset ?? Vector3.zero;
capsuleCollider.isTrigger = !info.hasCollision;
go.GetAddComponent<OWCollider>();
return capsuleCollider;
default:
throw new ArgumentOutOfRangeException(nameof(info.type), info.type, $"Unsupported collider type");
}
}
}
}

View File

@ -206,7 +206,7 @@ namespace NewHorizons.Builder.Props.TranslatorText
scrollItem._nomaiWallText = nomaiWallText;
scrollItem.SetSector(sector);
customScroll.transform.Find("Props_NOM_Scroll/Props_NOM_Scroll_Geo").GetComponent<MeshRenderer>().enabled = true;
customScroll.transform.Find("Props_NOM_Scroll/Props_NOM_Scroll_Collider").gameObject.SetActive(true);
customScroll.transform.Find("Props_NOM_Scroll/Props_NOM_Scroll_Collider").gameObject.SetActive(false);
nomaiWallText.gameObject.GetComponent<Collider>().enabled = false;
customScroll.GetComponent<CapsuleCollider>().enabled = true;
scrollItem._nomaiWallText.HideImmediate();
@ -471,7 +471,7 @@ namespace NewHorizons.Builder.Props.TranslatorText
if (info.arcInfo != null && info.arcInfo.Count() != dict.Values.Count())
{
NHLogger.LogError($"Can't make NomaiWallText, arcInfo length [{info.arcInfo.Count()}] doesn't equal number of TextBlocks [{dict.Values.Count()}] in the xml");
NHLogger.LogError($"Can't make NomaiWallText [{info.xmlFile}], arcInfo length [{info.arcInfo.Count()}] doesn't equal number of TextBlocks [{dict.Values.Count()}] in the xml");
return;
}

View File

@ -459,11 +459,6 @@ namespace NewHorizons.Builder.ShipLog
private static MapModeObject ConstructPrimaryNode(List<NewHorizonsBody> bodies)
{
float DistanceFromPrimary(NewHorizonsBody body)
{
return Mathf.Max(body.Config.Orbit.semiMajorAxis, body.Config.Orbit.staticPosition?.Length() ?? 0f);
}
foreach (NewHorizonsBody body in bodies.Where(b => b.Config.Base.centerOfSolarSystem))
{
bodies.Sort((b, o) => b.Config.Orbit.semiMajorAxis.CompareTo(o.Config.Orbit.semiMajorAxis));

View File

@ -25,7 +25,8 @@ namespace NewHorizons.Builder.Volumes
owAudioSource.SetTrack(info.track.ConvertToOW());
AudioUtilities.SetAudioClip(owAudioSource, info.audio, mod);
var audioVolume = go.AddComponent<AudioVolume>();
var audioVolume = PriorityVolumeBuilder.MakeExisting<AudioVolume>(go, planetGO, sector, info);
audioVolume._layer = info.layer;
audioVolume.SetPriority(info.priority);
audioVolume._fadeSeconds = info.fadeSeconds;
@ -33,11 +34,7 @@ namespace NewHorizons.Builder.Volumes
audioVolume._randomizePlayhead = info.randomizePlayhead;
audioVolume._pauseOnFadeOut = info.pauseOnFadeOut;
var shape = go.AddComponent<SphereShape>();
shape.radius = info.radius;
var owTriggerVolume = go.AddComponent<OWTriggerVolume>();
owTriggerVolume._shape = shape;
var owTriggerVolume = go.GetComponent<OWTriggerVolume>();
audioVolume._triggerVolumeOverride = owTriggerVolume;
go.SetActive(true);

View File

@ -13,6 +13,8 @@ namespace NewHorizons.Builder.Volumes
volume.TargetSolarSystem = info.targetStarSystem;
volume.TargetSpawnID = info.spawnPointID;
volume.gameObject.SetActive(true);
return volume;
}
}

View File

@ -0,0 +1,25 @@
using NewHorizons.Components.Volumes;
using NewHorizons.External.Modules.Volumes.VolumeInfos;
using UnityEngine;
namespace NewHorizons.Builder.Volumes
{
internal static class ConditionTriggerVolumeBuilder
{
public static ConditionTriggerVolume Make(GameObject planetGO, Sector sector, ConditionTriggerVolumeInfo info)
{
var volume = VolumeBuilder.Make<ConditionTriggerVolume>(planetGO, sector, info);
volume.Condition = info.condition;
volume.Persistent = info.persistent;
volume.Reversible = info.reversible;
volume.Player = info.player;
volume.Probe = info.probe;
volume.Ship = info.ship;
volume.gameObject.SetActive(true);
return volume;
}
}
}

View File

@ -1,5 +1,6 @@
using NewHorizons.Components.Volumes;
using NewHorizons.External.Modules.Volumes.VolumeInfos;
using OWML.Common;
using OWML.Utils;
using UnityEngine;
@ -7,12 +8,15 @@ namespace NewHorizons.Builder.Volumes
{
internal static class CreditsVolumeBuilder
{
public static LoadCreditsVolume Make(GameObject planetGO, Sector sector, LoadCreditsVolumeInfo info)
public static LoadCreditsVolume Make(GameObject planetGO, Sector sector, LoadCreditsVolumeInfo info, IModBehaviour mod)
{
var volume = VolumeBuilder.Make<LoadCreditsVolume>(planetGO, sector, info);
volume.gameOver = info.gameOver;
volume.deathType = info.deathType == null ? null : EnumUtils.Parse(info.deathType.ToString(), DeathType.Default);
volume.mod = mod;
volume.gameObject.SetActive(true);
return volume;
}

View File

@ -15,7 +15,8 @@ namespace NewHorizons.Builder.Volumes
var go = GeneralPropBuilder.MakeNew("DayNightAudioVolume", planetGO, sector, info);
go.layer = Layer.AdvancedEffectVolume;
var audioVolume = go.AddComponent<NHDayNightAudioVolume>();
var audioVolume = PriorityVolumeBuilder.MakeExisting<NHDayNightAudioVolume>(go, planetGO, sector, info);
audioVolume.sunName = info.sun;
audioVolume.dayWindow = info.dayWindow;
audioVolume.dayAudio = info.dayAudio;
@ -24,13 +25,7 @@ namespace NewHorizons.Builder.Volumes
audioVolume.volume = info.volume;
audioVolume.SetTrack(info.track.ConvertToOW());
var shape = go.AddComponent<SphereShape>();
shape.radius = info.radius;
var owTriggerVolume = go.AddComponent<OWTriggerVolume>();
owTriggerVolume._shape = shape;
go.SetActive(true);
audioVolume.gameObject.SetActive(true);
return audioVolume;
}

View File

@ -12,6 +12,8 @@ namespace NewHorizons.Builder.Volumes
volume._deathType = EnumUtils.Parse<DeathType>(info.deathType.ToString(), DeathType.Default);
volume.gameObject.SetActive(true);
return volume;
}
}

View File

@ -35,6 +35,8 @@ namespace NewHorizons.Builder.Volumes
volume._allowShipAutoroll = info.allowShipAutoroll;
volume._disableOnStart = info.disableOnStart;
volume.gameObject.SetActive(true);
return volume;
}
}

View File

@ -0,0 +1,111 @@
using NewHorizons.Builder.Props;
using NewHorizons.External;
using NewHorizons.External.Modules;
using NewHorizons.External.Modules.Volumes.VolumeInfos;
using NewHorizons.Utility.OuterWilds;
using OWML.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace NewHorizons.Builder.Volumes
{
public static class ForceVolumeBuilder
{
public static CylindricalForceVolume Make(GameObject planetGO, Sector sector, CylindricalForceVolumeInfo info)
{
var forceVolume = Make<CylindricalForceVolume>(planetGO, sector, info);
forceVolume._acceleration = info.force;
forceVolume._localAxis = info.normal ?? Vector3.up;
forceVolume._playGravityCrystalAudio = info.playGravityCrystalAudio;
forceVolume.gameObject.SetActive(true);
return forceVolume;
}
public static DirectionalForceVolume Make(GameObject planetGO, Sector sector, DirectionalForceVolumeInfo info)
{
var forceVolume = Make<DirectionalForceVolume>(planetGO, sector, info);
forceVolume._fieldDirection = info.normal ?? Vector3.up;
forceVolume._fieldMagnitude = info.force;
forceVolume._affectsAlignment = info.affectsAlignment;
forceVolume._offsetCentripetalForce = info.offsetCentripetalForce;
forceVolume._playGravityCrystalAudio = info.playGravityCrystalAudio;
forceVolume.gameObject.SetActive(true);
return forceVolume;
}
public static GravityVolume Make(GameObject planetGO, Sector sector, GravityVolumeInfo info)
{
var forceVolume = Make<GravityVolume>(planetGO, sector, info);
forceVolume._isPlanetGravityVolume = false;
forceVolume._setMass = false;
forceVolume._surfaceAcceleration = info.force;
forceVolume._upperSurfaceRadius = info.upperRadius;
forceVolume._lowerSurfaceRadius = info.lowerRadius;
forceVolume._cutoffAcceleration = info.minForce;
forceVolume._cutoffRadius = info.minRadius;
forceVolume._alignmentRadius = info.alignmentRadius ?? info.upperRadius * 1.5f;
forceVolume._falloffType = info.fallOff switch
{
GravityFallOff.Linear => GravityVolume.FalloffType.linear,
GravityFallOff.InverseSquared => GravityVolume.FalloffType.inverseSquared,
_ => throw new NotImplementedException(),
};
forceVolume.gameObject.SetActive(true);
return forceVolume;
}
public static PolarForceVolume Make(GameObject planetGO, Sector sector, PolarForceVolumeInfo info)
{
var forceVolume = Make<PolarForceVolume>(planetGO, sector, info);
forceVolume._acceleration = info.force;
forceVolume._localAxis = info.normal ?? Vector3.up;
forceVolume._fieldMode = info.tangential ? PolarForceVolume.ForceMode.Tangential : PolarForceVolume.ForceMode.Polar;
forceVolume.gameObject.SetActive(true);
return forceVolume;
}
public static RadialForceVolume Make(GameObject planetGO, Sector sector, RadialForceVolumeInfo info)
{
var forceVolume = Make<RadialForceVolume>(planetGO, sector, info);
forceVolume._acceleration = info.force;
forceVolume._falloff = info.fallOff switch
{
RadialForceVolumeInfo.FallOff.Constant => RadialForceVolume.Falloff.Constant,
RadialForceVolumeInfo.FallOff.Linear => RadialForceVolume.Falloff.Linear,
RadialForceVolumeInfo.FallOff.InverseSquared => RadialForceVolume.Falloff.InvSqr,
_ => throw new NotImplementedException(),
};
forceVolume.gameObject.SetActive(true);
return forceVolume;
}
public static TVolume Make<TVolume>(GameObject planetGO, Sector sector, ForceVolumeInfo info) where TVolume : ForceVolume
{
var forceVolume = PriorityVolumeBuilder.Make<TVolume>(planetGO, sector, info);
forceVolume._alignmentPriority = info.alignmentPriority;
forceVolume._inheritable = info.inheritable;
return forceVolume;
}
}
}

View File

@ -3,6 +3,7 @@ using NewHorizons.External.Modules.Volumes.VolumeInfos;
using NewHorizons.Utility.OuterWilds;
using OWML.Common;
using OWML.Utils;
using System;
using System.Linq;
using UnityEngine;
@ -13,35 +14,28 @@ namespace NewHorizons.Builder.Volumes
public static HazardVolume Make(GameObject planetGO, Sector sector, OWRigidbody owrb, HazardVolumeInfo info, IModBehaviour mod)
{
var go = GeneralPropBuilder.MakeNew("HazardVolume", planetGO, sector, info);
go.layer = Layer.BasicEffectVolume;
var shape = go.AddComponent<SphereShape>();
shape.radius = info.radius;
var owTriggerVolume = go.AddComponent<OWTriggerVolume>();
owTriggerVolume._shape = shape;
var volume = AddHazardVolume(go, sector, owrb, info.type, info.firstContactDamageType, info.firstContactDamage, info.damagePerSecond);
var volume = MakeExisting(go, planetGO, sector, owrb, info);
go.SetActive(true);
return volume;
}
public static HazardVolume AddHazardVolume(GameObject go, Sector sector, OWRigidbody owrb, HazardVolumeInfo.HazardType? type, HazardVolumeInfo.InstantDamageType? firstContactDamageType, float firstContactDamage, float damagePerSecond)
public static HazardVolume MakeExisting(GameObject go, GameObject planetGO, Sector sector, OWRigidbody owrb, HazardVolumeInfo info)
{
HazardVolume hazardVolume = null;
if (type == HazardVolumeInfo.HazardType.RIVERHEAT)
if (info.type == HazardVolumeInfo.HazardType.RIVERHEAT)
{
hazardVolume = go.AddComponent<RiverHeatHazardVolume>();
hazardVolume = VolumeBuilder.MakeExisting<RiverHeatHazardVolume>(go, planetGO, sector, info);
}
else if (type == HazardVolumeInfo.HazardType.HEAT)
else if (info.type == HazardVolumeInfo.HazardType.HEAT)
{
hazardVolume = go.AddComponent<HeatHazardVolume>();
hazardVolume = VolumeBuilder.MakeExisting<HeatHazardVolume>(go, planetGO, sector, info);
}
else if (type == HazardVolumeInfo.HazardType.DARKMATTER)
else if (info.type == HazardVolumeInfo.HazardType.DARKMATTER)
{
hazardVolume = go.AddComponent<DarkMatterVolume>();
hazardVolume = VolumeBuilder.MakeExisting<DarkMatterVolume>(go, planetGO, sector, info);
var visorFrostEffectVolume = go.AddComponent<VisorFrostEffectVolume>();
visorFrostEffectVolume._frostRate = 0.5f;
visorFrostEffectVolume._maxFrost = 0.91f;
@ -67,28 +61,38 @@ namespace NewHorizons.Builder.Volumes
submerge._fluidDetector = detector;
}
}
else if (type == HazardVolumeInfo.HazardType.ELECTRICITY)
else if (info.type == HazardVolumeInfo.HazardType.ELECTRICITY)
{
var electricityVolume = go.AddComponent<ElectricityVolume>();
var electricityVolume = VolumeBuilder.MakeExisting<ElectricityVolume>(go, planetGO, sector, info);
electricityVolume._shockAudioPool = new OWAudioSource[0];
hazardVolume = electricityVolume;
}
else
{
var simpleHazardVolume = go.AddComponent<SimpleHazardVolume>();
simpleHazardVolume._type = EnumUtils.Parse(type.ToString(), HazardVolume.HazardType.GENERAL);
simpleHazardVolume._type = EnumUtils.Parse(info.type.ToString(), HazardVolume.HazardType.GENERAL);
hazardVolume = simpleHazardVolume;
}
hazardVolume._attachedBody = owrb;
hazardVolume._damagePerSecond = type == null ? 0f : damagePerSecond;
hazardVolume._damagePerSecond = info.type == HazardVolumeInfo.HazardType.NONE ? 0f : info.damagePerSecond;
if (firstContactDamageType != null)
{
hazardVolume._firstContactDamageType = EnumUtils.Parse(firstContactDamageType.ToString(), InstantDamageType.Impact);
hazardVolume._firstContactDamage = firstContactDamage;
}
hazardVolume._firstContactDamageType = EnumUtils.Parse(info.firstContactDamageType.ToString(), InstantDamageType.Impact);
hazardVolume._firstContactDamage = info.firstContactDamage;
return hazardVolume;
}
public static HazardVolume AddHazardVolume(GameObject go, Sector sector, OWRigidbody owrb, HazardVolumeInfo.HazardType? type, HazardVolumeInfo.InstantDamageType? firstContactDamageType, float firstContactDamage, float damagePerSecond)
{
var planetGO = sector.transform.root.gameObject;
return MakeExisting(go, planetGO, sector, owrb, new HazardVolumeInfo
{
radius = 0f, // Volume builder should skip creating an extra trigger volume and collider if radius is 0
type = type ?? HazardVolumeInfo.HazardType.NONE,
firstContactDamageType = firstContactDamageType ?? HazardVolumeInfo.InstantDamageType.Impact,
firstContactDamage = firstContactDamage,
damagePerSecond = damagePerSecond
});
}
}
}

View File

@ -0,0 +1,87 @@
using NewHorizons.Components.Volumes;
using NewHorizons.External.Modules.Volumes.VolumeInfos;
using NewHorizons.Handlers;
using NewHorizons.Utility;
using NewHorizons.Utility.Files;
using NewHorizons.Utility.OuterWilds;
using NewHorizons.Utility.OWML;
using OWML.Common;
using UnityEngine;
namespace NewHorizons.Builder.Volumes
{
internal static class InteractionVolumeBuilder
{
public static InteractReceiver Make(GameObject planetGO, Sector sector, InteractionVolumeInfo info, IModBehaviour mod)
{
// Interaction volumes must use colliders because the first-person interaction system uses raycasting
if (info.shape != null)
{
info.shape.useShape = false;
}
var receiver = VolumeBuilder.Make<InteractReceiver>(planetGO, sector, info);
receiver.gameObject.layer = Layer.Interactible;
receiver._interactRange = info.range;
receiver._checkViewAngle = info.maxViewAngle.HasValue;
receiver._maxViewAngle = info.maxViewAngle ?? 180f;
receiver._usableInShip = info.usableInShip;
var volume = receiver.gameObject.AddComponent<NHInteractionVolume>();
volume.Reusable = info.reusable;
volume.Condition = info.condition;
volume.Persistent = info.persistent;
if (!string.IsNullOrEmpty(info.audio))
{
var audioSource = receiver.gameObject.AddComponent<AudioSource>();
// This could be more configurable but this should cover the most common use cases without bloating the info object
var owAudioSource = receiver.gameObject.AddComponent<OWAudioSource>();
owAudioSource._audioSource = audioSource;
owAudioSource.playOnAwake = false;
owAudioSource.loop = false;
owAudioSource.SetMaxVolume(1f);
owAudioSource.SetClipSelectionType(OWAudioSource.ClipSelectionOnPlay.RANDOM);
owAudioSource.SetTrack(OWAudioMixer.TrackName.Environment);
AudioUtilities.SetAudioClip(owAudioSource, info.audio, mod);
}
if (!string.IsNullOrEmpty(info.pathToAnimator))
{
var animObj = planetGO.transform.Find(info.pathToAnimator);
if (animObj == null)
{
NHLogger.LogError($"Couldn't find child of {planetGO.transform.GetPath()} at {info.pathToAnimator}");
}
else
{
var animator = animObj.GetComponent<Animator>();
if (animator == null)
{
NHLogger.LogError($"Couldn't find Animator on {animObj.name} at {info.pathToAnimator}");
}
else
{
volume.TargetAnimator = animator;
volume.AnimationTrigger = info.animationTrigger;
}
}
}
receiver.gameObject.SetActive(true);
var text = TranslationHandler.GetTranslation(info.prompt, TranslationHandler.TextType.UI);
Delay.FireOnNextUpdate(() =>
{
// This NREs if set immediately
receiver.ChangePrompt(text);
});
return receiver;
}
}
}

View File

@ -11,21 +11,16 @@ namespace NewHorizons.Builder.Volumes
{
public static NHNotificationVolume Make(GameObject planetGO, Sector sector, NotificationVolumeInfo info, IModBehaviour mod)
{
var go = GeneralPropBuilder.MakeNew("NotificationVolume", planetGO, sector, info);
go.layer = Layer.BasicEffectVolume;
var notificationVolume = VolumeBuilder.Make<NHNotificationVolume>(planetGO, sector, info);
var shape = go.AddComponent<SphereShape>();
shape.radius = info.radius;
// Preserving name for backwards compatibility
notificationVolume.gameObject.name = string.IsNullOrEmpty(info.rename) ? "NotificationVolume" : info.rename;
var owTriggerVolume = go.AddComponent<OWTriggerVolume>();
owTriggerVolume._shape = shape;
var notificationVolume = go.AddComponent<NHNotificationVolume>();
notificationVolume.SetTarget(info.target);
if (info.entryNotification != null) notificationVolume.SetEntryNotification(info.entryNotification.displayMessage, info.entryNotification.duration);
if (info.exitNotification != null) notificationVolume.SetExitNotification(info.exitNotification.displayMessage, info.exitNotification.duration);
go.SetActive(true);
notificationVolume.gameObject.SetActive(true);
return notificationVolume;
}

View File

@ -12,6 +12,8 @@ namespace NewHorizons.Builder.Volumes
volume._treeVolume = info.treeVolume;
volume._playRefillAudio = info.playRefillAudio;
volume.gameObject.SetActive(true);
return volume;
}
}

View File

@ -5,6 +5,17 @@ namespace NewHorizons.Builder.Volumes
{
public static class PriorityVolumeBuilder
{
public static TVolume MakeExisting<TVolume>(GameObject go, GameObject planetGO, Sector sector, PriorityVolumeInfo info) where TVolume : PriorityVolume
{
var volume = VolumeBuilder.MakeExisting<TVolume>(go, planetGO, sector, info);
volume._layer = info.layer;
volume.SetPriority(info.priority);
return volume;
}
public static TVolume Make<TVolume>(GameObject planetGO, Sector sector, PriorityVolumeInfo info) where TVolume : PriorityVolume
{
var volume = VolumeBuilder.Make<TVolume>(planetGO, sector, info);

View File

@ -0,0 +1,52 @@
using NewHorizons.Builder.Props;
using NewHorizons.Components.Volumes;
using NewHorizons.External.Modules.Props;
using NewHorizons.External.Modules.Volumes.VolumeInfos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace NewHorizons.Builder.Volumes
{
public static class RepairVolumeBuilder
{
public static NHRepairReceiver Make(GameObject planetGO, Sector sector, RepairVolumeInfo info)
{
// Repair receivers aren't technically volumes (no OWTriggerVolume) so we don't use the VolumeBuilder
var go = GeneralPropBuilder.MakeNew("RepairVolume", planetGO, sector, info);
if (info.shape != null)
{
ShapeBuilder.AddCollider(go, info.shape);
}
else
{
var shapeInfo = new ShapeInfo()
{
type = ShapeType.Sphere,
useShape = false,
hasCollision = true,
radius = info.radius,
};
ShapeBuilder.AddCollider(go, shapeInfo);
}
var repairReceiver = go.AddComponent<NHRepairReceiver>();
repairReceiver.displayName = info.name ?? info.rename ?? go.name;
repairReceiver.repairFraction = info.repairFraction;
repairReceiver.repairTime = info.repairTime;
repairReceiver.repairDistance = info.repairDistance;
repairReceiver.damagedCondition = info.damagedCondition;
repairReceiver.repairedCondition = info.repairedCondition;
repairReceiver.revealFact = info.revealFact;
go.SetActive(true);
return repairReceiver;
}
}
}

View File

@ -12,6 +12,8 @@ namespace NewHorizons.Builder.Volumes.Rulesets
volume.minImpactSpeed = info.minImpactSpeed;
volume.maxImpactSpeed = info.maxImpactSpeed;
volume.gameObject.SetActive(true);
return volume;
}
}

View File

@ -15,6 +15,8 @@ namespace NewHorizons.Builder.Volumes.Rulesets
volume._lanternRange = info.lanternRange;
volume._ignoreAnchor = info.ignoreAnchor;
volume.gameObject.SetActive(true);
return volume;
}
}

View File

@ -13,6 +13,8 @@ namespace NewHorizons.Builder.Volumes.Rulesets
volume._nerfJetpackBooster = info.nerfJetpackBooster;
volume._nerfDuration = info.nerfDuration;
volume.gameObject.SetActive(true);
return volume;
}
}

View File

@ -0,0 +1,22 @@
using NewHorizons.Components.Volumes;
using NewHorizons.External.Modules.Volumes.VolumeInfos;
using UnityEngine;
namespace NewHorizons.Builder.Volumes
{
public static class SpeedLimiterVolumeBuilder
{
public static SpeedLimiterVolume Make(GameObject planetGO, Sector sector, SpeedLimiterVolumeInfo info)
{
var volume = VolumeBuilder.Make<SpeedLimiterVolume>(planetGO, sector, info);
volume.maxSpeed = info.maxSpeed;
volume.stoppingDistance = info.stoppingDistance;
volume.maxEntryAngle = info.maxEntryAngle;
volume.gameObject.SetActive(true);
return volume;
}
}
}

View File

@ -12,6 +12,8 @@ namespace NewHorizons.Builder.Volumes
volume._speedLimit = info.speedLimit;
volume._acceleration = info.acceleration;
volume.gameObject.SetActive(true);
return volume;
}
}

View File

@ -1,6 +1,5 @@
using NewHorizons.Builder.Props;
using NewHorizons.External.Modules.Volumes.VolumeInfos;
using NewHorizons.Utility.OuterWilds;
using NewHorizons.Utility.OWML;
using UnityEngine;
namespace NewHorizons.Builder.Volumes
@ -9,27 +8,23 @@ namespace NewHorizons.Builder.Volumes
{
public static TVolume Make<TVolume>(GameObject planetGO, Sector sector, VanishVolumeInfo info) where TVolume : VanishVolume
{
var go = GeneralPropBuilder.MakeNew(typeof(TVolume).Name, planetGO, sector, info);
go.layer = Layer.BasicEffectVolume;
if (info.shape != null && info.shape?.useShape == false)
{
NHLogger.LogError($"Destruction/VanishVolumes only support colliders. Affects planet [{planetGO.name}]. Set useShape to false.");
}
var collider = go.AddComponent<SphereCollider>();
collider.isTrigger = true;
collider.radius = info.radius;
// VanishVolume is only compatible with sphere colliders
// If info.shape was null, it will still default to using a sphere with info.radius, just make sure it does so with a collider
info.shape ??= new();
info.shape.useShape = false;
var owCollider = go.AddComponent<OWCollider>();
owCollider._collider = collider;
var owTriggerVolume = go.AddComponent<OWTriggerVolume>();
owTriggerVolume._owCollider = owCollider;
var volume = go.AddComponent<TVolume>();
var volume = VolumeBuilder.Make<TVolume>(planetGO, sector, info);
var collider = volume.gameObject.GetComponent<Collider>();
volume._collider = collider;
volume._shrinkBodies = info.shrinkBodies;
volume._onlyAffectsPlayerAndShip = info.onlyAffectsPlayerRelatedBodies;
go.SetActive(true);
return volume;
}
}

View File

@ -12,6 +12,8 @@ namespace NewHorizons.Builder.Volumes.VisorEffects
volume._frostRate = info.frostRate;
volume._maxFrost = info.maxFrost;
volume.gameObject.SetActive(true);
return volume;
}
}

View File

@ -13,6 +13,8 @@ namespace NewHorizons.Builder.Volumes.VisorEffects
volume._dropletRate = info.dropletRate;
volume._streakRate = info.streakRate;
volume.gameObject.SetActive(true);
return volume;
}
}

View File

@ -1,27 +1,60 @@
using NewHorizons.Builder.Props;
using NewHorizons.External.Modules.Volumes.VolumeInfos;
using NewHorizons.Utility.OuterWilds;
using NewHorizons.Utility.OWML;
using UnityEngine;
namespace NewHorizons.Builder.Volumes
{
public static class VolumeBuilder
{
public static TVolume Make<TVolume>(GameObject planetGO, Sector sector, VolumeInfo info) where TVolume : MonoBehaviour //Could be BaseVolume but I need to create vanilla volumes too.
public static TVolume MakeExisting<TVolume>(GameObject go, GameObject planetGO, Sector sector, VolumeInfo info) where TVolume : MonoBehaviour
{
var go = GeneralPropBuilder.MakeNew(typeof(TVolume).Name, planetGO, sector, info);
go.layer = Layer.BasicEffectVolume;
// Backwards compat for the two possible radii settings
// Both radii default to 1
if (info.shape != null && info.shape.type == External.Modules.Props.ShapeType.Sphere && info.shape.radius != info.radius)
{
// If the info shape radius if the default but the info radius is not the default, use it
if (info.shape.radius == 1f && info.radius != 1f)
{
info.shape.radius = info.radius;
}
}
var shape = go.AddComponent<SphereShape>();
shape.radius = info.radius;
// Warning if you set the radius to not be one but are using a non sphere shape
if (info.radius != 1f && (info.shape != null && info.shape.type != External.Modules.Props.ShapeType.Sphere))
{
NHLogger.LogError($"Volume [{typeof(TVolume).Name}] on [{go.name}] has a radius value set but it's shape is [{info.shape.type}]");
}
var owTriggerVolume = go.AddComponent<OWTriggerVolume>();
owTriggerVolume._shape = shape;
// Respect existing layer if set to a valid volume layer
if (go.layer != Layer.AdvancedEffectVolume)
{
go.layer = Layer.BasicEffectVolume;
}
// Skip creating a trigger volume if one already exists and has a shape set and we aren't overriding it
var trigger = go.GetComponent<OWTriggerVolume>();
if (trigger == null || (trigger._shape == null && trigger._owCollider == null) || info.shape != null || info.radius > 0f)
{
ShapeBuilder.AddTriggerVolume(go, info.shape, info.radius);
}
var volume = go.AddComponent<TVolume>();
return volume;
}
go.SetActive(true);
public static TVolume Make<TVolume>(GameObject planetGO, Sector sector, VolumeInfo info) where TVolume : MonoBehaviour // Could be BaseVolume but I need to create vanilla volumes too.
{
var go = GeneralPropBuilder.MakeNew(typeof(TVolume).Name, planetGO, sector, info);
return MakeExisting<TVolume>(go, planetGO, sector, info);
}
public static TVolume MakeAndEnable<TVolume>(GameObject planetGO, Sector sector, VolumeInfo info) where TVolume : MonoBehaviour
{
var volume = Make<TVolume>(planetGO, sector, info);
volume.gameObject.SetActive(true);
return volume;
}
}

View File

@ -35,6 +35,13 @@ namespace NewHorizons.Builder.Volumes
AudioVolumeBuilder.Make(go, sector, audioVolume, mod);
}
}
if (config.Volumes.conditionTriggerVolumes != null)
{
foreach (var conditionTriggerVolume in config.Volumes.conditionTriggerVolumes)
{
ConditionTriggerVolumeBuilder.Make(go, sector, conditionTriggerVolume);
}
}
if (config.Volumes.dayNightAudioVolumes != null)
{
foreach (var dayNightAudioVolume in config.Volumes.dayNightAudioVolumes)
@ -60,28 +67,35 @@ namespace NewHorizons.Builder.Volumes
{
foreach (var mapRestrictionVolume in config.Volumes.mapRestrictionVolumes)
{
VolumeBuilder.Make<MapRestrictionVolume>(go, sector, mapRestrictionVolume);
VolumeBuilder.MakeAndEnable<MapRestrictionVolume>(go, sector, mapRestrictionVolume);
}
}
if (config.Volumes.interactionVolumes != null)
{
foreach (var interactionVolume in config.Volumes.interactionVolumes)
{
InteractionVolumeBuilder.Make(go, sector, interactionVolume, mod);
}
}
if (config.Volumes.interferenceVolumes != null)
{
foreach (var interferenceVolume in config.Volumes.interferenceVolumes)
{
VolumeBuilder.Make<Components.Volumes.InterferenceVolume>(go, sector, interferenceVolume);
VolumeBuilder.MakeAndEnable<Components.Volumes.InterferenceVolume>(go, sector, interferenceVolume);
}
}
if (config.Volumes.reverbVolumes != null)
{
foreach (var reverbVolume in config.Volumes.reverbVolumes)
{
VolumeBuilder.Make<ReverbTriggerVolume>(go, sector, reverbVolume);
VolumeBuilder.MakeAndEnable<ReverbTriggerVolume>(go, sector, reverbVolume);
}
}
if (config.Volumes.insulatingVolumes != null)
{
foreach (var insulatingVolume in config.Volumes.insulatingVolumes)
{
VolumeBuilder.Make<InsulatingVolume>(go, sector, insulatingVolume);
VolumeBuilder.MakeAndEnable<InsulatingVolume>(go, sector, insulatingVolume);
}
}
if (config.Volumes.zeroGravityVolumes != null)
@ -112,20 +126,58 @@ namespace NewHorizons.Builder.Volumes
FluidVolumeBuilder.Make(go, sector, fluidVolume);
}
}
if (config.Volumes.forces != null)
{
if (config.Volumes.forces.cylindricalVolumes != null)
{
foreach (var cylindricalVolume in config.Volumes.forces.cylindricalVolumes)
{
ForceVolumeBuilder.Make(go, sector, cylindricalVolume);
}
}
if (config.Volumes.forces.directionalVolumes != null)
{
foreach (var directionalVolume in config.Volumes.forces.directionalVolumes)
{
ForceVolumeBuilder.Make(go, sector, directionalVolume);
}
}
if (config.Volumes.forces.gravityVolumes != null)
{
foreach (var gravityVolume in config.Volumes.forces.gravityVolumes)
{
ForceVolumeBuilder.Make(go, sector, gravityVolume);
}
}
if (config.Volumes.forces.polarVolumes != null)
{
foreach (var polarVolume in config.Volumes.forces.polarVolumes)
{
ForceVolumeBuilder.Make(go, sector, polarVolume);
}
}
if (config.Volumes.forces.radialVolumes != null)
{
foreach (var radialVolume in config.Volumes.forces.radialVolumes)
{
ForceVolumeBuilder.Make(go, sector, radialVolume);
}
}
}
if (config.Volumes.probe != null)
{
if (config.Volumes.probe.destructionVolumes != null)
{
foreach (var destructionVolume in config.Volumes.probe.destructionVolumes)
{
VolumeBuilder.Make<ProbeDestructionVolume>(go, sector, destructionVolume);
VolumeBuilder.MakeAndEnable<ProbeDestructionVolume>(go, sector, destructionVolume);
}
}
if (config.Volumes.probe.safetyVolumes != null)
{
foreach (var safetyVolume in config.Volumes.probe.safetyVolumes)
{
VolumeBuilder.Make<ProbeSafetyVolume>(go, sector, safetyVolume);
VolumeBuilder.MakeAndEnable<ProbeSafetyVolume>(go, sector, safetyVolume);
}
}
}
@ -152,7 +204,7 @@ namespace NewHorizons.Builder.Volumes
{
foreach (var antiTravelMusicRuleset in config.Volumes.rulesets.antiTravelMusicRulesets)
{
VolumeBuilder.Make<AntiTravelMusicRuleset>(go, sector, antiTravelMusicRuleset);
VolumeBuilder.MakeAndEnable<AntiTravelMusicRuleset>(go, sector, antiTravelMusicRuleset);
}
}
if (config.Volumes.rulesets.playerImpactRulesets != null)
@ -181,7 +233,14 @@ namespace NewHorizons.Builder.Volumes
{
foreach (var referenceFrameBlockerVolume in config.Volumes.referenceFrameBlockerVolumes)
{
VolumeBuilder.Make<ReferenceFrameBlockerVolume>(go, sector, referenceFrameBlockerVolume);
VolumeBuilder.MakeAndEnable<ReferenceFrameBlockerVolume>(go, sector, referenceFrameBlockerVolume);
}
}
if (config.Volumes.repairVolumes != null)
{
foreach (var repairVolume in config.Volumes.repairVolumes)
{
RepairVolumeBuilder.Make(go, sector, repairVolume);
}
}
if (config.Volumes.speedTrapVolumes != null)
@ -191,11 +250,18 @@ namespace NewHorizons.Builder.Volumes
SpeedTrapVolumeBuilder.Make(go, sector, speedTrapVolume);
}
}
if (config.Volumes.speedLimiterVolumes != null)
{
foreach (var speedLimiterVolume in config.Volumes.speedLimiterVolumes)
{
SpeedLimiterVolumeBuilder.Make(go, sector, speedLimiterVolume);
}
}
if (config.Volumes.lightSourceVolumes != null)
{
foreach (var lightSourceVolume in config.Volumes.lightSourceVolumes)
{
VolumeBuilder.Make<LightlessLightSourceVolume>(go, sector, lightSourceVolume);
VolumeBuilder.MakeAndEnable<LightlessLightSourceVolume>(go, sector, lightSourceVolume);
}
}
if (config.Volumes.solarSystemVolume != null)
@ -209,7 +275,7 @@ namespace NewHorizons.Builder.Volumes
{
foreach (var creditsVolume in config.Volumes.creditsVolume)
{
CreditsVolumeBuilder.Make(go, sector, creditsVolume);
CreditsVolumeBuilder.Make(go, sector, creditsVolume, mod);
}
}
}

View File

@ -11,6 +11,8 @@ namespace NewHorizons.Builder.Volumes
volume._inheritable = true;
volume.gameObject.SetActive(true);
return volume;
}
}

View File

@ -0,0 +1,85 @@
using NewHorizons.External.Modules.Props.EchoesOfTheEye;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace NewHorizons.Components.EOTE
{
public class DreamLightConditionController : MonoBehaviour
{
public string Condition { get; set; }
public bool Persistent { get; set; }
public bool Reversible { get; set; }
public bool OnExtinguish { get; set; }
DreamObjectProjector _projector;
DreamCandle _dreamCandle;
public void SetFromInfo(DreamLightConditionInfo info)
{
Condition = info.condition;
Persistent = info.persistent;
Reversible = info.reversible;
OnExtinguish = info.onExtinguish;
}
protected void Awake()
{
_projector = GetComponent<DreamObjectProjector>();
_projector.OnProjectorLit.AddListener(OnProjectorLit);
_projector.OnProjectorExtinguished.AddListener(OnProjectorExtinguished);
_dreamCandle = GetComponent<DreamCandle>();
if (_dreamCandle != null)
{
_dreamCandle.OnLitStateChanged.AddListener(OnCandleLitStateChanged);
}
}
protected void OnDestroy()
{
if (_projector != null)
{
_projector.OnProjectorLit.RemoveListener(OnProjectorLit);
_projector.OnProjectorExtinguished.RemoveListener(OnProjectorExtinguished);
}
if (_dreamCandle != null)
{
_dreamCandle.OnLitStateChanged.RemoveListener(OnCandleLitStateChanged);
}
}
private void OnProjectorLit()
{
HandleCondition(!OnExtinguish);
}
private void OnProjectorExtinguished()
{
HandleCondition(OnExtinguish);
}
private void OnCandleLitStateChanged()
{
HandleCondition(OnExtinguish ? !_dreamCandle._lit : _dreamCandle._lit);
}
private void HandleCondition(bool shouldSet)
{
if (shouldSet || Reversible)
{
if (Persistent)
{
PlayerData.SetPersistentCondition(Condition, shouldSet);
}
else
{
DialogueConditionManager.SharedInstance.SetConditionState(Condition, shouldSet);
}
}
}
}
}

View File

@ -1,7 +1,11 @@
using NewHorizons.External.Modules;
using NewHorizons.External.SerializableEnums;
using NewHorizons.Handlers;
using NewHorizons.Patches.CreditsScenePatches;
using NewHorizons.Utility.Files;
using NewHorizons.Utility.OWML;
using OWML.Common;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
@ -15,14 +19,14 @@ namespace NewHorizons.Components
/// Mod unique id to game over module list
/// Done as a dictionary so that Reload Configs can overwrite entries per mod
/// </summary>
public static Dictionary<string, GameOverModule[]> gameOvers = new();
public static Dictionary<IModBehaviour, GameOverModule[]> gameOvers = new();
public static NHGameOverManager Instance { get; private set; }
private GameOverController _gameOverController;
private PlayerCameraEffectController _playerCameraEffectController;
private GameOverModule[] _gameOvers;
private (IModBehaviour mod, GameOverModule gameOver)[] _gameOvers;
private bool _gameOverSequenceStarted;
@ -36,25 +40,35 @@ namespace NewHorizons.Components
_gameOverController = FindObjectOfType<GameOverController>();
_playerCameraEffectController = FindObjectOfType<PlayerCameraEffectController>();
_gameOvers = gameOvers.SelectMany(x => x.Value).ToArray();
var gameOverList = new List<(IModBehaviour, GameOverModule)>();
foreach (var gameOverPair in gameOvers)
{
var mod = gameOverPair.Key;
foreach (var gameOver in gameOverPair.Value)
{
gameOverList.Add((mod, gameOver));
}
}
_gameOvers = gameOverList.ToArray();
}
public void TryHijackDeathSequence()
{
var gameOver = _gameOvers.FirstOrDefault(x => !string.IsNullOrEmpty(x.condition) && DialogueConditionManager.SharedInstance.GetConditionState(x.condition));
if (!_gameOverSequenceStarted && gameOver != null && !Locator.GetDeathManager()._finishedDLC)
var gameOver = _gameOvers.FirstOrDefault(x => !string.IsNullOrEmpty(x.gameOver.condition)
&& DialogueConditionManager.SharedInstance.GetConditionState(x.gameOver.condition));
if (!_gameOverSequenceStarted && gameOver != default && !Locator.GetDeathManager()._finishedDLC)
{
StartGameOverSequence(gameOver, null);
StartGameOverSequence(gameOver.gameOver, null, gameOver.mod);
}
}
public void StartGameOverSequence(GameOverModule gameOver, DeathType? deathType)
public void StartGameOverSequence(GameOverModule gameOver, DeathType? deathType, IModBehaviour mod)
{
_gameOverSequenceStarted = true;
Delay.StartCoroutine(GameOver(gameOver, deathType));
Delay.StartCoroutine(GameOver(gameOver, deathType, mod));
}
private IEnumerator GameOver(GameOverModule gameOver, DeathType? deathType)
private IEnumerator GameOver(GameOverModule gameOver, DeathType? deathType, IModBehaviour mod)
{
OWInput.ChangeInputMode(InputMode.None);
ReticleController.Hide();
@ -104,12 +118,12 @@ namespace NewHorizons.Components
yield return new WaitUntil(ReadytoLoadCreditsScene);
}
LoadCreditsScene(gameOver);
LoadCreditsScene(gameOver, mod);
}
private bool ReadytoLoadCreditsScene() => _gameOverController._fadedOutText && _gameOverController._textAnimator.IsComplete();
private void LoadCreditsScene(GameOverModule gameOver)
private void LoadCreditsScene(GameOverModule gameOver, IModBehaviour mod)
{
NHLogger.LogVerbose($"Load credits {gameOver.creditsType}");
@ -125,6 +139,9 @@ namespace NewHorizons.Components
TimelineObliterationController.s_hasRealityEnded = true;
LoadManager.LoadScene(OWScene.Credits_Fast, LoadManager.FadeType.ToBlack);
break;
case NHCreditsType.Custom:
LoadCustomCreditsScene(gameOver, mod);
break;
default:
// GameOverController disables post processing
_gameOverController._flashbackCamera.postProcessing.enabled = true;
@ -134,5 +151,42 @@ namespace NewHorizons.Components
break;
}
}
private void LoadCustomCreditsScene(GameOverModule gameOver, IModBehaviour mod)
{
LoadManager.LoadScene(OWScene.Credits_Fast, LoadManager.FadeType.ToBlack);
// Unfortunately we can't make this a private method, as EventArgs/EventHandler enforces the (sender, e) parameters, which prevents us from passing in gameOver and mod, which we need.
EventHandler onCreditsBuilt = null; // needs to be done so we can unsubscribe from within the lambda.
onCreditsBuilt = (sender, e) =>
{
// Unsubscribe first, playing it safe in case it NREs
CreditsPatches.CreditsBuilt -= onCreditsBuilt;
// Patch new music clip
var musicSource = Locator.FindObjectsOfType<OWAudioSource>().Where(x => x.name == "AudioSource").Single(); // AudioSource that plays the credits music is literally called "AudioSource", luckily it's the only one called that. Lazy OW devs do be lazy.
if (!string.IsNullOrEmpty(gameOver.audio)) // string.Empty is default value for "audio" in GameOverModule, means no audio is specified.
{
AudioUtilities.SetAudioClip(musicSource, gameOver.audio, mod); // Load audio if specified
}
else
{
musicSource.AssignAudioLibraryClip(AudioType.PLACEHOLDER); // Otherwise default custom credits are silent - AudioType.PLACEHOLDER is silence (apparently)
}
musicSource.loop = gameOver.audioLooping;
musicSource._maxSourceVolume = gameOver.audioVolume;
// Override fade in
musicSource.Stop();
musicSource.Play();
// Patch scroll duration
var creditsScroll = Locator.FindObjectOfType<CreditsScrollSection>();
creditsScroll._scrollDuration = gameOver.length;
};
CreditsPatches.CreditsBuilt += onCreditsBuilt;
}
}
}

View File

@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace NewHorizons.Components.Volumes
{
public class ConditionTriggerVolume : BaseVolume
{
public string Condition { get; set; }
public bool Persistent { get; set; }
public bool Reversible { get; set; }
public bool Player { get; set; } = true;
public bool Probe { get; set; }
public bool Ship { get; set; }
public override void OnTriggerVolumeEntry(GameObject hitObj)
{
if (TestHitObject(hitObj))
{
if (Persistent)
{
PlayerData.SetPersistentCondition(Condition, true);
}
else
{
DialogueConditionManager.SharedInstance.SetConditionState(Condition, true);
}
}
}
public override void OnTriggerVolumeExit(GameObject hitObj)
{
if (Reversible && TestHitObject(hitObj))
{
if (Persistent)
{
PlayerData.SetPersistentCondition(Condition, false);
}
else
{
DialogueConditionManager.SharedInstance.SetConditionState(Condition, false);
}
}
}
bool TestHitObject(GameObject hitObj)
{
if (Player && hitObj.CompareTag("PlayerDetector"))
{
return true;
}
if (Probe && hitObj.CompareTag("ProbeDetector"))
{
return true;
}
if (Ship && hitObj.CompareTag("ShipDetector"))
{
return true;
}
return false;
}
}
}

View File

@ -1,4 +1,5 @@
using NewHorizons.External.Modules;
using OWML.Common;
using UnityEngine;
@ -8,12 +9,13 @@ namespace NewHorizons.Components.Volumes
{
public GameOverModule gameOver;
public DeathType? deathType;
public IModBehaviour mod;
public override void OnTriggerVolumeEntry(GameObject hitObj)
{
if (hitObj.CompareTag("PlayerDetector") && enabled && (string.IsNullOrEmpty(gameOver.condition) || DialogueConditionManager.SharedInstance.GetConditionState(gameOver.condition)))
{
NHGameOverManager.Instance.StartGameOverSequence(gameOver, deathType);
NHGameOverManager.Instance.StartGameOverSequence(gameOver, deathType, mod);
}
}

View File

@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace NewHorizons.Components.Volumes
{
public class NHInteractionVolume : MonoBehaviour
{
public bool Reusable { get; set; }
public string Condition { get; set; }
public bool Persistent { get; set; }
public Animator TargetAnimator { get; set; }
public string AnimationTrigger { get; set; }
InteractReceiver _interactReceiver;
OWAudioSource _audioSource;
protected void Awake()
{
_interactReceiver = GetComponent<InteractReceiver>();
_audioSource = GetComponent<OWAudioSource>();
_interactReceiver.OnPressInteract += OnInteract;
}
protected void OnDestroy()
{
_interactReceiver.OnPressInteract -= OnInteract;
}
protected void OnInteract()
{
if (!string.IsNullOrEmpty(Condition))
{
if (Persistent)
{
PlayerData.SetPersistentCondition(Condition, true);
}
else
{
DialogueConditionManager.SharedInstance.SetConditionState(Condition, true);
}
}
if (_audioSource != null)
{
_audioSource.Play();
}
if (TargetAnimator)
{
TargetAnimator.SetTrigger(AnimationTrigger);
}
if (Reusable)
{
_interactReceiver.ResetInteraction();
_interactReceiver.EnableInteraction();
}
else
{
_interactReceiver.DisableInteraction();
}
}
}
}

View File

@ -0,0 +1,103 @@
using NewHorizons.Handlers;
using OWML.Utils;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Events;
namespace NewHorizons.Components.Volumes
{
// RepairReceiver isn't set up for proper subclassing but a subclass is necessary for the first-person manipulator to detect it.
public class NHRepairReceiver : RepairReceiver
{
public static Type RepairReceiverType = EnumUtils.Create<Type>("NewHorizons");
public class RepairEvent : UnityEvent<NHRepairReceiver> { }
public RepairEvent OnRepaired = new();
public RepairEvent OnDamaged = new();
public string displayName;
public float repairTime;
public string damagedCondition;
public string repairedCondition;
public string revealFact;
float _repairFraction = 0f;
UITextType _uiTextType = UITextType.None;
public float repairFraction
{
get => _repairFraction;
set
{
var prevValue = _repairFraction;
_repairFraction = Mathf.Clamp01(value);
if (prevValue < 1f && _repairFraction >= 1f)
{
Repair();
}
else if (prevValue >= 1f && _repairFraction < 1f)
{
Damage();
}
}
}
public new virtual bool IsRepairable() => IsDamaged();
public new virtual bool IsDamaged() => _repairFraction < 1f;
public new virtual float GetRepairFraction() => _repairFraction;
protected new void Awake()
{
base.Awake();
_type = RepairReceiverType;
if (IsDamaged()) Damage();
else Repair();
}
public new virtual void RepairTick()
{
if (!IsRepairable()) return;
repairFraction += Time.deltaTime / repairTime;
}
public new virtual UITextType GetRepairableName()
{
if (_uiTextType != UITextType.None) return _uiTextType;
var value = TranslationHandler.GetTranslation(displayName, TranslationHandler.TextType.UI);
_uiTextType = (UITextType)TranslationHandler.AddUI(value, false);
return _uiTextType;
}
void Damage()
{
if (!string.IsNullOrEmpty(damagedCondition))
{
DialogueConditionManager.SharedInstance.SetConditionState(damagedCondition, true);
}
if (!string.IsNullOrEmpty(repairedCondition))
{
DialogueConditionManager.SharedInstance.SetConditionState(repairedCondition, false);
}
OnDamaged.Invoke(this);
}
void Repair()
{
if (!string.IsNullOrEmpty(damagedCondition))
{
DialogueConditionManager.SharedInstance.SetConditionState(damagedCondition, false);
}
if (!string.IsNullOrEmpty(repairedCondition))
{
DialogueConditionManager.SharedInstance.SetConditionState(repairedCondition, true);
}
if (!string.IsNullOrEmpty(revealFact))
{
Locator.GetShipLogManager().RevealFact(revealFact);
}
OnRepaired.Invoke(this);
}
}
}

View File

@ -0,0 +1,164 @@
using System.Collections.Generic;
using System;
using UnityEngine;
namespace NewHorizons.Components.Volumes
{
public class SpeedLimiterVolume : BaseVolume
{
public float maxSpeed = 10f;
public float stoppingDistance = 100f;
public float maxEntryAngle = 60f;
private OWRigidbody _parentBody;
private List<TrackedBody> _trackedBodies = new List<TrackedBody>();
private bool _playerJustExitedDream;
public override void Awake()
{
_parentBody = GetComponentInParent<OWRigidbody>();
base.Awake();
GlobalMessenger.AddListener("ExitDreamWorld", OnExitDreamWorld);
}
public void Start()
{
enabled = false;
}
public override void OnDestroy()
{
base.OnDestroy();
GlobalMessenger.RemoveListener("ExitDreamWorld", OnExitDreamWorld);
}
public void FixedUpdate()
{
foreach (var trackedBody in _trackedBodies)
{
bool slowed = false;
Vector3 velocity = trackedBody.body.GetVelocity() - _parentBody.GetVelocity();
float magnitude = velocity.magnitude;
if (magnitude <= maxSpeed)
{
slowed = true;
}
else
{
bool needsSlowing = true;
float velocityReduction = trackedBody.deceleration * Time.deltaTime;
float requiredReduction = maxSpeed - magnitude;
if (requiredReduction > velocityReduction)
{
velocityReduction = requiredReduction;
slowed = true;
}
if (trackedBody.name == Detector.Name.Ship)
{
Autopilot component = Locator.GetShipTransform().GetComponent<Autopilot>();
if (component != null && component.IsFlyingToDestination())
{
needsSlowing = false;
}
}
if (needsSlowing)
{
Vector3 velocityChange = velocityReduction * velocity.normalized;
trackedBody.body.AddVelocityChange(velocityChange);
if (trackedBody.name == Detector.Name.Ship && PlayerState.IsInsideShip())
{
Locator.GetPlayerBody().AddVelocityChange(velocityChange);
}
}
}
if (slowed)
{
if (trackedBody.name == Detector.Name.Ship)
GlobalMessenger.FireEvent("ShipExitSpeedLimiter");
_trackedBodies.Remove(trackedBody);
if (_trackedBodies.Count == 0)
enabled = false;
}
}
}
private void OnExitDreamWorld()
{
_playerJustExitedDream = true;
}
public override void OnTriggerVolumeEntry(GameObject hitObj)
{
DynamicForceDetector component = hitObj.GetComponent<DynamicForceDetector>();
if (component == null || !component.CompareNameMask(Detector.Name.Player | Detector.Name.Probe | Detector.Name.Ship)) return;
if (component.GetName() == Detector.Name.Player && (PlayerState.IsInsideShip() || _playerJustExitedDream))
{
_playerJustExitedDream = false;
}
else
{
OWRigidbody attachedOWRigidbody = component.GetAttachedOWRigidbody();
Vector3 from = transform.position - attachedOWRigidbody.GetPosition();
Vector3 to = attachedOWRigidbody.GetVelocity() - _parentBody.GetVelocity();
float magnitude = to.magnitude;
if (magnitude > maxSpeed && Vector3.Angle(from, to) < maxEntryAngle)
{
float deceleration = (maxSpeed * maxSpeed - magnitude * magnitude) / (2f * stoppingDistance);
TrackedBody trackedBody = new TrackedBody(attachedOWRigidbody, component.GetName(), deceleration);
_trackedBodies.Add(trackedBody);
if (component.GetName() == Detector.Name.Ship)
GlobalMessenger.FireEvent("ShipEnterSpeedLimiter");
enabled = true;
}
}
}
public override void OnTriggerVolumeExit(GameObject hitObj)
{
DynamicForceDetector component = hitObj.GetComponent<DynamicForceDetector>();
if (component == null) return;
OWRigidbody body = component.GetAttachedOWRigidbody();
TrackedBody trackedBody = _trackedBodies.Find((TrackedBody i) => i.body == body);
if (trackedBody != null)
{
if (trackedBody.name == Detector.Name.Ship)
GlobalMessenger.FireEvent("ShipExitSpeedLimiter");
_trackedBodies.Remove(trackedBody);
if (_trackedBodies.Count == 0)
enabled = false;
}
}
[Serializable]
protected class TrackedBody
{
public OWRigidbody body;
public Detector.Name name;
public float deceleration;
public TrackedBody(OWRigidbody body, Detector.Name name, float deceleration)
{
this.body = body;
this.name = name;
this.deceleration = deceleration;
}
public override bool Equals(object obj)
{
if (obj is TrackedBody trackedBody)
{
return trackedBody.body == body && trackedBody.name == name;
}
return base.Equals(obj);
}
public override int GetHashCode() => body.GetHashCode();
}
}
}

View File

@ -669,14 +669,12 @@ namespace NewHorizons.External.Configs
{
if (!string.IsNullOrEmpty(volume.gameOverText))
{
if (volume.gameOver == null)
{
volume.gameOver = new();
}
volume.gameOver ??= new();
volume.gameOver.text = volume.gameOverText;
}
if (volume.creditsType != null)
{
volume.gameOver ??= new();
volume.gameOver.creditsType = (SerializableEnums.NHCreditsType)volume.creditsType;
}
}

View File

@ -304,12 +304,18 @@ namespace NewHorizons.External.Configs
// True by default so if one is false go false
canEnterViaWarpDrive = canEnterViaWarpDrive && otherConfig.canEnterViaWarpDrive;
canExitViaWarpDrive = canExitViaWarpDrive && otherConfig.canExitViaWarpDrive;
destroyStockPlanets = destroyStockPlanets && otherConfig.destroyStockPlanets;
enableTimeLoop = enableTimeLoop && otherConfig.enableTimeLoop;
// False by default
returnToSolarSystemWhenTooFar = returnToSolarSystemWhenTooFar || otherConfig.returnToSolarSystemWhenTooFar;
loopDuration = loopDuration == 22f ? otherConfig.loopDuration : loopDuration;
// If current one is null take the other
factRequiredForWarp = string.IsNullOrEmpty(factRequiredForWarp) ? otherConfig.factRequiredForWarp : factRequiredForWarp;
factRequiredToExitViaWarpDrive = string.IsNullOrEmpty(factRequiredToExitViaWarpDrive) ? otherConfig.factRequiredToExitViaWarpDrive : factRequiredToExitViaWarpDrive;
Skybox = Skybox == null ? otherConfig.Skybox : Skybox;
// False by default so if one is true go true

View File

@ -6,15 +6,24 @@ using Newtonsoft.Json;
namespace NewHorizons.External.Configs
{
/// <summary>
/// Allows you to configure the title screen with custom music, skyboxes, and loading props from asset bundles.
/// You can define a list of title screen configurations, with different persistent condition/ship log facts required to display them.
/// </summary>
[JsonObject]
public class TitleScreenConfig
{
/// <summary>
/// Create title screens
/// Create title screens.
/// The last title screen in the list with its display conditions (persistent condition and/or ship log) met will be displayed if this mod
/// is chosen to be shown on the main menu.
/// </summary>
public TitleScreenInfo[] titleScreens = new TitleScreenInfo[0];
}
/// <summary>
/// A single title screen configuration
/// </summary>
[JsonObject]
public class TitleScreenInfo
{

View File

@ -24,6 +24,31 @@ namespace NewHorizons.External.Modules
/// </summary>
public string condition;
/// <summary>
/// The audio to use for the credits music. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
/// Credits will be silent unless this attribute is specified.
/// Note: only applies when creditsType is set to "custom".
/// </summary>
public string audio;
/// <summary>
/// The length of the fade in and out for the credits music.
/// Note: only applies when creditsType is set to "custom".
/// </summary>
[DefaultValue(1f)] public float audioVolume = 1f;
/// <summary>
/// Determines if the credits music should loop.
/// Note: only applies when creditsType is set to "custom".
/// </summary>
[DefaultValue(false)] public bool audioLooping = false;
/// <summary>
/// Duration of the credits scroll in seconds.
/// Note: only applies when creditsType is set to "custom".
/// </summary>
[DefaultValue(120f)] public float length = 120f;
/// <summary>
/// The type of credits that will run after the game over message is shown
/// </summary>

View File

@ -58,6 +58,11 @@ namespace NewHorizons.External.Modules
/// </summary>
public RaftInfo[] rafts;
/// <summary>
/// Add raft docks to this planet (requires Echoes of the Eye DLC)
/// </summary>
public RaftDockInfo[] raftDocks;
/// <summary>
/// Scatter props around this planet's surface
/// </summary>

View File

@ -20,5 +20,10 @@ namespace NewHorizons.External.Modules.Props.EchoesOfTheEye
/// Whether the candle should start lit or extinguished.
/// </summary>
public bool startLit;
/// <summary>
/// A condition to set when the candle is lit.
/// </summary>
public DreamLightConditionInfo condition;
}
}

View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NewHorizons.External.Modules.Props.EchoesOfTheEye
{
public class DreamLightConditionInfo
{
/// <summary>
/// The name of the dialogue condition or persistent condition to set when the light is lit.
/// </summary>
public string condition;
/// <summary>
/// If true, the condition will persist across all future loops until unset.
/// </summary>
public bool persistent;
/// <summary>
/// Whether to unset the condition when the light is extinguished again.
/// </summary>
public bool reversible;
/// <summary>
/// Whether to set the condition when the light is extinguished instead. If `reversible` is true, the condition will be unset when the light is lit again.
/// </summary>
public bool onExtinguish;
}
}

View File

@ -82,7 +82,7 @@ namespace NewHorizons.External.Modules.Props.EchoesOfTheEye
[DefaultValue("sevenSlides")] public SlideReelType reelModel = SlideReelType.SevenSlides;
/// <summary>
/// Exclusive to the slide reel type. Condition/material of the reel. Antique is the Stranger, Pristine is the Dreamworld, Rusted is a burned reel.
/// Exclusive to the slide reel and standing vision torch type. Condition/material of the reel. Antique is the Stranger, Pristine is the Dreamworld, Rusted (exclusive to slide reels) is a burned reel.
/// </summary>
[DefaultValue("antique")] public SlideReelCondition reelCondition = SlideReelCondition.Antique;

View File

@ -45,5 +45,10 @@ namespace NewHorizons.External.Modules.Props.EchoesOfTheEye
/// If set, projected objects will be set to fully active or fully disabled instantly instead of smoothly fading lights/renderers/colliders. Use this if the normal behavior is insufficient for the objects you're using.
/// </summary>
public bool toggleProjectedObjectsActive;
/// <summary>
/// A condition to set when the totem is lit.
/// </summary>
public DreamLightConditionInfo condition;
}
}

View File

@ -0,0 +1,10 @@
using Newtonsoft.Json;
using System.ComponentModel;
namespace NewHorizons.External.Modules.Props.EchoesOfTheEye
{
[JsonObject]
public class RaftDockInfo : GeneralPropInfo
{
}
}

View File

@ -10,6 +10,16 @@ namespace NewHorizons.External.Modules.Props.EchoesOfTheEye
/// Acceleration of the raft. Default acceleration is 5.
/// </summary>
[DefaultValue(5f)] public float acceleration = 5f;
/// <summary>
/// Path to the dock this raft will start attached to.
/// </summary>
public string dockPath;
/// <summary>
/// Uses the raft model from the dreamworld
/// </summary>
public bool pristine;
}
}

View File

@ -32,6 +32,10 @@ namespace NewHorizons.External.Modules.Props.Item
/// </summary>
[DefaultValue(0.5f)] public float colliderRadius = 0.5f;
/// <summary>
/// Whether the added sphere collider will be a trigger (interactible but does not collide). Defaults to true.
/// </summary>
[DefaultValue(true)] public bool colliderIsTrigger = true;
/// <summary>
/// Whether the item can be dropped. Defaults to true.
/// </summary>
[DefaultValue(true)] public bool droppable = true;

View File

@ -19,6 +19,15 @@ namespace NewHorizons.External.Modules.Props.Item
/// </summary>
[DefaultValue(2f)] public float interactRange = 2f;
/// <summary>
/// Default collider radius when interacting with the socket
/// </summary>
[DefaultValue(0f)]
public float colliderRadius = 0f;
/// <summary>
/// Whether the added sphere collider will be a trigger (interactible but does not collide). Defaults to true.
/// </summary>
[DefaultValue(true)] public bool colliderIsTrigger = true;
/// <summary>
/// Whether to use "Give Item" / "Take Item" prompts instead of "Insert Item" / "Remove Item".
/// </summary>
public bool useGiveTakePrompts;
@ -46,10 +55,5 @@ namespace NewHorizons.External.Modules.Props.Item
/// A ship log fact to reveal when removing an item from this socket, or when the socket is empty.
/// </summary>
public string removalFact;
/// <summary>
/// Default collider radius when interacting with the socket
/// </summary>
[DefaultValue(0f)]
public float colliderRadius = 0f;
}
}

View File

@ -0,0 +1,94 @@
using NewHorizons.External.SerializableData;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace NewHorizons.External.Modules.Props
{
[JsonObject]
public class ShapeInfo
{
/// <summary>
/// The type of shape or collider to add. Sphere, box, and capsule colliders are more performant and support collision. Defaults to sphere.
/// </summary>
public ShapeType type = ShapeType.Sphere;
/// <summary>
/// The radius of the shape or collider. Defaults to 1 meter. Only used by spheres, capsules, cylinders, hemispheres, hemicapsules, and rings.
/// </summary>
public float radius = 1f;
/// <summary>
/// The height of the shape or collider. Defaults to 1 meter. Only used by capsules, cylinders, cones, hemicapsules, and rings.
/// </summary>
public float height = 1f;
/// <summary>
/// The axis that the shape or collider is aligned with. Defaults to the Y axis (up). The flat bottom of the shape will be pointing towards the negative axis. Only used by capsules, cones, hemispheres, and hemicapsules.
/// </summary>
public ColliderAxis direction = ColliderAxis.Y;
/// <summary>
/// The inner radius of the shape. Defaults to 0 meters. Only used by cones and rings.
/// </summary>
public float innerRadius = 0f;
/// <summary>
/// The outer radius of the shape. Defaults to 0.5 meters. Only used by cones and rings.
/// </summary>
public float outerRadius = 0.5f;
/// <summary>
/// Whether the shape has an end cap. Defaults to true. Only used by hemispheres and hemicapsules.
/// </summary>
public bool cap = true;
/// <summary>
/// The size of the shape or collider. Defaults to (1,1,1). Only used by boxes.
/// </summary>
public MVector3 size;
/// <summary>
/// The offset of the shape or collider from the object's origin. Defaults to (0,0,0). Supported by all collider and shape types.
/// </summary>
public MVector3 offset;
/// <summary>
/// Whether the collider should have collision enabled. If false, the collider will be a trigger. Defaults to false. Only supported for spheres, boxes, and capsules.
/// </summary>
public bool hasCollision = false;
/// <summary>
/// Setting this to false will force it to use a collider, and setting to true will force it to use a shape.
/// Shapes do not support collision and are less performant, but support a wider set of shapes and are required by some components.
/// If left empty it will defaults to using a shape, unless hasCollision is true in which case it defaults to using a collider.
/// </summary>
public bool? useShape;
}
[JsonConverter(typeof(StringEnumConverter))]
public enum ShapeType
{
[EnumMember(Value = @"sphere")] Sphere,
[EnumMember(Value = @"box")] Box,
[EnumMember(Value = @"capsule")] Capsule,
[EnumMember(Value = @"cylinder")] Cylinder,
[EnumMember(Value = @"cone")] Cone,
[EnumMember(Value = @"hemisphere")] Hemisphere,
[EnumMember(Value = @"hemicapsule")] Hemicapsule,
[EnumMember(Value = @"ring")] Ring,
}
[JsonConverter(typeof(StringEnumConverter))]
public enum ColliderAxis
{
[EnumMember(Value = @"x")] X = 0,
[EnumMember(Value = @"y")] Y = 1,
[EnumMember(Value = @"z")] Z = 2,
}
}

View File

@ -0,0 +1,40 @@
using NewHorizons.External.Modules.Volumes.VolumeInfos;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NewHorizons.External.Modules.Volumes
{
[JsonObject]
public class ForceModule
{
/// <summary>
/// Applies a constant force along the volume's XZ plane towards the volume's center. Affects alignment.
/// </summary>
public CylindricalForceVolumeInfo[] cylindricalVolumes;
/// <summary>
/// Applies a constant force in the direction of the volume's Y axis. May affect alignment.
/// </summary>
public DirectionalForceVolumeInfo[] directionalVolumes;
/// <summary>
/// Applies planet-like gravity towards the volume's center with falloff by distance. May affect alignment.
/// For actual planetary body gravity, use the properties in the Base module.
/// </summary>
public GravityVolumeInfo[] gravityVolumes;
/// <summary>
/// Applies a constant force towards the volume's center. Affects alignment.
/// </summary>
public PolarForceVolumeInfo[] polarVolumes;
/// <summary>
/// Applies a force towards the volume's center with falloff by distance. Affects alignment.
/// </summary>
public RadialForceVolumeInfo[] radialVolumes;
}
}

View File

@ -0,0 +1,39 @@
using Newtonsoft.Json;
using System.ComponentModel;
namespace NewHorizons.External.Modules.Volumes.VolumeInfos
{
[JsonObject]
public class ConditionTriggerVolumeInfo : VolumeInfo
{
/// <summary>
/// The name of the dialogue condition or persistent condition to set when entering the volume.
/// </summary>
public string condition;
/// <summary>
/// If true, the condition will persist across all future loops until unset.
/// </summary>
public bool persistent;
/// <summary>
/// Whether to unset the condition when existing the volume.
/// </summary>
public bool reversible;
/// <summary>
/// Whether to set the condition when the player enters this volume. Defaults to true.
/// </summary>
[DefaultValue(true)] public bool player = true;
/// <summary>
/// Whether to set the condition when the scout probe enters this volume.
/// </summary>
public bool probe;
/// <summary>
/// Whether to set the condition when the ship enters this volume.
/// </summary>
public bool ship;
}
}

View File

@ -0,0 +1,24 @@
using NewHorizons.External.SerializableData;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NewHorizons.External.Modules.Volumes.VolumeInfos
{
[JsonObject]
public class CylindricalForceVolumeInfo : ForceVolumeInfo
{
/// <summary>
/// The direction that the force applied by this volume will be perpendicular to. Defaults to up (0, 1, 0).
/// </summary>
public MVector3 normal;
/// <summary>
/// Whether to play the gravity crystal audio when the player is in this volume.
/// </summary>
public bool playGravityCrystalAudio;
}
}

View File

@ -0,0 +1,35 @@
using NewHorizons.External.SerializableData;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NewHorizons.External.Modules.Volumes.VolumeInfos
{
[JsonObject]
public class DirectionalForceVolumeInfo : ForceVolumeInfo
{
/// <summary>
/// The direction of the force applied by this volume. Defaults to up (0, 1, 0).
/// </summary>
public MVector3 normal;
/// <summary>
/// Whether this force volume affects alignment. Defaults to true.
/// </summary>
[DefaultValue(true)] public bool affectsAlignment = true;
/// <summary>
/// Whether the force applied by this volume takes the centripetal force of the volume's parent body into account. Defaults to false.
/// </summary>
public bool offsetCentripetalForce;
/// <summary>
/// Whether to play the gravity crystal audio when the player is in this volume.
/// </summary>
public bool playGravityCrystalAudio;
}
}

View File

@ -0,0 +1,35 @@
using NewHorizons.External.Modules.Props;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NewHorizons.External.Modules.Volumes.VolumeInfos
{
[JsonObject]
public class ForceVolumeInfo : PriorityVolumeInfo
{
/// <summary>
/// The force applied by this volume. Can be negative to reverse the direction.
/// </summary>
public float force;
/// <summary>
/// The priority of this force volume for the purposes of alignment.
///
/// Volumes of higher priority will override volumes of lower priority. Volumes of the same priority will stack like normal.
/// Ex: A player in a gravity volume with priority 0, and zero-gravity volume with priority 1, will feel zero gravity.
///
/// Default value here is 1 instead of 0 so it automatically overrides planet gravity, which is 0 by default.
/// </summary>
[DefaultValue(1)] public int alignmentPriority = 1;
/// <summary>
/// Whether this force volume is inheritable. The most recently activated inheritable force volume will stack with other force volumes even if their priorities differ.
/// </summary>
public bool inheritable;
}
}

View File

@ -0,0 +1,44 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NewHorizons.External.Modules.Volumes.VolumeInfos
{
[JsonObject]
public class GravityVolumeInfo : ForceVolumeInfo
{
/// <summary>
/// The upper bounds of the volume's "surface". Above this radius, the force applied by this volume will have falloff applied.
/// </summary>
public float upperRadius;
/// <summary>
/// The lower bounds of the volume's "surface". Above this radius and below the `upperRadius`, the force applied by this volume will be constant. Defaults to 0.
/// </summary>
[DefaultValue(0f)] public float lowerRadius;
/// <summary>
/// The volume's force will decrease linearly from `force` to `minForce` as distance decreases from `lowerRadius` to `minRadius`. Defaults to 0.
/// </summary>
[DefaultValue(0f)] public float minRadius;
/// <summary>
/// The minimum force applied by this volume between `lowerRadius` and `minRadius`. Defaults to 0.
/// </summary>
[DefaultValue(0f)] public float minForce;
/// <summary>
/// How the force falls off with distance. Most planets use linear but the sun and some moons use inverseSquared.
/// </summary>
[DefaultValue("linear")] public GravityFallOff fallOff = GravityFallOff.Linear;
/// <summary>
/// The radius where objects will be aligned to the volume's force. Defaults to 1.5x the `upperRadius`. Set to 0 to disable alignment.
/// </summary>
public float? alignmentRadius;
}
}

View File

@ -0,0 +1,65 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NewHorizons.External.Modules.Volumes.VolumeInfos
{
[JsonObject]
public class InteractionVolumeInfo : VolumeInfo
{
/// <summary>
/// The prompt to display when the volume is interacted with.
/// </summary>
public string prompt;
/// <summary>
/// The range at which the volume can be interacted with.
/// </summary>
[DefaultValue(2f)] public float range = 2f;
/// <summary>
/// The max view angle (in degrees) the player can see the volume with to interact with it. This will effectively be a cone extending from the volume's center forwards (along the Z axis) based on the volume's rotation.
/// If not specified, no view angle restriction will be applied.
/// </summary>
public float? maxViewAngle;
/// <summary>
/// Whether the volume can be interacted with while in the ship.
/// </summary>
public bool usableInShip;
/// <summary>
/// Whether the volume can be interacted with multiple times.
/// </summary>
public bool reusable;
/// <summary>
/// The name of the dialogue condition or persistent condition to set when the volume is interacted with.
/// </summary>
public string condition;
/// <summary>
/// If true, the condition will persist across all future loops until unset.
/// </summary>
public bool persistent;
/// <summary>
/// A sound to play when the volume is interacted with. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
/// </summary>
public string audio;
/// <summary>
/// A path to an animator component where an animation will be triggered when the volume is interacted with.
/// </summary>
public string pathToAnimator;
/// <summary>
/// The name of an animation trigger to set on the animator when the volume is interacted with.
/// </summary>
public string animationTrigger;
}
}

View File

@ -0,0 +1,23 @@
using NewHorizons.External.SerializableData;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NewHorizons.External.Modules.Volumes.VolumeInfos
{
[JsonObject]
public class PolarForceVolumeInfo : ForceVolumeInfo
{
/// <summary>
/// Tangential mode only. The force applied by this volume will be perpendicular to this direction and the direction to the other body. Defaults to up (0, 1, 0).
/// </summary>
public MVector3 normal;
/// <summary>
/// Enables tangential mode. The force applied by this volume will be perpendicular to the normal and the direction to the other body. Defaults to false.
/// </summary>
public bool tangential;
}
}

View File

@ -0,0 +1,32 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace NewHorizons.External.Modules.Volumes.VolumeInfos
{
[JsonObject]
public class RadialForceVolumeInfo : ForceVolumeInfo
{
/// <summary>
/// How the force falls off with distance. Defaults to linear.
/// </summary>
[DefaultValue("linear")] public FallOff fallOff = FallOff.Linear;
[JsonConverter(typeof(StringEnumConverter))]
public enum FallOff
{
[EnumMember(Value = @"constant")] Constant = 0,
[EnumMember(Value = @"linear")] Linear = 1,
[EnumMember(Value = @"inverseSquared")]
InverseSquared = 2
}
}
}

View File

@ -0,0 +1,49 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NewHorizons.External.Modules.Volumes.VolumeInfos
{
[JsonObject]
public class RepairVolumeInfo : VolumeInfo
{
/// <summary>
/// The name displayed in the UI when the player is repairing this object. If not set, the name of the object will be used.
/// </summary>
public string name;
/// <summary>
/// How much of the object is initially repaired. 0 = not repaired, 1 = fully repaired.
/// </summary>
[DefaultValue(0f)] public float repairFraction = 0f;
/// <summary>
/// The time it takes to repair the object. Defaults to 3 seconds.
/// </summary>
[DefaultValue(3f)] public float repairTime = 3f;
/// <summary>
/// The distance from the object that the player can be to repair it. Defaults to 3 meters.
/// </summary>
[DefaultValue(3f)] public float repairDistance = 3f;
/// <summary>
/// A dialogue condition that will be set while the object is damaged. It will be unset when the object is repaired.
/// </summary>
public string damagedCondition;
/// <summary>
/// A dialogue condition that will be set when the object is repaired. It will be unset if the object is damaged again.
/// </summary>
public string repairedCondition;
/// <summary>
/// A ship log fact that will be revealed when the object is repaired.
/// </summary>
public string revealFact;
}
}

View File

@ -29,7 +29,7 @@ namespace NewHorizons.External.Modules.Volumes.VolumeInfos
}
/// <summary>
/// The max view angle (in degrees) the player can see the volume with to unlock the fact (`observe` only)
/// The max view angle (in degrees) the player can see the volume with to unlock the fact (`observe` only). This will effectively be a cone extending from the volume's center forwards (along the Z axis) based on the volume's rotation.
/// </summary>
[DefaultValue(180f)]
public float maxAngle = 180f; // Observe Only

View File

@ -0,0 +1,28 @@
using Newtonsoft.Json;
using System.ComponentModel;
using UnityEngine;
namespace NewHorizons.External.Modules.Volumes.VolumeInfos
{
[JsonObject]
public class SpeedLimiterVolumeInfo : VolumeInfo
{
/// <summary>
/// The speed the volume will slow you down to when you enter it.
/// </summary>
[DefaultValue(10f)]
public float maxSpeed = 10f;
/// <summary>
/// The distance from the outside of the volume that the limiter slows you down to max speed at.
/// </summary>
[DefaultValue(100f)]
public float stoppingDistance = 100f;
/// <summary>
/// The maximum angle (in degrees) between the direction the incoming object is moving relative to the volume's center and the line from the object toward the center of the volume, within which the speed limiter will activate.
/// </summary>
[DefaultValue(60f)]
public float maxEntryAngle = 60f;
}
}

View File

@ -4,6 +4,9 @@ using System.ComponentModel;
namespace NewHorizons.External.Modules.Volumes.VolumeInfos
{
/// <summary>
/// Note: Only colliders work on vanish volumes!
/// </summary>
[JsonObject]
public class VanishVolumeInfo : VolumeInfo
{

View File

@ -1,14 +1,20 @@
using NewHorizons.External.Modules.Props;
using Newtonsoft.Json;
using System.ComponentModel;
namespace NewHorizons.External.Modules.Volumes.VolumeInfos
{
[JsonObject]
public class VolumeInfo : GeneralPointPropInfo
public class VolumeInfo : GeneralPropInfo
{
/// <summary>
/// The radius of this volume.
/// The radius of this volume, if a shape is not specified.
/// </summary>
[DefaultValue(1f)] public float radius = 1f;
/// <summary>
/// The shape of this volume. Defaults to a sphere with a radius of `radius` if not specified.
/// </summary>
public ShapeInfo shape;
}
}

View File

@ -11,6 +11,11 @@ namespace NewHorizons.External.Modules.Volumes
/// </summary>
public AudioVolumeInfo[] audioVolumes;
/// <summary>
/// Add condition trigger volumes to this planet. Sets a condition when the player, scout, or ship enters this volume.
/// </summary>
public ConditionTriggerVolumeInfo[] conditionTriggerVolumes;
/// <summary>
/// Add day night audio volumes to this planet. These volumes play a different clip depending on the time of day.
/// </summary>
@ -27,12 +32,23 @@ namespace NewHorizons.External.Modules.Volumes
/// </summary>
public FluidVolumeInfo[] fluidVolumes;
/// <summary>
/// Add force volumes to this planet.
/// </summary>
public ForceModule forces;
/// <summary>
/// Add hazard volumes to this planet.
/// Causes damage to player when inside this volume.
/// </summary>
public HazardVolumeInfo[] hazardVolumes;
/// <summary>
/// Add interaction volumes to this planet.
/// They can be interacted with by the player to trigger various effects.
/// </summary>
public InteractionVolumeInfo[] interactionVolumes;
/// <summary>
/// Add interference volumes to this planet.
/// Hides HUD markers of ship scout/probe and prevents scout photos if you are not inside the volume together with ship or scout probe.
@ -80,6 +96,11 @@ namespace NewHorizons.External.Modules.Volumes
/// </summary>
public VolumeInfo[] referenceFrameBlockerVolumes;
/// <summary>
/// Add repair volumes to this planet.
/// </summary>
public RepairVolumeInfo[] repairVolumes;
/// <summary>
/// Add triggers that reveal parts of the ship log on this planet.
/// </summary>
@ -101,6 +122,13 @@ namespace NewHorizons.External.Modules.Volumes
/// </summary>
public SpeedTrapVolumeInfo[] speedTrapVolumes;
/// <summary>
/// Add speed limiter volumes to this planet.
/// Slows down the player, ship, and probe when they enter this volume.
/// Used on the Stranger in DLC.
/// </summary>
public SpeedLimiterVolumeInfo[] speedLimiterVolumes;
/// <summary>
/// Add visor effect volumes to this planet.
/// </summary>

View File

@ -191,6 +191,7 @@ namespace NewHorizons.External
if (_activeProfile != null && !_activeProfile.PopupsRead.Contains(id))
{
_activeProfile.PopupsRead.Add(id);
Save();
}
}

View File

@ -13,6 +13,8 @@ namespace NewHorizons.External.SerializableEnums
[EnumMember(Value = @"kazoo")] Kazoo = 2,
[EnumMember(Value = @"none")] None = 3
[EnumMember(Value = @"custom")] Custom = 3,
[EnumMember(Value = @"none")] None = 4
}
}

View File

@ -96,7 +96,7 @@ namespace NewHorizons.Handlers
vesselAO._type = AstroObject.Type.SpaceStation;
vesselAO.Register();
vesselMapMarker._markerType = MapMarker.MarkerType.Moon;
vesselMapMarker._labelID = (UITextType)TranslationHandler.AddUI("Vessel");
vesselMapMarker._labelID = (UITextType)TranslationHandler.AddUI("Vessel", true);
RFVolumeBuilder.Make(vessel, vesselBody, 600, new External.Modules.ReferenceFrameModule { localPosition = new MVector3(0, 0, -207.375f) });
// Resize vessel sector so that the vessel is fully collidable.

View File

@ -5,6 +5,7 @@ using NewHorizons.Builder.Orbital;
using NewHorizons.Builder.Props;
using NewHorizons.Builder.ShipLog;
using NewHorizons.Builder.Volumes;
using NewHorizons.Components;
using NewHorizons.Components.Orbital;
using NewHorizons.Components.Quantum;
using NewHorizons.Components.Stars;
@ -20,10 +21,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using NewHorizons.Streaming;
using Newtonsoft.Json;
using NewHorizons.External.Modules.VariableSize;
using NewHorizons.Components;
namespace NewHorizons.Handlers
{
@ -45,6 +42,16 @@ namespace NewHorizons.Handlers
public static void Init(List<NewHorizonsBody> bodies)
{
// TH gets preloaded in title screen. custom systems dont need this
if (Main.Instance.CurrentStarSystem is not ("SolarSystem" or "EyeOfTheUniverse"))
{
foreach (var bundle in StreamingManager.s_activeBundles)
{
// save memory NOW instead of next frame when other stuff has loaded and taken memory
bundle.UnloadImmediate();
}
}
// Start by destroying all planets if need be
if (Main.SystemDict[Main.Instance.CurrentStarSystem].Config.destroyStockPlanets)
{
@ -657,7 +664,7 @@ namespace NewHorizons.Handlers
if (body.Config.CometTail != null)
{
CometTailBuilder.Make(go, sector, body.Config.CometTail, body.Config);
CometTailBuilder.Make(go, sector, body.Config.CometTail, body.Config, go.GetComponent<AstroObject>());
}
if (body.Config.Lava != null)

View File

@ -205,11 +205,14 @@ namespace NewHorizons.Handlers
TextTranslation.Get().m_table.theShipLogTable[key] = value;
}
public static int AddUI(string rawText)
public static int AddUI(string rawText) => AddUI(rawText, false);
public static int AddUI(string rawText, bool upper)
{
var uiTable = TextTranslation.Get().m_table.theUITable;
var text = GetTranslation(rawText, TextType.UI).ToUpperFixed();
var text = GetTranslation(rawText, TextType.UI);
if (upper) text = text.ToUpperFixed();
var key = uiTable.Keys.Max() + 1;
try

View File

@ -210,7 +210,7 @@ namespace NewHorizons.Handlers
vesselWarpController._whiteHoleOneShot = vesselWarpController._whiteHole.transform.parent.Find("WhiteHoleAudio_OneShot").GetComponent<OWAudioSource>();
vesselWarpController._whiteHole._startActive = true;
vesselObject.GetComponent<MapMarker>()._labelID = (UITextType)TranslationHandler.AddUI("Vessel");
vesselObject.GetComponent<MapMarker>()._labelID = (UITextType)TranslationHandler.AddUI("Vessel", true);
var hasParentBody = !string.IsNullOrEmpty(system.Config.Vessel?.vesselSpawn?.parentBody);
var hasPhysics = system.Config.Vessel?.hasPhysics ?? !hasParentBody;

View File

@ -255,5 +255,12 @@ namespace NewHorizons
/// <param name="persistentConditionRequired">Persistent condition required for this title screen to appear.</param>
/// <param name="factRequired">Ship log fact required for this title screen to appear.</param>
void RegisterTitleScreenBuilder(IModBehaviour mod, Action<GameObject> builder, bool disableNHPlanets = true, bool shareTitleScreen = false, string persistentConditionRequired = null, string factRequired = null);
/// <summary>
/// Clears all loaded configs for the given system.
/// This exists solely for Nomai Sky to use :bleh:
/// </summary>
/// <param name="name"></param>
void ClearSystem(string name);
}
}

View File

@ -46,6 +46,7 @@ namespace NewHorizons
// Settings
public static bool Debug { get; private set; }
public static bool VisualizeQuantumObjects { get; private set; }
public static bool VisualizeBrambleVolumeNames { get; private set; }
public static bool VerboseLogs { get; private set; }
public static bool SequentialPreCaching { get; private set; }
public static bool CustomTitleScreen { get; private set; }
@ -138,6 +139,7 @@ namespace NewHorizons
Debug = config.GetSettingsValue<bool>(nameof(Debug));
VisualizeQuantumObjects = config.GetSettingsValue<bool>(nameof(VisualizeQuantumObjects));
VisualizeBrambleVolumeNames = config.GetSettingsValue<bool>(nameof(VisualizeBrambleVolumeNames));
VerboseLogs = config.GetSettingsValue<bool>(nameof(VerboseLogs));
SequentialPreCaching = config.GetSettingsValue<bool>(nameof(SequentialPreCaching));
@ -380,6 +382,7 @@ namespace NewHorizons
ProjectionBuilder.InitPrefabs();
CloakBuilder.InitPrefab();
RaftBuilder.InitPrefab();
RaftDockBuilder.InitPrefab();
DreamCampfireBuilder.InitPrefab();
DreamArrivalPointBuilder.InitPrefab();
}
@ -436,6 +439,11 @@ namespace NewHorizons
TitleSceneHandler.Init();
}
if (isTitleScreen)
{
MenuHandler.TitleScreen();
}
// EOTU fixes
if (isEyeOfTheUniverse)
{
@ -847,7 +855,7 @@ namespace NewHorizons
}
if (addonConfig.gameOver != null)
{
NHGameOverManager.gameOvers[mod.ModHelper.Manifest.UniqueName] = addonConfig.gameOver;
NHGameOverManager.gameOvers[mod] = addonConfig.gameOver;
}
AddonConfigs[mod] = addonConfig;

View File

@ -1,4 +1,4 @@
<Project>
<Project>
<PropertyGroup>
<OutputPath>$(AppData)\OuterWildsModManager\OWML\Mods\xen.NewHorizons</OutputPath>
</PropertyGroup>

View File

@ -367,5 +367,17 @@ namespace NewHorizons
public void RegisterTitleScreenBuilder(IModBehaviour mod, Action<GameObject> builder, bool disableNHPlanets = true, bool shareTitleScreen = false, string persistentConditionRequired = null, string factRequired = null)
=> TitleSceneHandler.RegisterBuilder(mod, builder, disableNHPlanets, shareTitleScreen, persistentConditionRequired, factRequired);
public void ClearSystem(string name)
{
if (Main.SystemDict.ContainsKey(name))
{
Main.SystemDict.Remove(name);
}
if (Main.BodyDict.ContainsKey(name))
{
Main.BodyDict.Remove(name);
}
}
}
}

View File

@ -3,9 +3,11 @@ using NewHorizons.Handlers;
using NewHorizons.Utility;
using NewHorizons.Utility.OWML;
using OWML.Common;
using OWML.ModHelper;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using static TextTranslation;
namespace NewHorizons.OtherMods.MenuFramework
{
@ -61,5 +63,18 @@ namespace NewHorizons.OtherMods.MenuFramework
public static void RegisterFailedConfig(string filename) => _failedFiles.Add(filename);
public static void RegisterOneTimePopup(IModBehaviour mod, string message, bool repeat) => _registeredPopups.Add((mod, message, repeat));
public static void TitleScreen()
{
// Custom popup for recommending the Chinese Outer Wilds Font Fix mod if they are playing in chinese
// Only shows once per profile
if (TextTranslation.Get().m_language == Language.CHINESE_SIMPLE
&& !Main.Instance.ModHelper.Interaction.ModExists("nice2cu1.OuterWildFixFont")
&& !NewHorizonsData.HasReadOneTimePopup("INSTALL_OUTER_WILDS_CHINESE_FONT_FIX"))
{
Main.Instance.ModHelper.MenuHelper.PopupMenuManager.RegisterStartupPopup(TranslationHandler.GetTranslation("INSTALL_OUTER_WILDS_CHINESE_FONT_FIX", TranslationHandler.TextType.UI));
NewHorizonsData.ReadOneTimePopup("INSTALL_OUTER_WILDS_CHINESE_FONT_FIX");
}
}
}
}

View File

@ -1,17 +1,30 @@
using HarmonyLib;
using NewHorizons.Handlers;
using System;
namespace NewHorizons.Patches.CreditsScenePatches
{
[HarmonyPatch(typeof(Credits))]
public static class CreditsPatches
{
public static event EventHandler CreditsBuilt; // Used in NHGameOverManager to patch credits music and scroll speed
[HarmonyPrefix]
[HarmonyPatch(nameof(Credits.Start))]
public static void Credits_Start(Credits __instance)
{
CreditsHandler.AddCredits(__instance);
}
[HarmonyPostfix]
[HarmonyPatch(nameof(Credits.BuildCredits))]
public static void Credits_BuildCredits_Post(Credits __instance)
{
// Do things BuildCredits() normally does
// Fire event once finished
CreditsBuilt?.Invoke(__instance, new EventArgs());
}
}
}

Some files were not shown because too many files have changed in this diff Show More