From 55afeece54e4442c941ff28491b8b35a67ad4113 Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 5 Jul 2023 19:42:03 -0400 Subject: [PATCH 01/15] Update addon-manifest.json --- NewHorizons/Assets/addon-manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Assets/addon-manifest.json b/NewHorizons/Assets/addon-manifest.json index da53675c..363bc1bb 100644 --- a/NewHorizons/Assets/addon-manifest.json +++ b/NewHorizons/Assets/addon-manifest.json @@ -12,7 +12,7 @@ "Ernesto#Fish", "With help from#Raicuparta\n#dgarroDC\n#jtsalomo\n#and the modding community", " ", - "Based off Marshmallow made by#Mister_Nebula", + "Based off Marshmallow made by#_nebula", "With help from#AmazingAlek\n#Raicuparta\n#and the Outer Wilds discord server", " ", "This work is unofficial Fan Content and is not affiliated with Mobius Digital" From f60620c5a54d8f55cc4e3b08c3933f984ad96b4d Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 6 Jul 2023 00:21:20 -0400 Subject: [PATCH 02/15] Prevent softlock due to slide reels when changing system/reloading --- NewHorizons/Main.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 6ef0e65f..3036f720 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -811,6 +811,12 @@ namespace NewHorizons return; } + if (LoadManager.GetCurrentScene() == OWScene.SolarSystem || LoadManager.GetCurrentScene() == OWScene.EyeOfTheUniverse) + { + // Slide reel unloading is tied to being removed from the sector, so we do that here to prevent a softlock + Locator.GetPlayerSectorDetector().RemoveFromAllSectors(); + } + if (IsChangingStarSystem) return; IsWarpingFromShip = warp; From 6c4d89636780e0910b9b08ddf3b55c38a1770cb6 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 6 Jul 2023 00:53:22 -0400 Subject: [PATCH 03/15] Remove unneeded call to LoadStreamingTextures - leave todo for fixing low res --- NewHorizons/Builder/Props/DetailBuilder.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index 69ff3c11..7220a60d 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -1,5 +1,6 @@ using NewHorizons.Builder.General; using NewHorizons.Components; +using NewHorizons.Components.Fixers; using NewHorizons.External.Modules.Props; using NewHorizons.Handlers; using NewHorizons.Utility; @@ -265,10 +266,10 @@ namespace NewHorizons.Builder.Props socket._sector = sector; } - // Fix slide reel - Softlocks if this object is a vision torch - else if(!isTorch && component is SlideCollectionContainer container) + // TODO: Fix low res reels + else if(component is SlideReelItem) { - sector.OnOccupantEnterSector.AddListener(_ => container.LoadStreamingTextures()); + } else if(component is NomaiRemoteCameraPlatform remoteCameraPlatform) From 9ae8552badbeaa7b23459224e26e89cc676db869 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 6 Jul 2023 00:53:32 -0400 Subject: [PATCH 04/15] Update OWML version --- NewHorizons/NewHorizons.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/NewHorizons.csproj b/NewHorizons/NewHorizons.csproj index 722d08c8..d3623e53 100644 --- a/NewHorizons/NewHorizons.csproj +++ b/NewHorizons/NewHorizons.csproj @@ -15,8 +15,8 @@ none - + From 40643adacd62bf203a81bf7c9809d8f8cb7ad457 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Wed, 5 Jul 2023 22:08:45 -0700 Subject: [PATCH 05/15] remove isTorch --- NewHorizons/Builder/Props/DetailBuilder.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index 7220a60d..3cfd212f 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -1,6 +1,5 @@ using NewHorizons.Builder.General; using NewHorizons.Components; -using NewHorizons.Components.Fixers; using NewHorizons.External.Modules.Props; using NewHorizons.Handlers; using NewHorizons.Utility; @@ -103,7 +102,6 @@ namespace NewHorizons.Builder.Props StreamingHandler.SetUpStreaming(prop, detail.keepLoaded ? null : sector); // Could check this in the for loop but I'm not sure what order we need to know about this in - var isTorch = prop.GetComponent() != null; isItem = false; foreach (var component in prop.GetComponentsInChildren(true)) @@ -121,7 +119,7 @@ namespace NewHorizons.Builder.Props { if (FixUnsectoredComponent(component)) continue; } - else FixSectoredComponent(component, sector, isTorch, detail.keepLoaded); + else FixSectoredComponent(component, sector, detail.keepLoaded); FixComponent(component, go, detail.ignoreSun); } @@ -220,7 +218,7 @@ namespace NewHorizons.Builder.Props /// /// Fix components that have sectors. Has a specific fix if there is a VisionTorchItem on the object. /// - private static void FixSectoredComponent(Component component, Sector sector, bool isTorch, bool keepLoaded) + private static void FixSectoredComponent(Component component, Sector sector, bool keepLoaded) { // keepLoaded should remove existing groups // renderers/colliders get enabled later so we dont have to do that here From 834efb638a5818b47bb6f46d4bb5547e1b9b1ea7 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Wed, 5 Jul 2023 22:10:46 -0700 Subject: [PATCH 06/15] update TODO --- NewHorizons/Builder/Props/DetailBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index 3cfd212f..1a82eb4d 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -264,7 +264,7 @@ namespace NewHorizons.Builder.Props socket._sector = sector; } - // TODO: Fix low res reels + // TODO: Fix low res reels (probably in VanillaFix since its a vanilla bug) else if(component is SlideReelItem) { From b51b7023137e9319d5790f548c7d23b7533b325d Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Wed, 12 Jul 2023 02:44:49 -0400 Subject: [PATCH 07/15] Rename onlyAffectsPlayerAndShip to onlyAffectsPlayerRelatedBodies because this is what it actually does --- NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs | 2 +- NewHorizons/External/Configs/PlanetConfig.cs | 12 ++++++++++-- .../Modules/Volumes/VolumeInfos/VanishVolumeInfo.cs | 7 +++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs b/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs index 48be7181..9bc2a514 100644 --- a/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs +++ b/NewHorizons/Builder/Volumes/VanishVolumeBuilder.cs @@ -26,7 +26,7 @@ namespace NewHorizons.Builder.Volumes volume._collider = collider; volume._shrinkBodies = info.shrinkBodies; - volume._onlyAffectsPlayerAndShip = info.onlyAffectsPlayerAndShip; + volume._onlyAffectsPlayerAndShip = info.onlyAffectsPlayerRelatedBodies; go.SetActive(true); diff --git a/NewHorizons/External/Configs/PlanetConfig.cs b/NewHorizons/External/Configs/PlanetConfig.cs index 260896b3..e76225c4 100644 --- a/NewHorizons/External/Configs/PlanetConfig.cs +++ b/NewHorizons/External/Configs/PlanetConfig.cs @@ -217,7 +217,7 @@ namespace NewHorizons.External.Configs if (Base.centerOfSolarSystem) Orbit.isStatic = true; if (Atmosphere?.clouds?.lightningGradient != null) Atmosphere.clouds.hasLightning = true; if (Bramble?.dimension != null && Orbit?.staticPosition == null) throw new Exception($"Dimension {name} must have Orbit.staticPosition defined."); - if (Bramble?.dimension != null) canShowOnTitle = false; + if (Bramble?.dimension != null) canShowOnTitle = false; if (Orbit?.staticPosition != null) Orbit.isStatic = true; // For each quantum group, verify the following: @@ -463,7 +463,7 @@ namespace NewHorizons.External.Configs if (ring.curve != null) ring.scaleCurve = ring.curve; } } - + if (Base.zeroGravityRadius != 0f) { Volumes ??= new VolumesModule(); @@ -616,6 +616,14 @@ namespace NewHorizons.External.Configs CometTail.rotationOverride = Base.cometTailRotation; } } + + if (Volumes?.destructionVolumes != null) + { + foreach (var destructionVolume in Volumes.destructionVolumes) + { + if (destructionVolume.onlyAffectsPlayerAndShip) destructionVolume.onlyAffectsPlayerRelatedBodies = true; + } + } } #endregion } diff --git a/NewHorizons/External/Modules/Volumes/VolumeInfos/VanishVolumeInfo.cs b/NewHorizons/External/Modules/Volumes/VolumeInfos/VanishVolumeInfo.cs index 0cab17e6..bb66b0a8 100644 --- a/NewHorizons/External/Modules/Volumes/VolumeInfos/VanishVolumeInfo.cs +++ b/NewHorizons/External/Modules/Volumes/VolumeInfos/VanishVolumeInfo.cs @@ -1,4 +1,5 @@ using Newtonsoft.Json; +using System; using System.ComponentModel; namespace NewHorizons.External.Modules.Volumes.VolumeInfos @@ -12,9 +13,11 @@ namespace NewHorizons.External.Modules.Volumes.VolumeInfos [DefaultValue(true)] public bool shrinkBodies = true; /// - /// Whether this volume only affects the player and ship. + /// Whether this volume only affects the player, ship, probe/scout, model rocket ship, and nomai shuttle. /// - public bool onlyAffectsPlayerAndShip; + public bool onlyAffectsPlayerRelatedBodies; + + [Obsolete] public bool onlyAffectsPlayerAndShip; } } From 76c0cf895bcc7f48110f81f80f9120831cd938db Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Wed, 12 Jul 2023 02:45:30 -0400 Subject: [PATCH 08/15] Add more to the descriptions of volumes --- .../External/Modules/Volumes/ProbeModule.cs | 6 ++++-- .../External/Modules/Volumes/RulesetModule.cs | 4 +++- .../External/Modules/Volumes/VolumesModule.cs | 18 ++++++++++++++---- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/NewHorizons/External/Modules/Volumes/ProbeModule.cs b/NewHorizons/External/Modules/Volumes/ProbeModule.cs index 27568ae9..67348abc 100644 --- a/NewHorizons/External/Modules/Volumes/ProbeModule.cs +++ b/NewHorizons/External/Modules/Volumes/ProbeModule.cs @@ -7,12 +7,14 @@ namespace NewHorizons.External.Modules.Volumes public class ProbeModule { /// - /// Add probe destruction volumes to this planet. These will delete your probe. + /// Add probe destruction volumes to this planet. + /// These will delete your probe just like the eye of the universe does. /// public VolumeInfo[] destructionVolumes; /// - /// Add probe safety volumes to this planet. These will stop the probe destruction volumes from working. + /// Add probe safety volumes to this planet. + /// These will stop the probe destruction volumes from working. /// public VolumeInfo[] safetyVolumes; } diff --git a/NewHorizons/External/Modules/Volumes/RulesetModule.cs b/NewHorizons/External/Modules/Volumes/RulesetModule.cs index 3604ba2e..e5e74d0c 100644 --- a/NewHorizons/External/Modules/Volumes/RulesetModule.cs +++ b/NewHorizons/External/Modules/Volumes/RulesetModule.cs @@ -9,10 +9,12 @@ namespace NewHorizons.External.Modules.Volumes { /// /// Add anti travel music rulesets to this planet. + /// This means no space/traveling music while inside the ruleset/volume. + /// Usually used on planets. /// public VolumeInfo[] antiTravelMusicRulesets; /// - /// Add player impact rulesets to this planet. + /// Add player impact rulesets to this planet. /// public PlayerImpactRulesetInfo[] playerImpactRulesets; /// diff --git a/NewHorizons/External/Modules/Volumes/VolumesModule.cs b/NewHorizons/External/Modules/Volumes/VolumesModule.cs index 9d5a9163..f11189d9 100644 --- a/NewHorizons/External/Modules/Volumes/VolumesModule.cs +++ b/NewHorizons/External/Modules/Volumes/VolumesModule.cs @@ -13,6 +13,7 @@ namespace NewHorizons.External.Modules.Volumes /// /// Add destruction volumes to this planet. + /// Destroys bodies if they enter this volume. Can kill the player and recall the scout probe. /// public DestructionVolumeInfo[] destructionVolumes; @@ -23,31 +24,38 @@ namespace NewHorizons.External.Modules.Volumes /// /// Add hazard volumes to this planet. + /// Causes damage to player when inside this volume. /// public HazardVolumeInfo[] hazardVolumes; /// /// Add interference volumes to this planet. + /// Hides HUD markers of ship scout/probe and prevents scout photos if you are not inside the volume together with ship or scout probe. /// public VolumeInfo[] interferenceVolumes; /// - /// Add insulating volumes to this planet. These will stop electricty hazard volumes from affecting you (just like the jellyfish). + /// Add insulating volumes to this planet. + /// These will stop electricty hazard volumes from affecting you (just like the jellyfish). /// public VolumeInfo[] insulatingVolumes; /// - /// Add light source volumes to this planet. These will activate rafts and other light detectors. + /// Add light source volumes to this planet. + /// These will activate rafts and other light detectors. /// public VolumeInfo[] lightSourceVolumes; /// /// Add map restriction volumes to this planet. + /// The map will be disabled when inside this volume. /// public VolumeInfo[] mapRestrictionVolumes; /// /// Add notification volumes to this planet. + /// Sends a notification to the player just like ghost matter does when you get too close + /// and also to the ship just like when you damage a component on the ship. /// public NotificationVolumeInfo[] notificationVolumes; @@ -62,7 +70,8 @@ namespace NewHorizons.External.Modules.Volumes public ProbeModule probe; /// - /// Add reference frame blocker volumes to this planet. These will stop the player from seeing/targeting any reference frames. + /// Add reference frame blocker volumes to this planet. + /// These will stop the player from seeing/targeting any reference frames. /// public VolumeInfo[] referenceFrameBlockerVolumes; @@ -82,7 +91,8 @@ namespace NewHorizons.External.Modules.Volumes public RulesetModule rulesets; /// - /// Add speed trap volumes to this planet. Slows down the player when they enter this volume. + /// Add speed trap volumes to this planet. + /// Slows down the player when they enter this volume. /// public SpeedTrapVolumeInfo[] speedTrapVolumes; From 1c88e863bbe7e94f2226998b52d50f1f9b40e2fb Mon Sep 17 00:00:00 2001 From: Ben C Date: Wed, 12 Jul 2023 06:48:17 +0000 Subject: [PATCH 09/15] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 30 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 3f72f361..76873e3f 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -3263,7 +3263,7 @@ }, "destructionVolumes": { "type": "array", - "description": "Add destruction volumes to this planet.", + "description": "Add destruction volumes to this planet.\nDestroys bodies if they enter this volume. Can kill the player and recall the scout probe.", "items": { "$ref": "#/definitions/DestructionVolumeInfo" } @@ -3277,42 +3277,42 @@ }, "hazardVolumes": { "type": "array", - "description": "Add hazard volumes to this planet.", + "description": "Add hazard volumes to this planet.\nCauses damage to player when inside this volume.", "items": { "$ref": "#/definitions/HazardVolumeInfo" } }, "interferenceVolumes": { "type": "array", - "description": "Add interference volumes to this planet.", + "description": "Add interference volumes to this planet.\nHides HUD markers of ship scout/probe and prevents scout photos if you are not inside the volume together with ship or scout probe.", "items": { "$ref": "#/definitions/VolumeInfo" } }, "insulatingVolumes": { "type": "array", - "description": "Add insulating volumes to this planet. These will stop electricty hazard volumes from affecting you (just like the jellyfish).", + "description": "Add insulating volumes to this planet.\nThese will stop electricty hazard volumes from affecting you (just like the jellyfish).", "items": { "$ref": "#/definitions/VolumeInfo" } }, "lightSourceVolumes": { "type": "array", - "description": "Add light source volumes to this planet. These will activate rafts and other light detectors.", + "description": "Add light source volumes to this planet.\nThese will activate rafts and other light detectors.", "items": { "$ref": "#/definitions/VolumeInfo" } }, "mapRestrictionVolumes": { "type": "array", - "description": "Add map restriction volumes to this planet.", + "description": "Add map restriction volumes to this planet.\nThe map will be disabled when inside this volume.", "items": { "$ref": "#/definitions/VolumeInfo" } }, "notificationVolumes": { "type": "array", - "description": "Add notification volumes to this planet.", + "description": "Add notification volumes to this planet.\nSends a notification to the player just like ghost matter does when you get too close\nand also to the ship just like when you damage a component on the ship.", "items": { "$ref": "#/definitions/NotificationVolumeInfo" } @@ -3330,7 +3330,7 @@ }, "referenceFrameBlockerVolumes": { "type": "array", - "description": "Add reference frame blocker volumes to this planet. These will stop the player from seeing/targeting any reference frames.", + "description": "Add reference frame blocker volumes to this planet.\nThese will stop the player from seeing/targeting any reference frames.", "items": { "$ref": "#/definitions/VolumeInfo" } @@ -3355,7 +3355,7 @@ }, "speedTrapVolumes": { "type": "array", - "description": "Add speed trap volumes to this planet. Slows down the player when they enter this volume.", + "description": "Add speed trap volumes to this planet.\nSlows down the player when they enter this volume.", "items": { "$ref": "#/definitions/SpeedTrapVolumeInfo" } @@ -3494,9 +3494,9 @@ "description": "Whether the bodies will shrink when they enter this volume or just disappear instantly.", "default": true }, - "onlyAffectsPlayerAndShip": { + "onlyAffectsPlayerRelatedBodies": { "type": "boolean", - "description": "Whether this volume only affects the player and ship." + "description": "Whether this volume only affects the player, ship, probe/scout, model rocket ship, and nomai shuttle." }, "radius": { "type": "number", @@ -3859,14 +3859,14 @@ "properties": { "destructionVolumes": { "type": "array", - "description": "Add probe destruction volumes to this planet. These will delete your probe.", + "description": "Add probe destruction volumes to this planet.\nThese will delete your probe just like the eye of the universe does.", "items": { "$ref": "#/definitions/VolumeInfo" } }, "safetyVolumes": { "type": "array", - "description": "Add probe safety volumes to this planet. These will stop the probe destruction volumes from working.", + "description": "Add probe safety volumes to this planet.\nThese will stop the probe destruction volumes from working.", "items": { "$ref": "#/definitions/VolumeInfo" } @@ -3968,14 +3968,14 @@ "properties": { "antiTravelMusicRulesets": { "type": "array", - "description": "Add anti travel music rulesets to this planet.", + "description": "Add anti travel music rulesets to this planet.\nThis means no space/traveling music while inside the ruleset/volume.\nUsually used on planets.", "items": { "$ref": "#/definitions/VolumeInfo" } }, "playerImpactRulesets": { "type": "array", - "description": "Add player impact rulesets to this planet.", + "description": "Add player impact rulesets to this planet. ", "items": { "$ref": "#/definitions/PlayerImpactRulesetInfo" } From fbbaeb4fb66999a60ccc1ae7353947e27f20fe5c Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 13 Jul 2023 18:54:35 -0400 Subject: [PATCH 10/15] Make more fields public, create cloak volume manually --- NewHorizons/Builder/Body/CloakBuilder.cs | 17 ++++++++++++----- NewHorizons/External/Modules/CloakModule.cs | 17 +++++++++++++++-- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/NewHorizons/Builder/Body/CloakBuilder.cs b/NewHorizons/Builder/Body/CloakBuilder.cs index ccdee273..30ad35e6 100644 --- a/NewHorizons/Builder/Body/CloakBuilder.cs +++ b/NewHorizons/Builder/Body/CloakBuilder.cs @@ -44,14 +44,21 @@ namespace NewHorizons.Builder.Body Object.Destroy(newCloak.GetComponent()); var cloakFieldController = newCloak.GetComponent(); - cloakFieldController._cloakScaleDist = radius * 2000 / 3000f; - cloakFieldController._farCloakRadius = radius * 500 / 3000f; - cloakFieldController._innerCloakRadius = radius * 900 / 3000f; - cloakFieldController._nearCloakRadius = radius * 800 / 3000f; + cloakFieldController._cloakScaleDist = module.cloakScaleDist ?? (radius * 2000 / 3000f); + cloakFieldController._farCloakRadius = module.farCloakRadius ?? (radius * 500 / 3000f); + cloakFieldController._innerCloakRadius = module.innerCloakRadius ?? (radius * 900 / 3000f); + cloakFieldController._nearCloakRadius = module.nearCloakRadius ?? (radius * 800 / 3000f); cloakFieldController._referenceFrameVolume = OWRB._attachedRFVolume; cloakFieldController._exclusionSector = null; - cloakFieldController._cloakSphereVolume = (sector?.transform ?? planetGO.transform).GetComponentInChildren(); + + var cloakVolumeObj = new GameObject("CloakVolume"); + cloakVolumeObj.transform.parent = planetGO.transform; + cloakVolumeObj.transform.localPosition = Vector3.zero; + var cloakVolume = cloakVolumeObj.AddComponent(); + cloakVolume.radius = module.farCloakRadius ?? (radius * 500 / 3000f); + + cloakFieldController._cloakSphereVolume = cloakVolumeObj.AddComponent(); cloakFieldController._ringworldFadeRenderers = new OWRenderer[0]; var cloakSectorController = newCloak.AddComponent(); diff --git a/NewHorizons/External/Modules/CloakModule.cs b/NewHorizons/External/Modules/CloakModule.cs index 83d52012..b0d9a379 100644 --- a/NewHorizons/External/Modules/CloakModule.cs +++ b/NewHorizons/External/Modules/CloakModule.cs @@ -7,11 +7,24 @@ namespace NewHorizons.External.Modules public class CloakModule { /// - /// Radius of the cloaking field around the planet. It's a bit finicky so experiment with different values. If you - /// don't want a cloak, leave this as 0. + /// Radius of the cloaking field around the planet. For the Stranger this is 3000 /// public float radius; + /// + /// Not sure what this is. For the Stranger it is 2000. Optional (will default to be proportional to the cloak radius). + /// + public float? cloakScaleDist; + + /// Not sure what this is. For the Stranger it is 900. Optional (will default to be proportional to the cloak radius). + public float? innerCloakRadius; + + /// Not sure what this is. For the Stranger it is 800. Optional (will default to be proportional to the cloak radius). + public float? nearCloakRadius; + + /// Not sure what this is. For the Stranger it is 500. Optional (will default to be proportional to the cloak radius). + public float? farCloakRadius; + [Obsolete("audioClip is deprecated, please use audio instead")] public string audioClip; From 46da5957433797461ca99813b8677865980136d3 Mon Sep 17 00:00:00 2001 From: Ben C Date: Thu, 13 Jul 2023 22:56:11 +0000 Subject: [PATCH 11/15] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 31 +++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 3f72f361..9aae6df9 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -745,7 +745,36 @@ "properties": { "radius": { "type": "number", - "description": "Radius of the cloaking field around the planet. It's a bit finicky so experiment with different values. If you\ndon't want a cloak, leave this as 0.", + "description": "Radius of the cloaking field around the planet. For the Stranger this is 3000", + "format": "float" + }, + "cloakScaleDist": { + "type": [ + "null", + "number" + ], + "description": "Not sure what this is. For the Stranger it is 2000. Optional (will default to be proportional to the cloak radius).", + "format": "float" + }, + "innerCloakRadius": { + "type": [ + "null", + "number" + ], + "format": "float" + }, + "nearCloakRadius": { + "type": [ + "null", + "number" + ], + "format": "float" + }, + "farCloakRadius": { + "type": [ + "null", + "number" + ], "format": "float" }, "audio": { From d395a002cda4dfc0eb9cb229359c9fbf0d490f1e Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 13 Jul 2023 20:30:41 -0400 Subject: [PATCH 12/15] Instantiate inactive why not --- NewHorizons/Builder/Body/CloakBuilder.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Builder/Body/CloakBuilder.cs b/NewHorizons/Builder/Body/CloakBuilder.cs index 30ad35e6..513daa51 100644 --- a/NewHorizons/Builder/Body/CloakBuilder.cs +++ b/NewHorizons/Builder/Body/CloakBuilder.cs @@ -36,7 +36,8 @@ namespace NewHorizons.Builder.Body var radius = module.radius; - var newCloak = Object.Instantiate(_prefab, sector?.transform ?? planetGO.transform); + var newCloak = _prefab.InstantiateInactive(); + newCloak.transform.parent = sector?.transform ?? planetGO.transform; newCloak.transform.position = planetGO.transform.position; newCloak.transform.name = "CloakingField"; newCloak.transform.localScale = Vector3.one * radius; From 5dd73205664296a7a7f9e5408999943b4f09fd0c Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 13 Jul 2023 20:30:57 -0400 Subject: [PATCH 13/15] Always make reference frame even when enabled (fixes Cloak) --- NewHorizons/Builder/General/RFVolumeBuilder.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Builder/General/RFVolumeBuilder.cs b/NewHorizons/Builder/General/RFVolumeBuilder.cs index 5b274386..f359a7e0 100644 --- a/NewHorizons/Builder/General/RFVolumeBuilder.cs +++ b/NewHorizons/Builder/General/RFVolumeBuilder.cs @@ -8,7 +8,13 @@ namespace NewHorizons.Builder.General { public static GameObject Make(GameObject planetGO, OWRigidbody owrb, float sphereOfInfluence, ReferenceFrameModule module) { - if (!module.enabled) return null; + if (!module.enabled) + { + // We can't not build a reference frame volume, Cloak requires one to be there + module.maxTargetDistance = 0f; + module.hideInMap = true; + owrb.SetIsTargetable(false); + } var rfGO = new GameObject("RFVolume"); rfGO.transform.parent = planetGO.transform; From 3d942ec9d66d41d306136fec2b15945048e4b218 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 13 Jul 2023 22:19:21 -0400 Subject: [PATCH 14/15] Make multiple cloaks / zero cloaks work properly --- NewHorizons/Builder/Body/CloakBuilder.cs | 5 +- .../Components/EOTE/CloakLocatorController.cs | 77 ++++++++++++++++ NewHorizons/Handlers/CloakHandler.cs | 91 +++++++++++++++++++ .../Handlers/PlanetDestructionHandler.cs | 6 ++ .../Handlers/VesselCoordinatePromptHandler.cs | 2 +- NewHorizons/Main.cs | 3 + 6 files changed, 182 insertions(+), 2 deletions(-) create mode 100644 NewHorizons/Components/EOTE/CloakLocatorController.cs create mode 100644 NewHorizons/Handlers/CloakHandler.cs diff --git a/NewHorizons/Builder/Body/CloakBuilder.cs b/NewHorizons/Builder/Body/CloakBuilder.cs index 513daa51..a6ef5a63 100644 --- a/NewHorizons/Builder/Body/CloakBuilder.cs +++ b/NewHorizons/Builder/Body/CloakBuilder.cs @@ -1,5 +1,6 @@ using NewHorizons.Components.Sectored; using NewHorizons.External.Modules; +using NewHorizons.Handlers; using NewHorizons.Utility; using NewHorizons.Utility.Files; using NewHorizons.Utility.OWML; @@ -63,7 +64,7 @@ namespace NewHorizons.Builder.Body cloakFieldController._ringworldFadeRenderers = new OWRenderer[0]; var cloakSectorController = newCloak.AddComponent(); - cloakSectorController.Init(newCloak.GetComponent(), planetGO); + cloakSectorController.Init(cloakFieldController, planetGO); var cloakAudioSource = newCloak.GetComponentInChildren(); cloakAudioSource._audioSource = cloakAudioSource.GetComponent(); @@ -75,6 +76,8 @@ namespace NewHorizons.Builder.Body cloakSectorController.EnableCloak(); + CloakHandler.RegisterCloak(cloakFieldController); + // To cloak from the start Delay.FireOnNextUpdate(cloakSectorController.OnPlayerExit); Delay.FireOnNextUpdate(hasCustomAudio ? cloakSectorController.TurnOnMusic : cloakSectorController.TurnOffMusic); diff --git a/NewHorizons/Components/EOTE/CloakLocatorController.cs b/NewHorizons/Components/EOTE/CloakLocatorController.cs new file mode 100644 index 00000000..ad168e82 --- /dev/null +++ b/NewHorizons/Components/EOTE/CloakLocatorController.cs @@ -0,0 +1,77 @@ +using NewHorizons.Components.Stars; +using NewHorizons.Handlers; +using NewHorizons.Utility.OWML; +using UnityEngine; + +namespace NewHorizons.Components.EOTE +{ + internal class CloakLocatorController : MonoBehaviour + { + private float _currentAngle = float.MaxValue; + private CloakFieldController _currentController; + + public void Start() + { + // Enable and disable all cloaks, else Stranger state is weird at the start + foreach (var cloak in CloakHandler.Cloaks) + { + SetCurrentCloak(cloak); + cloak.enabled = false; + } + } + + // Always makes sure the Locator's cloak field controller is the one that is between the player and the sun + public void Update() + { + var sun = SunLightEffectsController.Instance?.transform; + if (sun != null) + { + // Keep tracking the angle to the current cloak + if (_currentController != null) + { + _currentAngle = CalculateAngleToCloak(_currentController.transform, sun); + } + + // Compare the current cloak to all the other ones + foreach (var cloak in CloakHandler.Cloaks) + { + if (cloak == _currentController) continue; + + var angle = CalculateAngleToCloak(cloak.transform, sun); + + if (angle < _currentAngle && cloak != _currentController) + { + _currentAngle = angle; + SetCurrentCloak(cloak); + NHLogger.LogVerbose($"Changed cloak controller to {_currentController.GetAttachedOWRigidbody().name} angle {_currentAngle}"); + } + } + } + } + + public void SetCurrentCloak(CloakFieldController cloak) + { + if (_currentController != null) + { + _currentController.enabled = false; + } + + _currentController = cloak; + + if (_currentController != null) + { + _currentController.enabled = true; + Locator.RegisterCloakFieldController(_currentController); + _currentController.UpdateCloakVisualsState(); + } + } + + private float CalculateAngleToCloak(Transform cloak, Transform sun) + { + var playerVector = Locator.GetPlayerTransform().position - sun.position; + var cloakVector = cloak.position - sun.position; + + return Vector3.Angle(playerVector, cloakVector); + } + } +} diff --git a/NewHorizons/Handlers/CloakHandler.cs b/NewHorizons/Handlers/CloakHandler.cs new file mode 100644 index 00000000..79bd8c47 --- /dev/null +++ b/NewHorizons/Handlers/CloakHandler.cs @@ -0,0 +1,91 @@ +using NewHorizons.Components.EOTE; +using NewHorizons.OtherMods.VoiceActing; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +namespace NewHorizons.Handlers +{ + public static class CloakHandler + { + private static HashSet _cloaks; + public static HashSet Cloaks => _cloaks; + + private static bool _flagStrangerDisabled; + public static bool FlagStrangerDisabled + { + get => _flagStrangerDisabled; + set + { + _flagStrangerDisabled = value; + if (value && _strangerCloak != null) + { + DeregisterCloak(_strangerCloak); + } + } + } + public static bool VisibleStrangerInstalled => Main.Instance.ModHelper.Interaction.ModExists("xen.Decloaked"); + + private static CloakFieldController _strangerCloak; + private static CloakLocatorController _cloakLocator; + + public static void Init() + { + _cloaks = new(); + FlagStrangerDisabled = false; + _strangerCloak = null; + _cloakLocator = null; + } + + public static void OnSystemReady() + { + // If NH is disabling the stranger it will not be gone yet, however other mods might have gotten rid of it + var stranger = Locator.GetAstroObject(AstroObject.Name.RingWorld)?.gameObject; + if (stranger != null && stranger.activeInHierarchy && !FlagStrangerDisabled && !VisibleStrangerInstalled) + { + _strangerCloak = stranger.GetComponentInChildren(); + RegisterCloak(_strangerCloak); + } + + _cloakLocator = Locator.GetRootTransform().gameObject.AddComponent(); + foreach (var cloak in _cloaks) + { + cloak.enabled = false; + cloak.UpdateCloakVisualsState(); + } + + Refresh(); + } + + public static void RegisterCloak(CloakFieldController cloak) + { + _cloaks.Add(cloak); + } + + public static void DeregisterCloak(CloakFieldController cloak) + { + if (_cloaks.Contains(cloak)) + { + cloak.enabled = false; + cloak.UpdateCloakVisualsState(); + _cloaks.Remove(cloak); + + Refresh(); + } + } + + private static void Refresh() + { + // Make sure we aren't using the disabled cloak + Locator.RegisterCloakFieldController(_cloaks.FirstOrDefault()); + + if (!_cloaks.Any()) + { + Locator.RegisterCloakFieldController(null); + Shader.DisableKeyword("_CLOAKINGFIELDENABLED"); + _cloakLocator.SetCurrentCloak(null); + _cloakLocator.enabled = false; + } + } + } +} diff --git a/NewHorizons/Handlers/PlanetDestructionHandler.cs b/NewHorizons/Handlers/PlanetDestructionHandler.cs index ba275d38..fdf15032 100644 --- a/NewHorizons/Handlers/PlanetDestructionHandler.cs +++ b/NewHorizons/Handlers/PlanetDestructionHandler.cs @@ -83,6 +83,12 @@ namespace NewHorizons.Handlers { NHLogger.LogVerbose($"Removing [{ao.name}]"); + if (ao.GetAstroObjectName() == AstroObject.Name.RingWorld) + { + CloakHandler.FlagStrangerDisabled = true; + if (Locator._cloakFieldController.GetComponentInParent() == ao) Locator._cloakFieldController = null; + } + if (ao.gameObject == null || !ao.gameObject.activeInHierarchy) { NHLogger.LogVerbose($"[{ao.name}] was already removed"); diff --git a/NewHorizons/Handlers/VesselCoordinatePromptHandler.cs b/NewHorizons/Handlers/VesselCoordinatePromptHandler.cs index 4f6d67cf..d53eb875 100644 --- a/NewHorizons/Handlers/VesselCoordinatePromptHandler.cs +++ b/NewHorizons/Handlers/VesselCoordinatePromptHandler.cs @@ -8,7 +8,7 @@ using static NewHorizons.External.Configs.StarSystemConfig; namespace NewHorizons.Handlers { - public class VesselCoordinatePromptHandler + public static class VesselCoordinatePromptHandler { private static List> _factSystemIDPrompt; // TODO: move this to ImageUtilities diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index 3036f720..40ce4684 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -403,6 +403,7 @@ namespace NewHorizons SingularityBuilder.Init(); AtmosphereBuilder.Init(); BrambleNodeBuilder.Init(BodyDict[CurrentStarSystem].Select(x => x.Config).Where(x => x.Bramble?.dimension != null).ToArray()); + CloakHandler.Init(); if (isSolarSystem) { @@ -570,6 +571,8 @@ namespace NewHorizons PlayerSpawnHandler.OnSystemReady(shouldWarpInFromShip, shouldWarpInFromVessel); VesselCoordinatePromptHandler.RegisterPrompts(SystemDict.Where(system => system.Value.Config.Vessel?.coords != null).Select(x => x.Value).ToList()); + + CloakHandler.OnSystemReady(); } public void EnableWarpDrive() From b792f73bb05c65a27bd8883464d43f59fa63aad0 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 13 Jul 2023 22:34:53 -0400 Subject: [PATCH 15/15] Update manifest.json --- NewHorizons/manifest.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NewHorizons/manifest.json b/NewHorizons/manifest.json index 56abd496..606a5f49 100644 --- a/NewHorizons/manifest.json +++ b/NewHorizons/manifest.json @@ -4,8 +4,8 @@ "author": "xen, Bwc9876, clay, MegaPiggy, John, Trifid, Hawkbar, Book", "name": "New Horizons", "uniqueName": "xen.NewHorizons", - "version": "1.12.1", - "owmlVersion": "2.9.0", + "version": "1.12.2", + "owmlVersion": "2.9.3", "dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ], "conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_CommonResources" ], "pathsToPreserve": [ "planets", "systems", "translations" ]