Merge pull request #223 from xen-42/fix-remove-children

Fix remove children & Toggle for verbose logs
This commit is contained in:
Nick 2022-07-05 22:27:00 -04:00 committed by GitHub
commit edcc0c86ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 175 additions and 204 deletions

View File

@ -20,7 +20,7 @@ namespace NewHorizons.AchievementsPlus
if (API == null) if (API == null)
{ {
Logger.Log("Achievements+ isn't installed"); Logger.LogVerbose("Achievements+ isn't installed");
Enabled = false; Enabled = false;
return; return;
} }

View File

@ -5,6 +5,7 @@ using NewHorizons.Utility;
using OWML.Common; using OWML.Common;
using UnityEngine; using UnityEngine;
using Random = UnityEngine.Random; using Random = UnityEngine.Random;
using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Builder.Body namespace NewHorizons.Builder.Body
{ {
public static class AsteroidBeltBuilder public static class AsteroidBeltBuilder
@ -13,12 +14,14 @@ namespace NewHorizons.Builder.Body
{ {
var belt = parentConfig.AsteroidBelt; var belt = parentConfig.AsteroidBelt;
float minSize = belt.minSize; var minSize = belt.minSize;
float maxSize = belt.maxSize; var maxSize = belt.maxSize;
int count = (int)(2f * Mathf.PI * belt.innerRadius / (10f * maxSize)); var count = (int)(2f * Mathf.PI * belt.innerRadius / (10f * maxSize));
if (belt.amount >= 0) count = belt.amount; if (belt.amount >= 0) count = belt.amount;
if (count > 200) count = 200; if (count > 200) count = 200;
Logger.Log($"Generating {count} asteroid belt around {bodyName}");
Random.InitState(belt.randomSeed); Random.InitState(belt.randomSeed);
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
@ -69,7 +72,7 @@ namespace NewHorizons.Builder.Body
} }
var asteroid = new NewHorizonsBody(config, mod); var asteroid = new NewHorizonsBody(config, mod);
PlanetCreationHandler.NextPassBodies.Add(asteroid); PlanetCreationHandler.GenerateBody(asteroid);
} }
} }
} }

View File

@ -76,14 +76,14 @@ namespace NewHorizons.Builder.Body
{ {
if (blackHole == null || whiteHole == null) return; if (blackHole == null || whiteHole == null) return;
Logger.Log($"Pairing singularities [{blackHoleID}], [{whiteHoleID}]"); Logger.LogVerbose($"Pairing singularities [{blackHoleID}], [{whiteHoleID}]");
var whiteHoleVolume = whiteHole.GetComponentInChildren<WhiteHoleVolume>(); var whiteHoleVolume = whiteHole.GetComponentInChildren<WhiteHoleVolume>();
var blackHoleVolume = blackHole.GetComponentInChildren<BlackHoleVolume>(); var blackHoleVolume = blackHole.GetComponentInChildren<BlackHoleVolume>();
if (whiteHoleVolume == null || blackHoleVolume == null) if (whiteHoleVolume == null || blackHoleVolume == null)
{ {
Logger.Log($"[{blackHoleID}] and [{whiteHoleID}] do not have compatible polarities"); Logger.LogWarning($"[{blackHoleID}] and [{whiteHoleID}] do not have compatible polarities");
return; return;
} }

View File

@ -1,4 +1,4 @@
using NewHorizons.Components.Orbital; using NewHorizons.Components.Orbital;
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using UnityEngine; using UnityEngine;
using Logger = NewHorizons.Utility.Logger; using Logger = NewHorizons.Utility.Logger;

View File

@ -62,7 +62,7 @@ namespace NewHorizons.Builder.General
if (Main.Instance.IsWarpingFromShip) if (Main.Instance.IsWarpingFromShip)
{ {
Logger.Log("Overriding player spawn to be inside ship"); Logger.LogVerbose("Overriding player spawn to be inside ship");
GameObject playerSpawnGO = new GameObject("PlayerSpawnPoint"); GameObject playerSpawnGO = new GameObject("PlayerSpawnPoint");
playerSpawnGO.transform.parent = ship.transform; playerSpawnGO.transform.parent = ship.transform;
playerSpawnGO.layer = 8; playerSpawnGO.layer = 8;
@ -81,7 +81,7 @@ namespace NewHorizons.Builder.General
Main.Instance.ModHelper.Events.Unity.RunWhen(() => Main.IsSystemReady, () => SuitUp()); Main.Instance.ModHelper.Events.Unity.RunWhen(() => Main.IsSystemReady, () => SuitUp());
} }
Logger.Log("Made spawnpoint on [" + planetGO.name + "]"); Logger.Log($"Made spawnpoint on [{planetGO.name}]");
return playerSpawn; return playerSpawn;
} }

View File

@ -80,7 +80,7 @@ namespace NewHorizons.Builder.Orbital
} }
else else
{ {
Logger.Log($"No primary gravity or focal point for {primaryBody}"); Logger.LogError($"No primary gravity or focal point for {primaryBody}");
} }
} }
@ -99,7 +99,7 @@ namespace NewHorizons.Builder.Orbital
private static void SetBinaryInitialMotion(AstroObject baryCenter, NHAstroObject primaryBody, NHAstroObject secondaryBody) private static void SetBinaryInitialMotion(AstroObject baryCenter, NHAstroObject primaryBody, NHAstroObject secondaryBody)
{ {
Logger.Log($"Setting binary initial motion [{primaryBody.name}] [{secondaryBody.name}]"); Logger.LogVerbose($"Setting binary initial motion [{primaryBody.name}] [{secondaryBody.name}]");
var primaryGravity = new Gravity(primaryBody._gravityVolume); var primaryGravity = new Gravity(primaryBody._gravityVolume);
var secondaryGravity = new Gravity(secondaryBody._gravityVolume); var secondaryGravity = new Gravity(secondaryBody._gravityVolume);
@ -172,7 +172,7 @@ namespace NewHorizons.Builder.Orbital
secondaryInitialMotion._cachedInitVelocity = baryCenterVelocity + secondaryVelocity; secondaryInitialMotion._cachedInitVelocity = baryCenterVelocity + secondaryVelocity;
secondaryInitialMotion._isInitVelocityDirty = false; secondaryInitialMotion._isInitVelocityDirty = false;
Logger.Log($"Binary Initial Motion: {m1}, {m2}, {r1}, {r2}, {primaryVelocity}, {secondaryVelocity}"); Logger.LogVerbose($"Binary Initial Motion: {m1}, {m2}, {r1}, {r2}, {primaryVelocity}, {secondaryVelocity}");
} }
} }
} }

View File

