Skip to content

Commit

Permalink
1.22.0 (#902)
Browse files Browse the repository at this point in the history
## Major features

- Added `GlobalMusic` module to system config (change end times, bramble
dimension, and final end times music) (Resolves #894)
- Slides are now loaded in the background instead of freezing your game.
Brings load time of current Eyes of the Past dev build from 2.5 minutes
to 40 seconds (hooray). (Fixes #812)

## Improvements

- Setting `parentPath` will be more robust on most props (retries the
build operation until it finds the parent)

## Bug fixes

- Fix quantum planet NRE when body gets updated (astro object gets
recreated)
- Fix custom signal NRE that happens when going to solar system to get
prefabs for eye
- Fixed global bramble music not playing because all dimensions have an
ambient audio volume
- No more infinite load when warping back to Outer Wilds system with the
Vessel
  • Loading branch information
xen-42 committed Jun 18, 2024
2 parents d660414 + c923af0 commit 07acba4
Show file tree
Hide file tree
Showing 29 changed files with 1,110 additions and 666 deletions.
Binary file added NewHorizons/Assets/textures/blank_slide_reel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions NewHorizons/Builder/Props/Audio/SignalBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public static SignalFrequency AddFrequency(string str)

public static string GetCustomFrequencyName(SignalFrequency frequencyName)
{
if (_customFrequencyNames == null) return string.Empty;
_customFrequencyNames.TryGetValue(frequencyName, out string name);
return name;
}
Expand All @@ -140,6 +141,7 @@ public static SignalName AddSignalName(string str)

public static string GetCustomSignalName(SignalName signalName)
{
if (_customSignalNames == null) return string.Empty;
_customSignalNames.TryGetValue(signalName, out string name);
return name;
}
Expand Down
4 changes: 4 additions & 0 deletions NewHorizons/Builder/Props/BrambleNodeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ private static void PropagateSignals(PlanetConfig[] dimensionConfigs)
if (dimension.Bramble.nodes == null) continue;
foreach (var node in dimension.Bramble.nodes)
{
if (!dimensionNameToIndex.ContainsKey(node.linksTo))
{
NHLogger.LogError($"There is no bramble dimension named {node.linksTo}");
}
var destinationDimensionIndex = dimensionNameToIndex[node.linksTo];
access[dimensionIndex, destinationDimensionIndex] = true;
}
Expand Down
276 changes: 201 additions & 75 deletions NewHorizons/Builder/Props/ProjectionBuilder.cs

Large diffs are not rendered by default.

351 changes: 111 additions & 240 deletions NewHorizons/Builder/Props/PropBuildManager.cs

Large diffs are not rendered by default.

43 changes: 37 additions & 6 deletions NewHorizons/Builder/Props/RemoteBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using OWML.Common;
using System;
using UnityEngine;
using NewHorizons.External.Modules;

namespace NewHorizons.Builder.Props
{
Expand Down Expand Up @@ -122,10 +123,36 @@ internal static void InitPrefabs()
}
}

public static void Make(GameObject go, Sector sector, RemoteInfo info, NewHorizonsBody nhBody)
public static void MakeGeneralProps(GameObject go, Sector sector, RemoteInfo[] remotes, NewHorizonsBody nhBody)
{
InitPrefabs();
if (remotes != null)
{
foreach (var remoteInfo in remotes)
{
try
{
var mod = nhBody.Mod;
var id = RemoteHandler.GetPlatformID(remoteInfo.id);

Texture2D decal = Texture2D.whiteTexture;
if (!string.IsNullOrWhiteSpace(remoteInfo.decalPath)) decal = ImageUtilities.GetTexture(mod, remoteInfo.decalPath, false, false, false);
else NHLogger.LogError($"Missing decal path on [{remoteInfo.id}] for [{go.name}]");

PropBuildManager.MakeGeneralProp(go, remoteInfo.platform, (platform) => MakePlatform(go, sector, id, decal, platform, mod), (platform) => remoteInfo.id);
PropBuildManager.MakeGeneralProp(go, remoteInfo.whiteboard, (whiteboard) => MakeWhiteboard(go, sector, id, decal, whiteboard, nhBody), (whiteboard) => remoteInfo.id);
PropBuildManager.MakeGeneralProps(go, remoteInfo.stones, (stone) => MakeStone(go, sector, id, decal, stone, mod), (stone) => remoteInfo.id);
}
catch (Exception ex)
{
NHLogger.LogError($"Couldn't make remote [{remoteInfo.id}] for [{go.name}]:\n{ex}");
}
}
}
}

[Obsolete("Use MakeGeneralProps instead")]
public static void Make(GameObject go, Sector sector, RemoteInfo info, NewHorizonsBody nhBody)
{
var mod = nhBody.Mod;
var id = RemoteHandler.GetPlatformID(info.id);

Expand All @@ -149,7 +176,7 @@ public static void Make(GameObject go, Sector sector, RemoteInfo info, NewHorizo
{
try
{
MakeWhiteboard(go, sector, nhBody.Mod, id, decal, info.whiteboard, nhBody);
MakeWhiteboard(go, sector, id, decal, info.whiteboard, nhBody);
}
catch (Exception ex)
{
Expand All @@ -173,8 +200,10 @@ public static void Make(GameObject go, Sector sector, RemoteInfo info, NewHorizo
}
}

public static void MakeWhiteboard(GameObject go, Sector sector, IModBehaviour mod, NomaiRemoteCameraPlatform.ID id, Texture2D decal, RemoteWhiteboardInfo info, NewHorizonsBody nhBody)
public static void MakeWhiteboard(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, RemoteWhiteboardInfo info, NewHorizonsBody nhBody)
{
InitPrefabs();
var mod = nhBody.Mod;
var whiteboard = DetailBuilder.Make(go, sector, mod, _whiteboardPrefab, new DetailInfo(info));
whiteboard.SetActive(false);

Expand Down Expand Up @@ -213,8 +242,9 @@ public static void MakeWhiteboard(GameObject go, Sector sector, IModBehaviour mo
whiteboard.SetActive(true);
}

public static void MakePlatform(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, PlatformInfo info, IModBehaviour mod)
public static void MakePlatform(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, RemotePlatformInfo info, IModBehaviour mod)
{
InitPrefabs();
var platform = DetailBuilder.Make(go, sector, mod, _remoteCameraPlatformPrefab, new DetailInfo(info));
platform.SetActive(false);

Expand All @@ -239,8 +269,9 @@ public static void MakePlatform(GameObject go, Sector sector, NomaiRemoteCameraP
platform.SetActive(true);
}

public static void MakeStone(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, StoneInfo info, IModBehaviour mod)
public static void MakeStone(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, ProjectionStoneInfo info, IModBehaviour mod)
{
InitPrefabs();
var shareStone = GeneralPropBuilder.MakeFromPrefab(_shareStonePrefab, "ShareStone_" + id.ToString(), go, sector, info);

shareStone.GetComponent<SharedStone>()._connectedPlatform = id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ internal static void RefreshArcs(NomaiWallText nomaiWallText, GameObject convers

if (info.arcInfo != null && info.arcInfo.Count() != dict.Values.Count())
{
NHLogger.LogError($"Can't make NomaiWallText, arcInfo length [{info.arcInfo.Count()}] doesn't equal text entries [{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");
return;
}

Expand Down
32 changes: 32 additions & 0 deletions NewHorizons/Components/EOTE/DreamWorldEndTimes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using NewHorizons.Utility.Files;
using OWML.Common;
using UnityEngine;

namespace NewHorizons.Components.EOTE
{
public class DreamWorldEndTimes : MonoBehaviour
{
private AudioType _endTimesAudio = AudioType.EndOfTime;
private AudioType _endTimesDreamAudio = AudioType.EndOfTime_Dream;

public void SetEndTimesAudio(AudioType audio)
{
_endTimesAudio = audio;
}

public void AssignEndTimes(OWAudioSource endTimesSource) => Assign(endTimesSource, _endTimesAudio);

public void SetEndTimesDreamAudio(AudioType audio)
{
_endTimesDreamAudio = audio;
}

public void AssignEndTimesDream(OWAudioSource endTimesSource) => Assign(endTimesSource, _endTimesDreamAudio);

public static void Assign(OWAudioSource endTimesSource, AudioType audio)
{
endTimesSource.Stop();
endTimesSource.AssignAudioLibraryClip(audio);
}
}
}
21 changes: 16 additions & 5 deletions NewHorizons/Components/Quantum/QuantumPlanet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ public class QuantumPlanet : QuantumObject
private OWRigidbody _rb;
private OrbitLine _orbitLine;

public NHAstroObject astroObject
{
get
{
if (_astroObject == null)
_astroObject = GetComponent<NHAstroObject>();
return _astroObject;
}
}

public int CurrentIndex { get; private set; }

public override void Awake()
Expand Down Expand Up @@ -97,7 +107,7 @@ public override bool ChangeQuantumState(bool skipInstantVisibilityCheck)

primaryBody = AstroObjectLocator.GetAstroObject(newOrbit.primaryBody);
var primaryGravity = new Gravity(primaryBody.GetGravityVolume());
var secondaryGravity = new Gravity(_astroObject.GetGravityVolume());
var secondaryGravity = new Gravity(astroObject.GetGravityVolume());
orbitalParams = newOrbit.GetOrbitalParameters(primaryGravity, secondaryGravity);

var pos = primaryBody.transform.position + orbitalParams.InitialPosition;
Expand Down Expand Up @@ -139,15 +149,16 @@ private void SetNewSector(State oldState, State newState)

private void SetNewOrbit(AstroObject primaryBody, OrbitalParameters orbitalParameters)
{
_astroObject._primaryBody = primaryBody;
DetectorBuilder.SetDetector(primaryBody, _astroObject, _detector);
astroObject._primaryBody = primaryBody;
DetectorBuilder.SetDetector(primaryBody, astroObject, _detector);
_detector._activeInheritedDetector = primaryBody.GetComponentInChildren<ForceDetector>();
_detector._activeVolumes = new List<EffectVolume>() { primaryBody.GetGravityVolume() };
if (_alignment != null) _alignment.SetTargetBody(primaryBody.GetComponent<OWRigidbody>());

_astroObject.SetOrbitalParametersFromTrueAnomaly(orbitalParameters.eccentricity, orbitalParameters.semiMajorAxis, orbitalParameters.inclination, orbitalParameters.argumentOfPeriapsis, orbitalParameters.longitudeOfAscendingNode, orbitalParameters.trueAnomaly);
astroObject.SetOrbitalParametersFromTrueAnomaly(orbitalParameters.eccentricity, orbitalParameters.semiMajorAxis, orbitalParameters.inclination, orbitalParameters.argumentOfPeriapsis, orbitalParameters.longitudeOfAscendingNode, orbitalParameters.trueAnomaly);

PlanetCreationHandler.UpdatePosition(gameObject, orbitalParameters, primaryBody, _astroObject);
PlanetCreationHandler.UpdatePosition(gameObject, orbitalParameters, primaryBody, astroObject);
gameObject.transform.parent = null;

if (!Physics.autoSyncTransforms)
{
Expand Down
67 changes: 64 additions & 3 deletions NewHorizons/External/Configs/StarSystemConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,13 @@ public class StarSystemConfig
[Obsolete("travelAudioFilePath is deprecated, please use travelAudio instead")]
public string travelAudioFilePath;

[Obsolete("travelAudio is deprecated, please use travelAudio instead")]
public string travelAudio;

/// <summary>
/// The audio that will play when travelling in space. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
/// Replace music that plays globally
/// </summary>
public string travelAudio;
public GlobalMusicModule GlobalMusic;

/// <summary>
/// Configure warping to this system with the vessel
Expand Down Expand Up @@ -192,6 +195,45 @@ public class SkyboxModule
public string backPath;
}

[JsonObject]
public class GlobalMusicModule
{
/// <summary>
/// The audio that will play when travelling in space. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
/// </summary>
public string travelAudio;

/// <summary>
/// The audio that will play right before the loop ends. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
/// </summary>
public string endTimesAudio;

/// <summary>
/// The audio that will play right before the loop ends while inside the dreamworld. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
/// </summary>
public string endTimesDreamAudio;

/// <summary>
/// The audio that will play when travelling through a bramble dimension. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
/// </summary>
public string brambleDimensionAudio;

/// <summary>
/// The audio that will play when you leave the ash twin project after taking out the advanced warp core. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
/// </summary>
public string finalEndTimesIntroAudio;

/// <summary>
/// The audio that will loop after the final end times intro. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
/// </summary>
public string finalEndTimesLoopAudio;

/// <summary>
/// The audio that will loop after the final end times intro while inside a bramble dimension. Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
/// </summary>
public string finalEndTimesBrambleDimensionAudio;
}

[JsonObject]
public class VesselModule
{
Expand Down Expand Up @@ -283,7 +325,6 @@ public void Merge(StarSystemConfig otherConfig)
// If current one is null take the other
factRequiredForWarp = string.IsNullOrEmpty(factRequiredForWarp) ? otherConfig.factRequiredForWarp : factRequiredForWarp;
Skybox = Skybox == null ? otherConfig.Skybox : Skybox;
travelAudio = string.IsNullOrEmpty(travelAudio) ? otherConfig.travelAudio : travelAudio;

// False by default so if one is true go true
mapRestricted = mapRestricted || otherConfig.mapRestricted;
Expand All @@ -302,6 +343,21 @@ public void Merge(StarSystemConfig otherConfig)
Vessel ??= otherConfig.Vessel;
}

if (GlobalMusic != null && otherConfig.GlobalMusic != null)
{
GlobalMusic.travelAudio = string.IsNullOrEmpty(GlobalMusic.travelAudio) ? otherConfig.GlobalMusic.travelAudio : GlobalMusic.travelAudio;
GlobalMusic.endTimesAudio = string.IsNullOrEmpty(GlobalMusic.endTimesAudio) ? otherConfig.GlobalMusic.endTimesAudio : GlobalMusic.endTimesAudio;
GlobalMusic.endTimesDreamAudio = string.IsNullOrEmpty(GlobalMusic.endTimesDreamAudio) ? otherConfig.GlobalMusic.endTimesDreamAudio : GlobalMusic.endTimesDreamAudio;
GlobalMusic.brambleDimensionAudio = string.IsNullOrEmpty(GlobalMusic.brambleDimensionAudio) ? otherConfig.GlobalMusic.brambleDimensionAudio : GlobalMusic.brambleDimensionAudio;
GlobalMusic.finalEndTimesIntroAudio = string.IsNullOrEmpty(GlobalMusic.finalEndTimesIntroAudio) ? otherConfig.GlobalMusic.finalEndTimesIntroAudio : GlobalMusic.finalEndTimesIntroAudio;
GlobalMusic.finalEndTimesLoopAudio = string.IsNullOrEmpty(GlobalMusic.finalEndTimesLoopAudio) ? otherConfig.GlobalMusic.finalEndTimesLoopAudio : GlobalMusic.finalEndTimesLoopAudio;
GlobalMusic.finalEndTimesBrambleDimensionAudio = string.IsNullOrEmpty(GlobalMusic.finalEndTimesBrambleDimensionAudio) ? otherConfig.GlobalMusic.finalEndTimesBrambleDimensionAudio : GlobalMusic.finalEndTimesBrambleDimensionAudio;
}
else
{
GlobalMusic ??= otherConfig.GlobalMusic;
}

entryPositions = Concatenate(entryPositions, otherConfig.entryPositions);
curiosities = Concatenate(curiosities, otherConfig.curiosities);
initialReveal = Concatenate(initialReveal, otherConfig.initialReveal);
Expand All @@ -319,6 +375,11 @@ public void Migrate()
#pragma warning disable 612, 618
if (!string.IsNullOrEmpty(travelAudioClip)) travelAudio = travelAudioClip;
if (!string.IsNullOrEmpty(travelAudioFilePath)) travelAudio = travelAudioFilePath;
if (!string.IsNullOrEmpty(travelAudio))
{
if (GlobalMusic == null) GlobalMusic = new GlobalMusicModule();
if (string.IsNullOrEmpty(GlobalMusic.travelAudio)) GlobalMusic.travelAudio = travelAudio;
}
if (coords != null || vesselPosition != null || vesselRotation != null || warpExitPosition != null || warpExitRotation != null)
{
if (Vessel == null)
Expand Down
22 changes: 13 additions & 9 deletions NewHorizons/External/Modules/GeneralPropInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,31 @@
namespace NewHorizons.External.Modules
{
[JsonObject]
public abstract class GeneralPointPropInfo
public abstract class BasePropInfo
{
/// <summary>
/// Position of the object
/// The relative path from the planet to the parent of this object. Optional (will default to the root sector).
/// </summary>
public MVector3 position;
public string parentPath;

/// <summary>
/// The relative path from the planet to the parent of this object. Optional (will default to the root sector).
/// An optional rename of this object
/// </summary>
public string parentPath;
public string rename;
}

[JsonObject]
public abstract class GeneralPointPropInfo : BasePropInfo
{
/// <summary>
/// Whether the positional and rotational coordinates are relative to parent instead of the root planet object.
/// Position of the object
/// </summary>
public bool isRelativeToParent;
public MVector3 position;

/// <summary>
/// An optional rename of this object
/// Whether the positional and rotational coordinates are relative to parent instead of the root planet object.
/// </summary>
public string rename;
public bool isRelativeToParent;
}

[JsonObject]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace NewHorizons.External.Modules.Props.Remote
{
[JsonObject]
public class StoneInfo : GeneralPropInfo
public class ProjectionStoneInfo : GeneralPropInfo
{

}
Expand Down
4 changes: 2 additions & 2 deletions NewHorizons/External/Modules/Props/Remote/RemoteInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public class RemoteInfo
/// <summary>
/// Camera platform that the stones can project to and from
/// </summary>
public PlatformInfo platform;
public RemotePlatformInfo platform;

/// <summary>
/// Projection stones
/// </summary>
public StoneInfo[] stones;
public ProjectionStoneInfo[] stones;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace NewHorizons.External.Modules.Props.Remote
{
[JsonObject]
public class PlatformInfo : GeneralPropInfo
public class RemotePlatformInfo : GeneralPropInfo
{
/// <summary>
/// A ship log fact to reveal when the platform is connected to.
Expand Down
Loading

0 comments on commit 07acba4

Please sign in to comment.