From 5dd8e8db4e32e6e79c1681478bd0cbcc2ff1f7d4 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 25 Mar 2023 21:50:07 -0400 Subject: [PATCH 01/19] Add in comet tail module --- NewHorizons/Builder/Body/CometTailBuilder.cs | 12 +- NewHorizons/Builder/Body/ProxyBuilder.cs | 4 +- NewHorizons/External/Configs/PlanetConfig.cs | 104 +++++++++++------- NewHorizons/External/Modules/BaseModule.cs | 16 +-- .../External/Modules/CometTailModule.cs | 25 +++++ NewHorizons/Handlers/PlanetCreationHandler.cs | 4 +- 6 files changed, 104 insertions(+), 61 deletions(-) create mode 100644 NewHorizons/External/Modules/CometTailModule.cs diff --git a/NewHorizons/Builder/Body/CometTailBuilder.cs b/NewHorizons/Builder/Body/CometTailBuilder.cs index 6cb8c267..95359416 100644 --- a/NewHorizons/Builder/Body/CometTailBuilder.cs +++ b/NewHorizons/Builder/Body/CometTailBuilder.cs @@ -1,6 +1,8 @@ using NewHorizons.External.Configs; +using NewHorizons.External.Modules; using NewHorizons.Utility; using UnityEngine; + namespace NewHorizons.Builder.Body { public static class CometTailBuilder @@ -12,17 +14,15 @@ namespace NewHorizons.Builder.Body if (_tailPrefab == null) _tailPrefab = SearchUtilities.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes").InstantiateInactive().Rename("Prefab_CO_Tail").DontDestroyOnLoad(); } - public static void Make(GameObject planetGO, Sector sector, PlanetConfig config) + public static void Make(GameObject planetGO, Sector sector, CometTailModule cometTailModule, float surfaceSize) { - InitPrefab(); - var cometTail = GameObject.Instantiate(_tailPrefab, sector?.transform ?? planetGO.transform); cometTail.transform.position = planetGO.transform.position; cometTail.name = "CometTail"; - cometTail.transform.localScale = Vector3.one * config.Base.surfaceSize / 110; + cometTail.transform.localScale = Vector3.one * (cometTailModule.innerRadius ?? surfaceSize) / 110; - Vector3 alignment = new Vector3(0, 270, 90); - if (config.Base.cometTailRotation != null) alignment = config.Base.cometTailRotation; + var alignment = new Vector3(0, 270, 90); + if (cometTailModule.rotationOverride != null) alignment = cometTailModule.rotationOverride; cometTail.transform.rotation = Quaternion.Euler(alignment); diff --git a/NewHorizons/Builder/Body/ProxyBuilder.cs b/NewHorizons/Builder/Body/ProxyBuilder.cs index 15e6953e..9a48f7c4 100644 --- a/NewHorizons/Builder/Body/ProxyBuilder.cs +++ b/NewHorizons/Builder/Body/ProxyBuilder.cs @@ -194,9 +194,9 @@ namespace NewHorizons.Builder.Body } } - if (body.Config.Base.hasCometTail) + if (body.Config.CometTail != null) { - CometTailBuilder.Make(proxy, null, body.Config); + CometTailBuilder.Make(proxy, null, body.Config.CometTail, body.Config.Base.surfaceSize); } if (body.Config.Props?.proxyDetails != null) diff --git a/NewHorizons/External/Configs/PlanetConfig.cs b/NewHorizons/External/Configs/PlanetConfig.cs index c934a721..d0176289 100644 --- a/NewHorizons/External/Configs/PlanetConfig.cs +++ b/NewHorizons/External/Configs/PlanetConfig.cs @@ -21,6 +21,7 @@ namespace NewHorizons.External.Configs [JsonObject(Title = "Celestial Body")] public class PlanetConfig { + #region Fields /// /// Unique name of your planet /// @@ -32,6 +33,34 @@ namespace NewHorizons.External.Configs /// [DefaultValue("SolarSystem")] public string starSystem = "SolarSystem"; + /// + /// Does this config describe a quantum state of a custom planet defined in another file? + /// + public bool isQuantumState; + + /// + /// Does this config describe a stellar remnant of a custom star defined in another file? + /// + public bool isStellarRemnant; + + /// + /// Should this planet ever be shown on the title screen? + /// + [DefaultValue(true)] public bool canShowOnTitle = true; + + /// + /// `true` if you want to delete this planet + /// + public bool destroy; + + /// + /// A list of paths to child GameObjects to destroy on this planet + /// + public string[] removeChildren; + + #endregion + + #region Modules /// /// Add ambient lights to this body /// @@ -57,37 +86,11 @@ namespace NewHorizons.External.Configs /// public BrambleModule Bramble; - /// - /// Should this planet ever be shown on the title screen? - /// - [DefaultValue(true)] public bool canShowOnTitle = true; - - #region Obsolete - - [Obsolete("ChildrenToDestroy is deprecated, please use RemoveChildren instead")] - public string[] childrenToDestroy; - - [Obsolete("Singularity is deprecated, please use Props->singularities")] - public SingularityModule Singularity; - - [Obsolete("Signal is deprecated, please use Props->signals")] - public SignalModule Signal; - - [Obsolete("Ring is deprecated, please use Rings")] - public RingModule Ring; - - #endregion Obsolete - /// /// Add a cloaking field to this planet /// public CloakModule Cloak; - /// - /// `true` if you want to delete this planet - /// - public bool destroy; - /// /// Make this body into a focal point (barycenter) /// @@ -103,16 +106,6 @@ namespace NewHorizons.External.Configs /// public HeightMapModule HeightMap; - /// - /// Does this config describe a quantum state of a custom planet defined in another file? - /// - public bool isQuantumState; - - /// - /// Does this config describe a stellar remnant of a custom star defined in another file? - /// - public bool isStellarRemnant; - /// /// Add lava to this planet /// @@ -138,11 +131,6 @@ namespace NewHorizons.External.Configs /// public ReferenceFrameModule ReferenceFrame; - /// - /// A list of paths to child GameObjects to destroy on this planet - /// - public string[] removeChildren; - /// /// Create rings around the planet /// @@ -183,11 +171,35 @@ namespace NewHorizons.External.Configs /// public VolumesModule Volumes; + /// + /// Add a comet tail to this body, like the Interloper + /// + public CometTailModule CometTail; + /// /// Extra data that may be used by extension mods /// public object extras; + #endregion + + #region Obsolete + + [Obsolete("ChildrenToDestroy is deprecated, please use RemoveChildren instead")] + public string[] childrenToDestroy; + + [Obsolete("Singularity is deprecated, please use Props->singularities")] + public SingularityModule Singularity; + + [Obsolete("Signal is deprecated, please use Props->signals")] + public SignalModule Signal; + + [Obsolete("Ring is deprecated, please use Rings")] + public RingModule Ring; + + #endregion Obsolete + + #region ctor validation and migration public PlanetConfig() { // Always have to have a base module @@ -566,6 +578,16 @@ namespace NewHorizons.External.Configs } } } + + if (Base.hasCometTail) + { + CometTail ??= new(); + if (Base.cometTailRotation != null) + { + CometTail.rotationOverride = Base.cometTailRotation; + } + } } + #endregion } } \ No newline at end of file diff --git a/NewHorizons/External/Modules/BaseModule.cs b/NewHorizons/External/Modules/BaseModule.cs index ffd754f5..2f36f5a4 100644 --- a/NewHorizons/External/Modules/BaseModule.cs +++ b/NewHorizons/External/Modules/BaseModule.cs @@ -25,11 +25,6 @@ namespace NewHorizons.External.Modules /// public bool centerOfSolarSystem; - /// - /// If it has a comet tail, it'll be oriented according to these Euler angles. - /// - public MVector3 cometTailRotation; - /// /// How gravity falls off with distance. Most planets use linear but the sun and some moons use inverseSquared. /// @@ -41,11 +36,6 @@ namespace NewHorizons.External.Modules /// public float groundSize; - /// - /// If you want the body to have a tail like the Interloper. - /// - public bool hasCometTail; - /// /// If the body should have a marker on the map screen. /// @@ -116,6 +106,12 @@ namespace NewHorizons.External.Modules [Obsolete("zeroGravityRadius is deprecated, please use Volumes->ZeroGravityVolumes instead")] public float zeroGravityRadius; + [Obsolete("hasCometTail is deprecated, please use CometTail instead")] + public bool hasCometTail; + + [Obsolete("cometTailRotation is deprecated, please use CometTail->rotationOverride instead")] + public MVector3 cometTailRotation; + #endregion Obsolete } } \ No newline at end of file diff --git a/NewHorizons/External/Modules/CometTailModule.cs b/NewHorizons/External/Modules/CometTailModule.cs new file mode 100644 index 00000000..2704ad1e --- /dev/null +++ b/NewHorizons/External/Modules/CometTailModule.cs @@ -0,0 +1,25 @@ +using NewHorizons.External.SerializableData; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NewHorizons.External.Modules +{ + [JsonObject] + public class CometTailModule + { + /// + /// Manually sets the local rotation + /// + public MVector3 rotationOverride; + + /// + /// Inner radius of the comet tail, defaults to match surfaceSize + /// + public float? innerRadius; + } +} diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index db6f8f22..9b7c90f0 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -599,9 +599,9 @@ namespace NewHorizons.Handlers AsteroidBeltBuilder.Make(body.Config.name, body.Config, body.Mod); } - if (body.Config.Base.hasCometTail) + if (body.Config.CometTail != null) { - CometTailBuilder.Make(go, sector, body.Config); + CometTailBuilder.Make(go, sector, body.Config.CometTail, body.Config.Base.surfaceSize); } if (body.Config.Lava != null) From b95f37efd3da351a2a6090ab9b3a5072a70d26e1 Mon Sep 17 00:00:00 2001 From: Ben C Date: Sun, 26 Mar 2023 01:52:40 +0000 Subject: [PATCH 02/19] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 78 ++++++++++++++++------------ 1 file changed, 46 insertions(+), 32 deletions(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 1be5476f..e884e8da 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -18,6 +18,30 @@ "description": "Unique star system containing your planet. If you set this to be a custom solar system remember to add a Spawn module to one of the bodies, or else you can't get to the system.", "default": "SolarSystem" }, + "isQuantumState": { + "type": "boolean", + "description": "Does this config describe a quantum state of a custom planet defined in another file?" + }, + "isStellarRemnant": { + "type": "boolean", + "description": "Does this config describe a stellar remnant of a custom star defined in another file?" + }, + "canShowOnTitle": { + "type": "boolean", + "description": "Should this planet ever be shown on the title screen?", + "default": true + }, + "destroy": { + "type": "boolean", + "description": "`true` if you want to delete this planet" + }, + "removeChildren": { + "type": "array", + "description": "A list of paths to child GameObjects to destroy on this planet", + "items": { + "type": "string" + } + }, "AmbientLights": { "type": "array", "description": "Add ambient lights to this body", @@ -41,19 +65,10 @@ "description": "Add bramble nodes to this planet and/or make this planet a bramble dimension", "$ref": "#/definitions/BrambleModule" }, - "canShowOnTitle": { - "type": "boolean", - "description": "Should this planet ever be shown on the title screen?", - "default": true - }, "Cloak": { "description": "Add a cloaking field to this planet", "$ref": "#/definitions/CloakModule" }, - "destroy": { - "type": "boolean", - "description": "`true` if you want to delete this planet" - }, "FocalPoint": { "description": "Make this body into a focal point (barycenter)", "$ref": "#/definitions/FocalPointModule" @@ -66,14 +81,6 @@ "description": "Generate the surface of this planet using a heightmap", "$ref": "#/definitions/HeightMapModule" }, - "isQuantumState": { - "type": "boolean", - "description": "Does this config describe a quantum state of a custom planet defined in another file?" - }, - "isStellarRemnant": { - "type": "boolean", - "description": "Does this config describe a stellar remnant of a custom star defined in another file?" - }, "Lava": { "description": "Add lava to this planet", "$ref": "#/definitions/LavaModule" @@ -94,13 +101,6 @@ "description": "Reference frame properties of this body", "$ref": "#/definitions/ReferenceFrameModule" }, - "removeChildren": { - "type": "array", - "description": "A list of paths to child GameObjects to destroy on this planet", - "items": { - "type": "string" - } - }, "Rings": { "type": "array", "description": "Create rings around the planet", @@ -136,6 +136,10 @@ "description": "Add various volumes on this body", "$ref": "#/definitions/VolumesModule" }, + "CometTail": { + "description": "Add a comet tail to this body, like the Interloper", + "$ref": "#/definitions/CometTailModule" + }, "extras": { "type": "object", "description": "Extra data that may be used by extension mods", @@ -515,10 +519,6 @@ "type": "boolean", "description": "Set this to true if you are replacing the sun with a different body. Only one object in a star system should ever\nhave this set to true." }, - "cometTailRotation": { - "description": "If it has a comet tail, it'll be oriented according to these Euler angles.", - "$ref": "#/definitions/MVector3" - }, "gravityFallOff": { "description": "How gravity falls off with distance. Most planets use linear but the sun and some moons use inverseSquared.", "default": "linear", @@ -529,10 +529,6 @@ "description": "Radius of a simple sphere used as the ground for the planet. If you want to use more complex terrain, leave this as\n0.", "format": "float" }, - "hasCometTail": { - "type": "boolean", - "description": "If you want the body to have a tail like the Interloper." - }, "hasMapMarker": { "type": "boolean", "description": "If the body should have a marker on the map screen." @@ -4255,6 +4251,24 @@ "final", "kazoo" ] + }, + "CometTailModule": { + "type": "object", + "additionalProperties": false, + "properties": { + "rotationOverride": { + "description": "Manually sets the local rotation", + "$ref": "#/definitions/MVector3" + }, + "innerRadius": { + "type": [ + "null", + "number" + ], + "description": "Inner radius of the comet tail, defaults to match surfaceSize", + "format": "float" + } + } } }, "$docs": { From 64e2e3ce194f1d64a8f1717c98eb88408940e6f6 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 25 Mar 2023 22:11:05 -0400 Subject: [PATCH 03/19] Rearrange components, add comet tail controller --- .../Builder/Atmosphere/CloudsBuilder.cs | 1 + .../Builder/Body/BrambleDimensionBuilder.cs | 2 +- NewHorizons/Builder/Body/CloakBuilder.cs | 2 +- NewHorizons/Builder/Body/CometTailBuilder.cs | 20 +++++++--- NewHorizons/Builder/Body/ProxyBuilder.cs | 3 +- NewHorizons/Builder/Body/RingBuilder.cs | 1 + .../Builder/Body/SupernovaEffectBuilder.cs | 2 +- .../Builder/General/AstroObjectBuilder.cs | 2 +- NewHorizons/Builder/Props/DialogueBuilder.cs | 2 +- NewHorizons/Builder/Props/TornadoBuilder.cs | 2 +- .../{ => EyeOfTheUniverse}/EyeAstroObject.cs | 2 +- .../EyeSunLightParamUpdater.cs | 2 +- NewHorizons/Components/NHProxy.cs | 1 + .../{ => Props}/NHCharacterDialogueTree.cs | 2 +- .../NHSupernovaPlanetEffectController.cs | 2 +- .../{ => Props}/NHTornadoWanderController.cs | 2 +- .../{ => Sectored}/BrambleSectorController.cs | 2 +- .../{ => Sectored}/CloakSectorController.cs | 2 +- .../CloakedTessSphereSectorToggle.cs | 2 +- .../SizeControllers/CometTailController.cs | 40 +++++++++++++++++++ .../SizeControllers/LavaSizeController.cs | 2 +- .../{ => Vessel}/VesselOrbLocker.cs | 2 +- .../{ => Vessel}/VesselSingularityRoot.cs | 2 +- .../External/Modules/CometTailModule.cs | 5 +++ NewHorizons/Handlers/EyeSceneHandler.cs | 2 +- NewHorizons/Handlers/PlanetCreationHandler.cs | 2 +- .../Handlers/SupernovaEffectHandler.cs | 2 +- NewHorizons/Handlers/VesselWarpHandler.cs | 3 +- NewHorizons/Main.cs | 2 +- .../CameraPatches/ProbeCameraPatches.cs | 3 +- .../CharacterDialogueTreePatches.cs | 2 +- .../CloakFieldControllerPatches.cs | 7 ++-- .../HUDPatches/ProbeHUDMarkerPatches.cs | 3 +- .../HUDPatches/ShipHUDMarkerPatches.cs | 3 +- .../ShipLogEntryHUDMarkerPatches.cs | 3 +- .../Geometry}/RingShape.cs | 7 ++-- 36 files changed, 105 insertions(+), 39 deletions(-) rename NewHorizons/Components/{ => EyeOfTheUniverse}/EyeAstroObject.cs (84%) rename NewHorizons/Components/{ => EyeOfTheUniverse}/EyeSunLightParamUpdater.cs (96%) rename NewHorizons/Components/{ => Props}/NHCharacterDialogueTree.cs (67%) rename NewHorizons/Components/{ => Props}/NHSupernovaPlanetEffectController.cs (99%) rename NewHorizons/Components/{ => Props}/NHTornadoWanderController.cs (98%) rename NewHorizons/Components/{ => Sectored}/BrambleSectorController.cs (98%) rename NewHorizons/Components/{ => Sectored}/CloakSectorController.cs (99%) rename NewHorizons/Components/{ => Sectored}/CloakedTessSphereSectorToggle.cs (98%) create mode 100644 NewHorizons/Components/SizeControllers/CometTailController.cs rename NewHorizons/Components/{ => Vessel}/VesselOrbLocker.cs (97%) rename NewHorizons/Components/{ => Vessel}/VesselSingularityRoot.cs (74%) rename NewHorizons/{Components => Utility/Geometry}/RingShape.cs (97%) diff --git a/NewHorizons/Builder/Atmosphere/CloudsBuilder.cs b/NewHorizons/Builder/Atmosphere/CloudsBuilder.cs index 7ddbe7d5..3fa30b09 100644 --- a/NewHorizons/Builder/Atmosphere/CloudsBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/CloudsBuilder.cs @@ -1,4 +1,5 @@ using NewHorizons.Components; +using NewHorizons.Components.Sectored; using NewHorizons.External.Modules; using NewHorizons.Utility; using NewHorizons.Utility.Files; diff --git a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs index 3ad3473b..9eba9930 100644 --- a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs +++ b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs @@ -1,6 +1,6 @@ using NewHorizons.Builder.Props; -using NewHorizons.Components; using NewHorizons.Components.Orbital; +using NewHorizons.Components.Sectored; using NewHorizons.External; using NewHorizons.External.Modules; using NewHorizons.External.Modules.Props; diff --git a/NewHorizons/Builder/Body/CloakBuilder.cs b/NewHorizons/Builder/Body/CloakBuilder.cs index dd1ece55..369683eb 100644 --- a/NewHorizons/Builder/Body/CloakBuilder.cs +++ b/NewHorizons/Builder/Body/CloakBuilder.cs @@ -1,4 +1,4 @@ -using NewHorizons.Components; +using NewHorizons.Components.Sectored; using NewHorizons.External.Modules; using NewHorizons.Utility; using NewHorizons.Utility.Files; diff --git a/NewHorizons/Builder/Body/CometTailBuilder.cs b/NewHorizons/Builder/Body/CometTailBuilder.cs index 95359416..1f3d80ab 100644 --- a/NewHorizons/Builder/Body/CometTailBuilder.cs +++ b/NewHorizons/Builder/Body/CometTailBuilder.cs @@ -1,6 +1,9 @@ +using NewHorizons.Components.SizeControllers; using NewHorizons.External.Configs; using NewHorizons.External.Modules; using NewHorizons.Utility; +using NewHorizons.Utility.OuterWilds; +using NewHorizons.Utility.OWML; using UnityEngine; namespace NewHorizons.Builder.Body @@ -14,17 +17,24 @@ namespace NewHorizons.Builder.Body if (_tailPrefab == null) _tailPrefab = SearchUtilities.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes").InstantiateInactive().Rename("Prefab_CO_Tail").DontDestroyOnLoad(); } - public static void Make(GameObject planetGO, Sector sector, CometTailModule cometTailModule, float surfaceSize) + public static void Make(GameObject planetGO, Sector sector, CometTailModule cometTailModule, PlanetConfig config) { var cometTail = GameObject.Instantiate(_tailPrefab, sector?.transform ?? planetGO.transform); cometTail.transform.position = planetGO.transform.position; cometTail.name = "CometTail"; - cometTail.transform.localScale = Vector3.one * (cometTailModule.innerRadius ?? surfaceSize) / 110; - var alignment = new Vector3(0, 270, 90); - if (cometTailModule.rotationOverride != null) alignment = cometTailModule.rotationOverride; + var controller = cometTail.AddComponent(); - cometTail.transform.rotation = Quaternion.Euler(alignment); + controller.size = (cometTailModule.innerRadius ?? config.Base.surfaceSize) / 110; + + if (cometTailModule.rotationOverride != null) controller.SetRotationOverride(cometTailModule.rotationOverride); + + if (string.IsNullOrEmpty(cometTailModule.primaryBody)) cometTailModule.primaryBody = config.Orbit.primaryBody; + + Delay.FireOnNextUpdate(() => + { + controller.SetPrimaryBody(AstroObjectLocator.GetAstroObject(cometTailModule.primaryBody).transform); + }); cometTail.SetActive(true); } diff --git a/NewHorizons/Builder/Body/ProxyBuilder.cs b/NewHorizons/Builder/Body/ProxyBuilder.cs index 9a48f7c4..1730470c 100644 --- a/NewHorizons/Builder/Body/ProxyBuilder.cs +++ b/NewHorizons/Builder/Body/ProxyBuilder.cs @@ -1,6 +1,7 @@ using NewHorizons.Builder.Atmosphere; using NewHorizons.Builder.Props; using NewHorizons.Components; +using NewHorizons.Components.Props; using NewHorizons.Components.SizeControllers; using NewHorizons.External; using NewHorizons.External.Modules.VariableSize; @@ -196,7 +197,7 @@ namespace NewHorizons.Builder.Body if (body.Config.CometTail != null) { - CometTailBuilder.Make(proxy, null, body.Config.CometTail, body.Config.Base.surfaceSize); + CometTailBuilder.Make(proxy, null, body.Config.CometTail, body.Config); } if (body.Config.Props?.proxyDetails != null) diff --git a/NewHorizons/Builder/Body/RingBuilder.cs b/NewHorizons/Builder/Body/RingBuilder.cs index d727e173..d7e18da0 100644 --- a/NewHorizons/Builder/Body/RingBuilder.cs +++ b/NewHorizons/Builder/Body/RingBuilder.cs @@ -4,6 +4,7 @@ using NewHorizons.Components.Volumes; using NewHorizons.External.Modules; using NewHorizons.Utility; using NewHorizons.Utility.Files; +using NewHorizons.Utility.Geometry; using NewHorizons.Utility.OuterWilds; using NewHorizons.Utility.OWML; using OWML.Common; diff --git a/NewHorizons/Builder/Body/SupernovaEffectBuilder.cs b/NewHorizons/Builder/Body/SupernovaEffectBuilder.cs index edc92b25..32086640 100644 --- a/NewHorizons/Builder/Body/SupernovaEffectBuilder.cs +++ b/NewHorizons/Builder/Body/SupernovaEffectBuilder.cs @@ -1,10 +1,10 @@ using UnityEngine; using NewHorizons.Utility; using NewHorizons.External.Configs; -using NewHorizons.Components; using System.Linq; using OWML.Common; using NewHorizons.Utility.Files; +using NewHorizons.Components.Props; namespace NewHorizons.Builder.Body { diff --git a/NewHorizons/Builder/General/AstroObjectBuilder.cs b/NewHorizons/Builder/General/AstroObjectBuilder.cs index a2777a4c..f51ab71f 100644 --- a/NewHorizons/Builder/General/AstroObjectBuilder.cs +++ b/NewHorizons/Builder/General/AstroObjectBuilder.cs @@ -18,7 +18,7 @@ namespace NewHorizons.Builder.General var type = AstroObject.Type.Planet; if (config.Orbit.isMoon) type = AstroObject.Type.Moon; // else if (config.Base.IsSatellite) type = AstroObject.Type.Satellite; - else if (config.Base.hasCometTail) type = AstroObject.Type.Comet; + else if (config.CometTail != null) type = AstroObject.Type.Comet; else if (config.Star != null) type = AstroObject.Type.Star; else if (config.FocalPoint != null) type = AstroObject.Type.None; astroObject._type = type; diff --git a/NewHorizons/Builder/Props/DialogueBuilder.cs b/NewHorizons/Builder/Props/DialogueBuilder.cs index 03fbc290..d4e849a6 100644 --- a/NewHorizons/Builder/Props/DialogueBuilder.cs +++ b/NewHorizons/Builder/Props/DialogueBuilder.cs @@ -1,4 +1,4 @@ -using NewHorizons.Components; +using NewHorizons.Components.Props; using NewHorizons.External.Modules.Props.Dialogue; using NewHorizons.Handlers; using NewHorizons.Utility; diff --git a/NewHorizons/Builder/Props/TornadoBuilder.cs b/NewHorizons/Builder/Props/TornadoBuilder.cs index 4d1907e4..90987169 100644 --- a/NewHorizons/Builder/Props/TornadoBuilder.cs +++ b/NewHorizons/Builder/Props/TornadoBuilder.cs @@ -1,4 +1,4 @@ -using NewHorizons.Components; +using NewHorizons.Components.Props; using NewHorizons.External.Modules.Props; using NewHorizons.Handlers; using NewHorizons.Utility; diff --git a/NewHorizons/Components/EyeAstroObject.cs b/NewHorizons/Components/EyeOfTheUniverse/EyeAstroObject.cs similarity index 84% rename from NewHorizons/Components/EyeAstroObject.cs rename to NewHorizons/Components/EyeOfTheUniverse/EyeAstroObject.cs index 799617bc..c863d1e5 100644 --- a/NewHorizons/Components/EyeAstroObject.cs +++ b/NewHorizons/Components/EyeOfTheUniverse/EyeAstroObject.cs @@ -1,4 +1,4 @@ -namespace NewHorizons.Components +namespace NewHorizons.Components.EyeOfTheUniverse { public class EyeAstroObject : AstroObject { diff --git a/NewHorizons/Components/EyeSunLightParamUpdater.cs b/NewHorizons/Components/EyeOfTheUniverse/EyeSunLightParamUpdater.cs similarity index 96% rename from NewHorizons/Components/EyeSunLightParamUpdater.cs rename to NewHorizons/Components/EyeOfTheUniverse/EyeSunLightParamUpdater.cs index 0649d90c..92a0ea1a 100644 --- a/NewHorizons/Components/EyeSunLightParamUpdater.cs +++ b/NewHorizons/Components/EyeOfTheUniverse/EyeSunLightParamUpdater.cs @@ -1,4 +1,4 @@ -namespace NewHorizons.Components +namespace NewHorizons.Components.EyeOfTheUniverse { /* public class EyeSunLightParamUpdater : MonoBehaviour diff --git a/NewHorizons/Components/NHProxy.cs b/NewHorizons/Components/NHProxy.cs index 9562678c..9aabe150 100644 --- a/NewHorizons/Components/NHProxy.cs +++ b/NewHorizons/Components/NHProxy.cs @@ -1,3 +1,4 @@ +using NewHorizons.Components.Props; using NewHorizons.Components.SizeControllers; using NewHorizons.Handlers; using NewHorizons.Utility.OuterWilds; diff --git a/NewHorizons/Components/NHCharacterDialogueTree.cs b/NewHorizons/Components/Props/NHCharacterDialogueTree.cs similarity index 67% rename from NewHorizons/Components/NHCharacterDialogueTree.cs rename to NewHorizons/Components/Props/NHCharacterDialogueTree.cs index c68c85f4..f509906b 100644 --- a/NewHorizons/Components/NHCharacterDialogueTree.cs +++ b/NewHorizons/Components/Props/NHCharacterDialogueTree.cs @@ -1,4 +1,4 @@ -namespace NewHorizons.Components +namespace NewHorizons.Components.Props { public class NHCharacterDialogueTree : CharacterDialogueTree { diff --git a/NewHorizons/Components/NHSupernovaPlanetEffectController.cs b/NewHorizons/Components/Props/NHSupernovaPlanetEffectController.cs similarity index 99% rename from NewHorizons/Components/NHSupernovaPlanetEffectController.cs rename to NewHorizons/Components/Props/NHSupernovaPlanetEffectController.cs index 4d9e9b22..df1ebc7b 100644 --- a/NewHorizons/Components/NHSupernovaPlanetEffectController.cs +++ b/NewHorizons/Components/Props/NHSupernovaPlanetEffectController.cs @@ -3,7 +3,7 @@ using NewHorizons.Handlers; using UnityEngine; using static SupernovaPlanetEffectController; -namespace NewHorizons.Components +namespace NewHorizons.Components.Props { public class NHSupernovaPlanetEffectController : MonoBehaviour { diff --git a/NewHorizons/Components/NHTornadoWanderController.cs b/NewHorizons/Components/Props/NHTornadoWanderController.cs similarity index 98% rename from NewHorizons/Components/NHTornadoWanderController.cs rename to NewHorizons/Components/Props/NHTornadoWanderController.cs index 6d8dcd0e..c8af273c 100644 --- a/NewHorizons/Components/NHTornadoWanderController.cs +++ b/NewHorizons/Components/Props/NHTornadoWanderController.cs @@ -1,6 +1,6 @@ using UnityEngine; using Random = UnityEngine.Random; -namespace NewHorizons.Components +namespace NewHorizons.Components.Props { public class NHTornadoWanderController : MonoBehaviour { diff --git a/NewHorizons/Components/BrambleSectorController.cs b/NewHorizons/Components/Sectored/BrambleSectorController.cs similarity index 98% rename from NewHorizons/Components/BrambleSectorController.cs rename to NewHorizons/Components/Sectored/BrambleSectorController.cs index b4c4fd16..3d48e53a 100644 --- a/NewHorizons/Components/BrambleSectorController.cs +++ b/NewHorizons/Components/Sectored/BrambleSectorController.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace NewHorizons.Components +namespace NewHorizons.Components.Sectored { public class BrambleSectorController : MonoBehaviour, ISectorGroup { diff --git a/NewHorizons/Components/CloakSectorController.cs b/NewHorizons/Components/Sectored/CloakSectorController.cs similarity index 99% rename from NewHorizons/Components/CloakSectorController.cs rename to NewHorizons/Components/Sectored/CloakSectorController.cs index 55bc4a88..caf3df97 100644 --- a/NewHorizons/Components/CloakSectorController.cs +++ b/NewHorizons/Components/Sectored/CloakSectorController.cs @@ -1,5 +1,5 @@ using UnityEngine; -namespace NewHorizons.Components +namespace NewHorizons.Components.Sectored { public class CloakSectorController : MonoBehaviour { diff --git a/NewHorizons/Components/CloakedTessSphereSectorToggle.cs b/NewHorizons/Components/Sectored/CloakedTessSphereSectorToggle.cs similarity index 98% rename from NewHorizons/Components/CloakedTessSphereSectorToggle.cs rename to NewHorizons/Components/Sectored/CloakedTessSphereSectorToggle.cs index b5232720..d0d59d4c 100644 --- a/NewHorizons/Components/CloakedTessSphereSectorToggle.cs +++ b/NewHorizons/Components/Sectored/CloakedTessSphereSectorToggle.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace NewHorizons.Components +namespace NewHorizons.Components.Sectored { [RequireComponent(typeof(TessellatedSphereRenderer))] public class CloakedTessSphereSectorToggle : SectoredMonoBehaviour diff --git a/NewHorizons/Components/SizeControllers/CometTailController.cs b/NewHorizons/Components/SizeControllers/CometTailController.cs new file mode 100644 index 00000000..6532cec1 --- /dev/null +++ b/NewHorizons/Components/SizeControllers/CometTailController.cs @@ -0,0 +1,40 @@ +using UnityEngine; + +namespace NewHorizons.Components.SizeControllers +{ + public class CometTailController : SizeController + { + private Transform _primaryBody; + private OWRigidbody _body; + + private bool _hasRotationOverride; + private bool _hasPrimaryBody; + + public void Start() + { + _body = transform.GetAttachedOWRigidbody(); + } + + public override void FixedUpdate() + { + base.FixedUpdate(); + + if (!_hasRotationOverride && _hasPrimaryBody) + { + transform.LookAt(_primaryBody, _body.GetVelocity().normalized); + } + } + + public void SetRotationOverride(Vector3 eulerAngles) + { + _hasRotationOverride = true; + transform.localRotation = Quaternion.Euler(eulerAngles); + } + + public void SetPrimaryBody(Transform primaryBody) + { + _hasPrimaryBody = true; + _primaryBody = primaryBody; + } + } +} diff --git a/NewHorizons/Components/SizeControllers/LavaSizeController.cs b/NewHorizons/Components/SizeControllers/LavaSizeController.cs index 829746f1..6d4f4a9f 100644 --- a/NewHorizons/Components/SizeControllers/LavaSizeController.cs +++ b/NewHorizons/Components/SizeControllers/LavaSizeController.cs @@ -8,7 +8,7 @@ namespace NewHorizons.Components.SizeControllers public Material material; public Material proxyMaterial; - protected new void FixedUpdate() + public override void FixedUpdate() { base.FixedUpdate(); diff --git a/NewHorizons/Components/VesselOrbLocker.cs b/NewHorizons/Components/Vessel/VesselOrbLocker.cs similarity index 97% rename from NewHorizons/Components/VesselOrbLocker.cs rename to NewHorizons/Components/Vessel/VesselOrbLocker.cs index a7343659..a10958fc 100644 --- a/NewHorizons/Components/VesselOrbLocker.cs +++ b/NewHorizons/Components/Vessel/VesselOrbLocker.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace NewHorizons.Components +namespace NewHorizons.Components.Vessel { [UsedInUnityProject] public class VesselOrbLocker : MonoBehaviour diff --git a/NewHorizons/Components/VesselSingularityRoot.cs b/NewHorizons/Components/Vessel/VesselSingularityRoot.cs similarity index 74% rename from NewHorizons/Components/VesselSingularityRoot.cs rename to NewHorizons/Components/Vessel/VesselSingularityRoot.cs index fcfc3fab..dce83f1d 100644 --- a/NewHorizons/Components/VesselSingularityRoot.cs +++ b/NewHorizons/Components/Vessel/VesselSingularityRoot.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace NewHorizons.Components +namespace NewHorizons.Components.Vessel { [UsedInUnityProject] public class VesselSingularityRoot : MonoBehaviour diff --git a/NewHorizons/External/Modules/CometTailModule.cs b/NewHorizons/External/Modules/CometTailModule.cs index 2704ad1e..e2156271 100644 --- a/NewHorizons/External/Modules/CometTailModule.cs +++ b/NewHorizons/External/Modules/CometTailModule.cs @@ -21,5 +21,10 @@ namespace NewHorizons.External.Modules /// Inner radius of the comet tail, defaults to match surfaceSize /// public float? innerRadius; + + /// + /// The body that the comet tail should always point away from + /// + public string primaryBody; } } diff --git a/NewHorizons/Handlers/EyeSceneHandler.cs b/NewHorizons/Handlers/EyeSceneHandler.cs index 15ee0e76..a0c925a9 100644 --- a/NewHorizons/Handlers/EyeSceneHandler.cs +++ b/NewHorizons/Handlers/EyeSceneHandler.cs @@ -1,5 +1,5 @@ using NewHorizons.Builder.General; -using NewHorizons.Components; +using NewHorizons.Components.EyeOfTheUniverse; using NewHorizons.Components.Stars; using NewHorizons.External.SerializableData; using NewHorizons.Utility; diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index 9b7c90f0..414ce9e7 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -601,7 +601,7 @@ namespace NewHorizons.Handlers if (body.Config.CometTail != null) { - CometTailBuilder.Make(go, sector, body.Config.CometTail, body.Config.Base.surfaceSize); + CometTailBuilder.Make(go, sector, body.Config.CometTail, body.Config); } if (body.Config.Lava != null) diff --git a/NewHorizons/Handlers/SupernovaEffectHandler.cs b/NewHorizons/Handlers/SupernovaEffectHandler.cs index de35d181..22483ece 100644 --- a/NewHorizons/Handlers/SupernovaEffectHandler.cs +++ b/NewHorizons/Handlers/SupernovaEffectHandler.cs @@ -1,4 +1,4 @@ -using NewHorizons.Components; +using NewHorizons.Components.Props; using NewHorizons.Components.SizeControllers; using System.Collections.Generic; using UnityEngine; diff --git a/NewHorizons/Handlers/VesselWarpHandler.cs b/NewHorizons/Handlers/VesselWarpHandler.cs index 935c4399..4066b711 100644 --- a/NewHorizons/Handlers/VesselWarpHandler.cs +++ b/NewHorizons/Handlers/VesselWarpHandler.cs @@ -1,11 +1,12 @@ using UnityEngine; -using NewHorizons.Components; using NewHorizons.Utility; using static NewHorizons.Main; using NewHorizons.Builder.Props; using NewHorizons.Utility.OWML; using NewHorizons.Utility.OuterWilds; +using NewHorizons.Components.Vessel; +using NewHorizons.Components.EyeOfTheUniverse; namespace NewHorizons.Handlers { diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 4412aae3..122abee8 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -4,7 +4,6 @@ using NewHorizons.Builder.Body; using NewHorizons.Builder.General; using NewHorizons.Builder.Props; using NewHorizons.Builder.Props.TranslatorText; -using NewHorizons.Components; using NewHorizons.Components.Fixers; using NewHorizons.Components.SizeControllers; using NewHorizons.External; @@ -32,6 +31,7 @@ using UnityEngine.SceneManagement; using NewHorizons.Utility.DebugTools; using NewHorizons.Utility.DebugTools.Menu; +using NewHorizons.Components.Ship; namespace NewHorizons { diff --git a/NewHorizons/Patches/CameraPatches/ProbeCameraPatches.cs b/NewHorizons/Patches/CameraPatches/ProbeCameraPatches.cs index 481c0f30..2b2cf116 100644 --- a/NewHorizons/Patches/CameraPatches/ProbeCameraPatches.cs +++ b/NewHorizons/Patches/CameraPatches/ProbeCameraPatches.cs @@ -1,4 +1,5 @@ using HarmonyLib; +using NewHorizons.Components.Sectored; using NewHorizons.Handlers; namespace NewHorizons.Patches.CameraPatches @@ -10,7 +11,7 @@ namespace NewHorizons.Patches.CameraPatches [HarmonyPatch(nameof(ProbeCamera.HasInterference))] public static void ProbeCamera_HasInterference(ProbeCamera __instance, ref bool __result) { - __result = __result || (__instance._id != ProbeCamera.ID.PreLaunch && (Components.CloakSectorController.isPlayerInside != Components.CloakSectorController.isProbeInside || !InterferenceHandler.IsPlayerSameAsProbe())); + __result = __result || (__instance._id != ProbeCamera.ID.PreLaunch && (CloakSectorController.isPlayerInside != CloakSectorController.isProbeInside || !InterferenceHandler.IsPlayerSameAsProbe())); } } } diff --git a/NewHorizons/Patches/DialoguePatches/CharacterDialogueTreePatches.cs b/NewHorizons/Patches/DialoguePatches/CharacterDialogueTreePatches.cs index 32cab4ad..1ef6c7b3 100644 --- a/NewHorizons/Patches/DialoguePatches/CharacterDialogueTreePatches.cs +++ b/NewHorizons/Patches/DialoguePatches/CharacterDialogueTreePatches.cs @@ -1,7 +1,7 @@ using HarmonyLib; -using NewHorizons.Components; using NewHorizons.OtherMods.AchievementsPlus.NH; using NewHorizons.OtherMods.AchievementsPlus; +using NewHorizons.Components.Props; namespace NewHorizons.Patches.DialoguePatches; diff --git a/NewHorizons/Patches/EchoesOfTheEyePatches/CloakFieldControllerPatches.cs b/NewHorizons/Patches/EchoesOfTheEyePatches/CloakFieldControllerPatches.cs index cdb8736c..7af04378 100644 --- a/NewHorizons/Patches/EchoesOfTheEyePatches/CloakFieldControllerPatches.cs +++ b/NewHorizons/Patches/EchoesOfTheEyePatches/CloakFieldControllerPatches.cs @@ -1,4 +1,5 @@ using HarmonyLib; +using NewHorizons.Components.Sectored; namespace NewHorizons.Patches.EchoesOfTheEyePatches { @@ -16,21 +17,21 @@ namespace NewHorizons.Patches.EchoesOfTheEyePatches [HarmonyPatch(nameof(CloakFieldController.isPlayerInsideCloak), MethodType.Getter)] public static void CloakFieldController_isPlayerInsideCloak(ref bool __result) { - __result = __result || Components.CloakSectorController.isPlayerInside; + __result = __result || CloakSectorController.isPlayerInside; } [HarmonyPostfix] [HarmonyPatch(nameof(CloakFieldController.isProbeInsideCloak), MethodType.Getter)] public static void CloakFieldController_isProbeInsideCloak(ref bool __result) { - __result = __result || Components.CloakSectorController.isProbeInside; + __result = __result || CloakSectorController.isProbeInside; } [HarmonyPostfix] [HarmonyPatch(nameof(CloakFieldController.isShipInsideCloak), MethodType.Getter)] public static void CloakFieldController_isShipInsideCloak(ref bool __result) { - __result = __result || Components.CloakSectorController.isShipInside; + __result = __result || CloakSectorController.isShipInside; } } } diff --git a/NewHorizons/Patches/HUDPatches/ProbeHUDMarkerPatches.cs b/NewHorizons/Patches/HUDPatches/ProbeHUDMarkerPatches.cs index dc464f3c..15da0b12 100644 --- a/NewHorizons/Patches/HUDPatches/ProbeHUDMarkerPatches.cs +++ b/NewHorizons/Patches/HUDPatches/ProbeHUDMarkerPatches.cs @@ -1,4 +1,5 @@ using HarmonyLib; +using NewHorizons.Components.Sectored; using NewHorizons.Handlers; namespace NewHorizons.Patches.HUDPatches @@ -30,7 +31,7 @@ namespace NewHorizons.Patches.HUDPatches bool insideQM = __instance._quantumMoon != null && (__instance._quantumMoon.IsPlayerInside() || __instance._quantumMoon.IsProbeInside()); bool insideRW = Locator.GetRingWorldController() != null && Locator.GetRingWorldController().isPlayerInside == Locator.GetRingWorldController().isProbeInside; bool insideIP = Locator.GetCloakFieldController() != null && Locator.GetCloakFieldController().isPlayerInsideCloak == Locator.GetCloakFieldController().isProbeInsideCloak; - bool insideCloak = Components.CloakSectorController.isPlayerInside == Components.CloakSectorController.isProbeInside; + bool insideCloak = CloakSectorController.isPlayerInside == CloakSectorController.isProbeInside; bool sameInterference = InterferenceHandler.IsPlayerSameAsProbe(); bool isActive = __instance.gameObject.activeInHierarchy || __instance._isTLCDuplicate; diff --git a/NewHorizons/Patches/HUDPatches/ShipHUDMarkerPatches.cs b/NewHorizons/Patches/HUDPatches/ShipHUDMarkerPatches.cs index c44f46dc..c99ae6fe 100644 --- a/NewHorizons/Patches/HUDPatches/ShipHUDMarkerPatches.cs +++ b/NewHorizons/Patches/HUDPatches/ShipHUDMarkerPatches.cs @@ -1,4 +1,5 @@ using HarmonyLib; +using NewHorizons.Components.Sectored; using NewHorizons.Handlers; namespace NewHorizons.Patches.HUDPatches @@ -14,7 +15,7 @@ namespace NewHorizons.Patches.HUDPatches bool insideQM = __instance._quantumMoon != null && (__instance._quantumMoon.IsPlayerInside() || __instance._quantumMoon.IsShipInside()); bool insideRW = Locator.GetRingWorldController() != null && Locator.GetRingWorldController().isPlayerInside; bool insideIP = Locator.GetCloakFieldController() != null && Locator.GetCloakFieldController().isPlayerInsideCloak == Locator.GetCloakFieldController().isShipInsideCloak; - bool insideCloak = Components.CloakSectorController.isPlayerInside == Components.CloakSectorController.isShipInside; + bool insideCloak = CloakSectorController.isPlayerInside == CloakSectorController.isShipInside; bool sameInterference = InterferenceHandler.IsPlayerSameAsShip(); __instance._isVisible = !insideEYE && !insideQM && !insideRW && !__instance._translatorEquipped && !__instance._inConversation && !__instance._shipDestroyed && !__instance._playerInShip && PlayerState.HasPlayerEnteredShip() && __instance._isWearingHelmet && insideIP && insideCloak && sameInterference; diff --git a/NewHorizons/Patches/HUDPatches/ShipLogEntryHUDMarkerPatches.cs b/NewHorizons/Patches/HUDPatches/ShipLogEntryHUDMarkerPatches.cs index 75800339..4860bee5 100644 --- a/NewHorizons/Patches/HUDPatches/ShipLogEntryHUDMarkerPatches.cs +++ b/NewHorizons/Patches/HUDPatches/ShipLogEntryHUDMarkerPatches.cs @@ -1,4 +1,5 @@ using HarmonyLib; +using NewHorizons.Components.Sectored; namespace NewHorizons.Patches.HUDPatches { @@ -14,7 +15,7 @@ namespace NewHorizons.Patches.HUDPatches bool insideQM = __instance._quantumMoon != null && __instance._quantumMoon.IsPlayerInside(); bool insideRW = Locator.GetRingWorldController() != null && Locator.GetRingWorldController().isPlayerInside && ShipLogEntryHUDMarker.s_entryLocationID == "IP_RING_WORLD"; bool insideIP = hasEntryLocation && ShipLogEntryHUDMarker.s_entryLocation.IsWithinCloakField() || !(Locator.GetCloakFieldController() != null && Locator.GetCloakFieldController().isPlayerInsideCloak); - bool insideCloak = hasEntryLocation && ShipLogEntryHUDMarker.s_entryLocation.IsWithinCloakField() || !Components.CloakSectorController.isPlayerInside; + bool insideCloak = hasEntryLocation && ShipLogEntryHUDMarker.s_entryLocation.IsWithinCloakField() || !CloakSectorController.isPlayerInside; __instance._isVisible = !insideEYE && !insideQM && !insideRW && !__instance._translatorEquipped && !__instance._inConversation && hasEntryLocation && (__instance._isWearingHelmet || __instance._atFlightConsole) && insideIP && insideCloak; diff --git a/NewHorizons/Components/RingShape.cs b/NewHorizons/Utility/Geometry/RingShape.cs similarity index 97% rename from NewHorizons/Components/RingShape.cs rename to NewHorizons/Utility/Geometry/RingShape.cs index e8d30478..85f36519 100644 --- a/NewHorizons/Components/RingShape.cs +++ b/NewHorizons/Utility/Geometry/RingShape.cs @@ -1,6 +1,7 @@ -using System.Collections.Generic; +using System.Collections.Generic; using UnityEngine; -namespace NewHorizons.Components + +namespace NewHorizons.Utility.Geometry { public class RingShape : Shape { @@ -185,7 +186,7 @@ namespace NewHorizons.Components public override bool PointInside(Vector3 point) { - return (!_innerCylinderShape.PointInside(point) && _outerCylinderShape.PointInside(point)); + return !_innerCylinderShape.PointInside(point) && _outerCylinderShape.PointInside(point); } private List _shapesInInner = new List(); From 8bb2138c0d76972f8e854663fd46c679cddf439e Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 25 Mar 2023 22:11:23 -0400 Subject: [PATCH 04/19] Move ship warp controller also --- .../Components/{ => Ship}/ShipWarpController.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename NewHorizons/Components/{ => Ship}/ShipWarpController.cs (95%) diff --git a/NewHorizons/Components/ShipWarpController.cs b/NewHorizons/Components/Ship/ShipWarpController.cs similarity index 95% rename from NewHorizons/Components/ShipWarpController.cs rename to NewHorizons/Components/Ship/ShipWarpController.cs index 3f4029c1..3d951631 100644 --- a/NewHorizons/Components/ShipWarpController.cs +++ b/NewHorizons/Components/Ship/ShipWarpController.cs @@ -3,7 +3,7 @@ using NewHorizons.Utility; using NewHorizons.Utility.OWML; using UnityEngine; -namespace NewHorizons.Components +namespace NewHorizons.Components.Ship { public class ShipWarpController : MonoBehaviour { @@ -65,7 +65,7 @@ namespace NewHorizons.Components if (blackHoleShader == null) blackHoleShader = _blackHolePrefab.GetComponent().sharedMaterial.shader; var blackHoleRender = new GameObject("BlackHoleRender"); - blackHoleRender.transform.parent = base.transform; + blackHoleRender.transform.parent = transform; blackHoleRender.transform.localPosition = new Vector3(0, 1, 0); blackHoleRender.transform.localScale = Vector3.one * size; @@ -92,7 +92,7 @@ namespace NewHorizons.Components if (whiteHoleShader == null) whiteHoleShader = _whiteHolePrefab.GetComponent().sharedMaterial.shader; var whiteHoleRenderer = new GameObject("WhiteHoleRenderer"); - whiteHoleRenderer.transform.parent = base.transform; + whiteHoleRenderer.transform.parent = transform; whiteHoleRenderer.transform.localPosition = new Vector3(0, 1, 0); whiteHoleRenderer.transform.localScale = Vector3.one * size * 2.8f; @@ -126,7 +126,7 @@ namespace NewHorizons.Components public void WarpOut() { NHLogger.LogVerbose("Starting warp-out"); - _oneShotSource.PlayOneShot(global::AudioType.VesselSingularityCreate, 1f); + _oneShotSource.PlayOneShot(AudioType.VesselSingularityCreate, 1f); _blackhole.Create(); } @@ -165,7 +165,7 @@ namespace NewHorizons.Components private void StartWarpInEffect() { NHLogger.LogVerbose("Starting warp-in effect"); - _oneShotSource.PlayOneShot(global::AudioType.VesselSingularityCollapse, 1f); + _oneShotSource.PlayOneShot(AudioType.VesselSingularityCollapse, 1f); Locator.GetDeathManager()._invincible = true; if (Main.Instance.CurrentStarSystem.Equals("SolarSystem")) TeleportToShip(); _whitehole.Create(); @@ -178,7 +178,7 @@ namespace NewHorizons.Components private void TeleportToShip() { - var playerSpawner = GameObject.FindObjectOfType(); + var playerSpawner = FindObjectOfType(); playerSpawner.DebugWarp(playerSpawner.GetSpawnPoint(SpawnLocation.Ship)); } From e3d684a1cb0a0374c5a8e0650d369ad62dc34fdc Mon Sep 17 00:00:00 2001 From: Ben C Date: Sun, 26 Mar 2023 02:14:38 +0000 Subject: [PATCH 05/19] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index e884e8da..31418a8f 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -4267,6 +4267,10 @@ ], "description": "Inner radius of the comet tail, defaults to match surfaceSize", "format": "float" + }, + "primaryBody": { + "type": "string", + "description": "The body that the comet tail should always point away from" } } } From 2d54076a6702ae0a8d87884fe8234e6abc3e858a Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 25 Mar 2023 22:35:46 -0400 Subject: [PATCH 06/19] Have comet face away from primary body --- NewHorizons/Builder/Body/CometTailBuilder.cs | 21 ++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/NewHorizons/Builder/Body/CometTailBuilder.cs b/NewHorizons/Builder/Body/CometTailBuilder.cs index 1f3d80ab..99346771 100644 --- a/NewHorizons/Builder/Body/CometTailBuilder.cs +++ b/NewHorizons/Builder/Body/CometTailBuilder.cs @@ -14,16 +14,25 @@ namespace NewHorizons.Builder.Body internal static void InitPrefab() { - if (_tailPrefab == null) _tailPrefab = SearchUtilities.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes").InstantiateInactive().Rename("Prefab_CO_Tail").DontDestroyOnLoad(); + if (_tailPrefab == null) + { + _tailPrefab = SearchUtilities.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes").InstantiateInactive().Rename("Prefab_CO_Tail").DontDestroyOnLoad(); + } } public static void Make(GameObject planetGO, Sector sector, CometTailModule cometTailModule, PlanetConfig config) { - var cometTail = GameObject.Instantiate(_tailPrefab, sector?.transform ?? planetGO.transform); - cometTail.transform.position = planetGO.transform.position; - cometTail.name = "CometTail"; + var rootObj = new GameObject("CometRoot"); + rootObj.SetActive(false); + rootObj.transform.parent = sector?.transform ?? planetGO.transform; + rootObj.transform.localPosition = Vector3.zero; - var controller = cometTail.AddComponent(); + var cometTail = GameObject.Instantiate(_tailPrefab, rootObj.transform).Rename("CometTail"); + cometTail.transform.localPosition = Vector3.zero; + cometTail.transform.localRotation = Quaternion.Euler(90, 90, 0); + cometTail.SetActive(true); + + var controller = rootObj.AddComponent(); controller.size = (cometTailModule.innerRadius ?? config.Base.surfaceSize) / 110; @@ -36,7 +45,7 @@ namespace NewHorizons.Builder.Body controller.SetPrimaryBody(AstroObjectLocator.GetAstroObject(cometTailModule.primaryBody).transform); }); - cometTail.SetActive(true); + rootObj.SetActive(true); } } } From 52e1971568afd495254286275715db8a1816a593 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 25 Mar 2023 22:42:25 -0400 Subject: [PATCH 07/19] Add scale curve to comet --- NewHorizons/Builder/Body/CometTailBuilder.cs | 2 ++ NewHorizons/External/Modules/CometTailModule.cs | 9 ++------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/NewHorizons/Builder/Body/CometTailBuilder.cs b/NewHorizons/Builder/Body/CometTailBuilder.cs index 99346771..b3d25e7b 100644 --- a/NewHorizons/Builder/Body/CometTailBuilder.cs +++ b/NewHorizons/Builder/Body/CometTailBuilder.cs @@ -45,6 +45,8 @@ namespace NewHorizons.Builder.Body controller.SetPrimaryBody(AstroObjectLocator.GetAstroObject(cometTailModule.primaryBody).transform); }); + controller.SetScaleCurve(cometTailModule.curve); + rootObj.SetActive(true); } } diff --git a/NewHorizons/External/Modules/CometTailModule.cs b/NewHorizons/External/Modules/CometTailModule.cs index e2156271..b74c88f3 100644 --- a/NewHorizons/External/Modules/CometTailModule.cs +++ b/NewHorizons/External/Modules/CometTailModule.cs @@ -1,16 +1,11 @@ +using NewHorizons.External.Modules.VariableSize; using NewHorizons.External.SerializableData; using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace NewHorizons.External.Modules { [JsonObject] - public class CometTailModule + public class CometTailModule : VariableSizeModule { /// /// Manually sets the local rotation From d63b3fed2572cc00eacc0481facefbcfea3ff9e8 Mon Sep 17 00:00:00 2001 From: Ben C Date: Sun, 26 Mar 2023 02:45:12 +0000 Subject: [PATCH 08/19] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 31418a8f..4cf8507b 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -4256,6 +4256,13 @@ "type": "object", "additionalProperties": false, "properties": { + "curve": { + "type": "array", + "description": "Scale this object over time", + "items": { + "$ref": "#/definitions/TimeValuePair" + } + }, "rotationOverride": { "description": "Manually sets the local rotation", "$ref": "#/definitions/MVector3" From d81dde6ea068cd92c5f44167cf8c48691f3058f3 Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 26 Mar 2023 00:19:36 -0400 Subject: [PATCH 09/19] Try and fail to make the tails move right --- NewHorizons/Builder/Body/CometTailBuilder.cs | 64 ++++++++++++++++--- .../SizeControllers/CometTailController.cs | 33 +++++++++- .../SizeControllers/SizeController.cs | 2 + NewHorizons/Utility/NewHorizonExtensions.cs | 10 +++ NewHorizons/Utility/OWML/NHLogger.cs | 10 +-- 5 files changed, 104 insertions(+), 15 deletions(-) diff --git a/NewHorizons/Builder/Body/CometTailBuilder.cs b/NewHorizons/Builder/Body/CometTailBuilder.cs index b3d25e7b..4d8e719f 100644 --- a/NewHorizons/Builder/Body/CometTailBuilder.cs +++ b/NewHorizons/Builder/Body/CometTailBuilder.cs @@ -10,14 +10,53 @@ namespace NewHorizons.Builder.Body { public static class CometTailBuilder { - private static GameObject _tailPrefab; + private static GameObject _dustPrefab; + private static GameObject _gasPrefab; internal static void InitPrefab() { - if (_tailPrefab == null) + if (_dustPrefab == null) { - _tailPrefab = SearchUtilities.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes").InstantiateInactive().Rename("Prefab_CO_Tail").DontDestroyOnLoad(); - } + _dustPrefab = new GameObject("Prefab_CO_Dust").DontDestroyOnLoad(); + + var dust1 = SearchUtilities.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes/Effects_CO_DustTail").Instantiate(); + dust1.transform.parent = _dustPrefab.transform; + dust1.transform.localPosition = Vector3.zero; + dust1.transform.localRotation = Quaternion.Euler(0, 270, 0); + + var dust2 = SearchUtilities.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes/Effects_CO_DustTail (1)").Instantiate(); + dust2.transform.parent = _dustPrefab.transform; + dust2.transform.localPosition = Vector3.zero; + dust2.transform.localRotation = Quaternion.Euler(0, 270, 0); + + var dust3 = SearchUtilities.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes/Effects_CO_DustTail (2)").Instantiate(); + dust3.transform.parent = _dustPrefab.transform; + dust3.transform.localPosition = Vector3.zero; + dust3.transform.localRotation = Quaternion.Euler(0, 270, 0); + + _dustPrefab.SetActive(false); + } + if (_gasPrefab == null) + { + _gasPrefab = new GameObject("Prefab_CO_Gas").DontDestroyOnLoad(); + + var gas1 = SearchUtilities.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes/Effects_CO_GasTail").Instantiate(); + gas1.transform.parent = _gasPrefab.transform; + gas1.transform.localPosition = Vector3.zero; + gas1.transform.localRotation = Quaternion.Euler(0, 270, 0); + + var gas2 = SearchUtilities.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes/Effects_CO_GasTail (1)").Instantiate(); + gas2.transform.parent = _gasPrefab.transform; + gas2.transform.localPosition = Vector3.zero; + gas2.transform.localRotation = Quaternion.Euler(0, 270, 0); + + var gas3 = SearchUtilities.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes/Effects_CO_GasTail (2)").Instantiate(); + gas3.transform.parent = _gasPrefab.transform; + gas3.transform.localPosition = Vector3.zero; + gas3.transform.localRotation = Quaternion.Euler(0, 270, 0); + + _gasPrefab.SetActive(false); + } } public static void Make(GameObject planetGO, Sector sector, CometTailModule cometTailModule, PlanetConfig config) @@ -27,11 +66,6 @@ namespace NewHorizons.Builder.Body rootObj.transform.parent = sector?.transform ?? planetGO.transform; rootObj.transform.localPosition = Vector3.zero; - var cometTail = GameObject.Instantiate(_tailPrefab, rootObj.transform).Rename("CometTail"); - cometTail.transform.localPosition = Vector3.zero; - cometTail.transform.localRotation = Quaternion.Euler(90, 90, 0); - cometTail.SetActive(true); - var controller = rootObj.AddComponent(); controller.size = (cometTailModule.innerRadius ?? config.Base.surfaceSize) / 110; @@ -47,6 +81,18 @@ namespace NewHorizons.Builder.Body controller.SetScaleCurve(cometTailModule.curve); + var dustTail = GameObject.Instantiate(_dustPrefab, rootObj.transform).Rename("DustTail"); + dustTail.transform.localPosition = Vector3.zero; + dustTail.transform.localRotation = Quaternion.Euler(90, 90, 0); + dustTail.SetActive(true); + controller.dustTail = dustTail; + + var gasTail = GameObject.Instantiate(_gasPrefab, rootObj.transform).Rename("GasTail"); + gasTail.transform.localPosition = Vector3.zero; + gasTail.transform.localRotation = Quaternion.Euler(90, 90, 0); + gasTail.SetActive(true); + controller.gasTail = gasTail; + rootObj.SetActive(true); } } diff --git a/NewHorizons/Components/SizeControllers/CometTailController.cs b/NewHorizons/Components/SizeControllers/CometTailController.cs index 6532cec1..b3bef490 100644 --- a/NewHorizons/Components/SizeControllers/CometTailController.cs +++ b/NewHorizons/Components/SizeControllers/CometTailController.cs @@ -1,3 +1,5 @@ +using NewHorizons.Utility; +using NewHorizons.Utility.OWML; using UnityEngine; namespace NewHorizons.Components.SizeControllers @@ -10,9 +12,24 @@ namespace NewHorizons.Components.SizeControllers private bool _hasRotationOverride; private bool _hasPrimaryBody; + public GameObject gasTail; + public GameObject dustTail; + + private Vector3 _gasTarget; + private Vector3 _dustTarget; + + private float _angularVelocity = 1f; + public void Start() { _body = transform.GetAttachedOWRigidbody(); + + if (!_hasRotationOverride && _hasPrimaryBody) + { + UpdateTargetPositions(); + dustTail?.transform?.LookAt(_dustTarget); + gasTail?.transform?.LookAt(_gasTarget); + } } public override void FixedUpdate() @@ -21,10 +38,24 @@ namespace NewHorizons.Components.SizeControllers if (!_hasRotationOverride && _hasPrimaryBody) { - transform.LookAt(_primaryBody, _body.GetVelocity().normalized); + UpdateTargetPositions(); + + dustTail?.SmoothLookAt(_dustTarget, Time.deltaTime, _angularVelocity); + gasTail?.SmoothLookAt(_gasTarget, Time.deltaTime, _angularVelocity); } } + private void UpdateTargetPositions() + { + var toPrimary = (_body.transform.position - _primaryBody.transform.position).normalized; + var velocityDirection = -_body.GetVelocity(); // Accept that this is flipped ok + + var tangentVel = Vector3.ProjectOnPlane(velocityDirection, toPrimary) / velocityDirection.magnitude; + + _gasTarget = toPrimary; + _dustTarget = (toPrimary + tangentVel).normalized; + } + public void SetRotationOverride(Vector3 eulerAngles) { _hasRotationOverride = true; diff --git a/NewHorizons/Components/SizeControllers/SizeController.cs b/NewHorizons/Components/SizeControllers/SizeController.cs index 4e645f56..a0c15f01 100644 --- a/NewHorizons/Components/SizeControllers/SizeController.cs +++ b/NewHorizons/Components/SizeControllers/SizeController.cs @@ -71,6 +71,8 @@ namespace NewHorizons.Components.SizeControllers public void SetScaleCurve(TimeValuePair[] curve) { + if (curve == null) return; + scaleCurve = new AnimationCurve(); foreach (var pair in curve) { diff --git a/NewHorizons/Utility/NewHorizonExtensions.cs b/NewHorizons/Utility/NewHorizonExtensions.cs index 9321e804..d20be830 100644 --- a/NewHorizons/Utility/NewHorizonExtensions.cs +++ b/NewHorizons/Utility/NewHorizonExtensions.cs @@ -255,5 +255,15 @@ namespace NewHorizons.Utility } public static FluidVolume.Type ConvertToOW(this NHFluidType fluidType, FluidVolume.Type @default = FluidVolume.Type.NONE) => EnumUtils.Parse(fluidType.ToString().ToUpper(), @default); + + public static void SmoothLookAt(this GameObject go, Vector3 direction, float dt, float angularVelocity) + { + var start = go.transform.rotation; + var end = Quaternion.FromToRotation(Vector3.forward, direction); + + var angle = Quaternion.Angle(start, end); + + go.transform.rotation = Quaternion.Slerp(start, end, angularVelocity / angle * dt * dt); + } } } diff --git a/NewHorizons/Utility/OWML/NHLogger.cs b/NewHorizons/Utility/OWML/NHLogger.cs index ea53aec6..080cdcad 100644 --- a/NewHorizons/Utility/OWML/NHLogger.cs +++ b/NewHorizons/Utility/OWML/NHLogger.cs @@ -13,16 +13,16 @@ namespace NewHorizons.Utility.OWML _logLevel = newLevel; } - private static void Log(string text, LogType type) + private static void Log(object 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 static void LogVerbose(object text) => Log(text, LogType.Verbose); + public static void Log(object text) => Log(text, LogType.Log); + public static void LogWarning(object text) => Log(text, LogType.Warning); + public static void LogError(object text) => Log(text, LogType.Error); public enum LogType { From 944ba3fde31c769d2ae776430491a070d4cc0c40 Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 26 Mar 2023 00:56:26 -0400 Subject: [PATCH 10/19] Add colours and fix orientation --- .../Assets/textures/Effects_CO_GasTail_d.png | Bin 0 -> 254 bytes NewHorizons/Builder/Body/CometTailBuilder.cs | 20 ++++++++++++++++++ .../SizeControllers/CometTailController.cs | 13 ++---------- .../External/Modules/CometTailModule.cs | 10 +++++++++ NewHorizons/Utility/NewHorizonExtensions.cs | 9 ++++++-- 5 files changed, 39 insertions(+), 13 deletions(-) create mode 100644 NewHorizons/Assets/textures/Effects_CO_GasTail_d.png diff --git a/NewHorizons/Assets/textures/Effects_CO_GasTail_d.png b/NewHorizons/Assets/textures/Effects_CO_GasTail_d.png new file mode 100644 index 0000000000000000000000000000000000000000..00859b6c4f6e4f91b1c86b785daa60506c258dba GIT binary patch literal 254 zcmeAS@N?(olHy`uVBq!ia0vp^j6m$b!3HF63(7ix1d4;)ofy`glX(f`u%tWsIx;Y9 z?C1WI$O`0h7I;J!GcfQS24TkI`72U@f|EU6978mM=bk;ucUXakCBQ^LBlYM1^F2*d z1WpC1t(;O_TOoD&SVwB4%91H;#(NiRt#j6V+OdD;K+ zs?E~yJ80t3YWS>W>$jF-y~EY}C$~r>J8>u$ZYa!uDzBZkRw6kjM`hvGZHvF}GoHI* xtJpGrFU_eXmnIa;S@b=2EXa2_^NU+?-;33Lg1eS@NdTS4;OXk;vd$@?2>{yCUDp5r literal 0 HcmV?d00001 diff --git a/NewHorizons/Builder/Body/CometTailBuilder.cs b/NewHorizons/Builder/Body/CometTailBuilder.cs index 4d8e719f..cdc691f5 100644 --- a/NewHorizons/Builder/Body/CometTailBuilder.cs +++ b/NewHorizons/Builder/Body/CometTailBuilder.cs @@ -2,6 +2,7 @@ using NewHorizons.Components.SizeControllers; using NewHorizons.External.Configs; using NewHorizons.External.Modules; using NewHorizons.Utility; +using NewHorizons.Utility.Files; using NewHorizons.Utility.OuterWilds; using NewHorizons.Utility.OWML; using UnityEngine; @@ -93,6 +94,25 @@ namespace NewHorizons.Builder.Body gasTail.SetActive(true); controller.gasTail = gasTail; + if (cometTailModule.dustTint != null) + { + foreach (var dust in dustTail.GetComponentsInChildren()) + { + var untintedDust = ImageUtilities.GetTexture(Main.Instance, "Assets/textures/Effects_CO_DustTail_d.png"); + dust.material.mainTexture = ImageUtilities.TintImage(untintedDust, cometTailModule.dustTint.ToColor()); + } + } + + if (cometTailModule.gasTint != null) + { + foreach (var gas in gasTail.GetComponentsInChildren()) + { + var untintedGas = ImageUtilities.GetTexture(Main.Instance, "Assets/textures/Effects_CO_GasTail_d.png"); + gas.material.mainTexture = untintedGas; + gas.material.color = cometTailModule.gasTint.ToColor(); + } + } + rootObj.SetActive(true); } } diff --git a/NewHorizons/Components/SizeControllers/CometTailController.cs b/NewHorizons/Components/SizeControllers/CometTailController.cs index b3bef490..b108d76e 100644 --- a/NewHorizons/Components/SizeControllers/CometTailController.cs +++ b/NewHorizons/Components/SizeControllers/CometTailController.cs @@ -18,18 +18,9 @@ namespace NewHorizons.Components.SizeControllers private Vector3 _gasTarget; private Vector3 _dustTarget; - private float _angularVelocity = 1f; - public void Start() { _body = transform.GetAttachedOWRigidbody(); - - if (!_hasRotationOverride && _hasPrimaryBody) - { - UpdateTargetPositions(); - dustTail?.transform?.LookAt(_dustTarget); - gasTail?.transform?.LookAt(_gasTarget); - } } public override void FixedUpdate() @@ -40,8 +31,8 @@ namespace NewHorizons.Components.SizeControllers { UpdateTargetPositions(); - dustTail?.SmoothLookAt(_dustTarget, Time.deltaTime, _angularVelocity); - gasTail?.SmoothLookAt(_gasTarget, Time.deltaTime, _angularVelocity); + dustTail?.LookDir(_dustTarget); + gasTail?.LookDir(_gasTarget); } } diff --git a/NewHorizons/External/Modules/CometTailModule.cs b/NewHorizons/External/Modules/CometTailModule.cs index b74c88f3..2750ba36 100644 --- a/NewHorizons/External/Modules/CometTailModule.cs +++ b/NewHorizons/External/Modules/CometTailModule.cs @@ -21,5 +21,15 @@ namespace NewHorizons.External.Modules /// The body that the comet tail should always point away from /// public string primaryBody; + + /// + /// Colour of the dust tail (the shorter part) + /// + public MColor dustTint; + + /// + /// Colour of the gas tail (the longer part) + /// + public MColor gasTint; } } diff --git a/NewHorizons/Utility/NewHorizonExtensions.cs b/NewHorizons/Utility/NewHorizonExtensions.cs index d20be830..275e6f52 100644 --- a/NewHorizons/Utility/NewHorizonExtensions.cs +++ b/NewHorizons/Utility/NewHorizonExtensions.cs @@ -256,14 +256,19 @@ namespace NewHorizons.Utility public static FluidVolume.Type ConvertToOW(this NHFluidType fluidType, FluidVolume.Type @default = FluidVolume.Type.NONE) => EnumUtils.Parse(fluidType.ToString().ToUpper(), @default); - public static void SmoothLookAt(this GameObject go, Vector3 direction, float dt, float angularVelocity) + public static void SmoothLookDir(this GameObject go, Vector3 direction, float dt, float angularVelocity) { var start = go.transform.rotation; var end = Quaternion.FromToRotation(Vector3.forward, direction); var angle = Quaternion.Angle(start, end); - go.transform.rotation = Quaternion.Slerp(start, end, angularVelocity / angle * dt * dt); + go.transform.rotation = Quaternion.Slerp(start, end, (angularVelocity / angle) * dt); + } + + public static void LookDir(this GameObject go, Vector3 direction) + { + go.transform.rotation = Quaternion.FromToRotation(Vector3.forward, direction); } } } From d97ca4fea9cf5fc797ff0402857c519eb54a9048 Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 26 Mar 2023 00:56:33 -0400 Subject: [PATCH 11/19] Create Effects_CO_DustTail_d.png --- .../Assets/textures/Effects_CO_DustTail_d.png | Bin 0 -> 249 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 NewHorizons/Assets/textures/Effects_CO_DustTail_d.png diff --git a/NewHorizons/Assets/textures/Effects_CO_DustTail_d.png b/NewHorizons/Assets/textures/Effects_CO_DustTail_d.png new file mode 100644 index 0000000000000000000000000000000000000000..747d0e483da5611d9d0afd735bca9ecaa05028d1 GIT binary patch literal 249 zcmeAS@N?(olHy`uVBq!ia0vp^j6m$b!3HF63(7ix1d4;)ofy`glX(f`u%tWsIx;Y9 z?C1WI$O`0h7I;J!GcfQS24TkI`72U@f_Yv4OZ{Jf`y2n{_=}FdzKFPp??eK`}SZd<*+c*Atr{BpUPug-#= z4qV|%TdwgPHn8Y4~9f63O=joMJSWp6M{u^Uz$&uE^qUv*$bG?QO1; qJe!Kw#ca67^<)nB|IYmakC+22y)`4heEAD>8H1;*pUXO@geCyVJ60qB literal 0 HcmV?d00001 From 8606b8a5b6b298d780925882134403c14eee67fd Mon Sep 17 00:00:00 2001 From: Ben C Date: Sun, 26 Mar 2023 05:00:20 +0000 Subject: [PATCH 12/19] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 4cf8507b..39452dfe 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -4278,6 +4278,14 @@ "primaryBody": { "type": "string", "description": "The body that the comet tail should always point away from" + }, + "dustTint": { + "description": "Colour of the dust tail (the shorter part)", + "$ref": "#/definitions/MColor" + }, + "gasTint": { + "description": "Colour of the gas tail (the longer part)", + "$ref": "#/definitions/MColor" } } } From 161bbd1dcb3212bca209d0cee2df32c896a219b2 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Sat, 22 Apr 2023 15:15:21 -0400 Subject: [PATCH 13/19] Add teenager arc type --- NewHorizons/Builder/Props/NomaiTextBuilder.cs | 11 +++++++++++ .../Props/TranslatorText/TranslatorTextBuilder.cs | 4 ++++ .../Modules/Props/TranslatorText/NomaiTextArcInfo.cs | 4 +++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Builder/Props/NomaiTextBuilder.cs b/NewHorizons/Builder/Props/NomaiTextBuilder.cs index 193acf96..afed4b3f 100644 --- a/NewHorizons/Builder/Props/NomaiTextBuilder.cs +++ b/NewHorizons/Builder/Props/NomaiTextBuilder.cs @@ -24,6 +24,7 @@ namespace NewHorizons.Builder.Props { private static List _arcPrefabs; private static List _childArcPrefabs; + private static GameObject _teenagerArcPrefab; private static List _ghostArcPrefabs; private static GameObject _scrollPrefab; private static GameObject _computerPrefab; @@ -52,6 +53,7 @@ namespace NewHorizons.Builder.Props public static List GetArcPrefabs() { return _arcPrefabs; } public static List GetChildArcPrefabs() { return _childArcPrefabs; } + public static GameObject GetTeenagerArcPrefab() { return _teenagerArcPrefab; } public static List GetGhostArcPrefabs() { return _ghostArcPrefabs; } private static bool _isInit; @@ -85,6 +87,12 @@ namespace NewHorizons.Builder.Props } } + if (_teenagerArcPrefab == null) + { + _teenagerArcPrefab = GameObject.FindObjectsOfType().FirstOrDefault(x => x.name.Equals("Arc_GD_StatueIsland_WindowNote")) + ?.gameObject?.transform?.Find("Arc 1")?.gameObject.InstantiateInactive().Rename("Arc (Teenager)").DontDestroyOnLoad(); + } + if (_ghostArcPrefabs == null) { var existingGhostArcs = GameObject.FindObjectsOfType() @@ -667,6 +675,9 @@ namespace NewHorizons.Builder.Props : (variation % _childArcPrefabs.Count()); arc = _childArcPrefabs[variation].InstantiateInactive(); break; + case NomaiTextArcInfo.NomaiTextArcType.Teenager: + arc = _teenagerArcPrefab.InstantiateInactive(); + break; case NomaiTextArcInfo.NomaiTextArcType.Stranger when _ghostArcPrefabs.Any(): variation = variation < 0 ? Random.Range(0, _ghostArcPrefabs.Count()) diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index aeaa9878..2b63a692 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -565,6 +565,10 @@ namespace NewHorizons.Builder.Props.TranslatorText profile = NomaiTextArcBuilder.childSpiralProfile; mat = _childArcMaterial; break; + case NomaiTextArcInfo.NomaiTextArcType.Teenager: + profile = NomaiTextArcBuilder.adultSpiralProfile; + mat = _childArcMaterial; + break; case NomaiTextArcInfo.NomaiTextArcType.Stranger when _ghostArcMaterial != null: profile = NomaiTextArcBuilder.strangerSpiralProfile; mat = _ghostArcMaterial; diff --git a/NewHorizons/External/Modules/Props/TranslatorText/NomaiTextArcInfo.cs b/NewHorizons/External/Modules/Props/TranslatorText/NomaiTextArcInfo.cs index 5616d003..aa8ab516 100644 --- a/NewHorizons/External/Modules/Props/TranslatorText/NomaiTextArcInfo.cs +++ b/NewHorizons/External/Modules/Props/TranslatorText/NomaiTextArcInfo.cs @@ -19,7 +19,9 @@ namespace NewHorizons.External.Modules.TranslatorText [EnumMember(Value = @"child")] Child = 1, - [EnumMember(Value = @"stranger")] Stranger = 2 + [EnumMember(Value = @"stranger")] Stranger = 2, + + [EnumMember(Value = @"teenager")] Teenager = 3 } /// From 7e3a8154602cf30e62575c6228ebabc0ceaeab64 Mon Sep 17 00:00:00 2001 From: Ben C Date: Sat, 22 Apr 2023 19:23:18 +0000 Subject: [PATCH 14/19] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 2e17f844..6e6e8f1b 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -1516,12 +1516,14 @@ "x-enumNames": [ "Adult", "Child", - "Stranger" + "Stranger", + "Teenager" ], "enum": [ "adult", "child", - "stranger" + "stranger", + "teenager" ] }, "MVector2": { From 2ad9784b34d2a3ff98383702a3135760da01f266 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 22 Apr 2023 15:51:36 -0400 Subject: [PATCH 15/19] Fix primary body stuff --- NewHorizons/Builder/Body/CometTailBuilder.cs | 11 ++++++++++- .../Components/SizeControllers/CometTailController.cs | 10 ++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/NewHorizons/Builder/Body/CometTailBuilder.cs b/NewHorizons/Builder/Body/CometTailBuilder.cs index cdc691f5..53883948 100644 --- a/NewHorizons/Builder/Body/CometTailBuilder.cs +++ b/NewHorizons/Builder/Body/CometTailBuilder.cs @@ -62,6 +62,12 @@ namespace NewHorizons.Builder.Body public static void Make(GameObject planetGO, Sector sector, CometTailModule cometTailModule, PlanetConfig config) { + if (config.Orbit.primaryBody == null) + { + NHLogger.LogError($"Comet {planetGO.name} does not orbit anything. That makes no sense"); + return; + } + var rootObj = new GameObject("CometRoot"); rootObj.SetActive(false); rootObj.transform.parent = sector?.transform ?? planetGO.transform; @@ -77,7 +83,10 @@ namespace NewHorizons.Builder.Body Delay.FireOnNextUpdate(() => { - controller.SetPrimaryBody(AstroObjectLocator.GetAstroObject(cometTailModule.primaryBody).transform); + controller.SetPrimaryBody( + AstroObjectLocator.GetAstroObject(cometTailModule.primaryBody).transform, + AstroObjectLocator.GetAstroObject(config.Orbit.primaryBody).GetAttachedOWRigidbody() + ); }); controller.SetScaleCurve(cometTailModule.curve); diff --git a/NewHorizons/Components/SizeControllers/CometTailController.cs b/NewHorizons/Components/SizeControllers/CometTailController.cs index b108d76e..65b0676b 100644 --- a/NewHorizons/Components/SizeControllers/CometTailController.cs +++ b/NewHorizons/Components/SizeControllers/CometTailController.cs @@ -6,7 +6,8 @@ namespace NewHorizons.Components.SizeControllers { public class CometTailController : SizeController { - private Transform _primaryBody; + private Transform _dustTargetBody; + private OWRigidbody _primaryBody; private OWRigidbody _body; private bool _hasRotationOverride; @@ -38,8 +39,8 @@ namespace NewHorizons.Components.SizeControllers private void UpdateTargetPositions() { - var toPrimary = (_body.transform.position - _primaryBody.transform.position).normalized; - var velocityDirection = -_body.GetVelocity(); // Accept that this is flipped ok + var toPrimary = (_body.transform.position - _dustTargetBody.transform.position).normalized; + var velocityDirection = (_primaryBody?.GetVelocity() ?? Vector3.zero) -_body.GetVelocity(); // Accept that this is flipped ok var tangentVel = Vector3.ProjectOnPlane(velocityDirection, toPrimary) / velocityDirection.magnitude; @@ -53,9 +54,10 @@ namespace NewHorizons.Components.SizeControllers transform.localRotation = Quaternion.Euler(eulerAngles); } - public void SetPrimaryBody(Transform primaryBody) + public void SetPrimaryBody(Transform dustTarget, OWRigidbody primaryBody) { _hasPrimaryBody = true; + _dustTargetBody = dustTarget; _primaryBody = primaryBody; } } From dfc751e20c465bab052fa0f37d779fc836af1e36 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sat, 22 Apr 2023 13:11:38 -0700 Subject: [PATCH 16/19] move ring shape back to components --- NewHorizons/{Utility/Geometry => Components}/RingShape.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename NewHorizons/{Utility/Geometry => Components}/RingShape.cs (99%) diff --git a/NewHorizons/Utility/Geometry/RingShape.cs b/NewHorizons/Components/RingShape.cs similarity index 99% rename from NewHorizons/Utility/Geometry/RingShape.cs rename to NewHorizons/Components/RingShape.cs index 85f36519..a1e2bcb7 100644 --- a/NewHorizons/Utility/Geometry/RingShape.cs +++ b/NewHorizons/Components/RingShape.cs @@ -1,7 +1,7 @@ -using System.Collections.Generic; +using System.Collections.Generic; using UnityEngine; -namespace NewHorizons.Utility.Geometry +namespace NewHorizons.Components { public class RingShape : Shape { From 942a37df2ac45a84cc904caea8651b673a4aa3cd Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 22 Apr 2023 16:11:55 -0400 Subject: [PATCH 17/19] im insano mode --- .../Builder/Atmosphere/AtmosphereBuilder.cs | 4 +- .../Builder/Atmosphere/EffectsBuilder.cs | 4 +- .../Builder/Body/BrambleDimensionBuilder.cs | 4 +- NewHorizons/Builder/Body/CloakBuilder.cs | 4 +- NewHorizons/Builder/Body/CometTailBuilder.cs | 4 +- NewHorizons/Builder/Body/FunnelBuilder.cs | 10 ++--- NewHorizons/Builder/Body/LavaBuilder.cs | 6 +-- NewHorizons/Builder/Body/ProxyBuilder.cs | 8 ++-- NewHorizons/Builder/Body/SandBuilder.cs | 10 ++--- .../Builder/Body/SingularityBuilder.cs | 10 ++--- NewHorizons/Builder/Body/StarBuilder.cs | 8 ++-- NewHorizons/Builder/Body/WaterBuilder.cs | 2 +- .../Builder/General/AmbientLightBuilder.cs | 2 +- .../Builder/Props/BrambleNodeBuilder.cs | 2 +- NewHorizons/Builder/Props/DetailBuilder.cs | 10 ++--- NewHorizons/Builder/Props/NomaiTextBuilder.cs | 6 +-- NewHorizons/Builder/Props/QuantumBuilder.cs | 4 +- NewHorizons/Builder/Props/RaftBuilder.cs | 2 +- NewHorizons/Builder/Props/RemoteBuilder.cs | 12 +++--- NewHorizons/Builder/Props/ScatterBuilder.cs | 2 +- .../TranslatorText/NomaiTextArcBuilder.cs | 14 +++--- .../TranslatorText/TranslatorTextBuilder.cs | 2 +- NewHorizons/Builder/Props/VolcanoBuilder.cs | 2 +- NewHorizons/Builder/Props/WarpPadBuilder.cs | 6 +-- NewHorizons/Builder/ShipLog/MapModeBuilder.cs | 2 +- NewHorizons/Components/Orbital/NHOrbitLine.cs | 8 ++-- .../Components/Orbital/TrackingOrbitLine.cs | 10 ++--- .../Quantum/NHMultiStateQuantumObject.cs | 2 +- .../Components/Volumes/LoadCreditsVolume.cs | 4 +- NewHorizons/Handlers/PlanetCreationHandler.cs | 10 ++--- .../Handlers/PlanetDestructionHandler.cs | 34 +++++++-------- NewHorizons/Handlers/StarChartHandler.cs | 2 +- NewHorizons/Handlers/TitleSceneHandler.cs | 4 +- NewHorizons/Handlers/VesselWarpHandler.cs | 43 +++++++++---------- NewHorizons/Main.cs | 8 ++-- .../Utility/DebugTools/DebugRaycaster.cs | 14 +++--- NewHorizons/Utility/NewHorizonExtensions.cs | 2 +- NewHorizons/Utility/RandomUtility.cs | 2 +- NewHorizons/Utility/SearchUtilities.cs | 4 +- 39 files changed, 143 insertions(+), 144 deletions(-) diff --git a/NewHorizons/Builder/Atmosphere/AtmosphereBuilder.cs b/NewHorizons/Builder/Atmosphere/AtmosphereBuilder.cs index d543e136..29854385 100644 --- a/NewHorizons/Builder/Atmosphere/AtmosphereBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/AtmosphereBuilder.cs @@ -31,7 +31,7 @@ namespace NewHorizons.Builder.Atmosphere _isInit = true; if (_atmospherePrefab == null) _atmospherePrefab = SearchUtilities.Find("TimberHearth_Body/Atmosphere_TH/AtmoSphere").InstantiateInactive().Rename("Atmosphere").DontDestroyOnLoad(); - if (_proxyAtmospherePrefab == null) _proxyAtmospherePrefab = GameObject.FindObjectOfType()._proxies.FirstOrDefault(apt => apt.astroName == AstroObject.Name.TimberHearth).proxyPrefab.FindChild("Atmosphere_TH/Atmosphere_LOD3").InstantiateInactive().Rename("ProxyAtmosphere").DontDestroyOnLoad(); + if (_proxyAtmospherePrefab == null) _proxyAtmospherePrefab = Object.FindObjectOfType()._proxies.FirstOrDefault(apt => apt.astroName == AstroObject.Name.TimberHearth).proxyPrefab.FindChild("Atmosphere_TH/Atmosphere_LOD3").InstantiateInactive().Rename("ProxyAtmosphere").DontDestroyOnLoad(); } public static GameObject Make(GameObject planetGO, Sector sector, AtmosphereModule atmosphereModule, float surfaceSize, bool proxy = false) @@ -48,7 +48,7 @@ namespace NewHorizons.Builder.Atmosphere if (prefab != null) { - GameObject atmo = GameObject.Instantiate(prefab, atmoGO.transform); + GameObject atmo = Object.Instantiate(prefab, atmoGO.transform); atmo.name = "Atmosphere"; atmo.transform.localPosition = Vector3.zero; atmo.transform.localEulerAngles = Vector3.zero; diff --git a/NewHorizons/Builder/Atmosphere/EffectsBuilder.cs b/NewHorizons/Builder/Atmosphere/EffectsBuilder.cs index 540e0a8b..3b11b857 100644 --- a/NewHorizons/Builder/Atmosphere/EffectsBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/EffectsBuilder.cs @@ -50,7 +50,7 @@ namespace NewHorizons.Builder.Atmosphere if (config.Atmosphere.hasRain) { - var rainGO = GameObject.Instantiate(_rainEmitterPrefab, effectsGO.transform); + var rainGO = Object.Instantiate(_rainEmitterPrefab, effectsGO.transform); rainGO.name = "RainEmitter"; rainGO.transform.position = planetGO.transform.position; @@ -74,7 +74,7 @@ namespace NewHorizons.Builder.Atmosphere snowGO.transform.position = planetGO.transform.position; for (int i = 0; i < 5; i++) { - var snowEmitter = GameObject.Instantiate(_snowEmitterPrefab, snowGO.transform); + var snowEmitter = Object.Instantiate(_snowEmitterPrefab, snowGO.transform); snowEmitter.name = "SnowEmitter"; snowEmitter.transform.position = planetGO.transform.position; diff --git a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs index 9eba9930..17707c01 100644 --- a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs +++ b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs @@ -134,11 +134,11 @@ namespace NewHorizons.Builder.Body if (config.vinePrefab == VinePrefabType.None) { // Replace batched collision with our own if removing vines - GameObject.Destroy(geometry.FindChild("BatchedGroup")); + Object.Destroy(geometry.FindChild("BatchedGroup")); var geoOtherComponentsGroup = geometry.FindChild("OtherComponentsGroup"); var dimensionWalls = geoOtherComponentsGroup.FindChild("Terrain_DB_BrambleSphere_Outer_v2"); dimensionWalls.transform.parent = geometry.transform; - GameObject.Destroy(geoOtherComponentsGroup); + Object.Destroy(geoOtherComponentsGroup); var newCollider = _wallCollision.InstantiateInactive(); newCollider.transform.parent = dimensionWalls.transform; diff --git a/NewHorizons/Builder/Body/CloakBuilder.cs b/NewHorizons/Builder/Body/CloakBuilder.cs index 369683eb..ccdee273 100644 --- a/NewHorizons/Builder/Body/CloakBuilder.cs +++ b/NewHorizons/Builder/Body/CloakBuilder.cs @@ -36,12 +36,12 @@ namespace NewHorizons.Builder.Body var radius = module.radius; - var newCloak = GameObject.Instantiate(_prefab, sector?.transform ?? planetGO.transform); + var newCloak = Object.Instantiate(_prefab, sector?.transform ?? planetGO.transform); newCloak.transform.position = planetGO.transform.position; newCloak.transform.name = "CloakingField"; newCloak.transform.localScale = Vector3.one * radius; - GameObject.Destroy(newCloak.GetComponent()); + Object.Destroy(newCloak.GetComponent()); var cloakFieldController = newCloak.GetComponent(); cloakFieldController._cloakScaleDist = radius * 2000 / 3000f; diff --git a/NewHorizons/Builder/Body/CometTailBuilder.cs b/NewHorizons/Builder/Body/CometTailBuilder.cs index 53883948..9633b316 100644 --- a/NewHorizons/Builder/Body/CometTailBuilder.cs +++ b/NewHorizons/Builder/Body/CometTailBuilder.cs @@ -91,13 +91,13 @@ namespace NewHorizons.Builder.Body controller.SetScaleCurve(cometTailModule.curve); - var dustTail = GameObject.Instantiate(_dustPrefab, rootObj.transform).Rename("DustTail"); + var dustTail = Object.Instantiate(_dustPrefab, rootObj.transform).Rename("DustTail"); dustTail.transform.localPosition = Vector3.zero; dustTail.transform.localRotation = Quaternion.Euler(90, 90, 0); dustTail.SetActive(true); controller.dustTail = dustTail; - var gasTail = GameObject.Instantiate(_gasPrefab, rootObj.transform).Rename("GasTail"); + var gasTail = Object.Instantiate(_gasPrefab, rootObj.transform).Rename("GasTail"); gasTail.transform.localPosition = Vector3.zero; gasTail.transform.localRotation = Quaternion.Euler(90, 90, 0); gasTail.SetActive(true); diff --git a/NewHorizons/Builder/Body/FunnelBuilder.cs b/NewHorizons/Builder/Body/FunnelBuilder.cs index a9311a72..3e5d242f 100644 --- a/NewHorizons/Builder/Body/FunnelBuilder.cs +++ b/NewHorizons/Builder/Body/FunnelBuilder.cs @@ -68,15 +68,15 @@ namespace NewHorizons.Builder.Body scaleRoot.transform.localPosition = Vector3.zero; scaleRoot.transform.localScale = new Vector3(1, 1, 1); - var proxyGO = GameObject.Instantiate(_proxySandFunnel, scaleRoot.transform); + var proxyGO = Object.Instantiate(_proxySandFunnel, scaleRoot.transform); proxyGO.name = "Proxy_Funnel"; proxyGO.SetActive(true); - var geoGO = GameObject.Instantiate(_geoSandFunnel, scaleRoot.transform); + var geoGO = Object.Instantiate(_geoSandFunnel, scaleRoot.transform); geoGO.name = "Geo_Funnel"; geoGO.SetActive(true); - var volumesGO = GameObject.Instantiate(_volumesSandFunnel, scaleRoot.transform); + var volumesGO = Object.Instantiate(_volumesSandFunnel, scaleRoot.transform); volumesGO.name = "Volumes_Funnel"; volumesGO.SetActive(true); var sfv = volumesGO.GetComponentInChildren(); @@ -90,7 +90,7 @@ namespace NewHorizons.Builder.Body case FunnelType.Water: sfv._fluidType = FluidVolume.Type.WATER; - GameObject.Destroy(geoGO.transform.Find("Effects_HT_SandColumn/SandColumn_Interior").gameObject); + Object.Destroy(geoGO.transform.Find("Effects_HT_SandColumn/SandColumn_Interior").gameObject); var waterMaterials = _waterMaterials; var materials = new Material[waterMaterials.Length]; @@ -138,7 +138,7 @@ namespace NewHorizons.Builder.Body case FunnelType.Star: sfv._fluidType = FluidVolume.Type.PLASMA; - GameObject.Destroy(geoGO.transform.Find("Effects_HT_SandColumn/SandColumn_Interior").gameObject); + Object.Destroy(geoGO.transform.Find("Effects_HT_SandColumn/SandColumn_Interior").gameObject); var lavaMaterial = new Material(_lavaMaterial); lavaMaterial.mainTextureOffset = new Vector2(0.1f, 0.2f); diff --git a/NewHorizons/Builder/Body/LavaBuilder.cs b/NewHorizons/Builder/Body/LavaBuilder.cs index f2bd38b4..16e48b32 100644 --- a/NewHorizons/Builder/Body/LavaBuilder.cs +++ b/NewHorizons/Builder/Body/LavaBuilder.cs @@ -42,7 +42,7 @@ namespace NewHorizons.Builder.Body moltenCore.transform.position = planetGO.transform.position; moltenCore.transform.localScale = Vector3.one * module.size; - var lavaSphere = GameObject.Instantiate(_lavaSphere, moltenCore.transform); + var lavaSphere = Object.Instantiate(_lavaSphere, moltenCore.transform); lavaSphere.transform.localScale = Vector3.one; lavaSphere.transform.name = "LavaSphere"; lavaSphere.GetComponent().material.SetFloat(HeightScale, 150f * multiplier); @@ -54,7 +54,7 @@ namespace NewHorizons.Builder.Body var sectorCullGroup = lavaSphere.GetComponent(); sectorCullGroup.SetSector(sector); - var moltenCoreProxy = GameObject.Instantiate(_moltenCoreProxy, moltenCore.transform); ; + var moltenCoreProxy = Object.Instantiate(_moltenCoreProxy, moltenCore.transform); ; moltenCoreProxy.name = "MoltenCore_Proxy"; moltenCoreProxy.SetActive(true); @@ -70,7 +70,7 @@ namespace NewHorizons.Builder.Body sectorProxy._renderers = new List { proxyLavaSphere.GetComponent() }; sectorProxy.SetSector(sector); - var destructionVolume = GameObject.Instantiate(_destructionVolume, moltenCore.transform); + var destructionVolume = Object.Instantiate(_destructionVolume, moltenCore.transform); destructionVolume.name = "DestructionVolume"; destructionVolume.GetComponent().radius = 1; destructionVolume.SetActive(true); diff --git a/NewHorizons/Builder/Body/ProxyBuilder.cs b/NewHorizons/Builder/Body/ProxyBuilder.cs index 1730470c..0f87a90a 100644 --- a/NewHorizons/Builder/Body/ProxyBuilder.cs +++ b/NewHorizons/Builder/Body/ProxyBuilder.cs @@ -54,7 +54,7 @@ namespace NewHorizons.Builder.Body var success = SharedMake(planetGO, rootProxy, proxyController, body); if (!success) { - GameObject.Destroy(proxy); + UnityEngine.Object.Destroy(proxy); return; } @@ -215,8 +215,8 @@ namespace NewHorizons.Builder.Body } // Remove all collisions if there are any - foreach (var col in proxy.GetComponentsInChildren()) GameObject.Destroy(col); - foreach (var col in proxy.GetComponentsInChildren()) GameObject.Destroy(col); + foreach (var col in proxy.GetComponentsInChildren()) UnityEngine.Object.Destroy(col); + foreach (var col in proxy.GetComponentsInChildren()) UnityEngine.Object.Destroy(col); foreach (var renderer in proxy.GetComponentsInChildren()) { @@ -267,7 +267,7 @@ namespace NewHorizons.Builder.Body sphereGO.transform.localScale = Vector3.one * size; sphereGO.transform.position = rootObj.transform.position; - GameObject.Destroy(sphereGO.GetComponent()); + UnityEngine.Object.Destroy(sphereGO.GetComponent()); sphereGO.GetComponent().material.color = color; diff --git a/NewHorizons/Builder/Body/SandBuilder.cs b/NewHorizons/Builder/Body/SandBuilder.cs index f18d7494..c5bbb17f 100644 --- a/NewHorizons/Builder/Body/SandBuilder.cs +++ b/NewHorizons/Builder/Body/SandBuilder.cs @@ -32,7 +32,7 @@ namespace NewHorizons.Builder.Body var sandGO = new GameObject("Sand"); sandGO.SetActive(false); - var sandSphere = GameObject.Instantiate(_sandSphere, sandGO.transform); + var sandSphere = Object.Instantiate(_sandSphere, sandGO.transform); sandSphere.name = "Sphere"; sandSphere.SetActive(true); if (module.tint != null) @@ -46,20 +46,20 @@ namespace NewHorizons.Builder.Body new Material(sandMaterials[0]), new Material(sandMaterials[1]) }; - GameObject.Destroy(oldMR); + Object.Destroy(oldMR); sandMR.sharedMaterials[0].color = module.tint.ToColor(); sandMR.sharedMaterials[1].color = module.tint.ToColor(); } - var collider = GameObject.Instantiate(_sandCollider, sandGO.transform); + var collider = Object.Instantiate(_sandCollider, sandGO.transform); collider.name = "Collider"; collider.SetActive(true); - var occlusionSphere = GameObject.Instantiate(_sandOcclusion, sandGO.transform); + var occlusionSphere = Object.Instantiate(_sandOcclusion, sandGO.transform); occlusionSphere.name = "Occlusion"; occlusionSphere.SetActive(true); - var proxyShadowCasterGO = GameObject.Instantiate(_sandProxyShadowCaster, sandGO.transform); + var proxyShadowCasterGO = Object.Instantiate(_sandProxyShadowCaster, sandGO.transform); proxyShadowCasterGO.name = "ProxyShadowCaster"; var proxyShadowCaster = proxyShadowCasterGO.GetComponent(); proxyShadowCaster.SetSuperGroup(sandGO.GetComponent()); diff --git a/NewHorizons/Builder/Body/SingularityBuilder.cs b/NewHorizons/Builder/Body/SingularityBuilder.cs index 4e403945..99493304 100644 --- a/NewHorizons/Builder/Body/SingularityBuilder.cs +++ b/NewHorizons/Builder/Body/SingularityBuilder.cs @@ -167,7 +167,7 @@ namespace NewHorizons.Builder.Body OWAudioSource oneShotOWAudioSource = null; - var singularityAmbience = GameObject.Instantiate(_blackHoleAmbience, singularity.transform); + var singularityAmbience = Object.Instantiate(_blackHoleAmbience, singularity.transform); singularityAmbience.name = polarity ? "BlackHoleAmbience" : "WhiteHoleAmbience"; singularityAmbience.SetActive(true); singularityAmbience.GetComponent().SetSector(sector); @@ -202,7 +202,7 @@ namespace NewHorizons.Builder.Body } else { - var blackHoleOneShot = GameObject.Instantiate(_blackHoleEmissionOneShot, singularity.transform); + var blackHoleOneShot = Object.Instantiate(_blackHoleEmissionOneShot, singularity.transform); blackHoleOneShot.name = "BlackHoleEmissionOneShot"; blackHoleOneShot.SetActive(true); oneShotOWAudioSource = blackHoleOneShot.GetComponent(); @@ -211,7 +211,7 @@ namespace NewHorizons.Builder.Body oneShotAudioSource.minDistance = horizon; if (sizeController != null) sizeController.oneShotAudioSource = oneShotAudioSource; - var blackHoleVolume = GameObject.Instantiate(_blackHoleVolume, singularity.transform); + var blackHoleVolume = Object.Instantiate(_blackHoleVolume, singularity.transform); blackHoleVolume.name = "BlackHoleVolume"; blackHoleVolume.SetActive(true); var bhVolume = blackHoleVolume.GetComponent(); @@ -226,7 +226,7 @@ namespace NewHorizons.Builder.Body { foreach (var renderer in blackHoleVolume.GetComponentsInChildren(true)) { - UnityEngine.Object.Destroy(renderer); + Object.Destroy(renderer); } }); } @@ -234,7 +234,7 @@ namespace NewHorizons.Builder.Body } else { - GameObject whiteHoleVolumeGO = GameObject.Instantiate(_whiteHoleVolume); + GameObject whiteHoleVolumeGO = Object.Instantiate(_whiteHoleVolume); whiteHoleVolumeGO.transform.parent = singularity.transform; whiteHoleVolumeGO.transform.localPosition = Vector3.zero; whiteHoleVolumeGO.transform.localScale = Vector3.one; diff --git a/NewHorizons/Builder/Body/StarBuilder.cs b/NewHorizons/Builder/Body/StarBuilder.cs index 9d44cf90..9a11ede9 100644 --- a/NewHorizons/Builder/Body/StarBuilder.cs +++ b/NewHorizons/Builder/Body/StarBuilder.cs @@ -48,7 +48,7 @@ namespace NewHorizons.Builder.Body if (_starAtmosphere == null) _starAtmosphere = SearchUtilities.Find("Sun_Body/Atmosphere_SUN").InstantiateInactive().Rename("Prefab_Atmosphere_Star").DontDestroyOnLoad(); if (_starAmbientLight == null) _starAmbientLight = SearchUtilities.Find("Sun_Body/AmbientLight_SUN").InstantiateInactive().Rename("Prefab_AmbientLight_Star").DontDestroyOnLoad(); if (_sunLight == null) _sunLight = SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").InstantiateInactive().Rename("Prefab_SunLight").DontDestroyOnLoad(); - if (_starProxyAtmosphere == null) _starProxyAtmosphere = GameObject.FindObjectOfType()._sunProxyPrefab.FindChild("Sun_Proxy_Body/Atmosphere_SUN").InstantiateInactive().Rename("Prefab_ProxyAtmosphere_Star").DontDestroyOnLoad(); + if (_starProxyAtmosphere == null) _starProxyAtmosphere = Object.FindObjectOfType()._sunProxyPrefab.FindChild("Sun_Proxy_Body/Atmosphere_SUN").InstantiateInactive().Rename("Prefab_ProxyAtmosphere_Star").DontDestroyOnLoad(); if (_starSurface == null) _starSurface = SearchUtilities.Find("Sun_Body/Sector_SUN/Geometry_SUN/Surface").InstantiateInactive().Rename("Prefab_Surface_Star").DontDestroyOnLoad(); if (_starSolarFlareEmitter == null) _starSolarFlareEmitter = SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SolarFlareEmitter").InstantiateInactive().Rename("Prefab_SolarFlareEmitter_Star").DontDestroyOnLoad(); if (_supernovaPrefab == null) _supernovaPrefab = SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/Supernova").InstantiateInactive().Rename("Prefab_Supernova").DontDestroyOnLoad(); @@ -69,7 +69,7 @@ namespace NewHorizons.Builder.Body var sunSurfaceAudio = sunAudio.GetComponentInChildren(); var surfaceAudio = sunSurfaceAudio.gameObject.AddComponent(); surfaceAudio._size = starModule.size; - GameObject.Destroy(sunSurfaceAudio); + Object.Destroy(sunSurfaceAudio); surfaceAudio.SetSector(sector); sunAudio.name = "Audio_Star"; @@ -96,7 +96,7 @@ namespace NewHorizons.Builder.Body var fog = sunAtmosphere.transform.Find("FogSphere").GetComponent(); fog.transform.localScale = Vector3.one; fog.fogRadius = starModule.size * OuterRadiusRatio; - fog.lodFadeDistance = fog.fogRadius * (StarBuilder.OuterRadiusRatio - 1f); + fog.lodFadeDistance = fog.fogRadius * (OuterRadiusRatio - 1f); fog.fogImpostor.material.SetFloat(Radius, starModule.size * OuterRadiusRatio); if (starModule.tint != null) @@ -416,7 +416,7 @@ namespace NewHorizons.Builder.Body stellarDeath.shockwaveAlpha = supernova._shockwaveAlpha; stellarDeath.shockwaveScale = supernova._shockwaveScale; stellarDeath.supernovaMaterial = supernova._supernovaMaterial; - GameObject.Destroy(supernova); + Object.Destroy(supernova); if (starModule.supernovaTint != null) { diff --git a/NewHorizons/Builder/Body/WaterBuilder.cs b/NewHorizons/Builder/Body/WaterBuilder.cs index 97ffc100..33e2ac5a 100644 --- a/NewHorizons/Builder/Body/WaterBuilder.cs +++ b/NewHorizons/Builder/Body/WaterBuilder.cs @@ -123,7 +123,7 @@ namespace NewHorizons.Builder.Body fluidVolume._density = module.density; fluidVolume._layer = LayerMask.NameToLayer("BasicEffectVolume"); - var fogGO = GameObject.Instantiate(_oceanFog, waterGO.transform); + var fogGO = Object.Instantiate(_oceanFog, waterGO.transform); fogGO.name = "OceanFog"; fogGO.transform.localPosition = Vector3.zero; fogGO.transform.localScale = Vector3.one; diff --git a/NewHorizons/Builder/General/AmbientLightBuilder.cs b/NewHorizons/Builder/General/AmbientLightBuilder.cs index a235a7ba..d0fadc7c 100644 --- a/NewHorizons/Builder/General/AmbientLightBuilder.cs +++ b/NewHorizons/Builder/General/AmbientLightBuilder.cs @@ -12,7 +12,7 @@ namespace NewHorizons.Builder.General var ambientLight = Main.Instance.CurrentStarSystem == "EyeOfTheUniverse" ? SearchUtilities.Find("EyeOfTheUniverse_Body/Sector_EyeOfTheUniverse/SixthPlanet_Root/QuantumMoonProxy_Pivot/QuantumMoonProxy_Root/MoonState_Root/AmbientLight_QM") : SearchUtilities.Find("QuantumMoon_Body/AmbientLight_QM"); if (ambientLight == null) return null; - GameObject lightGO = GameObject.Instantiate(ambientLight, sector?.transform ?? planetGO.transform); + GameObject lightGO = Object.Instantiate(ambientLight, sector?.transform ?? planetGO.transform); lightGO.transform.position = config.position == null ? planetGO.transform.position : planetGO.transform.TransformPoint(config.position); lightGO.name = "AmbientLight"; diff --git a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs index fc958b6c..bbad4250 100644 --- a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs +++ b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs @@ -195,7 +195,7 @@ namespace NewHorizons.Builder.Props var fogLight = brambleNode.GetComponent(); // This node comes with Feldspar's signal, we don't want that though - GameObject.Destroy(brambleNode.FindChild("Signal_Harmonica")); + Object.Destroy(brambleNode.FindChild("Signal_Harmonica")); // Fix some components fogLight._parentBody = go.GetComponent(); diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index 59f6bf08..1d3df4fa 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -29,7 +29,7 @@ namespace NewHorizons.Builder.Props { foreach (var prefab in _fixedPrefabCache.Values) { - GameObject.Destroy(prefab.prefab); + UnityEngine.Object.Destroy(prefab.prefab); } _fixedPrefabCache.Clear(); _detailInfoToCorrespondingSpawnedGameObject.Clear(); @@ -189,7 +189,7 @@ namespace NewHorizons.Builder.Props child.parent = newDetailGO.transform; } // Have to destroy it right away, else parented props might get attached to the old one - GameObject.DestroyImmediate(prop); + UnityEngine.Object.DestroyImmediate(prop); prop = newDetailGO; } @@ -225,7 +225,7 @@ namespace NewHorizons.Builder.Props // renderers/colliders get enabled later so we dont have to do that here if (keepLoaded && component is SectorCullGroup or SectorCollisionGroup or SectorLightsCullGroup) { - Component.DestroyImmediate(component); + UnityEngine.Object.DestroyImmediate(component); return; } @@ -283,7 +283,7 @@ namespace NewHorizons.Builder.Props { if (component is FogLight or SectoredMonoBehaviour or ISectorGroup) { - GameObject.DestroyImmediate(component); + UnityEngine.Object.DestroyImmediate(component); return true; } return false; @@ -306,7 +306,7 @@ namespace NewHorizons.Builder.Props // I forget why this is here else if (component is GhostIK or GhostEffects) { - Component.DestroyImmediate(component); + UnityEngine.Object.DestroyImmediate(component); return; } else if (component is DarkMatterVolume) diff --git a/NewHorizons/Builder/Props/NomaiTextBuilder.cs b/NewHorizons/Builder/Props/NomaiTextBuilder.cs index 193acf96..1508c3f2 100644 --- a/NewHorizons/Builder/Props/NomaiTextBuilder.cs +++ b/NewHorizons/Builder/Props/NomaiTextBuilder.cs @@ -65,7 +65,7 @@ namespace NewHorizons.Builder.Props if (_arcPrefabs == null || _childArcPrefabs == null) { // Just take every scroll and get the first arc - var existingArcs = GameObject.FindObjectsOfType() + var existingArcs = UnityEngine.Object.FindObjectsOfType() .Select(x => x?._nomaiWallText?.gameObject?.transform?.Find("Arc 1")?.gameObject) .Where(x => x != null) .OrderBy(x => x.transform.GetPath()) // order by path so game updates dont break things @@ -87,7 +87,7 @@ namespace NewHorizons.Builder.Props if (_ghostArcPrefabs == null) { - var existingGhostArcs = GameObject.FindObjectsOfType() + var existingGhostArcs = UnityEngine.Object.FindObjectsOfType() .Select(x => x?._textLine?.gameObject) .Where(x => x != null) .OrderBy(x => x.transform.GetPath()) // order by path so game updates dont break things @@ -245,7 +245,7 @@ namespace NewHorizons.Builder.Props var scrollItem = customScroll.GetComponent(); // Idk why this thing is always around - GameObject.Destroy(customScroll.transform.Find("Arc_BH_City_Forum_2").gameObject); + UnityEngine.Object.Destroy(customScroll.transform.Find("Arc_BH_City_Forum_2").gameObject); // This variable is the bane of my existence i dont get it scrollItem._nomaiWallText = nomaiWallText; diff --git a/NewHorizons/Builder/Props/QuantumBuilder.cs b/NewHorizons/Builder/Props/QuantumBuilder.cs index a2011a99..2848ee87 100644 --- a/NewHorizons/Builder/Props/QuantumBuilder.cs +++ b/NewHorizons/Builder/Props/QuantumBuilder.cs @@ -208,7 +208,7 @@ namespace NewHorizons.Builder.Props void Update() { - if (meshFilter == null && skinnedMeshRenderer == null) { NHLogger.LogVerbose("Useless BoxShapeFixer, destroying"); GameObject.DestroyImmediate(this); } + if (meshFilter == null && skinnedMeshRenderer == null) { NHLogger.LogVerbose("Useless BoxShapeFixer, destroying"); DestroyImmediate(this); } Mesh sharedMesh = null; if (meshFilter != null) sharedMesh = meshFilter.sharedMesh; @@ -220,7 +220,7 @@ namespace NewHorizons.Builder.Props shape.size = sharedMesh.bounds.size; shape.center = sharedMesh.bounds.center; - GameObject.DestroyImmediate(this); + DestroyImmediate(this); } } } diff --git a/NewHorizons/Builder/Props/RaftBuilder.cs b/NewHorizons/Builder/Props/RaftBuilder.cs index 526ea745..14ccf8d4 100644 --- a/NewHorizons/Builder/Props/RaftBuilder.cs +++ b/NewHorizons/Builder/Props/RaftBuilder.cs @@ -14,7 +14,7 @@ namespace NewHorizons.Builder.Props { if (_prefab == null) { - _prefab = GameObject.FindObjectOfType()?.gameObject?.InstantiateInactive()?.Rename("Raft_Body_Prefab")?.DontDestroyOnLoad(); + _prefab = Object.FindObjectOfType()?.gameObject?.InstantiateInactive()?.Rename("Raft_Body_Prefab")?.DontDestroyOnLoad(); if (_prefab == null) { NHLogger.LogWarning($"Tried to make a raft but couldn't. Do you have the DLC installed?"); diff --git a/NewHorizons/Builder/Props/RemoteBuilder.cs b/NewHorizons/Builder/Props/RemoteBuilder.cs index 1a077368..e4d6b547 100644 --- a/NewHorizons/Builder/Props/RemoteBuilder.cs +++ b/NewHorizons/Builder/Props/RemoteBuilder.cs @@ -65,7 +65,7 @@ namespace NewHorizons.Builder.Props quad.AddComponent(); quad.GetComponent().sharedMaterial = _decalMaterial; quad.name = "AstroBodySymbolRenderer"; - GameObject.DestroyImmediate(AstroBodySymbolRenderer); + UnityEngine.Object.DestroyImmediate(AstroBodySymbolRenderer); } if (_whiteboardPrefab == null) @@ -86,7 +86,7 @@ namespace NewHorizons.Builder.Props quadW.AddComponent(); quadW.GetComponent().sharedMaterial = _decalMaterial; quadW.name = "AstroBodySymbolRenderer"; - GameObject.DestroyImmediate(AstroBodySymbolRendererW); + UnityEngine.Object.DestroyImmediate(AstroBodySymbolRendererW); } if (_shareStonePrefab == null) @@ -109,7 +109,7 @@ namespace NewHorizons.Builder.Props TransformAnimator transformAnimator = animRoot.AddComponent(); item._animator = transformAnimator; OWRenderer renderer = SearchUtilities.FindResourceOfTypeAndName("Props_NOM_SharedStone"); - if (renderer != null) GameObject.Instantiate(renderer.gameObject, animRoot.transform); + if (renderer != null) UnityEngine.Object.Instantiate(renderer.gameObject, animRoot.transform); GameObject planetDecal = GameObject.CreatePrimitive(PrimitiveType.Quad); planetDecal.name = "PlanetDecal"; planetDecal.transform.parent = animRoot.transform; @@ -137,7 +137,7 @@ namespace NewHorizons.Builder.Props { try { - RemoteBuilder.MakePlatform(go, sector, id, decal, info.platform, mod); + MakePlatform(go, sector, id, decal, info.platform, mod); } catch (Exception ex) { @@ -149,7 +149,7 @@ namespace NewHorizons.Builder.Props { try { - RemoteBuilder.MakeWhiteboard(go, sector, id, decal, info.whiteboard, nhBody); + MakeWhiteboard(go, sector, id, decal, info.whiteboard, nhBody); } catch (Exception ex) { @@ -163,7 +163,7 @@ namespace NewHorizons.Builder.Props { try { - RemoteBuilder.MakeStone(go, sector, id, decal, stoneInfo, mod); + MakeStone(go, sector, id, decal, stoneInfo, mod); } catch (Exception ex) { diff --git a/NewHorizons/Builder/Props/ScatterBuilder.cs b/NewHorizons/Builder/Props/ScatterBuilder.cs index fdb1720d..26f859fe 100644 --- a/NewHorizons/Builder/Props/ScatterBuilder.cs +++ b/NewHorizons/Builder/Props/ScatterBuilder.cs @@ -139,7 +139,7 @@ namespace NewHorizons.Builder.Props prop.SetActive(true); } - GameObject.Destroy(scatterPrefab); + Object.Destroy(scatterPrefab); } } } diff --git a/NewHorizons/Builder/Props/TranslatorText/NomaiTextArcBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/NomaiTextArcBuilder.cs index e8f5e8ec..817084a5 100644 --- a/NewHorizons/Builder/Props/TranslatorText/NomaiTextArcBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/NomaiTextArcBuilder.cs @@ -148,12 +148,12 @@ namespace NewHorizons.Builder.Props.TranslatorText this.outerWidth = profile.outerWidth; this.uvScale = profile.uvScale; - this.uvOffset = UnityEngine.Random.value; + this.uvOffset = Random.value; } public override void Randomize() { base.Randomize(); - uvOffset = UnityEngine.Random.value; // this way even two spirals that are exactly the same shape will look different (this changes the starting point of the handwriting texture) + uvOffset = Random.value; // this way even two spirals that are exactly the same shape will look different (this changes the starting point of the handwriting texture) } internal void updateMesh() { @@ -288,11 +288,11 @@ namespace NewHorizons.Builder.Props.TranslatorText } public virtual void Randomize() { - this.a = UnityEngine.Random.Range(profile.a.x, profile.a.y); - this.b = UnityEngine.Random.Range(profile.b.x, profile.b.y); - this.endS = UnityEngine.Random.Range(profile.endS.x, profile.endS.y); - this.startS = UnityEngine.Random.Range(profile.startS.x, profile.startS.y); - this.scale = UnityEngine.Random.Range(profile.skeletonScale.x, profile.skeletonScale.y); + this.a = Random.Range(profile.a.x, profile.a.y); + this.b = Random.Range(profile.b.x, profile.b.y); + this.endS = Random.Range(profile.endS.x, profile.endS.y); + this.startS = Random.Range(profile.startS.x, profile.startS.y); + this.scale = Random.Range(profile.skeletonScale.x, profile.skeletonScale.y); } internal virtual void updateChild(MathematicalSpiral child) { diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index aeaa9878..adf1d3a6 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -176,7 +176,7 @@ namespace NewHorizons.Builder.Props.TranslatorText var scrollItem = customScroll.GetComponent(); // Idk why this thing is always around - GameObject.Destroy(customScroll.transform.Find("Arc_BH_City_Forum_2").gameObject); + UnityEngine.Object.Destroy(customScroll.transform.Find("Arc_BH_City_Forum_2").gameObject); // This variable is the bane of my existence i dont get it scrollItem._nomaiWallText = nomaiWallText; diff --git a/NewHorizons/Builder/Props/VolcanoBuilder.cs b/NewHorizons/Builder/Props/VolcanoBuilder.cs index e06c7a4c..7d8910f2 100644 --- a/NewHorizons/Builder/Props/VolcanoBuilder.cs +++ b/NewHorizons/Builder/Props/VolcanoBuilder.cs @@ -28,7 +28,7 @@ namespace NewHorizons.Builder.Props meteorLauncher._dynamicProbability = 0f; var meteorPrefab = meteorLauncher._meteorPrefab.InstantiateInactive().Rename("Prefab_VM_MoltenMeteor").DontDestroyOnLoad(); var meteor = meteorPrefab.GetComponent(); - GameObject.DestroyImmediate(meteorPrefab.FindChild("ConstantDetectors")); + Object.DestroyImmediate(meteorPrefab.FindChild("ConstantDetectors")); var detectors = meteorPrefab.FindChild("DynamicDetector"); var rigidbody = meteor.GetComponent(); meteor._owRigidbody = rigidbody; diff --git a/NewHorizons/Builder/Props/WarpPadBuilder.cs b/NewHorizons/Builder/Props/WarpPadBuilder.cs index f3fec976..07aa3e90 100644 --- a/NewHorizons/Builder/Props/WarpPadBuilder.cs +++ b/NewHorizons/Builder/Props/WarpPadBuilder.cs @@ -52,7 +52,7 @@ namespace NewHorizons.Builder.Props _detailedReceiverPrefab.DontDestroyOnLoad(); - GameObject.Destroy(_detailedReceiverPrefab.GetComponentInChildren().gameObject); + Object.Destroy(_detailedReceiverPrefab.GetComponentInChildren().gameObject); } if (_receiverPrefab == null) @@ -60,7 +60,7 @@ namespace NewHorizons.Builder.Props _receiverPrefab = SearchUtilities.Find("SunStation_Body/Sector_SunStation/Sector_WarpModule/Interactables_WarpModule/Prefab_NOM_WarpReceiver") .InstantiateInactive() .DontDestroyOnLoad(); - GameObject.Destroy(_receiverPrefab.GetComponentInChildren().gameObject); + Object.Destroy(_receiverPrefab.GetComponentInChildren().gameObject); var structure = _platformContainerPrefab.Instantiate(); structure.transform.parent = _receiverPrefab.transform; @@ -74,7 +74,7 @@ namespace NewHorizons.Builder.Props _transmitterPrefab = SearchUtilities.Find("TowerTwin_Body/Sector_TowerTwin/Sector_Tower_SS/Interactables_Tower_SS/Tower_SS_VisibleFrom_TowerTwin/Prefab_NOM_WarpTransmitter") .InstantiateInactive() .DontDestroyOnLoad(); - GameObject.Destroy(_transmitterPrefab.GetComponentInChildren().gameObject); + Object.Destroy(_transmitterPrefab.GetComponentInChildren().gameObject); var structure = _platformContainerPrefab.Instantiate(); structure.transform.parent = _transmitterPrefab.transform; diff --git a/NewHorizons/Builder/ShipLog/MapModeBuilder.cs b/NewHorizons/Builder/ShipLog/MapModeBuilder.cs index f1afd5f8..d1a174b0 100644 --- a/NewHorizons/Builder/ShipLog/MapModeBuilder.cs +++ b/NewHorizons/Builder/ShipLog/MapModeBuilder.cs @@ -133,7 +133,7 @@ namespace NewHorizons.Builder.ShipLog astroObject._image = revealedImage; } - astroObject._unviewedObj = GameObject.Instantiate(unviewedReference, gameObject.transform, false); + astroObject._unviewedObj = UnityEngine.Object.Instantiate(unviewedReference, gameObject.transform, false); astroObject._invisibleWhenHidden = body.Config.ShipLog?.mapMode?.invisibleWhenHidden ?? false; Rect imageRect = astroObject._imageObj.GetComponent().rect; diff --git a/NewHorizons/Components/Orbital/NHOrbitLine.cs b/NewHorizons/Components/Orbital/NHOrbitLine.cs index 2bd3f107..e76dca31 100644 --- a/NewHorizons/Components/Orbital/NHOrbitLine.cs +++ b/NewHorizons/Components/Orbital/NHOrbitLine.cs @@ -15,7 +15,7 @@ namespace NewHorizons.Components.Orbital public override void InitializeLineRenderer() { - base.GetComponent().positionCount = this._numVerts; + GetComponent().positionCount = this._numVerts; } public override void OnValidate() @@ -24,7 +24,7 @@ namespace NewHorizons.Components.Orbital { _numVerts = Mathf.Clamp(_numVerts, 0, 4096); } - if (base.GetComponent().positionCount != this._numVerts) + if (GetComponent().positionCount != this._numVerts) { InitializeLineRenderer(); } @@ -46,7 +46,7 @@ namespace NewHorizons.Components.Orbital transform.localRotation = Quaternion.Euler(270, 90, 0); - base.enabled = false; + enabled = false; } public override void Update() @@ -58,7 +58,7 @@ namespace NewHorizons.Components.Orbital // If it has nothing to orbit then why is this here if (primary == null || !primary.gameObject.activeSelf) { - base.enabled = false; + enabled = false; return; } diff --git a/NewHorizons/Components/Orbital/TrackingOrbitLine.cs b/NewHorizons/Components/Orbital/TrackingOrbitLine.cs index f5a06674..a72d1e62 100644 --- a/NewHorizons/Components/Orbital/TrackingOrbitLine.cs +++ b/NewHorizons/Components/Orbital/TrackingOrbitLine.cs @@ -34,7 +34,7 @@ namespace NewHorizons.Components.Orbital base.Start(); _vertices = new Vector3[_numVerts]; - base.enabled = true; + enabled = true; _lineRenderer.enabled = false; } @@ -75,8 +75,8 @@ namespace NewHorizons.Components.Orbital _vertices[0] = transform.parent.position - origin; _lineRenderer.SetPositions(_vertices); - base.transform.position = origin; - base.transform.rotation = Quaternion.AngleAxis(0f, Vector3.up); + transform.position = origin; + transform.rotation = Quaternion.AngleAxis(0f, Vector3.up); float num2 = DistanceToTrackingOrbitLine(Locator.GetActiveCamera().transform.position); float widthMultiplier = Mathf.Min(num2 * (_lineWidth / 1000f), _maxLineWidth); @@ -108,8 +108,8 @@ namespace NewHorizons.Components.Orbital var primary = _astroObject.GetPrimaryBody(); Vector3 origin = primary == null ? Locator.GetRootTransform().position : primary.transform.position; - base.transform.position = origin; - base.transform.rotation = Quaternion.AngleAxis(0f, Vector3.up); + transform.position = origin; + transform.rotation = Quaternion.AngleAxis(0f, Vector3.up); for (int i = _numVerts - 1; i > 0; i--) { diff --git a/NewHorizons/Components/Quantum/NHMultiStateQuantumObject.cs b/NewHorizons/Components/Quantum/NHMultiStateQuantumObject.cs index 56d3c3d3..17279ec5 100644 --- a/NewHorizons/Components/Quantum/NHMultiStateQuantumObject.cs +++ b/NewHorizons/Components/Quantum/NHMultiStateQuantumObject.cs @@ -136,7 +136,7 @@ namespace NewHorizons.Components.Quantum num += _probabilities[j]; } } - int num2 = UnityEngine.Random.Range(0, num); + int num2 = Random.Range(0, num); int num3 = 0; int num4 = 0; foreach (int k in indices) diff --git a/NewHorizons/Components/Volumes/LoadCreditsVolume.cs b/NewHorizons/Components/Volumes/LoadCreditsVolume.cs index 6657d4c8..3fc191f2 100644 --- a/NewHorizons/Components/Volumes/LoadCreditsVolume.cs +++ b/NewHorizons/Components/Volumes/LoadCreditsVolume.cs @@ -19,8 +19,8 @@ namespace NewHorizons.Components.Volumes public void Start() { - _gameOverController = GameObject.FindObjectOfType(); - _playerCameraEffectController = GameObject.FindObjectOfType(); + _gameOverController = FindObjectOfType(); + _playerCameraEffectController = FindObjectOfType(); } public override void OnTriggerVolumeEntry(GameObject hitObj) diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index 414ce9e7..8d0eceee 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -52,15 +52,15 @@ namespace NewHorizons.Handlers starController.Intensity = 0.9859f; starController.SunColor = new Color(1f, 0.8845f, 0.6677f, 1f); - var starLightGO = GameObject.Instantiate(sun.GetComponentInChildren().gameObject); + var starLightGO = UnityEngine.Object.Instantiate(sun.GetComponentInChildren().gameObject); foreach (var comp in starLightGO.GetComponents()) { if (!(comp is SunLightController) && !(comp is SunLightParamUpdater) && !(comp is Light) && !(comp is Transform)) { - GameObject.Destroy(comp); + UnityEngine.Object.Destroy(comp); } } - GameObject.Destroy(starLightGO.GetComponent()); + UnityEngine.Object.Destroy(starLightGO.GetComponent()); starLightGO.name = "StarLightController"; starLightGO.AddComponent(); @@ -715,7 +715,7 @@ namespace NewHorizons.Handlers // We need these for later var children = AstroObjectLocator.GetChildren(ao).Concat(AstroObjectLocator.GetMoons(ao)).ToArray(); AstroObjectLocator.DeregisterCustomAstroObject(ao); - GameObject.Destroy(ao); + UnityEngine.Object.Destroy(ao); Locator.RegisterAstroObject(newAO); AstroObjectLocator.RegisterCustomAstroObject(newAO); @@ -727,7 +727,7 @@ namespace NewHorizons.Handlers // QM and stuff don't have orbit lines var orbitLine = go.GetComponentInChildren()?.gameObject; - if (orbitLine != null) GameObject.Destroy(orbitLine); + if (orbitLine != null) UnityEngine.Object.Destroy(orbitLine); var isMoon = newAO.GetAstroObjectType() is AstroObject.Type.Moon or AstroObject.Type.Satellite or AstroObject.Type.SpaceStation; if (body.Config.Orbit.showOrbitLine) OrbitlineBuilder.Make(go, newAO, isMoon, body.Config); diff --git a/NewHorizons/Handlers/PlanetDestructionHandler.cs b/NewHorizons/Handlers/PlanetDestructionHandler.cs index 038c7a8b..ba275d38 100644 --- a/NewHorizons/Handlers/PlanetDestructionHandler.cs +++ b/NewHorizons/Handlers/PlanetDestructionHandler.cs @@ -107,7 +107,7 @@ namespace NewHorizons.Handlers RemoveBody(AstroObjectLocator.GetAstroObject(AstroObject.Name.WhiteHole.ToString()), delete, toDestroy); // Might prevent leftover fragments from existing // Might also prevent people from using their own detachable fragments however - foreach(var fragment in GameObject.FindObjectsOfType()) + foreach(var fragment in UnityEngine.Object.FindObjectsOfType()) { DisableBody(fragment.gameObject, delete); } @@ -120,7 +120,7 @@ namespace NewHorizons.Handlers case AstroObject.Name.GiantsDeep: // Might prevent leftover jellyfish from existing // Might also prevent people from using their own jellyfish however - foreach (var jelly in GameObject.FindObjectsOfType()) + foreach (var jelly in UnityEngine.Object.FindObjectsOfType()) { DisableBody(jelly.gameObject, delete); } @@ -131,11 +131,11 @@ namespace NewHorizons.Handlers // Always just fucking kill this one to stop THE WARP BUG!!! DisableBody(SearchUtilities.Find("StreamingGroup_TH"), true); - foreach (var obj in GameObject.FindObjectsOfType()) + foreach (var obj in UnityEngine.Object.FindObjectsOfType()) { DisableBody(obj.gameObject, true); } - foreach (var obj in GameObject.FindObjectsOfType()) + foreach (var obj in UnityEngine.Object.FindObjectsOfType()) { DisableBody(obj.gameObject, true); } @@ -144,27 +144,27 @@ namespace NewHorizons.Handlers var starController = ao.gameObject.GetComponent(); SunLightEffectsController.RemoveStar(starController); SunLightEffectsController.RemoveStarLight(ao.transform.Find("Sector_SUN/Effects_SUN/SunLight").GetComponent()); - GameObject.Destroy(starController); + UnityEngine.Object.Destroy(starController); var audio = ao.GetComponentInChildren(); - GameObject.Destroy(audio); + UnityEngine.Object.Destroy(audio); foreach (var owAudioSource in ao.GetComponentsInChildren()) { owAudioSource.Stop(); - GameObject.Destroy(owAudioSource); + UnityEngine.Object.Destroy(owAudioSource); } foreach (var audioSource in ao.GetComponentsInChildren()) { audioSource.Stop(); - GameObject.Destroy(audioSource); + UnityEngine.Object.Destroy(audioSource); } - foreach (var sunProxy in GameObject.FindObjectsOfType()) + foreach (var sunProxy in UnityEngine.Object.FindObjectsOfType()) { NHLogger.LogVerbose($"Destroying SunProxy {sunProxy.gameObject.name}"); - GameObject.Destroy(sunProxy.gameObject); + UnityEngine.Object.Destroy(sunProxy.gameObject); } // Stop the sun from breaking stuff when the supernova gets triggered @@ -203,7 +203,7 @@ namespace NewHorizons.Handlers } // Deal with proxies - foreach (var p in GameObject.FindObjectsOfType()) + foreach (var p in UnityEngine.Object.FindObjectsOfType()) { if (p._originalBody == ao.gameObject) { @@ -215,18 +215,18 @@ namespace NewHorizons.Handlers Delay.RunWhen(() => Main.IsSystemReady, () => DisableBody(ao.gameObject, delete)); - foreach (ProxyBody proxy in GameObject.FindObjectsOfType()) + foreach (ProxyBody proxy in UnityEngine.Object.FindObjectsOfType()) { if (proxy?._realObjectTransform?.gameObject == ao.gameObject) { - GameObject.Destroy(proxy.gameObject); + UnityEngine.Object.Destroy(proxy.gameObject); } } } public static void RemoveAllProxies() { - GameObject.Destroy(GameObject.FindObjectOfType().gameObject); + UnityEngine.Object.Destroy(UnityEngine.Object.FindObjectOfType().gameObject); foreach (var name in _solarSystemBodies) { @@ -274,7 +274,7 @@ namespace NewHorizons.Handlers if (delete) { - GameObject.Destroy(go); + UnityEngine.Object.Destroy(go); } else { @@ -294,8 +294,8 @@ namespace NewHorizons.Handlers var distantProxy = SearchUtilities.Find(name + "_DistantProxy", false); var distantProxyClone = SearchUtilities.Find(name + "_DistantProxy(Clone)", false); - if (distantProxy != null) GameObject.Destroy(distantProxy.gameObject); - if (distantProxyClone != null) GameObject.Destroy(distantProxyClone.gameObject); + if (distantProxy != null) UnityEngine.Object.Destroy(distantProxy.gameObject); + if (distantProxyClone != null) UnityEngine.Object.Destroy(distantProxyClone.gameObject); if (distantProxy == null && distantProxyClone == null) NHLogger.LogVerbose($"Couldn't find proxy for {name}"); diff --git a/NewHorizons/Handlers/StarChartHandler.cs b/NewHorizons/Handlers/StarChartHandler.cs index 9acaf8ff..c1dd0928 100644 --- a/NewHorizons/Handlers/StarChartHandler.cs +++ b/NewHorizons/Handlers/StarChartHandler.cs @@ -35,7 +35,7 @@ namespace NewHorizons.Handlers ShipLogStarChartMode = starChartLog.AddComponent(); - GameObject.Instantiate(reticleImage, starChartLog.transform); + Object.Instantiate(reticleImage, starChartLog.transform); var scaleRoot = new GameObject("ScaleRoot"); scaleRoot.transform.parent = starChartLog.transform; diff --git a/NewHorizons/Handlers/TitleSceneHandler.cs b/NewHorizons/Handlers/TitleSceneHandler.cs index be0249bb..e7337c12 100644 --- a/NewHorizons/Handlers/TitleSceneHandler.cs +++ b/NewHorizons/Handlers/TitleSceneHandler.cs @@ -156,11 +156,11 @@ namespace NewHorizons.Handlers } } - var pivot = GameObject.Instantiate(SearchUtilities.Find("Scene/Background/PlanetPivot"), SearchUtilities.Find("Scene/Background").transform); + var pivot = Object.Instantiate(SearchUtilities.Find("Scene/Background/PlanetPivot"), SearchUtilities.Find("Scene/Background").transform); pivot.GetComponent()._degreesPerSecond = 10f; foreach (Transform child in pivot.transform) { - GameObject.Destroy(child.gameObject); + Object.Destroy(child.gameObject); } pivot.name = "Pivot"; diff --git a/NewHorizons/Handlers/VesselWarpHandler.cs b/NewHorizons/Handlers/VesselWarpHandler.cs index ce17e778..803b9649 100644 --- a/NewHorizons/Handlers/VesselWarpHandler.cs +++ b/NewHorizons/Handlers/VesselWarpHandler.cs @@ -1,12 +1,11 @@ -using UnityEngine; -using NewHorizons.Utility; - -using static NewHorizons.Main; using NewHorizons.Builder.Props; -using NewHorizons.Utility.OWML; -using NewHorizons.Utility.OuterWilds; -using NewHorizons.Components.Vessel; using NewHorizons.Components.EyeOfTheUniverse; +using NewHorizons.Components.Vessel; +using NewHorizons.Utility; +using NewHorizons.Utility.OuterWilds; +using NewHorizons.Utility.OWML; +using UnityEngine; +using static NewHorizons.Main; namespace NewHorizons.Handlers { @@ -21,7 +20,7 @@ namespace NewHorizons.Handlers public static void Initialize() { - VesselPrefab = Main.NHPrivateAssetBundle.LoadAsset("Vessel_Body"); + VesselPrefab = NHPrivateAssetBundle.LoadAsset("Vessel_Body"); } public static bool IsVesselPresentAndActive() @@ -62,7 +61,7 @@ namespace NewHorizons.Handlers public static void TeleportToVessel() { - var playerSpawner = GameObject.FindObjectOfType(); + var playerSpawner = Object.FindObjectOfType(); playerSpawner.DebugWarp(_vesselSpawnPoint); Builder.General.SpawnPointBuilder.SuitUp(); @@ -110,34 +109,34 @@ namespace NewHorizons.Handlers GameObject warpBH = WarpPlatform.transform.Find("BlackHole").gameObject; GameObject warpWH = WarpPlatform.transform.Find("WhiteHole").gameObject; - GameObject sourceBH = GameObject.Instantiate(warpBH, vesselWarpController._sourceWarpPlatform.transform, false); + GameObject sourceBH = Object.Instantiate(warpBH, vesselWarpController._sourceWarpPlatform.transform, false); sourceBH.name = "BlackHole"; vesselWarpController._sourceWarpPlatform._blackHole = sourceBH.GetComponentInChildren(); vesselWarpController._sourceWarpPlatform._blackHole.OnCollapse += vesselWarpController._sourceWarpPlatform.OnBlackHoleCollapse; - GameObject sourceWH = GameObject.Instantiate(warpWH, vesselWarpController._sourceWarpPlatform.transform, false); + GameObject sourceWH = Object.Instantiate(warpWH, vesselWarpController._sourceWarpPlatform.transform, false); sourceWH.name = "WhiteHole"; vesselWarpController._sourceWarpPlatform._whiteHole = sourceWH.GetComponentInChildren(); vesselWarpController._sourceWarpPlatform._whiteHole.OnCollapse += vesselWarpController._sourceWarpPlatform.OnWhiteHoleCollapse; - GameObject targetBH = GameObject.Instantiate(warpBH, vesselWarpController._targetWarpPlatform.transform, false); + GameObject targetBH = Object.Instantiate(warpBH, vesselWarpController._targetWarpPlatform.transform, false); targetBH.name = "BlackHole"; vesselWarpController._targetWarpPlatform._blackHole = targetBH.GetComponentInChildren(); vesselWarpController._targetWarpPlatform._blackHole.OnCollapse += vesselWarpController._targetWarpPlatform.OnBlackHoleCollapse; - GameObject targetWH = GameObject.Instantiate(warpWH, vesselWarpController._targetWarpPlatform.transform, false); + GameObject targetWH = Object.Instantiate(warpWH, vesselWarpController._targetWarpPlatform.transform, false); targetWH.name = "WhiteHole"; vesselWarpController._targetWarpPlatform._whiteHole = targetWH.GetComponentInChildren(); vesselWarpController._targetWarpPlatform._whiteHole.OnCollapse += vesselWarpController._targetWarpPlatform.OnWhiteHoleCollapse; GameObject blackHole = SearchUtilities.Find("DB_VesselDimension_Body/Sector_VesselDimension/Sector_VesselBridge/Interactibles_VesselBridge/BlackHole"); - GameObject newBlackHole = GameObject.Instantiate(blackHole, Vector3.zero, Quaternion.identity, singularityRoot.transform); + GameObject newBlackHole = Object.Instantiate(blackHole, Vector3.zero, Quaternion.identity, singularityRoot.transform); newBlackHole.name = "BlackHole"; vesselWarpController._blackHole = newBlackHole.GetComponentInChildren(); vesselWarpController._blackHoleOneShot = vesselWarpController._blackHole.transform.parent.Find("BlackHoleAudio_OneShot").GetComponent(); GameObject whiteHole = SearchUtilities.Find("DB_VesselDimension_Body/Sector_VesselDimension/Sector_VesselBridge/Interactibles_VesselBridge/WhiteHole"); - GameObject newWhiteHole = GameObject.Instantiate(whiteHole, Vector3.zero, Quaternion.identity, singularityRoot.transform); + GameObject newWhiteHole = Object.Instantiate(whiteHole, Vector3.zero, Quaternion.identity, singularityRoot.transform); newWhiteHole.name = "WhiteHole"; vesselWarpController._whiteHole = newWhiteHole.GetComponentInChildren(); vesselWarpController._whiteHoleOneShot = vesselWarpController._whiteHole.transform.parent.Find("WhiteHoleAudio_OneShot").GetComponent(); @@ -155,14 +154,14 @@ namespace NewHorizons.Handlers else { vesselAO._owRigidbody = null; - UnityEngine.Object.DestroyImmediate(vesselObject.GetComponent()); - UnityEngine.Object.DestroyImmediate(vesselObject.GetComponent()); - UnityEngine.Object.DestroyImmediate(vesselObject.GetComponent()); - UnityEngine.Object.DestroyImmediate(vesselObject.GetComponent()); + Object.DestroyImmediate(vesselObject.GetComponent()); + Object.DestroyImmediate(vesselObject.GetComponent()); + Object.DestroyImmediate(vesselObject.GetComponent()); + Object.DestroyImmediate(vesselObject.GetComponent()); var rfVolume = vesselObject.transform.Find("RFVolume"); if (rfVolume != null) { - GameObject.Destroy(rfVolume.gameObject); + Object.Destroy(rfVolume.gameObject); } } @@ -182,7 +181,7 @@ namespace NewHorizons.Handlers var zeroGVolume = vesselObject.transform.Find("Sector_VesselBridge/Volumes_VesselBridge/ZeroGVolume"); if (zeroGVolume != null) { - GameObject.Destroy(zeroGVolume.gameObject); + Object.Destroy(zeroGVolume.gameObject); } } @@ -233,7 +232,7 @@ namespace NewHorizons.Handlers { if (core.GetWarpCoreType().Equals(WarpCoreType.Vessel)) { - var newCore = GameObject.Instantiate(core, AstroObjectLocator.GetAstroObject("Vessel Dimension")?.transform ?? Locator.GetPlayerBody()?.transform); + var newCore = Object.Instantiate(core, AstroObjectLocator.GetAstroObject("Vessel Dimension")?.transform ?? Locator.GetPlayerBody()?.transform); newCore._visible = true; foreach (OWRenderer render in newCore._renderers) { diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index dfc37056..f411e67f 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -332,7 +332,7 @@ namespace NewHorizons { TimeLoopUtilities.SetSecondsElapsed(SecondsElapsedInLoop); // Prevent the OPC from firing - var launchController = GameObject.FindObjectOfType(); + var launchController = FindObjectOfType(); if (launchController != null) { GlobalMessenger.RemoveListener("StartOfTimeLoop", launchController.OnStartOfTimeLoop); @@ -386,7 +386,7 @@ namespace NewHorizons if (isSolarSystem) { - foreach (var supernovaPlanetEffectController in GameObject.FindObjectsOfType()) + foreach (var supernovaPlanetEffectController in FindObjectsOfType()) { SupernovaEffectBuilder.ReplaceVanillaWithNH(supernovaPlanetEffectController); } @@ -417,7 +417,7 @@ namespace NewHorizons IsWarpingFromVessel = false; DidWarpFromVessel = shouldWarpInFromVessel; - var map = GameObject.FindObjectOfType(); + var map = FindObjectOfType(); if (map != null) map._maxPanDistance = FurthestOrbit * 1.5f; // Fix the map satellite @@ -499,7 +499,7 @@ namespace NewHorizons var ssrLight = solarSystemRoot.AddComponent(); ssrLight.innerSpotAngle = 0; ssrLight.spotAngle = 179; - ssrLight.range = Main.FurthestOrbit * (4f / 3f); + ssrLight.range = FurthestOrbit * (4f / 3f); ssrLight.intensity = 0.001f; var fluid = playerBody.FindChild("PlayerDetector").GetComponent(); diff --git a/NewHorizons/Utility/DebugTools/DebugRaycaster.cs b/NewHorizons/Utility/DebugTools/DebugRaycaster.cs index ea2f1fca..dd6cd9f4 100644 --- a/NewHorizons/Utility/DebugTools/DebugRaycaster.cs +++ b/NewHorizons/Utility/DebugTools/DebugRaycaster.cs @@ -80,13 +80,13 @@ namespace NewHorizons.Utility.DebugTools var normText = Vector3ToString(data.norm); var rotText = Vector3ToString(data.rot.eulerAngles); - if (_surfaceSphere != null) GameObject.Destroy(_surfaceSphere); - if (_normalSphere1 != null) GameObject.Destroy(_normalSphere1); - if (_normalSphere2 != null) GameObject.Destroy(_normalSphere2); - if (_planeUpRightSphere != null) GameObject.Destroy(_planeUpRightSphere); - if (_planeUpLeftSphere != null) GameObject.Destroy(_planeUpLeftSphere); - if (_planeDownLeftSphere != null) GameObject.Destroy(_planeDownLeftSphere); - if (_planeDownRightSphere != null) GameObject.Destroy(_planeDownRightSphere); + if (_surfaceSphere != null) Destroy(_surfaceSphere); + if (_normalSphere1 != null) Destroy(_normalSphere1); + if (_normalSphere2 != null) Destroy(_normalSphere2); + if (_planeUpRightSphere != null) Destroy(_planeUpRightSphere); + if (_planeUpLeftSphere != null) Destroy(_planeUpLeftSphere); + if (_planeDownLeftSphere != null) Destroy(_planeDownLeftSphere); + if (_planeDownRightSphere != null) Destroy(_planeDownRightSphere); _surfaceSphere = AddDebugShape.AddSphere(data.hitBodyGameObject, 0.1f, Color.green); _normalSphere1 = AddDebugShape.AddSphere(data.hitBodyGameObject, 0.01f, Color.red); diff --git a/NewHorizons/Utility/NewHorizonExtensions.cs b/NewHorizons/Utility/NewHorizonExtensions.cs index 6b0edbd9..a0a5303b 100644 --- a/NewHorizons/Utility/NewHorizonExtensions.cs +++ b/NewHorizons/Utility/NewHorizonExtensions.cs @@ -250,7 +250,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); - OWML.NHLogger.LogVerbose($"Coordinate Check for {system}: {xCorrect}, {yCorrect}, {zCorrect} [{string.Join("-", coordinates.x)}, {string.Join("-", coordinates.y)}, {string.Join("-", coordinates.z)}]"); + NHLogger.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/RandomUtility.cs b/NewHorizons/Utility/RandomUtility.cs index 971e1526..cca88186 100644 --- a/NewHorizons/Utility/RandomUtility.cs +++ b/NewHorizons/Utility/RandomUtility.cs @@ -15,7 +15,7 @@ namespace NewHorizons.Utility } for (var x = 0; x < count; x++) { - var randomIndex = UnityEngine.Random.Range(0, numbersInOrder.Count); + var randomIndex = Random.Range(0, numbersInOrder.Count); result[x] = numbersInOrder[randomIndex]; numbersInOrder.RemoveAt(randomIndex); } diff --git a/NewHorizons/Utility/SearchUtilities.cs b/NewHorizons/Utility/SearchUtilities.cs index 3d043925..0bbc5990 100644 --- a/NewHorizons/Utility/SearchUtilities.cs +++ b/NewHorizons/Utility/SearchUtilities.cs @@ -19,7 +19,7 @@ namespace NewHorizons.Utility public static List FindObjectsOfTypeAndName(string name) where T : Object { - T[] firstList = GameObject.FindObjectsOfType(); + T[] firstList = Object.FindObjectsOfType(); List finalList = new List(); for (var i = 0; i < firstList.Length; i++) @@ -35,7 +35,7 @@ namespace NewHorizons.Utility public static T FindObjectOfTypeAndName(string name) where T : Object { - T[] firstList = GameObject.FindObjectsOfType(); + T[] firstList = Object.FindObjectsOfType(); for (var i = 0; i < firstList.Length; i++) { From 2fb6324c1c651bce7fc156da75ea3c95f5b9415e Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 22 Apr 2023 16:16:02 -0400 Subject: [PATCH 18/19] Add tostring to MVector3 --- NewHorizons/External/SerializableData/MVector3.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NewHorizons/External/SerializableData/MVector3.cs b/NewHorizons/External/SerializableData/MVector3.cs index 91319224..33100bc1 100644 --- a/NewHorizons/External/SerializableData/MVector3.cs +++ b/NewHorizons/External/SerializableData/MVector3.cs @@ -26,5 +26,7 @@ namespace NewHorizons.External.SerializableData { return new Vector3(vec.x, vec.y, vec.z); } + + public override string ToString() => $"{x}, {y}, {z}"; } } From c7263070e00d303f58d5836aca79d5562598b324 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 22 Apr 2023 16:44:09 -0400 Subject: [PATCH 19/19] Fix the issue with unity project guys --- NewHorizons/Components/{Vessel => }/VesselOrbLocker.cs | 2 +- NewHorizons/Components/{Vessel => }/VesselSingularityRoot.cs | 2 +- NewHorizons/Handlers/VesselWarpHandler.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename NewHorizons/Components/{Vessel => }/VesselOrbLocker.cs (97%) rename NewHorizons/Components/{Vessel => }/VesselSingularityRoot.cs (74%) diff --git a/NewHorizons/Components/Vessel/VesselOrbLocker.cs b/NewHorizons/Components/VesselOrbLocker.cs similarity index 97% rename from NewHorizons/Components/Vessel/VesselOrbLocker.cs rename to NewHorizons/Components/VesselOrbLocker.cs index a10958fc..a7343659 100644 --- a/NewHorizons/Components/Vessel/VesselOrbLocker.cs +++ b/NewHorizons/Components/VesselOrbLocker.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace NewHorizons.Components.Vessel +namespace NewHorizons.Components { [UsedInUnityProject] public class VesselOrbLocker : MonoBehaviour diff --git a/NewHorizons/Components/Vessel/VesselSingularityRoot.cs b/NewHorizons/Components/VesselSingularityRoot.cs similarity index 74% rename from NewHorizons/Components/Vessel/VesselSingularityRoot.cs rename to NewHorizons/Components/VesselSingularityRoot.cs index dce83f1d..fcfc3fab 100644 --- a/NewHorizons/Components/Vessel/VesselSingularityRoot.cs +++ b/NewHorizons/Components/VesselSingularityRoot.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace NewHorizons.Components.Vessel +namespace NewHorizons.Components { [UsedInUnityProject] public class VesselSingularityRoot : MonoBehaviour diff --git a/NewHorizons/Handlers/VesselWarpHandler.cs b/NewHorizons/Handlers/VesselWarpHandler.cs index 803b9649..9cc279ce 100644 --- a/NewHorizons/Handlers/VesselWarpHandler.cs +++ b/NewHorizons/Handlers/VesselWarpHandler.cs @@ -1,6 +1,6 @@ using NewHorizons.Builder.Props; +using NewHorizons.Components; using NewHorizons.Components.EyeOfTheUniverse; -using NewHorizons.Components.Vessel; using NewHorizons.Utility; using NewHorizons.Utility.OuterWilds; using NewHorizons.Utility.OWML;