@ -40,13 +40,20 @@ namespace NewHorizons.Builder.Props
if (detail.removeChildren != null) if (detail.removeChildren != null)
{ {
var detailPath = detailGO.transform.GetPath(); var detailPath = detailGO.transform.GetPath();
var transforms = detailGO.GetComponentsInChildren<Transform>(true);
foreach (var childPath in detail.removeChildren) foreach (var childPath in detail.removeChildren)
{ {
// We purposefully use GameObject.Find here because we don't want to find inactive things. // Multiple children can have the same path so we delete all that match
// If you were to try and disable two children with the same name, if we were finding inactive then we'd disable the first one twice var path = $"{detailPath}/{childPath}";
var childObj = GameObject.Find($"{detailPath}/{childPath}");
if (childObj != null) childObj.gameObject.SetActive(false); var flag = true;
else Logger.LogWarning($"Couldn't find {childPath}"); foreach (var childObj in transforms.Where(x => x.GetPath() == path))
{
flag = false;
childObj.gameObject.SetActive(false);
}
if (flag) Logger.LogWarning($"Couldn't find \"{childPath}\".");
} }
} }
@ -227,7 +234,7 @@ namespace NewHorizons.Builder.Props
// If it's not a moving anglerfish make sure the anim controller is regular // If it's not a moving anglerfish make sure the anim controller is regular
else if (component is AnglerfishAnimController angler && angler.GetComponentInParent<AnglerfishController>() == null) else if (component is AnglerfishAnimController angler && angler.GetComponentInParent<AnglerfishController>() == null)
{ {
Logger.Log("Enabling anglerfish animation"); Logger.LogVerbose("Enabling anglerfish animation");
// Remove any reference to its angler // Remove any reference to its angler
if (angler._anglerfishController) if (angler._anglerfishController)
{ {

View File

@ -30,9 +30,10 @@ namespace NewHorizons.Builder.Props
} }
private static Dictionary<PropModule.NomaiTextInfo, GameObject> conversationInfoToCorrespondingSpawnedGameObject = new Dictionary<PropModule.NomaiTextInfo, GameObject>(); private static Dictionary<PropModule.NomaiTextInfo, GameObject> conversationInfoToCorrespondingSpawnedGameObject = new Dictionary<PropModule.NomaiTextInfo, GameObject>();
public static GameObject GetSpawnedGameObjectByNomaiTextInfo(PropModule.NomaiTextInfo convo) public static GameObject GetSpawnedGameObjectByNomaiTextInfo(PropModule.NomaiTextInfo convo)
{ {
Logger.Log("retrieving wall text obj for " + convo); Logger.LogVerbose("Retrieving wall text obj for " + convo);
if (!conversationInfoToCorrespondingSpawnedGameObject.ContainsKey(convo)) return null; if (!conversationInfoToCorrespondingSpawnedGameObject.ContainsKey(convo)) return null;
return conversationInfoToCorrespondingSpawnedGameObject[convo]; return conversationInfoToCorrespondingSpawnedGameObject[convo];
} }
@ -168,7 +169,7 @@ namespace NewHorizons.Builder.Props
() => Main.IsSystemReady, () => Main.IsSystemReady,
() => () =>
{ {
Logger.Log("Fixing scroll!"); Logger.LogVerbose("Fixing scroll!");
scrollItem._nomaiWallText = nomaiWallText; scrollItem._nomaiWallText = nomaiWallText;
scrollItem.SetSector(sector); scrollItem.SetSector(sector);
customScroll.transform.Find("Props_NOM_Scroll/Props_NOM_Scroll_Geo").GetComponent<MeshRenderer>().enabled = true; customScroll.transform.Find("Props_NOM_Scroll/Props_NOM_Scroll_Geo").GetComponent<MeshRenderer>().enabled = true;

View File

@ -216,7 +216,7 @@ namespace NewHorizons.Builder.Props
void Update() void Update()
{ {
if (meshFilter == null && skinnedMeshRenderer == null) { Logger.Log("Useless BoxShapeFixer, destroying"); GameObject.DestroyImmediate(this); } if (meshFilter == null && skinnedMeshRenderer == null) { Logger.LogVerbose("Useless BoxShapeFixer, destroying"); GameObject.DestroyImmediate(this); }
Mesh sharedMesh = null; Mesh sharedMesh = null;
if (meshFilter != null) sharedMesh = meshFilter.sharedMesh; if (meshFilter != null) sharedMesh = meshFilter.sharedMesh;

View File

@ -24,7 +24,7 @@ namespace NewHorizons.Builder.Props
public static void Init() public static void Init()
{ {
Logger.Log($"Initializing SignalBuilder"); Logger.LogVerbose($"Initializing SignalBuilder");
_customSignalNames = new Dictionary<SignalName, string>(); _customSignalNames = new Dictionary<SignalName, string>();
_availableSignalNames = new Stack<SignalName>(new SignalName[] _availableSignalNames = new Stack<SignalName>(new SignalName[]
{ {

View File

@ -99,7 +99,7 @@ namespace NewHorizons.Builder.ShipLog
{ {
const float unviewedIconOffset = 15; const float unviewedIconOffset = 15;
Logger.Log($"Adding ship log astro object for {body.Config.name}"); Logger.LogVerbose($"Adding ship log astro object for {body.Config.name}");
GameObject unviewedReference = SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/TimberHearth/UnviewedIcon"); GameObject unviewedReference = SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/TimberHearth/UnviewedIcon");

View File

@ -1,4 +1,4 @@
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using NewHorizons.Utility; using NewHorizons.Utility;
using OWML.Common; using OWML.Common;
using UnityEngine; using UnityEngine;

View File

@ -70,7 +70,7 @@ namespace NewHorizons.Components
if (previousIndex >= 0 && previousIndex < _states.Length) _states[previousIndex].SetVisible(visible: false); if (previousIndex >= 0 && previousIndex < _states.Length) _states[previousIndex].SetVisible(visible: false);
_states[_stateIndex].SetVisible(visible: true); _states[_stateIndex].SetVisible(visible: true);
Logger.Log("trying state " + _stateIndex); Logger.LogVerbose($"MultiStateQuantumObject - Trying to change state {_stateIndex}");
indices.Remove(_stateIndex); indices.Remove(_stateIndex);
} while (!CurrentStateIsValid() && indices.Count > 0); } while (!CurrentStateIsValid() && indices.Count > 0);

View File

@ -52,7 +52,7 @@ namespace NewHorizons.Components
public override bool ChangeQuantumState(bool skipInstantVisibilityCheck) public override bool ChangeQuantumState(bool skipInstantVisibilityCheck)
{ {
Logger.Log($"Trying to change quantum state"); Logger.LogVerbose($"QuantumPlanet - Trying to change quantum state");
if (states.Count <= 1) return false; if (states.Count <= 1) return false;

View File

@ -133,7 +133,7 @@ namespace NewHorizons.Components
else else
{ {
var path = $"planets/{uniqueID}.png"; var path = $"planets/{uniqueID}.png";
Logger.Log($"Trying to load {path}"); Logger.LogVerbose($"ShipLogStarChartManager - Trying to load {path}");
texture = ImageUtilities.GetTexture(Main.SystemDict[uniqueID].Mod, path); texture = ImageUtilities.GetTexture(Main.SystemDict[uniqueID].Mod, path);
} }
} }

View File

@ -99,7 +99,7 @@ namespace NewHorizons.Components
public void WarpIn(bool wearingSuit) public void WarpIn(bool wearingSuit)
{ {
Logger.Log("Starting warp-in"); Logger.LogVerbose("Starting warp-in");
// Trying really hard to stop the player from dying while warping in // Trying really hard to stop the player from dying while warping in
_impactDeathSpeed = Locator.GetDeathManager()._impactDeathSpeed; _impactDeathSpeed = Locator.GetDeathManager()._impactDeathSpeed;
Locator.GetDeathManager()._impactDeathSpeed = Mathf.Infinity; Locator.GetDeathManager()._impactDeathSpeed = Mathf.Infinity;
@ -112,7 +112,7 @@ namespace NewHorizons.Components
public void WarpOut() public void WarpOut()
{ {
Logger.Log("Starting warp-out"); Logger.LogVerbose("Starting warp-out");
_oneShotSource.PlayOneShot(global::AudioType.VesselSingularityCreate, 1f); _oneShotSource.PlayOneShot(global::AudioType.VesselSingularityCreate, 1f);
_blackhole.Create(); _blackhole.Create();
} }
@ -129,7 +129,7 @@ namespace NewHorizons.Components
{ {
if (Locator.GetPlayerTransform().TryGetComponent<PlayerResources>(out var resources) && resources._currentHealth < 100f) if (Locator.GetPlayerTransform().TryGetComponent<PlayerResources>(out var resources) && resources._currentHealth < 100f)
{ {
Logger.Log("Player died in a warp drive accident, reviving them"); Logger.LogVerbose("Player died in a warp drive accident, reviving them");
// Means the player was killed meaning they weren't teleported in // Means the player was killed meaning they weren't teleported in
resources._currentHealth = 100f; resources._currentHealth = 100f;
if (!PlayerState.AtFlightConsole()) TeleportToShip(); if (!PlayerState.AtFlightConsole()) TeleportToShip();
@ -151,7 +151,7 @@ namespace NewHorizons.Components
private void StartWarpInEffect() private void StartWarpInEffect()
{ {
Logger.Log("Starting warp-in effect"); Logger.LogVerbose("Starting warp-in effect");
_oneShotSource.PlayOneShot(global::AudioType.VesselSingularityCollapse, 1f); _oneShotSource.PlayOneShot(global::AudioType.VesselSingularityCollapse, 1f);
Locator.GetDeathManager()._invincible = true; Locator.GetDeathManager()._invincible = true;
if (Main.Instance.CurrentStarSystem.Equals("SolarSystem")) TeleportToShip(); if (Main.Instance.CurrentStarSystem.Equals("SolarSystem")) TeleportToShip();
@ -171,7 +171,7 @@ namespace NewHorizons.Components
public void FinishWarpIn() public void FinishWarpIn()
{ {
Logger.Log("Finishing warp"); Logger.LogVerbose("Finishing warp");
Locator.GetShipBody().GetComponentInChildren<ShipCockpitController>().OnPressInteract(); Locator.GetShipBody().GetComponentInChildren<ShipCockpitController>().OnPressInteract();
_waitingToBeSeated = false; _waitingToBeSeated = false;
Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => _whitehole.Collapse(), 30); Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => _whitehole.Collapse(), 30);

View File

@ -28,13 +28,13 @@ namespace NewHorizons.Components
{ {
if (star == null) return; if (star == null) return;
Logger.Log($"Adding new star to list: {star.gameObject.name}"); Logger.LogVerbose($"Adding new star to list: {star.gameObject.name}");
Instance._stars.Add(star); Instance._stars.Add(star);
} }
public static void RemoveStar(StarController star) public static void RemoveStar(StarController star)
{ {
Logger.Log($"Removing star from list: {star?.gameObject?.name}"); Logger.LogVerbose($"Removing star from list: {star?.gameObject?.name}");
if (Instance._stars.Contains(star)) if (Instance._stars.Contains(star))
{ {
if (Instance._activeStar != null && Instance._activeStar.Equals(star)) if (Instance._activeStar != null && Instance._activeStar.Equals(star))
@ -85,7 +85,7 @@ namespace NewHorizons.Components
if (_activeStar != null) _activeStar.Disable(); if (_activeStar != null) _activeStar.Disable();
Logger.Log($"Switching active star: {star.gameObject.name}"); Logger.LogVerbose($"Switching active star: {star.gameObject.name}");
_activeStar = star; _activeStar = star;

View File

@ -26,18 +26,18 @@ namespace NewHorizons.External
if (!_saveFile.Profiles.ContainsKey(_activeProfileName)) if (!_saveFile.Profiles.ContainsKey(_activeProfileName))
_saveFile.Profiles.Add(_activeProfileName, new NewHorizonsProfile()); _saveFile.Profiles.Add(_activeProfileName, new NewHorizonsProfile());
_activeProfile = _saveFile.Profiles[_activeProfileName]; _activeProfile = _saveFile.Profiles[_activeProfileName];
Logger.Log($"Loaded save data for {_activeProfileName}"); Logger.LogVerbose($"Loaded save data for {_activeProfileName}");
} }
catch (Exception) catch (Exception)
{ {
try try
{ {
Logger.Log($"Couldn't load save data from {FileName}, creating a new file"); Logger.LogVerbose($"Couldn't load save data from {FileName}, creating a new file");
_saveFile = new NewHorizonsSaveFile(); _saveFile = new NewHorizonsSaveFile();
_saveFile.Profiles.Add(_activeProfileName, new NewHorizonsProfile()); _saveFile.Profiles.Add(_activeProfileName, new NewHorizonsProfile());
_activeProfile = _saveFile.Profiles[_activeProfileName]; _activeProfile = _saveFile.Profiles[_activeProfileName];
Main.Instance.ModHelper.Storage.Save(_saveFile, FileName); Main.Instance.ModHelper.Storage.Save(_saveFile, FileName);
Logger.Log($"Loaded save data for {_activeProfileName}"); Logger.LogVerbose($"Loaded save data for {_activeProfileName}");
} }
catch (Exception e) catch (Exception e)
{ {
@ -55,7 +55,7 @@ namespace NewHorizons.External
public static void Reset() public static void Reset()
{ {
if (_saveFile == null || _activeProfile == null) Load(); if (_saveFile == null || _activeProfile == null) Load();
Logger.Log($"Resetting save data for {_activeProfileName}"); Logger.LogVerbose($"Resetting save data for {_activeProfileName}");
_activeProfile = new NewHorizonsProfile(); _activeProfile = new NewHorizonsProfile();
_saveFile.Profiles[_activeProfileName] = _activeProfile; _saveFile.Profiles[_activeProfileName] = _activeProfile;

View File

@ -219,7 +219,8 @@ namespace NewHorizons.Handlers
{ {
try try
{ {
GameObject planetObject = GenerateBody(body, defaultPrimaryToSun); Logger.Log($"Creating [{body.Config.name}]");
var planetObject = GenerateBody(body, defaultPrimaryToSun);
if (planetObject == null) return false; if (planetObject == null) return false;
planetObject.SetActive(true); planetObject.SetActive(true);
_dict.Add(planetObject.GetComponent<NHAstroObject>(), body); _dict.Add(planetObject.GetComponent<NHAstroObject>(), body);
@ -278,8 +279,8 @@ namespace NewHorizons.Handlers
{ {
if (defaultPrimaryToSun) if (defaultPrimaryToSun)
{ {
Logger.Log($"Couldn't find {body.Config.Orbit.primaryBody}, defaulting to Sun"); Logger.LogError($"Couldn't find {body.Config.Orbit.primaryBody}, defaulting to center of solar system");
primaryBody = AstroObjectLocator.GetAstroObject("Sun"); primaryBody = Locator.GetCenterOfTheUniverse().GetAttachedOWRigidbody().GetComponent<AstroObject>();
} }
else else
{ {
@ -293,8 +294,6 @@ namespace NewHorizons.Handlers
primaryBody = null; primaryBody = null;
} }
Logger.Log($"Begin generation sequence of [{body.Config.name}]");
var go = new GameObject(body.Config.name.Replace(" ", "").Replace("'", "") + "_Body"); var go = new GameObject(body.Config.name.Replace(" ", "").Replace("'", "") + "_Body");
go.SetActive(false); go.SetActive(false);
@ -339,7 +338,7 @@ namespace NewHorizons.Handlers
// Spawning on other planets is a bit hacky so we do it last // Spawning on other planets is a bit hacky so we do it last
if (body.Config.Spawn != null) if (body.Config.Spawn != null)
{ {
Logger.Log("Doing spawn point thing"); Logger.LogVerbose("Making spawn point");
Main.SystemDict[body.Config.starSystem].SpawnPoint = SpawnPointBuilder.Make(go, body.Config.Spawn, owRigidBody); Main.SystemDict[body.Config.starSystem].SpawnPoint = SpawnPointBuilder.Make(go, body.Config.Spawn, owRigidBody);
} }
@ -363,6 +362,8 @@ namespace NewHorizons.Handlers
ProxyBuilder.Make(go, body); ProxyBuilder.Make(go, body);
}); });
Logger.LogVerbose($"Finished creating [{body.Config.name}]");
return go; return go;
} }
@ -606,7 +607,7 @@ namespace NewHorizons.Handlers
public static void UpdatePosition(GameObject go, IOrbitalParameters orbit, AstroObject primaryBody, AstroObject secondaryBody) public static void UpdatePosition(GameObject go, IOrbitalParameters orbit, AstroObject primaryBody, AstroObject secondaryBody)
{ {
Logger.Log($"Placing [{secondaryBody?.name}] around [{primaryBody?.name}]"); Logger.LogVerbose($"Placing [{secondaryBody?.name}] around [{primaryBody?.name}]");
go.transform.parent = Locator.GetRootTransform(); go.transform.parent = Locator.GetRootTransform();

View File

@ -49,11 +49,11 @@ namespace NewHorizons.Handlers
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)
{ {
Logger.Log($"Removing [{ao.name}]"); Logger.LogVerbose($"Removing [{ao.name}]");
if (ao.gameObject == null || !ao.gameObject.activeInHierarchy) if (ao.gameObject == null || !ao.gameObject.activeInHierarchy)
{ {
Logger.Log($"[{ao.name}] was already removed"); Logger.LogVerbose($"[{ao.name}] was already removed");
return; return;
} }
@ -61,7 +61,7 @@ namespace NewHorizons.Handlers
if (toDestroy.Contains(ao)) if (toDestroy.Contains(ao))
{ {
Logger.LogError($"Possible infinite recursion in RemoveBody: {ao.name} might be it's own primary body?"); Logger.LogVerbose($"Possible infinite recursion in RemoveBody: {ao.name} might be it's own primary body?");
return; return;
} }
@ -133,7 +133,7 @@ namespace NewHorizons.Handlers
foreach (var sunProxy in GameObject.FindObjectsOfType<SunProxy>()) foreach (var sunProxy in GameObject.FindObjectsOfType<SunProxy>())
{ {
Logger.Log($"Destroying SunProxy {sunProxy.gameObject.name}"); Logger.LogVerbose($"Destroying SunProxy {sunProxy.gameObject.name}");
GameObject.Destroy(sunProxy.gameObject); GameObject.Destroy(sunProxy.gameObject);
} }
@ -143,12 +143,12 @@ namespace NewHorizons.Handlers
} }
// Always delete the children // Always delete the children
Logger.Log($"Removing Children of [{ao._name}], [{ao._customName}]"); Logger.LogVerbose($"Removing Children of [{ao._name}], [{ao._customName}]");
foreach (var child in AstroObjectLocator.GetChildren(ao)) foreach (var child in AstroObjectLocator.GetChildren(ao))
{ {
if (child == null) continue; if (child == null) continue;
Logger.Log($"Removing child [{child.name}] of [{ao._name}]"); Logger.LogVerbose($"Removing child [{child.name}] of [{ao._name}]");
// Ship starts as a child of TH but obvious we want to keep that // Ship starts as a child of TH but obvious we want to keep that
if (child.name == "Ship_Body") continue; if (child.name == "Ship_Body") continue;
@ -208,7 +208,7 @@ namespace NewHorizons.Handlers
{ {
if (go == null) return; if (go == null) return;
Logger.Log($"Removing [{go.name}]"); Logger.LogVerbose($"Removing [{go.name}]");
if (delete) if (delete)
{ {
@ -236,7 +236,7 @@ namespace NewHorizons.Handlers
if (distantProxyClone != null) GameObject.Destroy(distantProxyClone.gameObject); if (distantProxyClone != null) GameObject.Destroy(distantProxyClone.gameObject);
if (distantProxy == null && distantProxyClone == null) if (distantProxy == null && distantProxyClone == null)
Logger.Log($"Couldn't find proxy for {name}"); Logger.LogVerbose($"Couldn't find proxy for {name}");
} }
} }
} }

View File

@ -109,7 +109,7 @@ namespace NewHorizons.Handlers
foreach (var node in nodeDict.Values.ToList()) foreach (var node in nodeDict.Values.ToList())
{ {
var childrenString = String.Join(", ", node.children.Select(x => x?.body?.Config?.name).ToList()); var childrenString = String.Join(", ", node.children.Select(x => x?.body?.Config?.name).ToList());
Logger.Log($"NODE: [{node?.body?.Config?.name}], [{node?.parent?.body?.Config?.name}], [{childrenString}]"); Logger.LogVerbose($"NODE: [{node?.body?.Config?.name}], [{node?.parent?.body?.Config?.name}], [{childrenString}]");
} }
// Return all tree roots (no parents) // Return all tree roots (no parents)

View File

@ -97,7 +97,7 @@ namespace NewHorizons.Handlers
{ {
if (_factIDToStarSystem.TryGetValue(factID, out var systemUnlocked)) if (_factIDToStarSystem.TryGetValue(factID, out var systemUnlocked))
{ {
Logger.Log($"Just learned [{factID}] and unlocked [{systemUnlocked}]"); Logger.LogVerbose($"Just learned [{factID}] and unlocked [{systemUnlocked}]");
if (!Main.HasWarpDrive) Main.Instance.EnableWarpDrive(); if (!Main.HasWarpDrive) Main.Instance.EnableWarpDrive();
ShipLogStarChartMode.AddSystemCard(systemUnlocked); ShipLogStarChartMode.AddSystemCard(systemUnlocked);
} }
@ -105,7 +105,7 @@ namespace NewHorizons.Handlers
public static void RegisterFactForSystem(string factID, string system) public static void RegisterFactForSystem(string factID, string system)
{ {
Logger.Log($"Need to know [{factID}] to unlock [{system}]"); Logger.LogVerbose($"Need to know [{factID}] to unlock [{system}]");
_starSystemToFactID.Add(system, factID); _starSystemToFactID.Add(system, factID);
_factIDToStarSystem.Add(factID, system); _factIDToStarSystem.Add(factID, system);
} }

View File

@ -36,7 +36,7 @@ namespace NewHorizons.Handlers
var selectionCount = Mathf.Min(eligibleCount, 3); var selectionCount = Mathf.Min(eligibleCount, 3);
var indices = RandomUtility.GetUniqueRandomArray(0, eligible.Count(), selectionCount); var indices = RandomUtility.GetUniqueRandomArray(0, eligible.Count(), selectionCount);
Logger.Log($"Displaying {selectionCount} bodies on the title screen"); Logger.LogVerbose($"Displaying {selectionCount} bodies on the title screen");
GameObject body1, body2, body3; GameObject body1, body2, body3;
@ -74,7 +74,7 @@ namespace NewHorizons.Handlers
private static GameObject LoadTitleScreenBody(NewHorizonsBody body) private static GameObject LoadTitleScreenBody(NewHorizonsBody body)
{ {
Logger.Log($"Displaying {body.Config.name} on the title screen"); Logger.LogVerbose($"Displaying {body.Config.name} on the title screen");
GameObject titleScreenGO = new GameObject(body.Config.name + "_TitleScreen"); GameObject titleScreenGO = new GameObject(body.Config.name + "_TitleScreen");
HeightMapModule heightMap = new HeightMapModule(); HeightMapModule heightMap = new HeightMapModule();
var minSize = 15; var minSize = 15;

View File

@ -75,10 +75,10 @@ namespace NewHorizons.Handlers
{ {
var system = SystemDict[Instance.CurrentStarSystem]; var system = SystemDict[Instance.CurrentStarSystem];
Logger.Log("Checking for Vessel Prefab"); Logger.LogVerbose("Checking for Vessel Prefab");
if (VesselPrefab == null) return null; if (VesselPrefab == null) return null;
Logger.Log("Creating Vessel"); Logger.LogVerbose("Creating Vessel");
var vesselObject = GameObject.Instantiate(VesselPrefab); var vesselObject = GameObject.Instantiate(VesselPrefab);
VesselObject = vesselObject; VesselObject = vesselObject;
vesselObject.name = VesselPrefab.name; vesselObject.name = VesselPrefab.name;
@ -159,7 +159,7 @@ namespace NewHorizons.Handlers
{ {
var system = SystemDict[Instance.CurrentStarSystem]; var system = SystemDict[Instance.CurrentStarSystem];
Logger.Log("Updating DB Vessel"); Logger.LogVerbose("Updating DB Vessel");
var vectorSector = SearchUtilities.Find("DB_VesselDimension_Body/Sector_VesselDimension"); var vectorSector = SearchUtilities.Find("DB_VesselDimension_Body/Sector_VesselDimension");
VesselObject = vectorSector; VesselObject = vectorSector;

View File

@ -31,6 +31,7 @@ namespace NewHorizons
// Settings // Settings
public static bool Debug { get; private set; } public static bool Debug { get; private set; }
public static bool VerboseLogs { get; private set; }
private static bool _useCustomTitleScreen; private static bool _useCustomTitleScreen;
private static bool _wasConfigured = false; private static bool _wasConfigured = false;
private static string _defaultSystemOverride; private static string _defaultSystemOverride;
@ -75,11 +76,12 @@ namespace NewHorizons
public override void Configure(IModConfig config) public override void Configure(IModConfig config)
{ {
Logger.Log("Settings changed"); Logger.LogVerbose("Settings changed");
var currentScene = SceneManager.GetActiveScene().name; var currentScene = SceneManager.GetActiveScene().name;
Debug = config.GetSettingsValue<bool>("Debug"); Debug = config.GetSettingsValue<bool>("Debug");
VerboseLogs = config.GetSettingsValue<bool>("Verbose Logs");
if (currentScene == "SolarSystem") if (currentScene == "SolarSystem")
{ {
@ -87,7 +89,9 @@ namespace NewHorizons
DebugMenu.UpdatePauseMenuButton(); DebugMenu.UpdatePauseMenuButton();
} }
Logger.UpdateLogLevel(Debug ? Logger.LogType.Log : Logger.LogType.Error); if (VerboseLogs) Logger.UpdateLogLevel(Logger.LogType.Verbose);
else if (Debug) Logger.UpdateLogLevel(Logger.LogType.Log);
else Logger.UpdateLogLevel(Logger.LogType.Error);
_defaultSystemOverride = config.GetSettingsValue<string>("Default System Override"); _defaultSystemOverride = config.GetSettingsValue<string>("Default System Override");
@ -103,7 +107,7 @@ namespace NewHorizons
// Don't reload if we haven't configured yet (called on game start) // Don't reload if we haven't configured yet (called on game start)
if (wasUsingCustomTitleScreen != _useCustomTitleScreen && SceneManager.GetActiveScene().name == "TitleScreen" && _wasConfigured) if (wasUsingCustomTitleScreen != _useCustomTitleScreen && SceneManager.GetActiveScene().name == "TitleScreen" && _wasConfigured)
{ {
Logger.Log("Reloading"); Logger.LogVerbose("Reloading");
SceneManager.LoadScene("TitleScreen", LoadSceneMode.Single); SceneManager.LoadScene("TitleScreen", LoadSceneMode.Single);
} }
@ -168,7 +172,7 @@ namespace NewHorizons
ResetConfigs(resetTranslation: false); ResetConfigs(resetTranslation: false);
Logger.Log("Begin load of config files...", Logger.LogType.Log); Logger.Log("Begin load of config files...");
try try
{ {
@ -213,7 +217,7 @@ namespace NewHorizons
private void OnSceneLoaded(Scene scene, LoadSceneMode mode) private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{ {
Logger.Log($"Scene Loaded: {scene.name} {mode}"); Logger.LogVerbose($"Scene Loaded: {scene.name} {mode}");
// Set time loop stuff if its enabled and if we're warping to a new place // Set time loop stuff if its enabled and if we're warping to a new place
if (IsChangingStarSystem && (SystemDict[_currentStarSystem].Config.enableTimeLoop || _currentStarSystem == "SolarSystem") && SecondsLeftInLoop > 0f) if (IsChangingStarSystem && (SystemDict[_currentStarSystem].Config.enableTimeLoop || _currentStarSystem == "SolarSystem") && SecondsLeftInLoop > 0f)
@ -254,11 +258,6 @@ namespace NewHorizons
if (scene.name == "SolarSystem") if (scene.name == "SolarSystem")
{ {
foreach (var body in GameObject.FindObjectsOfType<AstroObject>())
{
Logger.Log($"{body.name}, {body.transform.rotation}");
}
if (_ship != null) if (_ship != null)
{ {
_ship = SearchUtilities.Find("Ship_Body").InstantiateInactive(); _ship = SearchUtilities.Find("Ship_Body").InstantiateInactive();
@ -298,7 +297,7 @@ namespace NewHorizons
try try
{ {
Logger.Log($"Star system loaded [{Instance.CurrentStarSystem}]"); Logger.Log($"Star system finished loading [{Instance.CurrentStarSystem}]");
Instance.OnStarSystemLoaded?.Invoke(Instance.CurrentStarSystem); Instance.OnStarSystemLoaded?.Invoke(Instance.CurrentStarSystem);
} }
catch (Exception e) catch (Exception e)
@ -340,7 +339,7 @@ namespace NewHorizons
public void EnableWarpDrive() public void EnableWarpDrive()
{ {
Logger.Log("Setting up warp drive"); Logger.LogVerbose("Setting up warp drive");
PlanetCreationHandler.LoadBody(LoadConfig(this, "Assets/WarpDriveConfig.json")); PlanetCreationHandler.LoadBody(LoadConfig(this, "Assets/WarpDriveConfig.json"));
HasWarpDrive = true; HasWarpDrive = true;
} }
@ -364,7 +363,7 @@ namespace NewHorizons
{ {
var name = Path.GetFileNameWithoutExtension(file); var name = Path.GetFileNameWithoutExtension(file);
Logger.Log($"Loading system {name}"); Logger.LogVerbose($"Loading system {name}");
var relativePath = file.Replace(folder, ""); var relativePath = file.Replace(folder, "");
var starSystemConfig = mod.ModHelper.Storage.Load<StarSystemConfig>(relativePath); var starSystemConfig = mod.ModHelper.Storage.Load<StarSystemConfig>(relativePath);
@ -438,7 +437,7 @@ namespace NewHorizons
if (File.Exists($"{folder}{relativeFile}")) if (File.Exists($"{folder}{relativeFile}"))
{ {
Logger.Log($"Registering {language} translation from {mod.ModHelper.Manifest.Name} from {relativeFile}"); Logger.LogVerbose($"Registering {language} translation from {mod.ModHelper.Manifest.Name} from {relativeFile}");
var config = new TranslationConfig($"{folder}{relativeFile}"); var config = new TranslationConfig($"{folder}{relativeFile}");
@ -467,7 +466,7 @@ namespace NewHorizons
return null; return null;
} }
Logger.Log($"Loaded {config.name}"); Logger.LogVerbose($"Loaded {config.name}");
if (!SystemDict.ContainsKey(config.starSystem)) if (!SystemDict.ContainsKey(config.starSystem))
{ {

View File

@ -9,7 +9,7 @@ namespace NewHorizons.Patches
[HarmonyPatch(typeof(PlayerSpawner), nameof(PlayerSpawner.SpawnPlayer))] [HarmonyPatch(typeof(PlayerSpawner), nameof(PlayerSpawner.SpawnPlayer))]
public static void PlayerSpawner_SpawnPlayer(PlayerSpawner __instance) public static void PlayerSpawner_SpawnPlayer(PlayerSpawner __instance)
{ {
Logger.Log("Player spawning"); Logger.LogVerbose("Player spawning");
__instance.SetInitialSpawnPoint(Main.SystemDict[Main.Instance.CurrentStarSystem].SpawnPoint); __instance.SetInitialSpawnPoint(Main.SystemDict[Main.Instance.CurrentStarSystem].SpawnPoint);
} }
} }

View File

@ -21,7 +21,7 @@ namespace NewHorizons.Patches
{ {
RumorModeBuilder.Init(); RumorModeBuilder.Init();
ShipLogHandler.Init(); ShipLogHandler.Init();
Logger.Log("Beginning Ship Log Generation For: " + Main.Instance.CurrentStarSystem, Logger.LogType.Log); Logger.Log($"Beginning Ship Log Generation For: {Main.Instance.CurrentStarSystem}");
if (Main.Instance.CurrentStarSystem != "SolarSystem") if (Main.Instance.CurrentStarSystem != "SolarSystem")
{ {
__instance._shipLogXmlAssets = new TextAsset[] { }; __instance._shipLogXmlAssets = new TextAsset[] { };
@ -58,7 +58,7 @@ namespace NewHorizons.Patches
RumorModeBuilder.UpdateEntryCuriosity(ref logEntry); RumorModeBuilder.UpdateEntryCuriosity(ref logEntry);
} }
Logger.Log("Ship Log Generation Complete For: " + Main.Instance.CurrentStarSystem, Logger.LogType.Log); Logger.Log($"Ship Log Generation Complete For: {Main.Instance.CurrentStarSystem}");
} }
[HarmonyPrefix] [HarmonyPrefix]
@ -157,7 +157,7 @@ namespace NewHorizons.Patches
} }
} }
Logger.Log("Map Mode Construction Complete", Logger.LogType.Log); Logger.Log("Map Mode Construction Complete");
} }
[HarmonyPrefix] [HarmonyPrefix]

View File

@ -68,7 +68,7 @@ namespace NewHorizons.Utility
} }
else else
{ {
Logger.Log($"Registering [{ao.name}] as [{key}]"); Logger.LogVerbose($"Registering [{ao.name}] as [{key}]");
_customAstroObjectDictionary.Add(key, ao); _customAstroObjectDictionary.Add(key, ao);
} }
} }

View File

@ -13,10 +13,10 @@ namespace NewHorizons.Utility
{ {
if (_loadedAudioClips.ContainsKey(path)) if (_loadedAudioClips.ContainsKey(path))
{ {
Logger.Log($"Already loaded audio at path: {path}"); Logger.LogVerbose($"Already loaded audio at path: {path}");
return _loadedAudioClips[path]; return _loadedAudioClips[path];
} }
Logger.Log($"Loading audio at path: {path}"); Logger.LogVerbose($"Loading audio at path: {path}");
var task = Task.Run(async () => await GetAudioClip(path)); var task = Task.Run(async () => await GetAudioClip(path));
task.Wait(); task.Wait();
_loadedAudioClips.Add(path, task.Result); _loadedAudioClips.Add(path, task.Result);
@ -25,7 +25,7 @@ namespace NewHorizons.Utility
public static void ClearCache() public static void ClearCache()
{ {
Logger.Log("Clearing audio cache"); Logger.LogVerbose("Clearing audio cache");
foreach (var audioClip in _loadedAudioClips.Values) foreach (var audioClip in _loadedAudioClips.Values)
{ {

View File

@ -200,7 +200,7 @@ namespace NewHorizons.Utility.DebugMenu
{ {
if (body.RelativePath == null) if (body.RelativePath == null)
{ {
Logger.Log($"Error loading config for {body.Config.name} in {body.Config.starSystem}"); Logger.LogWarning($"Error loading config for {body.Config.name} in {body.Config.starSystem}");
continue; continue;
} }
@ -219,7 +219,7 @@ namespace NewHorizons.Utility.DebugMenu
foreach (var filePath in loadedConfigFiles.Keys) foreach (var filePath in loadedConfigFiles.Keys)
{ {
Logger.Log($"Possibly Saving... {loadedConfigFiles[filePath].name} @ {filePath}"); Logger.LogVerbose($"Possibly Saving... {loadedConfigFiles[filePath].name} @ {filePath}");
if (loadedConfigFiles[filePath].starSystem != Main.Instance.CurrentStarSystem) continue; if (loadedConfigFiles[filePath].starSystem != Main.Instance.CurrentStarSystem) continue;

View File

@ -101,7 +101,7 @@ namespace NewHorizons.Utility.DebugMenu
collapsed = true collapsed = true
}; };
Logger.Log("adding go " + conversationMetadata.conversationGo); Logger.LogVerbose("Adding conversation Game Object " + conversationMetadata.conversationGo);
conversations.Add(conversationMetadata); conversations.Add(conversationMetadata);
@ -128,7 +128,7 @@ namespace NewHorizons.Utility.DebugMenu
var parentID = (new Regex(regex)).Matches(metadata.spiralGo.name)[0].Groups[1].Value; var parentID = (new Regex(regex)).Matches(metadata.spiralGo.name)[0].Groups[1].Value;
metadata.parentID = parentID == "" ? -1 : int.Parse(parentID); metadata.parentID = parentID == "" ? -1 : int.Parse(parentID);
Logger.Log("Parent id for '" + metadata.spiralGo.name + "' : " + parentID); Logger.LogVerbose("Parent id for '" + metadata.spiralGo.name + "' : " + parentID);
} }
conversationMetadata.spirals.Add(metadata); conversationMetadata.spirals.Add(metadata);
@ -190,7 +190,7 @@ namespace NewHorizons.Utility.DebugMenu
if (GUILayout.Button(arrow + conversationMeta.planetConfig.name + " - " + i, menu._submenuStyle)) if (GUILayout.Button(arrow + conversationMeta.planetConfig.name + " - " + i, menu._submenuStyle))
{ {
conversationMeta.collapsed = !conversationMeta.collapsed; conversationMeta.collapsed = !conversationMeta.collapsed;
Logger.Log("BUTTON " + i); Logger.LogVerbose("BUTTON " + i);
} }
if (!conversationMeta.collapsed) if (!conversationMeta.collapsed)
@ -204,7 +204,7 @@ namespace NewHorizons.Utility.DebugMenu
//conversationMeta.conversation.type == PropModule.NomaiTextInfo.NomaiTextType.Wall && //conversationMeta.conversation.type == PropModule.NomaiTextInfo.NomaiTextType.Wall &&
GUILayout.Button("Place conversation with G") GUILayout.Button("Place conversation with G")
) { ) {
Logger.Log(conversationMeta.conversationGo+" 0"); Logger.LogVerbose(conversationMeta.conversationGo+" 0");
DebugNomaiTextPlacer.active = true; DebugNomaiTextPlacer.active = true;
_dnp.onRaycast = (DebugRaycastData data) => _dnp.onRaycast = (DebugRaycastData data) =>
{ {
@ -423,7 +423,7 @@ namespace NewHorizons.Utility.DebugMenu
SpiralMetadata parentSpiralMeta = GetParent(spiralMetadata); SpiralMetadata parentSpiralMeta = GetParent(spiralMetadata);
var parentPoints = parentSpiralMeta.spiralGo.GetComponent<NomaiTextLine>()._points; var parentPoints = parentSpiralMeta.spiralGo.GetComponent<NomaiTextLine>()._points;
Logger.Log("got parent and parent points"); Logger.Log("Got parent and parent points");
var prevPointOnParent = parentPoints[Mathf.Max(0, spiralMetadata.pointOnParent-1)]; var prevPointOnParent = parentPoints[Mathf.Max(0, spiralMetadata.pointOnParent-1)];
var nextPointOnParent = parentPoints[Mathf.Min(parentPoints.Count()-1, spiralMetadata.pointOnParent+1)]; var nextPointOnParent = parentPoints[Mathf.Min(parentPoints.Count()-1, spiralMetadata.pointOnParent+1)];
@ -432,14 +432,14 @@ namespace NewHorizons.Utility.DebugMenu
var newRotationRelativeToParent = parentTangent + 90; var newRotationRelativeToParent = parentTangent + 90;
spiralMetadata.spiral.zRotation = parentSpiralMeta.spiral.zRotation + newRotationRelativeToParent; spiralMetadata.spiral.zRotation = parentSpiralMeta.spiral.zRotation + newRotationRelativeToParent;
Logger.Log("got zRotation: " + newRotationRelativeToParent + " -=- " + spiralMetadata.spiral.zRotation); Logger.Log("Got zRotation: " + newRotationRelativeToParent + " -=- " + spiralMetadata.spiral.zRotation);
var pointOnParent = parentPoints[spiralMetadata.pointOnParent]; var pointOnParent = parentPoints[spiralMetadata.pointOnParent];
var selfBasePoint = spiralMetadata.spiralGo.GetComponent<NomaiTextLine>()._points[0]; var selfBasePoint = spiralMetadata.spiralGo.GetComponent<NomaiTextLine>()._points[0];
var newPointRelativeToParent = -selfBasePoint + pointOnParent; var newPointRelativeToParent = -selfBasePoint + pointOnParent;
spiralMetadata.spiral.position = parentSpiralMeta.spiral.position + new Vector2(newPointRelativeToParent.x, newPointRelativeToParent.y); spiralMetadata.spiral.position = parentSpiralMeta.spiral.position + new Vector2(newPointRelativeToParent.x, newPointRelativeToParent.y);
Logger.Log("got position " + newPointRelativeToParent + " -=- " + spiralMetadata.spiral.position); Logger.Log("Got position " + newPointRelativeToParent + " -=- " + spiralMetadata.spiral.position);
spiralMetadata.spiralGo.transform.localPosition = new Vector3(spiralMetadata.spiral.position.x, spiralMetadata.spiral.position.y, 0); spiralMetadata.spiralGo.transform.localPosition = new Vector3(spiralMetadata.spiral.position.x, spiralMetadata.spiral.position.y, 0);
spiralMetadata.spiralGo.transform.localEulerAngles = new Vector3(0, 0, spiralMetadata.spiral.zRotation); spiralMetadata.spiralGo.transform.localEulerAngles = new Vector3(0, 0, spiralMetadata.spiral.zRotation);
@ -450,9 +450,9 @@ namespace NewHorizons.Utility.DebugMenu
private void UpdateChildrenLocations(SpiralMetadata parentSprialMetadata) private void UpdateChildrenLocations(SpiralMetadata parentSprialMetadata)
{ {
Logger.Log("updating children"); Logger.Log("Updating children");
ConversationMetadata convoMeta = conversations.Where(m => m.conversation == parentSprialMetadata.conversation).First(); ConversationMetadata convoMeta = conversations.Where(m => m.conversation == parentSprialMetadata.conversation).First();
Logger.Log("got convo meta"); Logger.Log("Got conversation metadata");
convoMeta.spirals convoMeta.spirals
.Where(spiralMeta => spiralMeta.parentID == parentSprialMetadata.id && spiralMeta.id != parentSprialMetadata.id) .Where(spiralMeta => spiralMeta.parentID == parentSprialMetadata.id && spiralMeta.id != parentSprialMetadata.id)
@ -482,15 +482,10 @@ namespace NewHorizons.Utility.DebugMenu
{ {
var nomaiWallTextObj = conversationMetadata.conversationGo; var nomaiWallTextObj = conversationMetadata.conversationGo;
if (nomaiWallTextObj == null) return; if (nomaiWallTextObj == null) return;
var planetGO = sectorParent; var planetGO = sectorParent;
var info = conversationMetadata.conversation; var info = conversationMetadata.conversation;
Logger.Log(nomaiWallTextObj + " 1");
Logger.Log(nomaiWallTextObj?.transform + " 2");
Logger.Log(planetGO + " 3");
Logger.Log(planetGO?.transform + " 4");
Logger.Log(info + " 5");
Logger.Log(info?.position + " 6");
nomaiWallTextObj.transform.position = planetGO.transform.TransformPoint(info.position); nomaiWallTextObj.transform.position = planetGO.transform.TransformPoint(info.position);
if (info.normal != null) if (info.normal != null)
{ {

View File

@ -311,14 +311,14 @@ namespace NewHorizons.Utility.DebugMenu
// Get all configs // Get all configs
foreach (var filePath in menu.loadedConfigFiles.Keys) foreach (var filePath in menu.loadedConfigFiles.Keys)
{ {
Logger.Log($"Potentially updating copy of config at {filePath}"); Logger.LogVerbose($"Potentially updating copy of config at {filePath}");
Logger.Log($"{menu.loadedConfigFiles[filePath].name} {AstroObjectLocator.GetAstroObject(menu.loadedConfigFiles[filePath].name)?.name}"); Logger.LogVerbose($"{menu.loadedConfigFiles[filePath].name} {AstroObjectLocator.GetAstroObject(menu.loadedConfigFiles[filePath].name)?.name}");
Logger.Log($"{menu.loadedConfigFiles[filePath].name}"); Logger.LogVerbose($"{menu.loadedConfigFiles[filePath].name}");
if (menu.loadedConfigFiles[filePath].starSystem != Main.Instance.CurrentStarSystem) return; if (menu.loadedConfigFiles[filePath].starSystem != Main.Instance.CurrentStarSystem) return;
if (menu.loadedConfigFiles[filePath].name == null || AstroObjectLocator.GetAstroObject(menu.loadedConfigFiles[filePath].name) == null) if (menu.loadedConfigFiles[filePath].name == null || AstroObjectLocator.GetAstroObject(menu.loadedConfigFiles[filePath].name) == null)
{ {
Logger.Log("Failed to update copy of config at " + filePath); Logger.LogWarning("Failed to update copy of config at " + filePath);
continue; continue;
} }

View File

@ -98,7 +98,7 @@ namespace NewHorizons.Utility.DebugUtilities
if (!data.hitBodyGameObject.name.EndsWith("_Body")) if (!data.hitBodyGameObject.name.EndsWith("_Body"))
{ {
Logger.Log("Cannot place object on non-body object: " + data.hitBodyGameObject.name); Logger.LogWarning("Cannot place object on non-body object: " + data.hitBodyGameObject.name);
} }
try try
@ -115,7 +115,7 @@ namespace NewHorizons.Utility.DebugUtilities
} }
catch catch
{ {
Logger.Log($"Failed to place object {currentObject} on body ${data.hitBodyGameObject} at location ${data.pos}."); Logger.LogError($"Failed to place object {currentObject} on body ${data.hitBodyGameObject} at location ${data.pos}.");
} }
} }
@ -198,7 +198,7 @@ namespace NewHorizons.Utility.DebugUtilities
//var body = AstroObjectLocator.GetAstroObject(bodyGameObjectName); //var body = AstroObjectLocator.GetAstroObject(bodyGameObjectName);
Logger.Log($"Adding prop to {Main.Instance.CurrentStarSystem}::{body.name}"); Logger.LogVerbose($"Adding prop to {Main.Instance.CurrentStarSystem}::{body.name}");
detailInfo = detailInfo == null ? new DetailInfo() : detailInfo; detailInfo = detailInfo == null ? new DetailInfo() : detailInfo;
@ -230,7 +230,7 @@ namespace NewHorizons.Utility.DebugUtilities
if (bodyProps == null || bodyProps.Count == 0) continue; if (bodyProps == null || bodyProps.Count == 0) continue;
if (bodyProps[0].body == null) continue; if (bodyProps[0].body == null) continue;
var body = bodyProps[0].body; var body = bodyProps[0].body;
Logger.Log("getting prop group for body " + body.name); Logger.LogVerbose("getting prop group for body " + body.name);
//string bodyName = GetAstroObjectName(bodyProps[0].body); //string bodyName = GetAstroObjectName(bodyProps[0].body);
DetailInfo[] infoArray = new DetailInfo[bodyProps.Count]; DetailInfo[] infoArray = new DetailInfo[bodyProps.Count];

View File

@ -43,7 +43,7 @@ namespace NewHorizons.Utility.DebugUtilities
if (!data.hit) if (!data.hit)
{ {
Logger.Log("Debug Raycast Didn't Hit Anything! (Try moving closer)"); Logger.LogWarning("Debug Raycast Didn't Hit Anything! (Try moving closer)");
return; return;
} }
@ -120,7 +120,7 @@ namespace NewHorizons.Utility.DebugUtilities
if (Vector3.Cross(U, N) == Vector3.zero) U = new Vector3(0, 0, 1); if (Vector3.Cross(U, N) == Vector3.zero) U = new Vector3(0, 0, 1);
if (Vector3.Cross(U, N) == Vector3.zero) U = new Vector3(0, 1, 0); // if 0,0,1 was actually the same vector U already was (lol), try (0,1,0) instead if (Vector3.Cross(U, N) == Vector3.zero) U = new Vector3(0, 1, 0); // if 0,0,1 was actually the same vector U already was (lol), try (0,1,0) instead
Logger.Log("Up vector is " + U.ToString()); Logger.LogVerbose("Up vector is " + U.ToString());
// stackoverflow.com/a/9605695 // stackoverflow.com/a/9605695
// I don't know exactly how this works, but I'm projecting a point that is located above the plane's origin, relative to the planet, onto the plane. this gets us our v vector // I don't know exactly how this works, but I'm projecting a point that is located above the plane's origin, relative to the planet, onto the plane. this gets us our v vector

View File

@ -29,7 +29,7 @@ namespace NewHorizons.Utility.DebugUtilities
private static void ReloadConfigs() private static void ReloadConfigs()
{ {
Logger.Log("Begin reload of config files...", Logger.LogType.Log); Logger.Log("Begin reload of config files...");
Main.ResetConfigs(); Main.ResetConfigs();

View File

@ -31,11 +31,11 @@ namespace NewHorizons.Utility
var path = mod.ModHelper.Manifest.ModFolderPath + filename; var path = mod.ModHelper.Manifest.ModFolderPath + filename;
if (_loadedTextures.ContainsKey(path)) if (_loadedTextures.ContainsKey(path))
{ {
Logger.Log($"Already loaded image at path: {path}"); Logger.LogVerbose($"Already loaded image at path: {path}");
return _loadedTextures[path]; return _loadedTextures[path];
} }
Logger.Log($"Loading image at path: {path}"); Logger.LogVerbose($"Loading image at path: {path}");
try try
{ {
var data = File.ReadAllBytes(path); var data = File.ReadAllBytes(path);
@ -70,7 +70,7 @@ namespace NewHorizons.Utility
public static void ClearCache() public static void ClearCache()
{ {
Logger.Log("Clearing image cache"); Logger.LogVerbose("Clearing image cache");
foreach (var texture in _loadedTextures.Values) foreach (var texture in _loadedTextures.Values)
{ {
@ -368,7 +368,7 @@ namespace NewHorizons.Utility
{ {
if (_loadedTextures.ContainsKey(url)) if (_loadedTextures.ContainsKey(url))
{ {
Logger.Log($"Already loaded image at path: {url}"); Logger.LogVerbose($"Already loaded image at path: {url}");
var texture = _loadedTextures[url]; var texture = _loadedTextures[url];
imageLoadedEvent.Invoke(texture, index); imageLoadedEvent.Invoke(texture, index);
yield break; yield break;
@ -390,7 +390,7 @@ namespace NewHorizons.Utility
if (_loadedTextures.ContainsKey(url)) if (_loadedTextures.ContainsKey(url))
{ {
Logger.Log($"Already loaded image at path: {url}"); Logger.LogVerbose($"Already loaded image at path: {url}");
Destroy(texture); Destroy(texture);
texture = _loadedTextures[url]; texture = _loadedTextures[url];
} }

View File

@ -1,4 +1,4 @@
using OWML.Common; using OWML.Common;
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using UnityEngine; using UnityEngine;
@ -14,67 +14,31 @@ namespace NewHorizons.Utility
_logLevel = newLevel; _logLevel = newLevel;
} }
public static void LogProperties(UnityEngine.Object obj) private static void Log(string text, LogType type)
{ {
foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(obj)) if (type < _logLevel) return;
{ Main.Instance.ModHelper.Console.WriteLine($"{Enum.GetName(typeof(LogType), type)} : {text}", LogTypeToMessageType(type));
string name = descriptor?.Name;
object value;
try
{
value = descriptor.GetValue(obj);
}
catch (Exception)
{
value = null;
}
Log($"{obj.name} {name}={value}");
}
} }
public static void LogPath(GameObject go) public static void LogVerbose(string text) => Log(text, LogType.Verbose);
{ public static void Log(string text) => Log(text, LogType.Log);
if (go == null) Log("Can't print path: GameObject is null"); public static void LogWarning(string text) => Log(text, LogType.Warning);
else Log($"{go.transform.GetPath()}"); public static void LogError(string text) => Log(text, LogType.Error);
}
public static void Log(string text, LogType type)
{
if ((int)type < (int)_logLevel) return;
Main.Instance.ModHelper.Console.WriteLine(Enum.GetName(typeof(LogType), type) + " : " + text, LogTypeToMessageType(type));
}
public static void Log(string text)
{
Log(text, LogType.Log);
}
public static void LogError(string text)
{
Log(text, LogType.Error);
}
public static void LogWarning(string text)
{
Log(text, LogType.Warning);
}
public enum LogType public enum LogType
{ {
Todo, Verbose,
Log, Log,
Warning, Warning,
Error, Error,
} }
private static MessageType LogTypeToMessageType(LogType t)
{ private static MessageType LogTypeToMessageType(LogType t) =>
switch (t) t switch
{ {
case LogType.Error: LogType.Error => MessageType.Error,
return MessageType.Error; LogType.Warning => MessageType.Warning,
case LogType.Warning: _ => MessageType.Info
return MessageType.Warning; };
default:
return MessageType.Info;
}
}
} }
} }

View File

@ -146,7 +146,7 @@ namespace NewHorizons.Utility
bool xCorrect = nomaiCoordinateInterface._nodeControllers[0].CheckCoordinate(coordinates.x); bool xCorrect = nomaiCoordinateInterface._nodeControllers[0].CheckCoordinate(coordinates.x);
bool yCorrect = nomaiCoordinateInterface._nodeControllers[1].CheckCoordinate(coordinates.y); bool yCorrect = nomaiCoordinateInterface._nodeControllers[1].CheckCoordinate(coordinates.y);
bool zCorrect = nomaiCoordinateInterface._nodeControllers[2].CheckCoordinate(coordinates.z); bool zCorrect = nomaiCoordinateInterface._nodeControllers[2].CheckCoordinate(coordinates.z);
Utility.Logger.Log($"Coordinate Check for {system}: {xCorrect}, {yCorrect}, {zCorrect} [{string.Join("-", coordinates.x)}, {string.Join("-", coordinates.y)}, {string.Join("-", coordinates.z)}]"); Utility.Logger.LogVerbose($"Coordinate Check for {system}: {xCorrect}, {yCorrect}, {zCorrect} [{string.Join("-", coordinates.x)}, {string.Join("-", coordinates.y)}, {string.Join("-", coordinates.z)}]");
return xCorrect && yCorrect && zCorrect; return xCorrect && yCorrect && zCorrect;
} }
} }

View File

@ -13,7 +13,7 @@ namespace NewHorizons.Utility
public static void ClearCache() public static void ClearCache()
{ {
Logger.Log("Clearing search cache"); Logger.LogVerbose("Clearing search cache");
CachedGameObjects.Clear(); CachedGameObjects.Clear();
} }

View File

@ -16,7 +16,7 @@ namespace NewHorizons.VoiceActing
if (API == null) if (API == null)
{ {
Logger.Log("VoiceMod isn't installed"); Logger.LogVerbose("VoiceMod isn't installed");
Enabled = false; Enabled = false;
return; return;
} }
@ -33,7 +33,7 @@ namespace NewHorizons.VoiceActing
} }
else else
{ {
Logger.Log($"Didn't find VoiceMod audio for {mod.ModHelper.Manifest.Name} at {folder}"); Logger.LogVerbose($"Didn't find VoiceMod audio for {mod.ModHelper.Manifest.Name} at {folder}");
} }
} }
} }

View File

@ -3,6 +3,7 @@
"settings": { "settings": {
"Debug": false, "Debug": false,
"Custom title screen": true, "Custom title screen": true,
"Default System Override": "" "Default System Override": "",
"Verbose Logs": false
} }
} }