Merge pull request #80 from xen-42/dev

v0.10.1
This commit is contained in:
Ben C 2022-04-03 14:34:31 -07:00 committed by GitHub
commit 528e4ea828
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 268 additions and 52 deletions

View File

@ -1,4 +1,5 @@
using OWML.Utils; using NewHorizons.Utility;
using OWML.Utils;
using UnityEngine; using UnityEngine;
using Logger = NewHorizons.Utility.Logger; using Logger = NewHorizons.Utility.Logger;
@ -22,7 +23,7 @@ namespace NewHorizons.Builder.Atmosphere
if(hasRain) if(hasRain)
{ {
var rainGO = GameObject.Instantiate(GameObject.Find("/GiantsDeep_Body/Sector_GD/Sector_GDInterior/Effects_GDInterior/Effects_GD_Rain"), effectsGO.transform); var rainGO = GameObject.Instantiate(SearchUtilities.CachedFind("/GiantsDeep_Body/Sector_GD/Sector_GDInterior/Effects_GDInterior/Effects_GD_Rain"), effectsGO.transform);
rainGO.transform.localPosition = Vector3.zero; rainGO.transform.localPosition = Vector3.zero;
var pvc = rainGO.GetComponent<PlanetaryVectionController>(); var pvc = rainGO.GetComponent<PlanetaryVectionController>();
@ -45,7 +46,7 @@ namespace NewHorizons.Builder.Atmosphere
snowGO.transform.localPosition = Vector3.zero; snowGO.transform.localPosition = Vector3.zero;
for(int i = 0; i < 5; i++) for(int i = 0; i < 5; i++)
{ {
var snowEmitter = GameObject.Instantiate(GameObject.Find("/BrittleHollow_Body/Sector_BH/Effects_BH/Effects_BH_Snowflakes"), snowGO.transform); var snowEmitter = GameObject.Instantiate(SearchUtilities.CachedFind("/BrittleHollow_Body/Sector_BH/Effects_BH/Effects_BH_Snowflakes"), snowGO.transform);
snowEmitter.name = "SnowEmitter"; snowEmitter.name = "SnowEmitter";
snowEmitter.transform.localPosition = Vector3.zero; snowEmitter.transform.localPosition = Vector3.zero;

View File

@ -43,11 +43,11 @@ namespace NewHorizons.Builder.General
foreach(var name in _solarSystemBodies) foreach(var name in _solarSystemBodies)
{ {
var ao = AstroObjectLocator.GetAstroObject(name); var ao = AstroObjectLocator.GetAstroObject(name);
if (ao != null) Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => RemoveBody(ao, false)); if (ao != null) Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => RemoveBody(ao, false), 2);
} }
// Bring the sun back because why not // Bring the sun back because why not
Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => { if (Locator.GetAstroObject(AstroObject.Name.Sun).gameObject.activeInHierarchy) { sunVolumes.SetActive(true); } }, 2); Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => { if (Locator.GetAstroObject(AstroObject.Name.Sun).gameObject.activeInHierarchy) { sunVolumes.SetActive(true); } }, 3);
} }
public static void RemoveBody(AstroObject ao, bool delete = false, List<AstroObject> toDestroy = null) public static void RemoveBody(AstroObject ao, bool delete = false, List<AstroObject> toDestroy = null)

View File

