Skip to content

Commit

Permalink
1.22.2 (#911)
Browse files Browse the repository at this point in the history
<!-- A new module or something else important -->

## Major features

-

<!-- A new parameter added to a module, or API feature -->

## Minor features

-

<!-- Some improvement that requires no action on the part of add-on
creators i.e., improved star graphics -->

## Improvements

- When making changes to the Eye of the Universe you can now use any
path from the base solar system. Note some objects might not behave as
expected since many things aren't made to exist at the eye.

<!-- Be sure to reference the existing issue if it exists -->

## Bug fixes

- Copied dream lanterns now look correct
  • Loading branch information
JohnCorby authored Jun 21, 2024
2 parents 0e7d1b0 + 9e00c22 commit c32935a
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 6 deletions.
59 changes: 57 additions & 2 deletions NewHorizons/Builder/Props/DetailBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ public static GameObject Make(GameObject go, Sector sector, IModBehaviour mod, G
DialogueBuilder.HandleUnityCreatedDialogue(dialogue);
}

// copied details need their lanterns fixed
if (!isFromAssetBundle && component is DreamLanternController lantern)
{
lantern.gameObject.AddComponent<DreamLanternControllerFixer>();
}

FixComponent(component, go, detail.ignoreSun);
}
catch(Exception e)
Expand Down Expand Up @@ -438,15 +444,16 @@ public void Start()

NHLogger.LogVerbose("Fixing anglerfish animation");

// Remove any event reference to its angler
// Remove any event reference to its angler so that they dont change its state
if (angler._anglerfishController)
{
angler._anglerfishController.OnChangeAnglerState -= angler.OnChangeAnglerState;
angler._anglerfishController.OnAnglerTurn -= angler.OnAnglerTurn;
angler._anglerfishController.OnAnglerSuspended -= angler.OnAnglerSuspended;
angler._anglerfishController.OnAnglerUnsuspended -= angler.OnAnglerUnsuspended;
}
angler.enabled = true;
// Disable the angler anim controller because we don't want Update or LateUpdate to run, just need it to set the initial Animator state
angler.enabled = false;
angler.OnChangeAnglerState(AnglerfishController.AnglerState.Lurking);

Destroy(this);
Expand Down Expand Up @@ -500,5 +507,53 @@ public void Start()
Destroy(this);
}
}

/// <summary>
/// need component here to run after DreamLanternController.Awake
/// </summary>
[RequireComponent(typeof(DreamLanternController))]
private class DreamLanternControllerFixer : MonoBehaviour
{
private void Start()
{
// based on https://github.com/Bwc9876/OW-Amogus/blob/master/Amogus/LanternCreator.cs
// needed to fix petals looking backwards, among other things

var lantern = GetComponent<DreamLanternController>();

// this is set in Awake, we wanna override it

// Manually copied these values from a artifact lantern so that we don't have to find it (works in Eye)
lantern._origLensFlareBrightness = 0f;
lantern._focuserPetalsBaseEulerAngles = new Vector3[]
{
new Vector3(0.7f, 270.0f, 357.5f),
new Vector3(288.7f, 270.1f, 357.4f),
new Vector3(323.3f, 90.0f, 177.5f),
new Vector3(35.3f, 90.0f, 177.5f),
new Vector3(72.7f, 270.1f, 357.5f)
};
lantern._dirtyFlag_focus = true;
lantern._concealerRootsBaseScale = new Vector3[]
{
Vector3.one,
Vector3.one,
Vector3.one
};
lantern._concealerCoversStartPos = new Vector3[]
{
new Vector3(0.0f, 0.0f, 0.0f),
new Vector3(0.0f, -0.1f, 0.0f),
new Vector3(0.0f, -0.2f, 0.0f),
new Vector3(0.0f, 0.2f, 0.0f),
new Vector3(0.0f, 0.1f, 0.0f),
new Vector3(0.0f, 0.0f, 0.0f)
};
lantern._dirtyFlag_concealment = true;
lantern.UpdateVisuals();

Destroy(this);
}
}
}
}
63 changes: 63 additions & 0 deletions NewHorizons/Handlers/EyeDetailCacher.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using NewHorizons.Utility;
using NewHorizons.Utility.OWML;
using System.Linq;

namespace NewHorizons.Handlers;

