diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index e4e59795e..291201dd7 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -3,6 +3,7 @@ using NewHorizons.External.Modules; using NewHorizons.Handlers; using NewHorizons.Utility; +using NewHorizons.Utility.OWUtilities; using OWML.Common; using System; using System.Collections.Generic; @@ -118,7 +119,7 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, P { if (FixUnsectoredComponent(component)) continue; } - else FixSectoredComponent(component, sector, isTorch); + else FixSectoredComponent(component, sector, isTorch, detail.keepLoaded); FixComponent(component, go); } @@ -213,11 +214,16 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, P /// /// 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 = false) + private static void FixSectoredComponent(Component component, Sector sector, bool isTorch, bool keepLoaded) { + // keepLoaded should remove existing groups + // 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); + return; + } + // fix Sector stuff, eg SectorCullGroup (without this, props that have a SectorCullGroup component will become invisible inappropriately) if (component is ISectorGroup sectorGroup) { @@ -234,6 +240,12 @@ private static void FixSectoredComponent(Component component, Sector sector, boo else if (component is SectorCullGroup sectorCullGroup) { sectorCullGroup._controllingProxy = null; + + // fixes sector cull group deactivating renderers on map view enter and fast foward + // TODO: does this actually work? what? how? + sectorCullGroup._inMapView = false; + sectorCullGroup._isFastForwarding = false; + sectorCullGroup.SetVisible(sectorCullGroup.ShouldBeVisible(), true, false); } else if(component is SectoredMonoBehaviour behaviour) @@ -264,7 +276,7 @@ private static void FixSectoredComponent(Component component, Sector sector, boo /// private static bool FixUnsectoredComponent(Component component) { - if (component is FogLight or SectoredMonoBehaviour) + if (component is FogLight or SectoredMonoBehaviour or ISectorGroup) { GameObject.DestroyImmediate(component); return true; @@ -275,8 +287,13 @@ private static bool FixUnsectoredComponent(Component component) private static void FixComponent(Component component, GameObject planetGO) { // Fix other components + // IgnoreSun is just a shadow casting optimization for caves and stuff so we can get rid of it + if (component is Transform && component.gameObject.layer == Layer.IgnoreSun) + { + component.gameObject.layer = Layer.Default; + } // I forget why this is here - if (component is GhostIK or GhostEffects) + else if (component is GhostIK or GhostEffects) { Component.DestroyImmediate(component); return; @@ -334,15 +351,6 @@ private static void FixComponent(Component component, GameObject planetGO) else if (component is Renderer renderer && component.gameObject.GetComponent() == null) renderer.enabled = true; else if(component is Shape shape) shape.enabled = true; - // fixes sector cull group deactivating renderers on map view enter and fast foward - // TODO: does this actually work? what? how? - else if(component is SectorCullGroup sectorCullGroup) - { - sectorCullGroup._inMapView = false; - sectorCullGroup._isFastForwarding = false; - sectorCullGroup.SetVisible(sectorCullGroup.ShouldBeVisible(), true, false); - } - // If it's not a moving anglerfish make sure the anim controller is regular else if(component is AnglerfishAnimController && component.GetComponentInParent() == null) { diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index 2c096bd86..213f3605a 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -1,3 +1,4 @@ +using HarmonyLib; using NewHorizons.External.Modules; using NewHorizons.Handlers; using NewHorizons.Utility; @@ -276,12 +277,16 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Tra cairnObject.SetActive(true); // Make it do the thing when it finishes being knocked over - foreach (var rock in cairnObject.GetComponent()._rocks) + // idk why, but sometimes stuff is null here, so just wait a frame to let it initialize + Delay.FireOnNextUpdate(() => { - rock._returning = false; - rock._owCollider.SetActivation(true); - rock.enabled = false; - } + foreach (var rock in cairnObject.GetComponent()._rocks) + { + rock._returning = false; + rock._owCollider.SetActivation(true); + rock.enabled = false; + } + }); // So we can actually knock it over cairnObject.GetComponent().enabled = true; @@ -350,15 +355,10 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Tra } case PropModule.NomaiTextType.Whiteboard: { - var whiteboardInfo = new PropModule.DetailInfo() + var whiteboardInfo = new PropModule.DetailInfo(info) { - alignRadial = info.alignRadial, - isRelativeToParent = info.isRelativeToParent, - parentPath = info.parentPath, path = "BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/Sector_NorthPole/Sector_HangingCity/Sector_HangingCity_District2/Interactables_HangingCity_District2/VisibleFrom_HangingCity/Props_NOM_Whiteboard (1)", - position = info.position, rename = info.rename ?? "Props_NOM_Whiteboard", - rotation = info.rotation, }; var whiteboardObject = DetailBuilder.Make(planetGO, sector, whiteboardInfo); @@ -522,14 +522,12 @@ internal static void RefreshArcs(NomaiWallText nomaiWallText, GameObject convers var arcInfo = info.arcInfo[j]; var arc = arranger.spirals[j]; - if (arcInfo.position != null) arc.transform.localPosition = new Vector3(arcInfo.position.x, arcInfo.position.y, 0); - - if (arcInfo.zRotation != null) arc.transform.localRotation = Quaternion.Euler(0, 0, arcInfo.zRotation.Value); - - if (arcInfo.mirror != null) + if (arcInfo.position != null || arcInfo.zRotation != null || arcInfo.mirror != null) { - if (arcInfo.mirror.Value) arc.transform.localScale = new Vector3(-1, 1, 1); - else arc.transform.localScale = new Vector3(1, 1, 1); + var pos = (Vector2)(arcInfo.position ?? Vector2.zero); + arc.transform.localPosition = new Vector3(pos.x, pos.y, 0); + arc.transform.localRotation = Quaternion.Euler(0, 0, arcInfo.zRotation.GetValueOrDefault()); + arc.transform.localScale = arcInfo.mirror.GetValueOrDefault() ? new Vector3(-1, 1, 1) : new Vector3(1, 1, 1); } } diff --git a/NewHorizons/Builder/Props/WarpPadBuilder.cs b/NewHorizons/Builder/Props/WarpPadBuilder.cs index f106dc57e..c4de76793 100644 --- a/NewHorizons/Builder/Props/WarpPadBuilder.cs +++ b/NewHorizons/Builder/Props/WarpPadBuilder.cs @@ -113,6 +113,8 @@ public static void Make(GameObject planetGO, Sector sector, NomaiWarpTransmitter transmitter._alignmentWindow = info.alignmentWindow; + transmitter._upsideDown = info.flipAlignment; + transmitter.GetComponent().enabled = true; transmitterObject.SetActive(true); diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index 8ed805bd1..78b12b35d 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -610,30 +610,30 @@ public enum NomaiTextArcType } /// - /// Whether to flip the spiral from left-curling to right-curling or vice versa. If not specified, will use auto spiral generated value. + /// The type of text to display. /// - public bool? mirror; - + [DefaultValue("adult")] public NomaiTextArcType type = NomaiTextArcType.Adult; + /// - /// The local position of this object on the wall. If not specified, will use auto spiral generated value. + /// The local position of this object on the wall. If specified, auto spiral will not touch this arc. /// public MVector2 position; /// - /// The type of text to display. + /// The z euler angle for this arc. If specified, auto spiral will not touch this arc. /// - [DefaultValue("adult")] public NomaiTextArcType type = NomaiTextArcType.Adult; + [Range(0f, 360f)] public float? zRotation; /// - /// Which variation of the chosen type to place. If not specified, a random variation will be selected based on the seed provided in the parent module. + /// Whether to flip the spiral from left-curling to right-curling or vice versa. If specified, auto spiral will not touch this arc. /// - [Obsolete("only used in old nomai text")] - [DefaultValue(-1)] public int variation = -1; + public bool? mirror; /// - /// The z euler angle for this arc. If not specified, will use auto spiral generated value. + /// Which variation of the chosen type to place. If not specified, a random variation will be selected based on the seed provided in the parent module. /// - [Range(0f, 360f)] public float? zRotation; + [Obsolete("only used in old nomai text")] + [DefaultValue(-1)] public int variation = -1; } [JsonObject] diff --git a/NewHorizons/External/Modules/WarpPad/NomaiWarpTransmitterInfo.cs b/NewHorizons/External/Modules/WarpPad/NomaiWarpTransmitterInfo.cs index 6e704f368..3a1dd55ca 100644 --- a/NewHorizons/External/Modules/WarpPad/NomaiWarpTransmitterInfo.cs +++ b/NewHorizons/External/Modules/WarpPad/NomaiWarpTransmitterInfo.cs @@ -12,8 +12,8 @@ public class NomaiWarpTransmitterInfo : NomaiWarpPadInfo [DefaultValue(5f)] public float alignmentWindow = 5f; /// - /// Is this transmitter upsidedown? Means alignment will be checked facing the other way. + /// This makes the alignment happen if the destination planet is BELOW you rather than above. /// - public bool upsideDown = false; + public bool flipAlignment; } } diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 6b56c515e..b21da199d 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -1471,45 +1471,31 @@ "type": "object", "additionalProperties": false, "properties": { - "mirror": { - "type": [ - "boolean", - "null" - ], - "description": "Whether to flip the spiral from left-curling to right-curling or vice versa. If not specified, will use auto spiral generated value." - }, - "position": { - "description": "The local position of this object on the wall. If not specified, will use auto spiral generated value.", - "$ref": "#/definitions/MVector2" - }, "type": { "description": "The type of text to display.", "default": "adult", "$ref": "#/definitions/NomaiTextArcType" }, + "position": { + "description": "The local position of this object on the wall. If specified, auto spiral will not touch this arc.", + "$ref": "#/definitions/MVector2" + }, "zRotation": { "type": [ "null", "number" ], - "description": "The z euler angle for this arc. If not specified, will use auto spiral generated value.", + "description": "The z euler angle for this arc. If specified, auto spiral will not touch this arc.", "format": "float", "maximum": 360.0, "minimum": 0.0 - } - } - }, - "MVector2": { - "type": "object", - "additionalProperties": false, - "properties": { - "x": { - "type": "number", - "format": "float" }, - "y": { - "type": "number", - "format": "float" + "mirror": { + "type": [ + "boolean", + "null" + ], + "description": "Whether to flip the spiral from left-curling to right-curling or vice versa. If specified, auto spiral will not touch this arc." } } }, @@ -1527,6 +1513,20 @@ "stranger" ] }, + "MVector2": { + "type": "object", + "additionalProperties": false, + "properties": { + "x": { + "type": "number", + "format": "float" + }, + "y": { + "type": "number", + "format": "float" + } + } + }, "NomaiTextType": { "type": "string", "description": "", @@ -2528,9 +2528,9 @@ "format": "float", "default": 5.0 }, - "upsideDown": { + "flipAlignment": { "type": "boolean", - "description": "Is this transmitter upsidedown? Means alignment will be checked facing the other way." + "description": "This makes the alignment happen if the destination planet is BELOW you rather than above." } } },