@ -72,33 +72,35 @@ namespace NewHorizons.Builder.General
{ {
suitUpQueued = false; suitUpQueued = false;
if (Locator.GetPlayerController()._isWearingSuit) return; if (Locator.GetPlayerController()._isWearingSuit) return;
try
{
var spv = GameObject.Find("Ship_Body/Module_Supplies/Systems_Supplies/ExpeditionGear").GetComponent<SuitPickupVolume>();
spv.SetValue("_containsSuit", false);
if (spv.GetValue<bool>("_allowSuitReturn"))
spv.GetValue<MultipleInteractionVolume>("_interactVolume").ChangePrompt(UITextType.ReturnSuitPrompt, spv.GetValue<int>("_pickupSuitCommandIndex"));
else
spv.GetValue<MultipleInteractionVolume>("_interactVolume").EnableSingleInteraction(false, spv.GetValue<int>("_pickupSuitCommandIndex"));
Locator.GetPlayerTransform().GetComponent<PlayerSpacesuit>().SuitUp(false, true, true); Locator.GetPlayerTransform().GetComponent<PlayerSpacesuit>().SuitUp(false, true, true);
spv.SetValue("_timer", 0f); // Make the ship act as if the player took the suit
spv.SetValue("_index", 0); var spv = GameObject.Find("Ship_Body/Module_Supplies/Systems_Supplies/ExpeditionGear")?.GetComponent<SuitPickupVolume>();
GameObject suitGeometry = spv.GetValue<GameObject>("_suitGeometry"); if (spv == null) return;
spv._containsSuit = false;
if (spv._allowSuitReturn)
{
spv._interactVolume.ChangePrompt(UITextType.ReturnSuitPrompt, spv._pickupSuitCommandIndex);
}
else
{
spv._interactVolume.EnableSingleInteraction(false, spv._pickupSuitCommandIndex);
}
spv._timer = 0f;
spv._index = 0;
GameObject suitGeometry = spv._suitGeometry;
if (suitGeometry != null) suitGeometry.SetActive(false); if (suitGeometry != null) suitGeometry.SetActive(false);
OWCollider suitOWCollider = spv.GetValue<OWCollider>("_suitOWCollider"); OWCollider suitOWCollider = spv._suitOWCollider;
if (suitOWCollider != null) suitOWCollider.SetActivation(false); if (suitOWCollider != null) suitOWCollider.SetActivation(false);
spv.enabled = true; spv.enabled = true;
} }
catch(Exception e)
{
Logger.LogWarning($"Was unable to suit up player. {e.Message}, {e.StackTrace}");
}
}
} }
} }

View File