public static class EyeDetailCacher
{
public static bool IsInitialized;

public static void Init()
{
if (IsInitialized) return;

SearchUtilities.ClearDontDestroyOnLoadCache();

IsInitialized = true;

foreach (var body in Main.BodyDict["EyeOfTheUniverse"])
{
NHLogger.LogVerbose($"{nameof(EyeDetailCacher)}: {body.Config.name}");
if (body.Config?.Props?.details != null)
{
foreach (var detail in body.Config.Props.details)
{
if (!string.IsNullOrEmpty(detail.assetBundle)) continue;

AddPathToCache(detail.path);
}
}

if (body.Config?.Props?.scatter != null)
{
foreach (var scatter in body.Config.Props.scatter)
{
if (!string.IsNullOrEmpty(scatter.assetBundle)) continue;

AddPathToCache(scatter.path);
}
}
}
}

private static void AddPathToCache(string path)
{
NHLogger.LogVerbose($"{nameof(EyeDetailCacher)}: {path}");

if (string.IsNullOrEmpty(path)) return;

var planet = path.Contains('/') ? path.Split('/').First() : string.Empty;

if (planet != "EyeOfTheUniverse_Body" && planet != "Vessel_Body")
{
NHLogger.LogVerbose($"{nameof(EyeDetailCacher)}: Looking for {path}");
var obj = SearchUtilities.Find(path);
if (obj != null)
{
NHLogger.LogVerbose($"{nameof(EyeDetailCacher)}: Added solar system asset to dont destroy on load cache for eye: {path}");
SearchUtilities.AddToDontDestroyOnLoadCache(path, obj);
}
}
}
}
5 changes: 4 additions & 1 deletion NewHorizons/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
try
{
EyeDetailCacher.Init();

AtmosphereBuilder.InitPrefabs();
BrambleDimensionBuilder.InitPrefabs();
BrambleNodeBuilder.InitPrefabs();
Expand Down Expand Up @@ -967,7 +969,8 @@ public void ChangeCurrentStarSystem(string newStarSystem, bool warp = false, boo
}
else
{
PlayerData.SaveEyeCompletion(); // So that the title screen doesn't keep warping you back to eye
if (!IsWarpingBackToEye)
PlayerData.SaveEyeCompletion(); // So that the title screen doesn't keep warping you back to eye

if (SystemDict[CurrentStarSystem].Config.enableTimeLoop) SecondsElapsedInLoop = TimeLoop.GetSecondsElapsed();
else SecondsElapsedInLoop = -1;
Expand Down
15 changes: 13 additions & 2 deletions NewHorizons/Utility/DebugTools/DebugReload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,21 @@ private static void ReloadConfigs()
NHLogger.LogWarning("Error While Reloading");
}

Main.Instance.ForceClearCaches = true;


SearchUtilities.Find("/PauseMenu/PauseMenuManagers").GetComponent<PauseMenuManager>().OnSkipToNextTimeLoop();

Main.Instance.ForceClearCaches = true;
Main.Instance.ChangeCurrentStarSystem(Main.Instance.CurrentStarSystem, Main.Instance.DidWarpFromShip, Main.Instance.DidWarpFromVessel);
if (Main.Instance.CurrentStarSystem == "EyeOfTheUniverse")
{
Main.Instance.IsWarpingBackToEye = true;
EyeDetailCacher.IsInitialized = false;
Main.Instance.ChangeCurrentStarSystem("SolarSystem");
}
else
{
Main.Instance.ChangeCurrentStarSystem(Main.Instance.CurrentStarSystem, Main.Instance.DidWarpFromShip, Main.Instance.DidWarpFromVessel);
}

Main.SecondsElapsedInLoop = -1f;
}
Expand Down
3 changes: 3 additions & 0 deletions NewHorizons/Utility/OuterWilds/AstroObjectLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ public static GameObject[] GetChildren(AstroObject primary)
.Select(x => x.gameObject)
.Where(x => x.name == "SS_Debris_Body"));
break;
case AstroObject.Name.Eye:
otherChildren.Add(SearchUtilities.Find("Vessel_Body"));
break;
// Just in case GetChildren runs before sun station's name is changed
case AstroObject.Name.CustomString:
if (primary._customName.Equals("Sun Station"))
Expand Down
17 changes: 17 additions & 0 deletions NewHorizons/Utility/SearchUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,24 @@ namespace NewHorizons.Utility
{
public static class SearchUtilities
{
private static readonly Dictionary<string, GameObject> DontDestroyOnLoadCachedGameObjects = new Dictionary<string, GameObject>();
private static readonly Dictionary<string, GameObject> CachedGameObjects = new Dictionary<string, GameObject>();
private static readonly Dictionary<string, GameObject> CachedRootGameObjects = new Dictionary<string, GameObject>();

public static void AddToDontDestroyOnLoadCache(string path, GameObject go)
{
DontDestroyOnLoadCachedGameObjects[path] = go.InstantiateInactive().DontDestroyOnLoad();
}

public static void ClearDontDestroyOnLoadCache()
{
foreach (var go in DontDestroyOnLoadCachedGameObjects.Values)
{
GameObject.Destroy(go);
}
DontDestroyOnLoadCachedGameObjects.Clear();
}

public static void ClearCache()
{
NHLogger.LogVerbose("Clearing search cache");
Expand Down Expand Up @@ -96,6 +111,8 @@ public static GameObject FindChild(this GameObject g, string childPath) =>
/// </summary>
public static GameObject Find(string path, bool warn = true)
{
if (DontDestroyOnLoadCachedGameObjects.TryGetValue(path, out var gameObject)) return gameObject;

if (CachedGameObjects.TryGetValue(path, out var go)) return go;

// 1: normal find
Expand Down
2 changes: 1 addition & 1 deletion NewHorizons/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"author": "xen, Bwc9876, JohnCorby, MegaPiggy, Clay, Trifid, and friends",
"name": "New Horizons",
"uniqueName": "xen.NewHorizons",
"version": "1.22.1",
"version": "1.22.2",
"owmlVersion": "2.12.1",
"dependencies": [ "JohnCorby.VanillaFix", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ],
"conflicts": [ "PacificEngine.OW_CommonResources" ],
Expand Down

0 comments on commit c32935a

Please sign in to comment.