mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
48 lines
2.0 KiB
C#
48 lines
2.0 KiB
C#
using HarmonyLib;
|
|
using NewHorizons.Builder.ShipLog;
|
|
using NewHorizons.Handlers;
|
|
using NewHorizons.Utility;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
using Logger = NewHorizons.Utility.Logger;
|
|
|
|
namespace NewHorizons.Patches.ShipLogPatches
|
|
{
|
|
[HarmonyPatch(typeof(ShipLogMapMode))]
|
|
public static class ShipLogMapModePatches
|
|
{
|
|
[HarmonyPostfix]
|
|
[HarmonyPatch(nameof(ShipLogMapMode.Initialize))]
|
|
public static void ShipLogMapMode_Initialize(ShipLogMapMode __instance)
|
|
{
|
|
GameObject panRoot = SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH);
|
|
GameObject sunObject = SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/Sun");
|
|
ShipLogAstroObject[][] navMatrix = MapModeBuilder.ConstructMapMode(Main.Instance.CurrentStarSystem, panRoot, __instance._astroObjects, sunObject.layer);
|
|
if (navMatrix == null || navMatrix.Length <= 1)
|
|
{
|
|
Logger.LogWarning("Skipping Map Mode Generation.");
|
|
}
|
|
else
|
|
{
|
|
__instance._astroObjects = navMatrix;
|
|
__instance._startingAstroObjectID = navMatrix[1][0].GetID();
|
|
if (Main.Instance.CurrentStarSystem != "SolarSystem")
|
|
{
|
|
List<GameObject> delete = panRoot.GetAllChildren().Where(g => g.name.Contains("_ShipLog") == false).ToList();
|
|
foreach (GameObject gameObject in delete)
|
|
{
|
|
Object.Destroy(SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + gameObject.name));
|
|
}
|
|
if (SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + "SandFunnel") == null)
|
|
{
|
|
__instance._sandFunnel = __instance.gameObject.AddComponent<ShipLogSandFunnel>();
|
|
}
|
|
}
|
|
}
|
|
|
|
Logger.Log("Map Mode Construction Complete");
|
|
}
|
|
}
|
|
}
|