@ -73,9 +73,14 @@ namespace NewHorizons.Builder.Props
foreach (var component in prop.GetComponents<Component>().Concat(prop.GetComponentsInChildren<Component>())) foreach (var component in prop.GetComponents<Component>().Concat(prop.GetComponentsInChildren<Component>()))
{ {
// Enable all children or something // Enable all children or something
var enabledField = component.GetType().GetField("enabled"); var enabledField = component?.GetType()?.GetField("enabled");
if (enabledField != null && enabledField.FieldType == typeof(bool)) Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => enabledField.SetValue(component, true)); if (enabledField != null && enabledField.FieldType == typeof(bool)) Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => enabledField.SetValue(component, true));
if(component is Sector)
{
(component as Sector)._parentSector = sector;
}
// TODO: Make this work or smthng // TODO: Make this work or smthng
if (component is GhostIK) (component as GhostIK).enabled = false; if (component is GhostIK) (component as GhostIK).enabled = false;
if (component is GhostEffects) (component as GhostEffects).enabled = false; if (component is GhostEffects) (component as GhostEffects).enabled = false;
@ -99,6 +104,11 @@ namespace NewHorizons.Builder.Props
{ {
(component as SectoredMonoBehaviour).SetSector(sector); (component as SectoredMonoBehaviour).SetSector(sector);
} }
else
{
var sectorField = component?.GetType()?.GetField("_sector");
if (sectorField != null && sectorField.FieldType == typeof(Sector)) Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => sectorField.SetValue(component, sector));
}
if (component is AnglerfishController) if (component is AnglerfishController)
{ {

View File

@ -46,7 +46,14 @@ namespace NewHorizons.Builder.Props
{ {
foreach(var tornadoInfo in config.Props.Tornados) foreach(var tornadoInfo in config.Props.Tornados)
{ {
//TornadoBuilder.Make(go, sector, tornadoInfo, config.Atmosphere?.Cloud != null); TornadoBuilder.Make(go, sector, tornadoInfo, config.Atmosphere?.Cloud != null);
}
}
if (config.Props.Volcanos != null)
{
foreach (var volcanoInfo in config.Props.Volcanos)
{
VolcanoBuilder.Make(go, sector, volcanoInfo);
} }
} }
if (config.Props.Dialogue != null) if (config.Props.Dialogue != null)

View File

@ -0,0 +1,53 @@
using NewHorizons.External;
using NewHorizons.Utility;
using UnityEngine;
using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Builder.Props
{
public static class VolcanoBuilder
{
private static Color defaultStoneTint = new Color(0.07450981f, 0.07450981f, 0.07450981f);
private static Color defaultLavaTint = new Color(4.594794f, 0.3419145f, 0f, 1f);
public static void Make(GameObject go, Sector sector, PropModule.VolcanoInfo info)
{
var prefab = GameObject.Find("VolcanicMoon_Body/Sector_VM/Effects_VM/VolcanoPivot (2)/MeteorLauncher");
var launcherGO = prefab.InstantiateInactive();
launcherGO.transform.parent = sector.transform;
launcherGO.transform.localPosition = info.position == null ? Vector3.zero : (Vector3) info.position;
launcherGO.name = "MeteorLauncher";
var meteorLauncher = launcherGO.GetComponent<MeteorLauncher>();
meteorLauncher._dynamicMeteorPrefab = null;
meteorLauncher._detectableFluid = null;
meteorLauncher._detectableField = null;
meteorLauncher._launchDirection = info.position == null ? Vector3.up : ((Vector3)info.position).normalized;
var meteorPrefab = GameObject.Instantiate(meteorLauncher._meteorPrefab);
FixMeteor(meteorPrefab, info);
meteorLauncher._meteorPrefab = meteorPrefab;
launcherGO.SetActive(true);
// Kill the prefab when its done with it
Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => meteorPrefab.SetActive(false));
}
private static void FixMeteor(GameObject meteor, PropModule.VolcanoInfo info)
{
var mat = meteor.GetComponentInChildren<MeshRenderer>().material;
mat.SetColor("_Color", info.stoneTint == null ? defaultStoneTint : info.stoneTint.ToColor());
mat.SetColor("_EmissionColor", info.lavaTint == null ? defaultLavaTint : info.lavaTint.ToColor());
var detectors = meteor.transform.Find("ConstantDetectors");
GameObject.Destroy(detectors.GetComponent<ConstantForceDetector>());
GameObject.Destroy(detectors.GetComponent<ConstantFluidDetector>());
detectors.gameObject.AddComponent<DynamicForceDetector>();
detectors.gameObject.AddComponent<DynamicFluidDetector>();
}
}
}

View File

@ -102,7 +102,7 @@ namespace NewHorizons.Builder.ShipLog
{ {
const float unviewedIconOffset = 15; const float unviewedIconOffset = 15;
GameObject unviewedReference = GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/TimberHearth/UnviewedIcon"); GameObject unviewedReference = SearchUtilities.CachedFind(ShipLogHandler.PAN_ROOT_PATH + "/TimberHearth/UnviewedIcon");
ShipLogAstroObject astroObject = gameObject.AddComponent<ShipLogAstroObject>(); ShipLogAstroObject astroObject = gameObject.AddComponent<ShipLogAstroObject>();
astroObject._id = ShipLogHandler.GetAstroObjectId(body); astroObject._id = ShipLogHandler.GetAstroObjectId(body);
@ -244,7 +244,7 @@ namespace NewHorizons.Builder.ShipLog
} }
else if (Main.Instance.CurrentStarSystem == "SolarSystem") else if (Main.Instance.CurrentStarSystem == "SolarSystem")
{ {
GameObject gameObject = GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + name); GameObject gameObject = SearchUtilities.CachedFind(ShipLogHandler.PAN_ROOT_PATH + "/" + name);
if (body.Config.Destroy || (body.Config.ShipLog?.mapMode?.remove ?? false)) if (body.Config.Destroy || (body.Config.ShipLog?.mapMode?.remove ?? false))
{ {
ShipLogAstroObject astroObject = gameObject.GetComponent<ShipLogAstroObject>(); ShipLogAstroObject astroObject = gameObject.GetComponent<ShipLogAstroObject>();
@ -305,15 +305,15 @@ namespace NewHorizons.Builder.ShipLog
public List<MapModeObject> children; public List<MapModeObject> children;
public MapModeObject parent; public MapModeObject parent;
public MapModeObject lastSibling; public MapModeObject lastSibling;
public void Increment_width() public void IncrementWidth()
{ {
branch_width++; branch_width++;
parent?.Increment_width(); parent?.IncrementWidth();
} }
public void Increment_height() public void IncrementHeight()
{ {
branch_height++; branch_height++;
parent?.Increment_height(); parent?.IncrementHeight();
} }
} }
@ -416,12 +416,12 @@ namespace NewHorizons.Builder.ShipLog
if (even) if (even)
{ {
newY += newNode.branch_height; newY += newNode.branch_height;
parent.Increment_height(); parent.IncrementHeight();
} }
else else
{ {
newX += newNode.branch_width; newX += newNode.branch_width;
parent.Increment_width(); parent.IncrementWidth();
} }
lastSibling = newNode; lastSibling = newNode;
@ -488,7 +488,6 @@ namespace NewHorizons.Builder.ShipLog
astroObject._imageObj.GetComponent<Image>().enabled = false; astroObject._imageObj.GetComponent<Image>().enabled = false;
astroObject._outlineObj.GetComponent<Image>().enabled = false; astroObject._outlineObj.GetComponent<Image>().enabled = false;
astroObject._unviewedObj.GetComponent<Image>().enabled = false; astroObject._unviewedObj.GetComponent<Image>().enabled = false;
astroObject.transform.localScale = node.lastSibling.astroObject.transform.localScale;
} }
node.astroObject = astroObject; node.astroObject = astroObject;
if (node.lastSibling != null) ConnectNodeToLastSibling(node, greyScaleMaterial); if (node.lastSibling != null) ConnectNodeToLastSibling(node, greyScaleMaterial);

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using NewHorizons.Handlers;
using Logger = NewHorizons.Utility.Logger; using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.External namespace NewHorizons.External
@ -59,13 +60,15 @@ namespace NewHorizons.External
{ {
Load(); Load();
} }
Logger.Log($"Reseting save data for {_activeProfileName}"); Logger.Log($"Resetting save data for {_activeProfileName}");
_activeProfile = new NewHorizonsProfile(); _activeProfile = new NewHorizonsProfile();
_saveFile.Profiles[_activeProfileName] = _activeProfile; _saveFile.Profiles[_activeProfileName] = _activeProfile;
Save(); Save();
} }
# region Frequencies
public static bool KnowsFrequency(string frequency) public static bool KnowsFrequency(string frequency)
{ {
if (_activeProfile == null) return true; if (_activeProfile == null) return true;
@ -82,6 +85,15 @@ namespace NewHorizons.External
} }
} }
public static bool KnowsMultipleFrequencies()
{
return (_activeProfile != null && _activeProfile.KnownFrequencies.Count > 0);
}
# endregion
# region Signals
public static bool KnowsSignal(string signal) public static bool KnowsSignal(string signal)
{ {
if (_activeProfile == null) return true; if (_activeProfile == null) return true;
@ -98,11 +110,29 @@ namespace NewHorizons.External
} }
} }
public static bool KnowsMultipleFrequencies() # endregion
# region Newly Revealed Facts
public static void AddNewlyRevealedFactID(string id)
{ {
return (_activeProfile != null && _activeProfile.KnownFrequencies.Count > 0); _activeProfile?.NewlyRevealedFactIDs.Add(id);
Save();
} }
public static List<string> GetNewlyRevealedFactIDs()
{
return _activeProfile?.NewlyRevealedFactIDs;
}
public static void ClearNewlyRevealedFactIDs()
{
_activeProfile?.NewlyRevealedFactIDs.Clear();
Save();
}
# endregion
private class NewHorizonsSaveFile private class NewHorizonsSaveFile
{ {
public NewHorizonsSaveFile() public NewHorizonsSaveFile()
@ -119,10 +149,13 @@ namespace NewHorizons.External
{ {
KnownFrequencies = new List<string>(); KnownFrequencies = new List<string>();
KnownSignals = new List<string>(); KnownSignals = new List<string>();
NewlyRevealedFactIDs = new List<string>();
} }
public List<string> KnownFrequencies { get; set; } public List<string> KnownFrequencies { get; set; }
public List<string> KnownSignals { get; set; } public List<string> KnownSignals { get; set; }
public List<string> NewlyRevealedFactIDs { get; set; }
} }
} }
} }

