diff --git a/NewHorizons/AchievementsPlus/AchievementHandler.cs b/NewHorizons/AchievementsPlus/AchievementHandler.cs index da9014f8..b7ea6a48 100644 --- a/NewHorizons/AchievementsPlus/AchievementHandler.cs +++ b/NewHorizons/AchievementsPlus/AchievementHandler.cs @@ -20,7 +20,7 @@ namespace NewHorizons.AchievementsPlus if (API == null) { - Logger.Log("Achievements+ isn't installed"); + Logger.LogVerbose("Achievements+ isn't installed"); Enabled = false; return; } diff --git a/NewHorizons/Builder/Body/AsteroidBeltBuilder.cs b/NewHorizons/Builder/Body/AsteroidBeltBuilder.cs index 5e71238f..b106ebb4 100644 --- a/NewHorizons/Builder/Body/AsteroidBeltBuilder.cs +++ b/NewHorizons/Builder/Body/AsteroidBeltBuilder.cs @@ -5,6 +5,7 @@ using NewHorizons.Utility; using OWML.Common; using UnityEngine; using Random = UnityEngine.Random; +using Logger = NewHorizons.Utility.Logger; namespace NewHorizons.Builder.Body { public static class AsteroidBeltBuilder @@ -13,12 +14,14 @@ namespace NewHorizons.Builder.Body { var belt = parentConfig.AsteroidBelt; - float minSize = belt.minSize; - float maxSize = belt.maxSize; - int count = (int)(2f * Mathf.PI * belt.innerRadius / (10f * maxSize)); + var minSize = belt.minSize; + var maxSize = belt.maxSize; + var count = (int)(2f * Mathf.PI * belt.innerRadius / (10f * maxSize)); if (belt.amount >= 0) count = belt.amount; if (count > 200) count = 200; + Logger.Log($"Generating {count} asteroid belt around {bodyName}"); + Random.InitState(belt.randomSeed); for (int i = 0; i < count; i++) @@ -69,7 +72,7 @@ namespace NewHorizons.Builder.Body } var asteroid = new NewHorizonsBody(config, mod); - PlanetCreationHandler.NextPassBodies.Add(asteroid); + PlanetCreationHandler.GenerateBody(asteroid); } } } diff --git a/NewHorizons/Builder/Body/SingularityBuilder.cs b/NewHorizons/Builder/Body/SingularityBuilder.cs index ef261d82..286780c3 100644 --- a/NewHorizons/Builder/Body/SingularityBuilder.cs +++ b/NewHorizons/Builder/Body/SingularityBuilder.cs @@ -76,14 +76,14 @@ namespace NewHorizons.Builder.Body { if (blackHole == null || whiteHole == null) return; - Logger.Log($"Pairing singularities [{blackHoleID}], [{whiteHoleID}]"); + Logger.LogVerbose($"Pairing singularities [{blackHoleID}], [{whiteHoleID}]"); var whiteHoleVolume = whiteHole.GetComponentInChildren(); var blackHoleVolume = blackHole.GetComponentInChildren(); 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; } diff --git a/NewHorizons/Builder/General/AstroObjectBuilder.cs b/NewHorizons/Builder/General/AstroObjectBuilder.cs index a2fecf27..0e17e777 100644 --- a/NewHorizons/Builder/General/AstroObjectBuilder.cs +++ b/NewHorizons/Builder/General/AstroObjectBuilder.cs @@ -1,4 +1,4 @@ -using NewHorizons.Components.Orbital; +using NewHorizons.Components.Orbital; using NewHorizons.External.Configs; using UnityEngine; using Logger = NewHorizons.Utility.Logger; diff --git a/NewHorizons/Builder/General/SpawnPointBuilder.cs b/NewHorizons/Builder/General/SpawnPointBuilder.cs index a2ec2b99..0311374f 100644 --- a/NewHorizons/Builder/General/SpawnPointBuilder.cs +++ b/NewHorizons/Builder/General/SpawnPointBuilder.cs @@ -62,7 +62,7 @@ namespace NewHorizons.Builder.General 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"); playerSpawnGO.transform.parent = ship.transform; playerSpawnGO.layer = 8; @@ -81,7 +81,7 @@ namespace NewHorizons.Builder.General 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; } diff --git a/NewHorizons/Builder/Orbital/InitialMotionBuilder.cs b/NewHorizons/Builder/Orbital/InitialMotionBuilder.cs index 36ece316..8caa1d8f 100644 --- a/NewHorizons/Builder/Orbital/InitialMotionBuilder.cs +++ b/NewHorizons/Builder/Orbital/InitialMotionBuilder.cs @@ -80,7 +80,7 @@ namespace NewHorizons.Builder.Orbital } 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) { - 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 secondaryGravity = new Gravity(secondaryBody._gravityVolume); @@ -172,7 +172,7 @@ namespace NewHorizons.Builder.Orbital secondaryInitialMotion._cachedInitVelocity = baryCenterVelocity + secondaryVelocity; 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}"); } } } diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index fdbe5256..0d1c8c7a 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -40,13 +40,20 @@ namespace NewHorizons.Builder.Props if (detail.removeChildren != null) { var detailPath = detailGO.transform.GetPath(); + var transforms = detailGO.GetComponentsInChildren(true); foreach (var childPath in detail.removeChildren) { - // We purposefully use GameObject.Find here because we don't want to find inactive things. - // 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 childObj = GameObject.Find($"{detailPath}/{childPath}"); - if (childObj != null) childObj.gameObject.SetActive(false); - else Logger.LogWarning($"Couldn't find {childPath}"); + // Multiple children can have the same path so we delete all that match + var path = $"{detailPath}/{childPath}"; + + var flag = true; + 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 else if (component is AnglerfishAnimController angler && angler.GetComponentInParent() == null) { - Logger.Log("Enabling anglerfish animation"); + Logger.LogVerbose("Enabling anglerfish animation"); // Remove any reference to its angler if (angler._anglerfishController) { diff --git a/NewHorizons/Builder/Props/NomaiTextBuilder.cs b/NewHorizons/Builder/Props/NomaiTextBuilder.cs index 6ade077e..0fa1fd58 100644 --- a/NewHorizons/Builder/Props/NomaiTextBuilder.cs +++ b/NewHorizons/Builder/Props/NomaiTextBuilder.cs @@ -30,9 +30,10 @@ namespace NewHorizons.Builder.Props } private static Dictionary conversationInfoToCorrespondingSpawnedGameObject = new Dictionary(); + 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; return conversationInfoToCorrespondingSpawnedGameObject[convo]; } @@ -168,7 +169,7 @@ namespace NewHorizons.Builder.Props () => Main.IsSystemReady, () => { - Logger.Log("Fixing scroll!"); + Logger.LogVerbose("Fixing scroll!"); scrollItem._nomaiWallText = nomaiWallText; scrollItem.SetSector(sector); customScroll.transform.Find("Props_NOM_Scroll/Props_NOM_Scroll_Geo").GetComponent().enabled = true; diff --git a/NewHorizons/Builder/Props/QuantumBuilder.cs b/NewHorizons/Builder/Props/QuantumBuilder.cs index 52311c93..06bfe4f1 100644 --- a/NewHorizons/Builder/Props/QuantumBuilder.cs +++ b/NewHorizons/Builder/Props/QuantumBuilder.cs @@ -216,7 +216,7 @@ namespace NewHorizons.Builder.Props 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; if (meshFilter != null) sharedMesh = meshFilter.sharedMesh; diff --git a/NewHorizons/Builder/Props/SignalBuilder.cs b/NewHorizons/Builder/Props/SignalBuilder.cs index 24da4772..a245958b 100644 --- a/NewHorizons/Builder/Props/SignalBuilder.cs +++ b/NewHorizons/Builder/Props/SignalBuilder.cs @@ -24,7 +24,7 @@ namespace NewHorizons.Builder.Props public static void Init() { - Logger.Log($"Initializing SignalBuilder"); + Logger.LogVerbose($"Initializing SignalBuilder"); _customSignalNames = new Dictionary(); _availableSignalNames = new Stack(new SignalName[] { diff --git a/NewHorizons/Builder/ShipLog/MapModeBuilder.cs b/NewHorizons/Builder/ShipLog/MapModeBuilder.cs index c87438b0..b377bf51 100644 --- a/NewHorizons/Builder/ShipLog/MapModeBuilder.cs +++ b/NewHorizons/Builder/ShipLog/MapModeBuilder.cs @@ -99,7 +99,7 @@ namespace NewHorizons.Builder.ShipLog { 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"); diff --git a/NewHorizons/Builder/StarSystem/SkyboxBuilder.cs b/NewHorizons/Builder/StarSystem/SkyboxBuilder.cs index 02437a83..44d27945 100644 --- a/NewHorizons/Builder/StarSystem/SkyboxBuilder.cs +++ b/NewHorizons/Builder/StarSystem/SkyboxBuilder.cs @@ -1,4 +1,4 @@ -using NewHorizons.External.Configs; +using NewHorizons.External.Configs; using NewHorizons.Utility; using OWML.Common; using UnityEngine; diff --git a/NewHorizons/Components/NHMultiStateQuantumObject.cs b/NewHorizons/Components/NHMultiStateQuantumObject.cs index 502d5996..5838c70d 100644 --- a/NewHorizons/Components/NHMultiStateQuantumObject.cs +++ b/NewHorizons/Components/NHMultiStateQuantumObject.cs @@ -70,7 +70,7 @@ namespace NewHorizons.Components if (previousIndex >= 0 && previousIndex < _states.Length) _states[previousIndex].SetVisible(visible: false); _states[_stateIndex].SetVisible(visible: true); - Logger.Log("trying state " + _stateIndex); + Logger.LogVerbose($"MultiStateQuantumObject - Trying to change state {_stateIndex}"); indices.Remove(_stateIndex); } while (!CurrentStateIsValid() && indices.Count > 0); diff --git a/NewHorizons/Components/QuantumPlanet.cs b/NewHorizons/Components/QuantumPlanet.cs index 796bddd5..32eaa09d 100644 --- a/NewHorizons/Components/QuantumPlanet.cs +++ b/NewHorizons/Components/QuantumPlanet.cs @@ -52,7 +52,7 @@ namespace NewHorizons.Components 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; diff --git a/NewHorizons/Components/ShipLogStarChartMode.cs b/NewHorizons/Components/ShipLogStarChartMode.cs index 314985b3..83035ab7 100644 --- a/NewHorizons/Components/ShipLogStarChartMode.cs +++ b/NewHorizons/Components/ShipLogStarChartMode.cs @@ -133,7 +133,7 @@ namespace NewHorizons.Components else { 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); } } diff --git a/NewHorizons/Components/ShipWarpController.cs b/NewHorizons/Components/ShipWarpController.cs index b79a60d9..e34f9626 100644 --- a/NewHorizons/Components/ShipWarpController.cs +++ b/NewHorizons/Components/ShipWarpController.cs @@ -99,7 +99,7 @@ namespace NewHorizons.Components 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 _impactDeathSpeed = Locator.GetDeathManager()._impactDeathSpeed; Locator.GetDeathManager()._impactDeathSpeed = Mathf.Infinity; @@ -112,7 +112,7 @@ namespace NewHorizons.Components public void WarpOut() { - Logger.Log("Starting warp-out"); + Logger.LogVerbose("Starting warp-out"); _oneShotSource.PlayOneShot(global::AudioType.VesselSingularityCreate, 1f); _blackhole.Create(); } @@ -129,7 +129,7 @@ namespace NewHorizons.Components { if (Locator.GetPlayerTransform().TryGetComponent(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 resources._currentHealth = 100f; if (!PlayerState.AtFlightConsole()) TeleportToShip(); @@ -151,7 +151,7 @@ namespace NewHorizons.Components private void StartWarpInEffect() { - Logger.Log("Starting warp-in effect"); + Logger.LogVerbose("Starting warp-in effect"); _oneShotSource.PlayOneShot(global::AudioType.VesselSingularityCollapse, 1f); Locator.GetDeathManager()._invincible = true; if (Main.Instance.CurrentStarSystem.Equals("SolarSystem")) TeleportToShip(); @@ -171,7 +171,7 @@ namespace NewHorizons.Components public void FinishWarpIn() { - Logger.Log("Finishing warp"); + Logger.LogVerbose("Finishing warp"); Locator.GetShipBody().GetComponentInChildren().OnPressInteract(); _waitingToBeSeated = false; Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => _whitehole.Collapse(), 30); diff --git a/NewHorizons/Components/StarLightController.cs b/NewHorizons/Components/StarLightController.cs index 7e46459d..310616e1 100644 --- a/NewHorizons/Components/StarLightController.cs +++ b/NewHorizons/Components/StarLightController.cs @@ -28,13 +28,13 @@ namespace NewHorizons.Components { 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); } 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._activeStar != null && Instance._activeStar.Equals(star)) @@ -85,7 +85,7 @@ namespace NewHorizons.Components if (_activeStar != null) _activeStar.Disable(); - Logger.Log($"Switching active star: {star.gameObject.name}"); + Logger.LogVerbose($"Switching active star: {star.gameObject.name}"); _activeStar = star; diff --git a/NewHorizons/External/NewHorizonsData.cs b/NewHorizons/External/NewHorizonsData.cs index 2a1a3e63..afda8857 100644 --- a/NewHorizons/External/NewHorizonsData.cs +++ b/NewHorizons/External/NewHorizonsData.cs @@ -26,18 +26,18 @@ namespace NewHorizons.External if (!_saveFile.Profiles.ContainsKey(_activeProfileName)) _saveFile.Profiles.Add(_activeProfileName, new NewHorizonsProfile()); _activeProfile = _saveFile.Profiles[_activeProfileName]; - Logger.Log($"Loaded save data for {_activeProfileName}"); + Logger.LogVerbose($"Loaded save data for {_activeProfileName}"); } catch (Exception) { 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.Profiles.Add(_activeProfileName, new NewHorizonsProfile()); _activeProfile = _saveFile.Profiles[_activeProfileName]; Main.Instance.ModHelper.Storage.Save(_saveFile, FileName); - Logger.Log($"Loaded save data for {_activeProfileName}"); + Logger.LogVerbose($"Loaded save data for {_activeProfileName}"); } catch (Exception e) { @@ -55,7 +55,7 @@ namespace NewHorizons.External public static void Reset() { if (_saveFile == null || _activeProfile == null) Load(); - Logger.Log($"Resetting save data for {_activeProfileName}"); + Logger.LogVerbose($"Resetting save data for {_activeProfileName}"); _activeProfile = new NewHorizonsProfile(); _saveFile.Profiles[_activeProfileName] = _activeProfile; diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index f0ff27b9..a2a36aab 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -219,7 +219,8 @@ namespace NewHorizons.Handlers { try { - GameObject planetObject = GenerateBody(body, defaultPrimaryToSun); + Logger.Log($"Creating [{body.Config.name}]"); + var planetObject = GenerateBody(body, defaultPrimaryToSun); if (planetObject == null) return false; planetObject.SetActive(true); _dict.Add(planetObject.GetComponent(), body); @@ -278,8 +279,8 @@ namespace NewHorizons.Handlers { if (defaultPrimaryToSun) { - Logger.Log($"Couldn't find {body.Config.Orbit.primaryBody}, defaulting to Sun"); - primaryBody = AstroObjectLocator.GetAstroObject("Sun"); + Logger.LogError($"Couldn't find {body.Config.Orbit.primaryBody}, defaulting to center of solar system"); + primaryBody = Locator.GetCenterOfTheUniverse().GetAttachedOWRigidbody().GetComponent(); } else { @@ -293,8 +294,6 @@ namespace NewHorizons.Handlers primaryBody = null; } - Logger.Log($"Begin generation sequence of [{body.Config.name}]"); - var go = new GameObject(body.Config.name.Replace(" ", "").Replace("'", "") + "_Body"); go.SetActive(false); @@ -339,7 +338,7 @@ namespace NewHorizons.Handlers // Spawning on other planets is a bit hacky so we do it last 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); } @@ -363,6 +362,8 @@ namespace NewHorizons.Handlers ProxyBuilder.Make(go, body); }); + Logger.LogVerbose($"Finished creating [{body.Config.name}]"); + return go; } @@ -606,7 +607,7 @@ namespace NewHorizons.Handlers 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(); diff --git a/NewHorizons/Handlers/PlanetDestructionHandler.cs b/NewHorizons/Handlers/PlanetDestructionHandler.cs index 82c0454a..33ffbb39 100644 --- a/NewHorizons/Handlers/PlanetDestructionHandler.cs +++ b/NewHorizons/Handlers/PlanetDestructionHandler.cs @@ -49,11 +49,11 @@ namespace NewHorizons.Handlers public static void RemoveBody(AstroObject ao, bool delete = false, List toDestroy = null) { - Logger.Log($"Removing [{ao.name}]"); + Logger.LogVerbose($"Removing [{ao.name}]"); if (ao.gameObject == null || !ao.gameObject.activeInHierarchy) { - Logger.Log($"[{ao.name}] was already removed"); + Logger.LogVerbose($"[{ao.name}] was already removed"); return; } @@ -61,7 +61,7 @@ namespace NewHorizons.Handlers 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; } @@ -133,7 +133,7 @@ namespace NewHorizons.Handlers foreach (var sunProxy in GameObject.FindObjectsOfType()) { - Logger.Log($"Destroying SunProxy {sunProxy.gameObject.name}"); + Logger.LogVerbose($"Destroying SunProxy {sunProxy.gameObject.name}"); GameObject.Destroy(sunProxy.gameObject); } @@ -143,12 +143,12 @@ namespace NewHorizons.Handlers } // 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)) { 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 if (child.name == "Ship_Body") continue; @@ -208,7 +208,7 @@ namespace NewHorizons.Handlers { if (go == null) return; - Logger.Log($"Removing [{go.name}]"); + Logger.LogVerbose($"Removing [{go.name}]"); if (delete) { @@ -236,7 +236,7 @@ namespace NewHorizons.Handlers if (distantProxyClone != null) GameObject.Destroy(distantProxyClone.gameObject); if (distantProxy == null && distantProxyClone == null) - Logger.Log($"Couldn't find proxy for {name}"); + Logger.LogVerbose($"Couldn't find proxy for {name}"); } } } diff --git a/NewHorizons/Handlers/PlanetGraphHandler.cs b/NewHorizons/Handlers/PlanetGraphHandler.cs index da99907d..20b87cb4 100644 --- a/NewHorizons/Handlers/PlanetGraphHandler.cs +++ b/NewHorizons/Handlers/PlanetGraphHandler.cs @@ -109,7 +109,7 @@ namespace NewHorizons.Handlers foreach (var node in nodeDict.Values.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) diff --git a/NewHorizons/Handlers/StarChartHandler.cs b/NewHorizons/Handlers/StarChartHandler.cs index 4b1844e6..a6a3aa1c 100644 --- a/NewHorizons/Handlers/StarChartHandler.cs +++ b/NewHorizons/Handlers/StarChartHandler.cs @@ -97,7 +97,7 @@ namespace NewHorizons.Handlers { 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(); ShipLogStarChartMode.AddSystemCard(systemUnlocked); } @@ -105,7 +105,7 @@ namespace NewHorizons.Handlers 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); _factIDToStarSystem.Add(factID, system); } diff --git a/NewHorizons/Handlers/TitleSceneHandler.cs b/NewHorizons/Handlers/TitleSceneHandler.cs index 242590a4..38d6321d 100644 --- a/NewHorizons/Handlers/TitleSceneHandler.cs +++ b/NewHorizons/Handlers/TitleSceneHandler.cs @@ -36,7 +36,7 @@ namespace NewHorizons.Handlers var selectionCount = Mathf.Min(eligibleCount, 3); 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; @@ -74,7 +74,7 @@ namespace NewHorizons.Handlers 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"); HeightMapModule heightMap = new HeightMapModule(); var minSize = 15; diff --git a/NewHorizons/Handlers/VesselWarpHandler.cs b/NewHorizons/Handlers/VesselWarpHandler.cs index f124096a..308713fe 100644 --- a/NewHorizons/Handlers/VesselWarpHandler.cs +++ b/NewHorizons/Handlers/VesselWarpHandler.cs @@ -75,10 +75,10 @@ namespace NewHorizons.Handlers { var system = SystemDict[Instance.CurrentStarSystem]; - Logger.Log("Checking for Vessel Prefab"); + Logger.LogVerbose("Checking for Vessel Prefab"); if (VesselPrefab == null) return null; - Logger.Log("Creating Vessel"); + Logger.LogVerbose("Creating Vessel"); var vesselObject = GameObject.Instantiate(VesselPrefab); VesselObject = vesselObject; vesselObject.name = VesselPrefab.name; @@ -159,7 +159,7 @@ namespace NewHorizons.Handlers { var system = SystemDict[Instance.CurrentStarSystem]; - Logger.Log("Updating DB Vessel"); + Logger.LogVerbose("Updating DB Vessel"); var vectorSector = SearchUtilities.Find("DB_VesselDimension_Body/Sector_VesselDimension"); VesselObject = vectorSector; diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 955b7cd5..e0d67abf 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -31,6 +31,7 @@ namespace NewHorizons // Settings public static bool Debug { get; private set; } + public static bool VerboseLogs { get; private set; } private static bool _useCustomTitleScreen; private static bool _wasConfigured = false; private static string _defaultSystemOverride; @@ -75,11 +76,12 @@ namespace NewHorizons public override void Configure(IModConfig config) { - Logger.Log("Settings changed"); + Logger.LogVerbose("Settings changed"); var currentScene = SceneManager.GetActiveScene().name; Debug = config.GetSettingsValue("Debug"); + VerboseLogs = config.GetSettingsValue("Verbose Logs"); if (currentScene == "SolarSystem") { @@ -87,7 +89,9 @@ namespace NewHorizons 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("Default System Override"); @@ -103,7 +107,7 @@ namespace NewHorizons // Don't reload if we haven't configured yet (called on game start) if (wasUsingCustomTitleScreen != _useCustomTitleScreen && SceneManager.GetActiveScene().name == "TitleScreen" && _wasConfigured) { - Logger.Log("Reloading"); + Logger.LogVerbose("Reloading"); SceneManager.LoadScene("TitleScreen", LoadSceneMode.Single); } @@ -168,7 +172,7 @@ namespace NewHorizons ResetConfigs(resetTranslation: false); - Logger.Log("Begin load of config files...", Logger.LogType.Log); + Logger.Log("Begin load of config files..."); try { @@ -213,7 +217,7 @@ namespace NewHorizons 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 if (IsChangingStarSystem && (SystemDict[_currentStarSystem].Config.enableTimeLoop || _currentStarSystem == "SolarSystem") && SecondsLeftInLoop > 0f) @@ -254,11 +258,6 @@ namespace NewHorizons if (scene.name == "SolarSystem") { - foreach (var body in GameObject.FindObjectsOfType()) - { - Logger.Log($"{body.name}, {body.transform.rotation}"); - } - if (_ship != null) { _ship = SearchUtilities.Find("Ship_Body").InstantiateInactive(); @@ -298,7 +297,7 @@ namespace NewHorizons try { - Logger.Log($"Star system loaded [{Instance.CurrentStarSystem}]"); + Logger.Log($"Star system finished loading [{Instance.CurrentStarSystem}]"); Instance.OnStarSystemLoaded?.Invoke(Instance.CurrentStarSystem); } catch (Exception e) @@ -340,7 +339,7 @@ namespace NewHorizons public void EnableWarpDrive() { - Logger.Log("Setting up warp drive"); + Logger.LogVerbose("Setting up warp drive"); PlanetCreationHandler.LoadBody(LoadConfig(this, "Assets/WarpDriveConfig.json")); HasWarpDrive = true; } @@ -364,7 +363,7 @@ namespace NewHorizons { var name = Path.GetFileNameWithoutExtension(file); - Logger.Log($"Loading system {name}"); + Logger.LogVerbose($"Loading system {name}"); var relativePath = file.Replace(folder, ""); var starSystemConfig = mod.ModHelper.Storage.Load(relativePath); @@ -438,7 +437,7 @@ namespace NewHorizons 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}"); @@ -467,7 +466,7 @@ namespace NewHorizons return null; } - Logger.Log($"Loaded {config.name}"); + Logger.LogVerbose($"Loaded {config.name}"); if (!SystemDict.ContainsKey(config.starSystem)) { diff --git a/NewHorizons/Patches/PlayerSpawnerPatches.cs b/NewHorizons/Patches/PlayerSpawnerPatches.cs index 09e9ff0a..327a70ad 100644 --- a/NewHorizons/Patches/PlayerSpawnerPatches.cs +++ b/NewHorizons/Patches/PlayerSpawnerPatches.cs @@ -9,7 +9,7 @@ namespace NewHorizons.Patches [HarmonyPatch(typeof(PlayerSpawner), nameof(PlayerSpawner.SpawnPlayer))] public static void PlayerSpawner_SpawnPlayer(PlayerSpawner __instance) { - Logger.Log("Player spawning"); + Logger.LogVerbose("Player spawning"); __instance.SetInitialSpawnPoint(Main.SystemDict[Main.Instance.CurrentStarSystem].SpawnPoint); } } diff --git a/NewHorizons/Patches/ShipLogPatches.cs b/NewHorizons/Patches/ShipLogPatches.cs index e61263be..306b53a9 100644 --- a/NewHorizons/Patches/ShipLogPatches.cs +++ b/NewHorizons/Patches/ShipLogPatches.cs @@ -21,7 +21,7 @@ namespace NewHorizons.Patches { RumorModeBuilder.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") { __instance._shipLogXmlAssets = new TextAsset[] { }; @@ -58,7 +58,7 @@ namespace NewHorizons.Patches 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] @@ -157,7 +157,7 @@ namespace NewHorizons.Patches } } - Logger.Log("Map Mode Construction Complete", Logger.LogType.Log); + Logger.Log("Map Mode Construction Complete"); } [HarmonyPrefix] diff --git a/NewHorizons/Utility/AstroObjectLocator.cs b/NewHorizons/Utility/AstroObjectLocator.cs index c03449b3..ad8ab0ae 100644 --- a/NewHorizons/Utility/AstroObjectLocator.cs +++ b/NewHorizons/Utility/AstroObjectLocator.cs @@ -68,7 +68,7 @@ namespace NewHorizons.Utility } else { - Logger.Log($"Registering [{ao.name}] as [{key}]"); + Logger.LogVerbose($"Registering [{ao.name}] as [{key}]"); _customAstroObjectDictionary.Add(key, ao); } } diff --git a/NewHorizons/Utility/AudioUtilities.cs b/NewHorizons/Utility/AudioUtilities.cs index 45b68261..b5e04bf1 100644 --- a/NewHorizons/Utility/AudioUtilities.cs +++ b/NewHorizons/Utility/AudioUtilities.cs @@ -13,10 +13,10 @@ namespace NewHorizons.Utility { if (_loadedAudioClips.ContainsKey(path)) { - Logger.Log($"Already loaded audio at path: {path}"); + Logger.LogVerbose($"Already loaded audio at path: {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)); task.Wait(); _loadedAudioClips.Add(path, task.Result); @@ -25,7 +25,7 @@ namespace NewHorizons.Utility public static void ClearCache() { - Logger.Log("Clearing audio cache"); + Logger.LogVerbose("Clearing audio cache"); foreach (var audioClip in _loadedAudioClips.Values) { diff --git a/NewHorizons/Utility/DebugMenu/DebugMenu.cs b/NewHorizons/Utility/DebugMenu/DebugMenu.cs index c33e77f5..0c5b35ae 100644 --- a/NewHorizons/Utility/DebugMenu/DebugMenu.cs +++ b/NewHorizons/Utility/DebugMenu/DebugMenu.cs @@ -200,7 +200,7 @@ namespace NewHorizons.Utility.DebugMenu { 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; } @@ -219,7 +219,7 @@ namespace NewHorizons.Utility.DebugMenu 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; diff --git a/NewHorizons/Utility/DebugMenu/DebugMenuNomaiText.cs b/NewHorizons/Utility/DebugMenu/DebugMenuNomaiText.cs index c8d82122..30903469 100644 --- a/NewHorizons/Utility/DebugMenu/DebugMenuNomaiText.cs +++ b/NewHorizons/Utility/DebugMenu/DebugMenuNomaiText.cs @@ -101,7 +101,7 @@ namespace NewHorizons.Utility.DebugMenu collapsed = true }; - Logger.Log("adding go " + conversationMetadata.conversationGo); + Logger.LogVerbose("Adding conversation Game Object " + conversationMetadata.conversationGo); conversations.Add(conversationMetadata); @@ -128,7 +128,7 @@ namespace NewHorizons.Utility.DebugMenu var parentID = (new Regex(regex)).Matches(metadata.spiralGo.name)[0].Groups[1].Value; 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); @@ -190,7 +190,7 @@ namespace NewHorizons.Utility.DebugMenu if (GUILayout.Button(arrow + conversationMeta.planetConfig.name + " - " + i, menu._submenuStyle)) { conversationMeta.collapsed = !conversationMeta.collapsed; - Logger.Log("BUTTON " + i); + Logger.LogVerbose("BUTTON " + i); } if (!conversationMeta.collapsed) @@ -204,7 +204,7 @@ namespace NewHorizons.Utility.DebugMenu //conversationMeta.conversation.type == PropModule.NomaiTextInfo.NomaiTextType.Wall && GUILayout.Button("Place conversation with G") ) { - Logger.Log(conversationMeta.conversationGo+" 0"); + Logger.LogVerbose(conversationMeta.conversationGo+" 0"); DebugNomaiTextPlacer.active = true; _dnp.onRaycast = (DebugRaycastData data) => { @@ -423,7 +423,7 @@ namespace NewHorizons.Utility.DebugMenu SpiralMetadata parentSpiralMeta = GetParent(spiralMetadata); var parentPoints = parentSpiralMeta.spiralGo.GetComponent()._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 nextPointOnParent = parentPoints[Mathf.Min(parentPoints.Count()-1, spiralMetadata.pointOnParent+1)]; @@ -432,14 +432,14 @@ namespace NewHorizons.Utility.DebugMenu var newRotationRelativeToParent = parentTangent + 90; 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 selfBasePoint = spiralMetadata.spiralGo.GetComponent()._points[0]; var newPointRelativeToParent = -selfBasePoint + pointOnParent; 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.localEulerAngles = new Vector3(0, 0, spiralMetadata.spiral.zRotation); @@ -450,9 +450,9 @@ namespace NewHorizons.Utility.DebugMenu private void UpdateChildrenLocations(SpiralMetadata parentSprialMetadata) { - Logger.Log("updating children"); + Logger.Log("Updating children"); ConversationMetadata convoMeta = conversations.Where(m => m.conversation == parentSprialMetadata.conversation).First(); - Logger.Log("got convo meta"); + Logger.Log("Got conversation metadata"); convoMeta.spirals .Where(spiralMeta => spiralMeta.parentID == parentSprialMetadata.id && spiralMeta.id != parentSprialMetadata.id) @@ -482,15 +482,10 @@ namespace NewHorizons.Utility.DebugMenu { var nomaiWallTextObj = conversationMetadata.conversationGo; if (nomaiWallTextObj == null) return; + var planetGO = sectorParent; 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); if (info.normal != null) { diff --git a/NewHorizons/Utility/DebugMenu/DebugMenuPropPlacer.cs b/NewHorizons/Utility/DebugMenu/DebugMenuPropPlacer.cs index 9d61f2f1..76d3462d 100644 --- a/NewHorizons/Utility/DebugMenu/DebugMenuPropPlacer.cs +++ b/NewHorizons/Utility/DebugMenu/DebugMenuPropPlacer.cs @@ -311,14 +311,14 @@ namespace NewHorizons.Utility.DebugMenu // Get all configs foreach (var filePath in menu.loadedConfigFiles.Keys) { - Logger.Log($"Potentially updating copy of config at {filePath}"); - Logger.Log($"{menu.loadedConfigFiles[filePath].name} {AstroObjectLocator.GetAstroObject(menu.loadedConfigFiles[filePath].name)?.name}"); - Logger.Log($"{menu.loadedConfigFiles[filePath].name}"); + Logger.LogVerbose($"Potentially updating copy of config at {filePath}"); + Logger.LogVerbose($"{menu.loadedConfigFiles[filePath].name} {AstroObjectLocator.GetAstroObject(menu.loadedConfigFiles[filePath].name)?.name}"); + Logger.LogVerbose($"{menu.loadedConfigFiles[filePath].name}"); if (menu.loadedConfigFiles[filePath].starSystem != Main.Instance.CurrentStarSystem) return; 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; } diff --git a/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs b/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs index e482d84f..9a5812a7 100644 --- a/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs +++ b/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs @@ -98,7 +98,7 @@ namespace NewHorizons.Utility.DebugUtilities 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 @@ -115,7 +115,7 @@ namespace NewHorizons.Utility.DebugUtilities } 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); - 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; @@ -230,7 +230,7 @@ namespace NewHorizons.Utility.DebugUtilities if (bodyProps == null || bodyProps.Count == 0) continue; if (bodyProps[0].body == null) continue; 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); DetailInfo[] infoArray = new DetailInfo[bodyProps.Count]; diff --git a/NewHorizons/Utility/DebugUtilities/DebugRaycaster.cs b/NewHorizons/Utility/DebugUtilities/DebugRaycaster.cs index 6d5890f1..d7930ad1 100644 --- a/NewHorizons/Utility/DebugUtilities/DebugRaycaster.cs +++ b/NewHorizons/Utility/DebugUtilities/DebugRaycaster.cs @@ -43,7 +43,7 @@ namespace NewHorizons.Utility.DebugUtilities 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; } @@ -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, 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 // 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 diff --git a/NewHorizons/Utility/DebugUtilities/DebugReload.cs b/NewHorizons/Utility/DebugUtilities/DebugReload.cs index ac48c7ad..eaa09373 100644 --- a/NewHorizons/Utility/DebugUtilities/DebugReload.cs +++ b/NewHorizons/Utility/DebugUtilities/DebugReload.cs @@ -29,7 +29,7 @@ namespace NewHorizons.Utility.DebugUtilities private static void ReloadConfigs() { - Logger.Log("Begin reload of config files...", Logger.LogType.Log); + Logger.Log("Begin reload of config files..."); Main.ResetConfigs(); diff --git a/NewHorizons/Utility/ImageUtilities.cs b/NewHorizons/Utility/ImageUtilities.cs index b65ea0e9..ea4abafa 100644 --- a/NewHorizons/Utility/ImageUtilities.cs +++ b/NewHorizons/Utility/ImageUtilities.cs @@ -31,11 +31,11 @@ namespace NewHorizons.Utility var path = mod.ModHelper.Manifest.ModFolderPath + filename; if (_loadedTextures.ContainsKey(path)) { - Logger.Log($"Already loaded image at path: {path}"); + Logger.LogVerbose($"Already loaded image at path: {path}"); return _loadedTextures[path]; } - Logger.Log($"Loading image at path: {path}"); + Logger.LogVerbose($"Loading image at path: {path}"); try { var data = File.ReadAllBytes(path); @@ -70,7 +70,7 @@ namespace NewHorizons.Utility public static void ClearCache() { - Logger.Log("Clearing image cache"); + Logger.LogVerbose("Clearing image cache"); foreach (var texture in _loadedTextures.Values) { @@ -368,7 +368,7 @@ namespace NewHorizons.Utility { if (_loadedTextures.ContainsKey(url)) { - Logger.Log($"Already loaded image at path: {url}"); + Logger.LogVerbose($"Already loaded image at path: {url}"); var texture = _loadedTextures[url]; imageLoadedEvent.Invoke(texture, index); yield break; @@ -390,7 +390,7 @@ namespace NewHorizons.Utility if (_loadedTextures.ContainsKey(url)) { - Logger.Log($"Already loaded image at path: {url}"); + Logger.LogVerbose($"Already loaded image at path: {url}"); Destroy(texture); texture = _loadedTextures[url]; } diff --git a/NewHorizons/Utility/Logger.cs b/NewHorizons/Utility/Logger.cs index 5935b269..4716a37e 100644 --- a/NewHorizons/Utility/Logger.cs +++ b/NewHorizons/Utility/Logger.cs @@ -1,80 +1,44 @@ -using OWML.Common; -using System; -using System.ComponentModel; -using UnityEngine; -namespace NewHorizons.Utility -{ - public static class Logger - { - - private static LogType _logLevel = LogType.Error; - - public static void UpdateLogLevel(LogType newLevel) - { - _logLevel = newLevel; - } - - public static void LogProperties(UnityEngine.Object obj) - { - foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(obj)) - { - 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) - { - if (go == null) Log("Can't print path: GameObject is null"); - else Log($"{go.transform.GetPath()}"); - } - - 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 - { - Todo, - Log, - Warning, - Error, - } - private static MessageType LogTypeToMessageType(LogType t) - { - switch (t) - { - case LogType.Error: - return MessageType.Error; - case LogType.Warning: - return MessageType.Warning; - default: - return MessageType.Info; - } - } - } -} +using OWML.Common; +using System; +using System.ComponentModel; +using UnityEngine; +namespace NewHorizons.Utility +{ + public static class Logger + { + + private static LogType _logLevel = LogType.Error; + + public static void UpdateLogLevel(LogType newLevel) + { + _logLevel = newLevel; + } + + private static void Log(string text, LogType type) + { + if (type < _logLevel) return; + Main.Instance.ModHelper.Console.WriteLine($"{Enum.GetName(typeof(LogType), type)} : {text}", LogTypeToMessageType(type)); + } + + public static void LogVerbose(string text) => Log(text, LogType.Verbose); + public static void Log(string text) => Log(text, LogType.Log); + public static void LogWarning(string text) => Log(text, LogType.Warning); + public static void LogError(string text) => Log(text, LogType.Error); + + public enum LogType + { + Verbose, + Log, + Warning, + Error, + } + + private static MessageType LogTypeToMessageType(LogType t) => + t switch + { + LogType.Error => MessageType.Error, + LogType.Warning => MessageType.Warning, + _ => MessageType.Info + }; + } +} diff --git a/NewHorizons/Utility/NewHorizonExtensions.cs b/NewHorizons/Utility/NewHorizonExtensions.cs index 9c04d33d..2776a671 100644 --- a/NewHorizons/Utility/NewHorizonExtensions.cs +++ b/NewHorizons/Utility/NewHorizonExtensions.cs @@ -146,7 +146,7 @@ namespace NewHorizons.Utility bool xCorrect = nomaiCoordinateInterface._nodeControllers[0].CheckCoordinate(coordinates.x); bool yCorrect = nomaiCoordinateInterface._nodeControllers[1].CheckCoordinate(coordinates.y); 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; } } diff --git a/NewHorizons/Utility/SearchUtilities.cs b/NewHorizons/Utility/SearchUtilities.cs index d31310e6..18f3299e 100644 --- a/NewHorizons/Utility/SearchUtilities.cs +++ b/NewHorizons/Utility/SearchUtilities.cs @@ -13,7 +13,7 @@ namespace NewHorizons.Utility public static void ClearCache() { - Logger.Log("Clearing search cache"); + Logger.LogVerbose("Clearing search cache"); CachedGameObjects.Clear(); } diff --git a/NewHorizons/VoiceActing/VoiceHandler.cs b/NewHorizons/VoiceActing/VoiceHandler.cs index 4718d5a3..de24099e 100644 --- a/NewHorizons/VoiceActing/VoiceHandler.cs +++ b/NewHorizons/VoiceActing/VoiceHandler.cs @@ -16,7 +16,7 @@ namespace NewHorizons.VoiceActing if (API == null) { - Logger.Log("VoiceMod isn't installed"); + Logger.LogVerbose("VoiceMod isn't installed"); Enabled = false; return; } @@ -33,7 +33,7 @@ namespace NewHorizons.VoiceActing } 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}"); } } } diff --git a/NewHorizons/default-config.json b/NewHorizons/default-config.json index f5200a8d..146eb9fe 100644 --- a/NewHorizons/default-config.json +++ b/NewHorizons/default-config.json @@ -3,6 +3,7 @@ "settings": { "Debug": false, "Custom title screen": true, - "Default System Override": "" + "Default System Override": "", + "Verbose Logs": false } } \ No newline at end of file