Skip to content

Commit

Permalink
1.10.0 (#539)
Browse files Browse the repository at this point in the history
## Major features
- Nomai warp pads! You can build transmitters (like the towers on Ash
Twin) and receivers on other planets. Can also be used to just make
permanent teleportation pads if the alignment window is set to 360
degrees. Receivers also take in general prop arguments for a Nomai
computer which will display the departure and arrival times.

## Minor features
- Adds `gameOverText` and `deathType` to credits volumes to display
orange text explaining the ending. (#512)
- Unified parenting, positioning, and rotating code across all prop-like
objects, adding support for parent-relative offsets and rotations to
rafts, geysers, tornados, volcanos, and others. All prop-like objects
have the common fields `rename`, `parentPath`, and `isRelativeToParent`,
as well as any applicable position and rotation fields.
- Added `alignRadial` to all props with rotations, replacing
`alignToNormal` on details. This now stacks with normal rotations, where
behavior was inconsistent before.
- `translatorText` props now behave like other props in terms of
positioning and rotating. `normal` is no longer used to calculate
rotations of some objects; instead you can use `alignRadial` and/or
`rotation`. Wall text continues to use `normal` to indicate the
direction of the surface to align the text to. Existing `nomaiText` wall
text and props are unaffected by all of these changes.
- Moved the Spawn module player spawn and ship spawn fields to new
`playerSpawn` and `shipSpawn` prop-like object fields.
- Moved dialogue remote trigger fields to a new `remoteTrigger`
prop-like object field.
- Moved the Vessel module vessel location and warp exit location fields
to new `vesselSpawn` and `warpExit` prop-like object fields. They also
have a `parentBody` field to specify the planet to attach them to.
- Made quantum group sockets and bramble nodes/seeds prop-like objects.
- Other Vessel changes
- Added a new `alwaysPresent` property to the Vessel module to spawn the
vessel whether it was used to warp to the system or not, and a
`spawnOnVessel` property to always spawn on the vessel when entering the
system, if it is present.
- Added a new `hasPhysics` property to the Vessel module to allow users
to disable the default behavior of the vessel floating on its own and
allow it to be parented to other planets or bodies.
- Added a new `attachToVessel` property to `warpExit` to keep the old
behavior of the warp exit following the vessel.
- Added a `whiteboard` type to `translatorText` props. If `xmlFile` is
set, it will spawn with a scroll already inserted with that text.

## Improvements
- Improved error logging when a detail fails to be created because a
script component's script is missing
- Added `isRelativeToParent` to geysers to match other prop-like
objects.
- Added `rename` to signals to match other prop-like objects.
- Slightly better error logging if `xmlFile` is not provided for
translator text props that require it
- Now we use nullable values in `translatorText` instead of separate
`keepAutoPlacement` bool
- Deferred singularity linking until after all planets are built, so
build order no longer affects pairs where only one has
`pairedSingularity` set.

## Bug fixes
- Fixed a vanilla bug that would sometimes cause the camera's vertical
rotation to get locked in place when spawning on the vessel
- Fixed several edge cases of props not respecting relative rotations
when `isRelativeToParent` was set
- Fixed geyser rotations being slightly off due to inheriting the
original prefab's rotation
- Fixed ship spawn points not actually being rotated, just the ship
itself (only noticeable if re-using the spawn point game object after
initial spawn)
- Details with `keepLoaded` will no longer have cull groups etc on them,
so they should work in map mode.

## Note for add-on devs:
We rearranged some internal stuff, so if you were referencing the NH dll
in your projects some stuff might have broken. Tested it only with
addons that were actually released.
  • Loading branch information
xen-42 committed Mar 24, 2023
2 parents 54ea75c + 1b441d0 commit 69a5c47
Show file tree
Hide file tree
Showing 193 changed files with 3,935 additions and 3,438 deletions.
3 changes: 2 additions & 1 deletion NewHorizons/Builder/Atmosphere/AirBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NewHorizons.External.Configs;
using NewHorizons.Utility.OWUtilities;
using UnityEngine;
namespace NewHorizons.Builder.Atmosphere
{
Expand All @@ -8,7 +9,7 @@ public static void Make(GameObject planetGO, Sector sector, PlanetConfig config)
{
var airGO = new GameObject("Air");
airGO.SetActive(false);
airGO.layer = 17;
airGO.layer = Layer.BasicEffectVolume;
airGO.transform.parent = sector?.transform ?? planetGO.transform;

var sc = airGO.AddComponent<SphereCollider>();
Expand Down
7 changes: 4 additions & 3 deletions NewHorizons/Builder/Atmosphere/CloudsBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Logger = NewHorizons.Utility.Logger;
using System.Collections.Generic;
using Tessellation;
using NewHorizons.Utility.OWUtilities;

namespace NewHorizons.Builder.Atmosphere
{
Expand Down Expand Up @@ -118,7 +119,7 @@ public static void Make(GameObject planetGO, Sector sector, AtmosphereModule atm

GameObject cloudsFluidGO = new GameObject("CloudsFluid");
cloudsFluidGO.SetActive(false);
cloudsFluidGO.layer = 17;
cloudsFluidGO.layer = Layer.BasicEffectVolume;
cloudsFluidGO.transform.parent = cloudsMainGO.transform;

SphereCollider fluidSC = cloudsFluidGO.AddComponent<SphereCollider>();
Expand Down Expand Up @@ -251,7 +252,7 @@ public static GameObject MakeTopClouds(GameObject rootObject, AtmosphereModule a

if (atmo.clouds.unlit)
{
cloudsTopGO.layer = LayerMask.NameToLayer("IgnoreSun");
cloudsTopGO.layer = Layer.IgnoreSun;
}

if (atmo.clouds.rotationSpeed != 0f)
Expand Down Expand Up @@ -303,7 +304,7 @@ public static GameObject MakeTransparentClouds(GameObject rootObject, Atmosphere
{
GameObject tcrqcGO = new GameObject("TransparentCloudRenderQueueController");
tcrqcGO.transform.SetParent(cloudsTransparentGO.transform, false);
tcrqcGO.layer = LayerMask.NameToLayer("BasicEffectVolume");
tcrqcGO.layer = Layer.BasicEffectVolume;

var shape = tcrqcGO.AddComponent<SphereShape>();
shape.radius = 1;
Expand Down
12 changes: 6 additions & 6 deletions NewHorizons/Builder/Body/BrambleDimensionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using UnityEngine;
using Logger = NewHorizons.Utility.Logger;
using static NewHorizons.Main;
using NewHorizons.Utility.OWMLUtilities;

namespace NewHorizons.Builder.Body
{
Expand Down Expand Up @@ -103,8 +104,7 @@ public static GameObject Make(NewHorizonsBody body, GameObject go, NHAstroObject
default: geometryPrefab = _hubGeometry; break;
}

var detailInfo = new PropModule.DetailInfo();
var geometry = DetailBuilder.Make(go, sector, geometryPrefab, detailInfo);
var geometry = DetailBuilder.Make(go, sector, geometryPrefab, new PropModule.DetailInfo());

var exitWarps = _exitWarps.InstantiateInactive();
var repelVolume = _repelVolume.InstantiateInactive();
Expand Down Expand Up @@ -245,13 +245,13 @@ public static GameObject Make(NewHorizonsBody body, GameObject go, NHAstroObject
cloak._sectors = new Sector[] { sector };
cloak.GetComponent<Renderer>().enabled = true;

// Cull stuff
var cullController = go.AddComponent<BrambleSectorController>();
cullController.SetSector(sector);

// Do next update so other nodes can be built first
Delay.FireOnNextUpdate(() =>
{
// Cull stuff
var cullController = go.AddComponent<BrambleSectorController>();
cullController.SetSector(sector);
// Prevent recursion from causing hard crash
foreach (var senderWarp in outerFogWarpVolume._senderWarps.ToList())
{
Expand Down
1 change: 1 addition & 0 deletions NewHorizons/Builder/Body/CloakBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using NewHorizons.Components;
using NewHorizons.External.Modules;
using NewHorizons.Utility;
using NewHorizons.Utility.OWMLUtilities;
using OWML.Common;
using UnityEngine;
using Logger = NewHorizons.Utility.Logger;
Expand Down
4 changes: 3 additions & 1 deletion NewHorizons/Builder/Body/FunnelBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System.Runtime.Serialization;
using NewHorizons.Components;
using NewHorizons.Utility;
using UnityEngine;
using Logger = NewHorizons.Utility.Logger;
using NewHorizons.External.Modules.VariableSize;
using NewHorizons.Components.Orbital;
using NewHorizons.Utility.OWMLUtilities;
using NewHorizons.Utility.OWUtilities;
using NewHorizons.Components.SizeControllers;

namespace NewHorizons.Builder.Body
{
Expand Down
2 changes: 1 addition & 1 deletion NewHorizons/Builder/Body/Geometry/CubeSphere.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NewHorizons.Utility;
using NewHorizons.Utility.Geometry;
using UnityEngine;
using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Builder.Body.Geometry
Expand Down
3 changes: 2 additions & 1 deletion NewHorizons/Builder/Body/RingBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using UnityEngine;
using Logger = NewHorizons.Utility.Logger;
using NewHorizons.Components.Volumes;
using NewHorizons.Utility.OWUtilities;

namespace NewHorizons.Builder.Body
{
Expand All @@ -30,7 +31,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, RingModule rin
ringVolume.transform.localPosition = Vector3.zero;
ringVolume.transform.localScale = Vector3.one;
ringVolume.transform.localRotation = Quaternion.identity;
ringVolume.layer = LayerMask.NameToLayer("BasicEffectVolume");
ringVolume.layer = Layer.BasicEffectVolume;

var ringShape = ringVolume.AddComponent<RingShape>();
ringShape.innerRadius = ring.innerRadius;
Expand Down
125 changes: 55 additions & 70 deletions NewHorizons/Builder/Body/SingularityBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
using System.Drawing;
using Color = UnityEngine.Color;
using NewHorizons.Components.Volumes;
using NewHorizons.Builder.Props;
using NewHorizons.Utility.OWMLUtilities;
using NewHorizons.Utility.OWUtilities;

namespace NewHorizons.Builder.Body
{
Expand All @@ -29,6 +32,7 @@ public static class SingularityBuilder
public static readonly int Color1 = Shader.PropertyToID("_Color");

private static Dictionary<string, GameObject> _singularitiesByID;
private static List<(string, string)> _pairsToLink;

private static Mesh _blackHoleMesh;
private static GameObject _blackHoleAmbience;
Expand All @@ -42,14 +46,8 @@ public static class SingularityBuilder
private static GameObject _whiteHoleRulesetVolume;
private static GameObject _whiteHoleVolume;

private static bool _isInit;

internal static void InitPrefabs()
{
if (_isInit) return;

_isInit = true;

if (_blackHoleProxyPrefab == null) _blackHoleProxyPrefab = SearchUtilities.Find(_blackHoleProxyPath).InstantiateInactive().Rename("BlackHoleSingularity").DontDestroyOnLoad();
if (_whiteHoleProxyPrefab == null) _whiteHoleProxyPrefab = SearchUtilities.Find(_whiteHoleProxyPath).InstantiateInactive().Rename("WhiteHoleSingularity").DontDestroyOnLoad();

Expand All @@ -69,13 +67,14 @@ internal static void InitPrefabs()
if (_whiteHoleVolume == null) _whiteHoleVolume = SearchUtilities.Find("WhiteHole_Body/WhiteHoleVolume").InstantiateInactive().Rename("WhiteHoleVolume").DontDestroyOnLoad();
}

public static void Make(GameObject go, Sector sector, OWRigidbody OWRB, PlanetConfig config, SingularityModule singularity)
public static void Init()
{
InitPrefabs();

// If we've reloaded the first one will now be null so we have to refresh the list
if (_singularitiesByID?.Values?.FirstOrDefault() == null) _singularitiesByID = new Dictionary<string, GameObject>();
_singularitiesByID = new Dictionary<string, GameObject>();
_pairsToLink = new List<(string, string)>();
}

public static void Make(GameObject go, Sector sector, OWRigidbody OWRB, PlanetConfig config, SingularityModule singularity)
{
var horizonRadius = singularity.horizonRadius;
var distortRadius = singularity.distortRadius != 0f ? singularity.distortRadius : horizonRadius * 2.5f;
var pairedSingularity = singularity.pairedSingularity;
Expand All @@ -92,73 +91,69 @@ public static void Make(GameObject go, Sector sector, OWRigidbody OWRB, PlanetCo
hasHazardVolume, singularity.targetStarSystem, singularity.curve, singularity.hasWarpEffects, singularity.renderQueueOverride, singularity.rename, singularity.parentPath, singularity.isRelativeToParent);

var uniqueID = string.IsNullOrEmpty(singularity.uniqueID) ? config.name : singularity.uniqueID;

_singularitiesByID.Add(uniqueID, newSingularity);

// Try to pair them
if (!string.IsNullOrEmpty(pairedSingularity) && newSingularity != null)
if (!string.IsNullOrEmpty(pairedSingularity))
{
if (_singularitiesByID.TryGetValue(pairedSingularity, out var pairedSingularityGO))
if (polarity)
{
switch (polarity)
{
case true:
PairSingularities(uniqueID, pairedSingularity, newSingularity, pairedSingularityGO);
break;
case false:
PairSingularities(pairedSingularity, uniqueID, pairedSingularityGO, newSingularity);
break;
}
_pairsToLink.Add((uniqueID, pairedSingularity));
}
else
{
_pairsToLink.Add((pairedSingularity, uniqueID));
}
}

}

public static void PairSingularities(string blackHoleID, string whiteHoleID, GameObject blackHole, GameObject whiteHole)
public static void PairAllSingularities()
{
InitPrefabs();

if (blackHole == null || whiteHole == null) return;

Logger.LogVerbose($"Pairing singularities [{blackHoleID}], [{whiteHoleID}]");

var whiteHoleVolume = whiteHole.GetComponentInChildren<WhiteHoleVolume>();
var blackHoleVolume = blackHole.GetComponentInChildren<BlackHoleVolume>();

if (whiteHoleVolume == null || blackHoleVolume == null)
foreach (var pair in _pairsToLink)
{
Logger.LogWarning($"[{blackHoleID}] and [{whiteHoleID}] do not have compatible polarities");
return;
var (blackHoleID, whiteHoleID) = pair;
if (!_singularitiesByID.TryGetValue(blackHoleID, out GameObject blackHole))
{
Logger.LogWarning($"Black hole [{blackHoleID}] is missing.");
break;
}
if (!_singularitiesByID.TryGetValue(whiteHoleID, out GameObject whiteHole))
{
Logger.LogWarning($"White hole [{whiteHoleID}] is missing.");
break;
}
var whiteHoleVolume = whiteHole.GetComponentInChildren<WhiteHoleVolume>();
var blackHoleVolume = blackHole.GetComponentInChildren<BlackHoleVolume>();
if (whiteHoleVolume == null || blackHoleVolume == null)
{
Logger.LogWarning($"Singularities [{blackHoleID}] and [{whiteHoleID}] do not have compatible polarities.");
break;
}
if (blackHoleVolume._whiteHole != null && blackHoleVolume._whiteHole != whiteHoleVolume)
{
Logger.LogWarning($"Black hole [{blackHoleID}] has already been linked!");
break;
}
Logger.LogVerbose($"Pairing singularities [{blackHoleID}], [{whiteHoleID}]");
blackHoleVolume._whiteHole = whiteHoleVolume;
}

blackHoleVolume._whiteHole = whiteHoleVolume;
}

public static GameObject MakeSingularity(GameObject planetGO, Sector sector, Vector3 position, Vector3 rotation, bool polarity, float horizon, float distort,
bool hasDestructionVolume, string targetStarSystem = null, TimeValuePair[] curve = null, bool warpEffects = true, int renderQueue = 2985, string rename = null, string parentPath = null, bool isRelativeToParent = false)
{
InitPrefabs();

// polarity true = black, false = white

var singularity = new GameObject(!string.IsNullOrEmpty(rename) ? rename : (polarity ? "BlackHole" : "WhiteHole"));
singularity.transform.parent = sector?.transform ?? planetGO.transform;

if (!string.IsNullOrEmpty(parentPath))
var info = new SingularityModule
{
var newParent = planetGO.transform.Find(parentPath);
if (newParent != null)
{
singularity.transform.parent = newParent;
}
else
{
Logger.LogError($"Cannot find parent object at path: {planetGO.name}/{parentPath}");
}
}
position = position,
rotation = rotation,
isRelativeToParent = isRelativeToParent,
parentPath = parentPath,
rename = rename,
};

if (isRelativeToParent)
singularity.transform.localPosition = position;
else
singularity.transform.position = planetGO.transform.TransformPoint(position);
var singularity = GeneralPropBuilder.MakeNew(polarity ? "BlackHole" : "WhiteHole", planetGO, sector, info);

var singularityRenderer = MakeSingularityGraphics(singularity, polarity, horizon, distort, renderQueue);

Expand Down Expand Up @@ -190,7 +185,7 @@ public static void PairSingularities(string blackHoleID, string whiteHoleID, Gam
if (hasDestructionVolume || targetStarSystem != null)
{
var destructionVolumeGO = new GameObject("DestructionVolume");
destructionVolumeGO.layer = LayerMask.NameToLayer("BasicEffectVolume");
destructionVolumeGO.layer = Layer.BasicEffectVolume;
destructionVolumeGO.transform.parent = singularity.transform;
destructionVolumeGO.transform.localScale = Vector3.one;
destructionVolumeGO.transform.localPosition = Vector3.zero;
Expand Down Expand Up @@ -273,20 +268,12 @@ public static void PairSingularities(string blackHoleID, string whiteHoleID, Gam
whiteHoleFluidVolume.enabled = true;
}

var rot = Quaternion.Euler(rotation);
if (isRelativeToParent)
singularity.transform.localRotation = rot;
else
singularity.transform.rotation = planetGO.transform.TransformRotation(rot);

singularity.SetActive(true);
return singularity;
}

public static MeshRenderer MakeSingularityGraphics(GameObject singularity, bool polarity, float horizon, float distort, int queue = 2985)
{
InitPrefabs();

var singularityRenderer = new GameObject(polarity ? "BlackHoleRenderer" : "WhiteHoleRenderer");
singularityRenderer.transform.parent = singularity.transform;
singularityRenderer.transform.localPosition = Vector3.zero;
Expand All @@ -309,8 +296,6 @@ public static MeshRenderer MakeSingularityGraphics(GameObject singularity, bool

public static GameObject MakeSingularityProxy(GameObject rootObject, MVector3 position, bool polarity, float horizon, float distort, TimeValuePair[] curve = null, int queue = 2985)
{
InitPrefabs();

var singularityRenderer = MakeSingularityGraphics(rootObject, polarity, horizon, distort, queue);
if (position != null) singularityRenderer.transform.localPosition = position;

Expand Down
9 changes: 5 additions & 4 deletions NewHorizons/Builder/Body/StarBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using UnityEngine.InputSystem.XR;
using System.Linq;
using NewHorizons.Components.Stars;
using NewHorizons.Utility.OWUtilities;

namespace NewHorizons.Builder.Body
{
Expand Down Expand Up @@ -122,7 +123,7 @@ public static (GameObject, StarController, StarEvolutionController, Light) Make(
heatVolume.transform.SetParent(starGO.transform, false);
heatVolume.transform.localPosition = Vector3.zero;
heatVolume.transform.localScale = Vector3.one;
heatVolume.layer = LayerMask.NameToLayer("BasicEffectVolume");
heatVolume.layer = Layer.BasicEffectVolume;
heatVolume.AddComponent<SphereShape>().radius = 1.1f;
heatVolume.AddComponent<OWTriggerVolume>();
heatVolume.AddComponent<HeatHazardVolume>()._damagePerSecond = 20f;
Expand All @@ -132,7 +133,7 @@ public static (GameObject, StarController, StarEvolutionController, Light) Make(
deathVolume.transform.SetParent(starGO.transform, false);
deathVolume.transform.localPosition = Vector3.zero;
deathVolume.transform.localScale = Vector3.one;
deathVolume.layer = LayerMask.NameToLayer("BasicEffectVolume");
deathVolume.layer = Layer.BasicEffectVolume;
var sphereCollider = deathVolume.AddComponent<SphereCollider>();
sphereCollider.radius = 1f;
sphereCollider.isTrigger = true;
Expand All @@ -148,7 +149,7 @@ public static (GameObject, StarController, StarEvolutionController, Light) Make(
planetDestructionVolume.transform.SetParent(starGO.transform, false);
planetDestructionVolume.transform.localPosition = Vector3.zero;
planetDestructionVolume.transform.localScale = Vector3.one;
planetDestructionVolume.layer = LayerMask.NameToLayer("BasicEffectVolume");
planetDestructionVolume.layer = Layer.BasicEffectVolume;
var planetSphereCollider = planetDestructionVolume.AddComponent<SphereCollider>();
planetSphereCollider.radius = 0.8f;
planetSphereCollider.isTrigger = true;
Expand Down Expand Up @@ -445,7 +446,7 @@ public static StellarDeathController MakeSupernova(GameObject starGO, StarModule
supernovaWallAudio.transform.SetParent(supernovaGO.transform, false);
supernovaWallAudio.transform.localPosition = Vector3.zero;
supernovaWallAudio.transform.localScale = Vector3.one;
supernovaWallAudio.layer = LayerMask.NameToLayer("BasicEffectVolume");
supernovaWallAudio.layer = Layer.BasicEffectVolume;
var audioSource = supernovaWallAudio.AddComponent<AudioSource>();
audioSource.loop = true;
audioSource.maxDistance = 2000;
Expand Down
Loading

0 comments on commit 69a5c47

Please sign in to comment.