View File

@ -14,6 +14,7 @@ namespace NewHorizons.External
public RaftInfo[] Rafts; public RaftInfo[] Rafts;
public GeyserInfo[] Geysers; public GeyserInfo[] Geysers;
public TornadoInfo[] Tornados; public TornadoInfo[] Tornados;
public VolcanoInfo[] Volcanos;
public DialogueInfo[] Dialogue; public DialogueInfo[] Dialogue;
public RevealInfo[] Reveal; public RevealInfo[] Reveal;
public EntryLocationInfo[] EntryLocation; public EntryLocationInfo[] EntryLocation;
@ -61,6 +62,13 @@ namespace NewHorizons.External
public MColor tint; public MColor tint;
} }
public class VolcanoInfo
{
public MVector3 position = null;
public MColor stoneTint = null;
public MColor lavaTint = null;
}
public class DialogueInfo public class DialogueInfo
{ {
public MVector3 position; public MVector3 position;

View File

@ -128,8 +128,8 @@ namespace NewHorizons.Handlers
if (body.Config.Destroy) if (body.Config.Destroy)
{ {
var ao = existingPlanet.GetComponent<AstroObject>(); var ao = existingPlanet.GetComponent<AstroObject>();
if (ao != null) Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => PlanetDestroyer.RemoveBody(ao), 1); if (ao != null) Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => PlanetDestroyer.RemoveBody(ao), 2);
else Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => existingPlanet.SetActive(false), 1); else Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => existingPlanet.SetActive(false), 2);
} }
else UpdateBody(body, existingPlanet); else UpdateBody(body, existingPlanet);
} }

View File

@ -23,8 +23,9 @@ namespace NewHorizons.Handlers
// NewHorizonsBody -> AstroID // NewHorizonsBody -> AstroID
private static Dictionary<NewHorizonsBody, string> _nhBodyToAstroIDs; private static Dictionary<NewHorizonsBody, string> _nhBodyToAstroIDs;
private static string[] vanillaBodies; private static string[] _vanillaBodies;
private static string[] vanillaIDs; private static string[] _vanillaBodyIDs;
private static string[] _moddedFactsIDs;
public static void Init() public static void Init()
{ {
@ -33,13 +34,19 @@ namespace NewHorizons.Handlers
_nhBodyToAstroIDs = new Dictionary<NewHorizonsBody, string>(); _nhBodyToAstroIDs = new Dictionary<NewHorizonsBody, string>();
List<GameObject> gameObjects = SearchUtilities.GetAllChildren(GameObject.Find(PAN_ROOT_PATH)); List<GameObject> gameObjects = SearchUtilities.GetAllChildren(GameObject.Find(PAN_ROOT_PATH));
vanillaBodies = gameObjects.ConvertAll(g => g.name).ToArray(); _vanillaBodies = gameObjects.ConvertAll(g => g.name).ToArray();
vanillaIDs = gameObjects.ConvertAll(g => g.GetComponent<ShipLogAstroObject>()?.GetID()).ToArray(); _vanillaBodyIDs = gameObjects.ConvertAll(g => g.GetComponent<ShipLogAstroObject>()?.GetID()).ToArray();
}
public static void CheckForModdedFacts(ShipLogManager manager)
{
List<ShipLogFact> moddedFacts = manager._factList.Where(e => manager._entryDataDict.ContainsKey(e._entryID) == false).ToList();
_moddedFactsIDs = moddedFacts.ConvertAll(e => e.GetID()).ToArray();
} }
public static bool IsVanillaAstroID(string astroId) public static bool IsVanillaAstroID(string astroId)
{ {
return vanillaIDs.Contains(astroId); return _vanillaBodyIDs.Contains(astroId);
} }
public static bool IsVanillaBody(NewHorizonsBody body) public static bool IsVanillaBody(NewHorizonsBody body)
@ -48,7 +55,7 @@ namespace NewHorizons.Handlers
if (existingBody != null && existingBody.GetAstroObjectName() != AstroObject.Name.CustomString) if (existingBody != null && existingBody.GetAstroObjectName() != AstroObject.Name.CustomString)
return true; return true;
return vanillaBodies.Contains(body.Config.Name.Replace(" ", "")); return _vanillaBodies.Contains(body.Config.Name.Replace(" ", ""));
} }
public static string GetNameFromAstroID(string astroID) public static string GetNameFromAstroID(string astroID)
@ -66,6 +73,11 @@ namespace NewHorizons.Handlers
} }
} }
public static bool IsModdedFact(string FactID)
{
return _moddedFactsIDs.Contains(FactID);
}
public static void AddConfig(string astroID, List<string> entryIDs, NewHorizonsBody body) public static void AddConfig(string astroID, List<string> entryIDs, NewHorizonsBody body)
{ {
// Nice to be able to just get the AstroID from the body // Nice to be able to just get the AstroID from the body

View File

@ -140,5 +140,12 @@ namespace NewHorizons.Handlers
return key; return key;
} }
public static void ClearTables()
{
_shipLogTranslationDictionary.Clear();
_dialogueTranslationDictionary.Clear();
_uiTranslationDictionary.Clear();
}
} }
} }

View File

@ -151,6 +151,8 @@ namespace NewHorizons
{ {
Logger.Log($"Scene Loaded: {scene.name} {mode}"); Logger.Log($"Scene Loaded: {scene.name} {mode}");
SearchUtilities.ClearCache();
_isChangingStarSystem = false; _isChangingStarSystem = false;
if (scene.name == "TitleScreen") if (scene.name == "TitleScreen")
@ -418,6 +420,19 @@ namespace NewHorizons
{ {
return Main.Instance.OnStarSystemLoaded; return Main.Instance.OnStarSystemLoaded;
} }
public bool ChangeCurrentStarSystem(string name)
{
if (!Main.SystemDict.ContainsKey(name)) return false;
Main.Instance.ChangeCurrentStarSystem(name);
return true;
}
public string[] GetInstalledAddons()
{
return Main.MountedAddons.Select(x => x.ModHelper.Manifest.UniqueName).ToArray();
}
} }
#endregion API #endregion API
} }

View File

@ -55,6 +55,14 @@ namespace NewHorizons.Tools
var playerDataResetGame = typeof(PlayerData).GetMethod("ResetGame"); var playerDataResetGame = typeof(PlayerData).GetMethod("ResetGame");
Main.Instance.ModHelper.HarmonyHelper.AddPostfix(playerDataResetGame, typeof(Patches), nameof(Patches.OnPlayerDataResetGame)); Main.Instance.ModHelper.HarmonyHelper.AddPostfix(playerDataResetGame, typeof(Patches), nameof(Patches.OnPlayerDataResetGame));
var playerDataAddNewlyRevealedFactID = typeof(PlayerData).GetMethod("AddNewlyRevealedFactID");
Main.Instance.ModHelper.HarmonyHelper.AddPrefix(playerDataAddNewlyRevealedFactID, typeof(Patches), nameof(Patches.OnPlayerDataAddNewlyRevealedFactID));
var playerDataGetNewlyRevealedFactIDs = typeof(PlayerData).GetMethod("GetNewlyRevealedFactIDs");
Main.Instance.ModHelper.HarmonyHelper.AddPrefix(playerDataGetNewlyRevealedFactIDs, typeof(Patches), nameof(Patches.OnPlayerDataGetNewlyRevealedFactIDs));
var playerDataClearNewlyRevealedFactIDs = typeof(PlayerData).GetMethod("ClearNewlyRevealedFactIDs");
Main.Instance.ModHelper.HarmonyHelper.AddPrefix(playerDataClearNewlyRevealedFactIDs, typeof(Patches), nameof(Patches.OnPlayerDataClearNewlyRevealedFactIDs));
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<BlackHoleVolume>("Start", typeof(Patches), nameof(Patches.OnBlackHoleVolumeStart)); Main.Instance.ModHelper.HarmonyHelper.AddPrefix<BlackHoleVolume>("Start", typeof(Patches), nameof(Patches.OnBlackHoleVolumeStart));
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<WhiteHoleVolume>("Awake", typeof(Patches), nameof(Patches.OnWhiteHoleVolumeAwake)); Main.Instance.ModHelper.HarmonyHelper.AddPrefix<WhiteHoleVolume>("Awake", typeof(Patches), nameof(Patches.OnWhiteHoleVolumeAwake));
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<ProbeLauncher>("UpdateOrbitalLaunchValues", typeof(Patches), nameof(Patches.OnProbeLauncherUpdateOrbitalLaunchValues)); Main.Instance.ModHelper.HarmonyHelper.AddPrefix<ProbeLauncher>("UpdateOrbitalLaunchValues", typeof(Patches), nameof(Patches.OnProbeLauncherUpdateOrbitalLaunchValues));
@ -311,6 +319,32 @@ namespace NewHorizons.Tools
return true; return true;
} }
public static bool OnPlayerDataAddNewlyRevealedFactID(string __0)
{
if (ShipLogHandler.IsModdedFact(__0))
{
NewHorizonsData.AddNewlyRevealedFactID(__0);
return false;
}
else
{
return true;
}
}
public static bool OnPlayerDataGetNewlyRevealedFactIDs(ref List<string> __result)
{
__result = PlayerData._currentGameSave.newlyRevealedFactIDs.Concat(NewHorizonsData.GetNewlyRevealedFactIDs()).ToList();
return false;
}
public static bool OnPlayerDataClearNewlyRevealedFactIDs()
{
PlayerData._currentGameSave.newlyRevealedFactIDs.Clear();
NewHorizonsData.ClearNewlyRevealedFactIDs();
return false;
}
public static void OnPlayerDataResetGame() public static void OnPlayerDataResetGame()
{ {
NewHorizonsData.Reset(); NewHorizonsData.Reset();

View File

@ -66,6 +66,7 @@ namespace NewHorizons.Tools
public static void OnShipLogManagerAwakeComplete(ShipLogManager __instance) public static void OnShipLogManagerAwakeComplete(ShipLogManager __instance)
{ {
ShipLogHandler.CheckForModdedFacts(__instance);
RumorModeBuilder.GenerateEntryData(__instance); RumorModeBuilder.GenerateEntryData(__instance);
for (var i = 0; i < __instance._entryList.Count; i++) for (var i = 0; i < __instance._entryList.Count; i++)
{ {

View File

@ -41,6 +41,7 @@ namespace NewHorizons.Utility
bundle.Unload(true); bundle.Unload(true);
} }
Main.AssetBundles.Clear(); Main.AssetBundles.Clear();
TranslationHandler.ClearTables();
Logger.Log("Begin reload of config files...", Logger.LogType.Log); Logger.Log("Begin reload of config files...", Logger.LogType.Log);

View File

@ -10,6 +10,30 @@ namespace NewHorizons.Utility
{ {
public static class SearchUtilities public static class SearchUtilities
{ {
private static readonly Dictionary<string, GameObject> CachedGameObjects = new Dictionary<string, GameObject>();
public static void ClearCache()
{
CachedGameObjects.Clear();
}
public static GameObject CachedFind(string path)
{
if (CachedGameObjects.ContainsKey(path))
{
return CachedGameObjects[path];
}
else
{
GameObject foundObject = GameObject.Find(path);
if (foundObject != null)
{
CachedGameObjects.Add(path, foundObject);
}
return foundObject;
}
}
public static List<T> FindObjectsOfTypeAndName<T>(string name) where T : Object public static List<T> FindObjectsOfTypeAndName<T>(string name) where T : Object
{ {
T[] firstList = GameObject.FindObjectsOfType<T>(); T[] firstList = GameObject.FindObjectsOfType<T>();
@ -99,6 +123,10 @@ namespace NewHorizons.Utility
public static GameObject Find(string path) public static GameObject Find(string path)
{ {
if (CachedGameObjects.ContainsKey(path))
{
return CachedGameObjects[path];
}
try try
{ {
var go = GameObject.Find(path); var go = GameObject.Find(path);
@ -155,6 +183,11 @@ namespace NewHorizons.Utility
go = FindObjectOfTypeAndName<GameObject>(name); go = FindObjectOfTypeAndName<GameObject>(name);
} }
if (go != null)
{
CachedGameObjects.Add(path, go);
}
return go; return go;
} }
catch(Exception) catch(Exception)

View File

@ -3,7 +3,7 @@
"author": "xen, Idiot, & Book", "author": "xen, Idiot, & Book",
"name": "New Horizons", "name": "New Horizons",
"uniqueName": "xen.NewHorizons", "uniqueName": "xen.NewHorizons",
"version": "0.10.0", "version": "0.10.1",
"owmlVersion": "2.1.0", "owmlVersion": "2.1.0",
"dependencies": [ "PacificEngine.OW_CommonResources" ], "dependencies": [ "PacificEngine.OW_CommonResources" ],
"conflicts": [ "Raicuparta.QuantumSpaceBuddies", "Vesper.OuterWildsMMO", "Vesper.AutoResume" ], "conflicts": [ "Raicuparta.QuantumSpaceBuddies", "Vesper.OuterWildsMMO", "Vesper.AutoResume" ],