better version of remove keepautoplacement (#549)

also 
- remove ignoresun on details
- fix cairn nre
- remove groups from keeploaded details
- make unused field in warp transmitter info used
This commit is contained in:
Will Corby 2023-03-23 17:49:14 -07:00 committed by GitHub
commit c252112215
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 82 additions and 74 deletions

View File

@ -3,6 +3,7 @@ using NewHorizons.Components;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Handlers; using NewHorizons.Handlers;
using NewHorizons.Utility; using NewHorizons.Utility;
using NewHorizons.Utility.OWUtilities;
using OWML.Common; using OWML.Common;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -118,7 +119,7 @@ namespace NewHorizons.Builder.Props
{ {
if (FixUnsectoredComponent(component)) continue; if (FixUnsectoredComponent(component)) continue;
} }
else FixSectoredComponent(component, sector, isTorch); else FixSectoredComponent(component, sector, isTorch, detail.keepLoaded);
FixComponent(component, go); FixComponent(component, go);
} }
@ -213,11 +214,16 @@ namespace NewHorizons.Builder.Props
/// <summary> /// <summary>
/// Fix components that have sectors. Has a specific fix if there is a VisionTorchItem on the object. /// Fix components that have sectors. Has a specific fix if there is a VisionTorchItem on the object.
/// </summary> /// </summary>
/// <param name="component"></param> private static void FixSectoredComponent(Component component, Sector sector, bool isTorch, bool keepLoaded)
/// <param name="sector"></param>
/// <param name="isTorch"></param>
private static void FixSectoredComponent(Component component, Sector sector, bool isTorch = false)
{ {
// 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) // fix Sector stuff, eg SectorCullGroup (without this, props that have a SectorCullGroup component will become invisible inappropriately)
if (component is ISectorGroup sectorGroup) if (component is ISectorGroup sectorGroup)
{ {
@ -234,6 +240,12 @@ namespace NewHorizons.Builder.Props
else if (component is SectorCullGroup sectorCullGroup) else if (component is SectorCullGroup sectorCullGroup)
{ {
sectorCullGroup._controllingProxy = null; 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) else if(component is SectoredMonoBehaviour behaviour)
@ -264,7 +276,7 @@ namespace NewHorizons.Builder.Props
/// </summary> /// </summary>
private static bool FixUnsectoredComponent(Component component) private static bool FixUnsectoredComponent(Component component)
{ {
if (component is FogLight or SectoredMonoBehaviour) if (component is FogLight or SectoredMonoBehaviour or ISectorGroup)
{ {
GameObject.DestroyImmediate(component); GameObject.DestroyImmediate(component);
return true; return true;
@ -275,8 +287,13 @@ namespace NewHorizons.Builder.Props
private static void FixComponent(Component component, GameObject planetGO) private static void FixComponent(Component component, GameObject planetGO)
{ {
// Fix other components // 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 // I forget why this is here
if (component is GhostIK or GhostEffects) else if (component is GhostIK or GhostEffects)
{ {
Component.DestroyImmediate(component); Component.DestroyImmediate(component);
return; return;
@ -334,15 +351,6 @@ namespace NewHorizons.Builder.Props
else if (component is Renderer renderer && component.gameObject.GetComponent<ElectricityEffect>() == null) renderer.enabled = true; else if (component is Renderer renderer && component.gameObject.GetComponent<ElectricityEffect>() == null) renderer.enabled = true;
else if(component is Shape shape) shape.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 // If it's not a moving anglerfish make sure the anim controller is regular
else if(component is AnglerfishAnimController && component.GetComponentInParent<AnglerfishController>() == null) else if(component is AnglerfishAnimController && component.GetComponentInParent<AnglerfishController>() == null)
{ {

View File

@ -1,3 +1,4 @@
using HarmonyLib;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Handlers; using NewHorizons.Handlers;
using NewHorizons.Utility; using NewHorizons.Utility;
@ -276,12 +277,16 @@ namespace NewHorizons.Builder.Props.TranslatorText
cairnObject.SetActive(true); cairnObject.SetActive(true);
// Make it do the thing when it finishes being knocked over // Make it do the thing when it finishes being knocked over
foreach (var rock in cairnObject.GetComponent<NomaiCairn>()._rocks) // idk why, but sometimes stuff is null here, so just wait a frame to let it initialize
Delay.FireOnNextUpdate(() =>
{ {
rock._returning = false; foreach (var rock in cairnObject.GetComponent<NomaiCairn>()._rocks)
rock._owCollider.SetActivation(true); {
rock.enabled = false; rock._returning = false;
} rock._owCollider.SetActivation(true);
rock.enabled = false;
}
});
// So we can actually knock it over // So we can actually knock it over
cairnObject.GetComponent<CapsuleCollider>().enabled = true; cairnObject.GetComponent<CapsuleCollider>().enabled = true;
@ -350,15 +355,10 @@ namespace NewHorizons.Builder.Props.TranslatorText
} }
case PropModule.NomaiTextType.Whiteboard: 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)", 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", rename = info.rename ?? "Props_NOM_Whiteboard",
rotation = info.rotation,
}; };
var whiteboardObject = DetailBuilder.Make(planetGO, sector, whiteboardInfo); var whiteboardObject = DetailBuilder.Make(planetGO, sector, whiteboardInfo);
@ -522,14 +522,12 @@ namespace NewHorizons.Builder.Props.TranslatorText
var arcInfo = info.arcInfo[j]; var arcInfo = info.arcInfo[j];
var arc = arranger.spirals[j]; var arc = arranger.spirals[j];
if (arcInfo.position != null) arc.transform.localPosition = new Vector3(arcInfo.position.x, arcInfo.position.y, 0); if (arcInfo.position != null || arcInfo.zRotation != null || arcInfo.mirror != null)
if (arcInfo.zRotation != null) arc.transform.localRotation = Quaternion.Euler(0, 0, arcInfo.zRotation.Value);
if (arcInfo.mirror != null)
{ {
if (arcInfo.mirror.Value) arc.transform.localScale = new Vector3(-1, 1, 1); var pos = (Vector2)(arcInfo.position ?? Vector2.zero);
else arc.transform.localScale = new Vector3(1, 1, 1); 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);
} }
} }

View File

@ -113,6 +113,8 @@ namespace NewHorizons.Builder.Props
transmitter._alignmentWindow = info.alignmentWindow; transmitter._alignmentWindow = info.alignmentWindow;
transmitter._upsideDown = info.flipAlignment;
transmitter.GetComponent<BoxShape>().enabled = true; transmitter.GetComponent<BoxShape>().enabled = true;
transmitterObject.SetActive(true); transmitterObject.SetActive(true);

View File

@ -610,30 +610,30 @@ namespace NewHorizons.External.Modules
} }
/// <summary> /// <summary>
/// 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.
/// </summary> /// </summary>
public bool? mirror; [DefaultValue("adult")] public NomaiTextArcType type = NomaiTextArcType.Adult;
/// <summary> /// <summary>
/// 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.
/// </summary> /// </summary>
public MVector2 position; public MVector2 position;
/// <summary> /// <summary>
/// The type of text to display. /// The z euler angle for this arc. If specified, auto spiral will not touch this arc.
/// </summary> /// </summary>
[DefaultValue("adult")] public NomaiTextArcType type = NomaiTextArcType.Adult; [Range(0f, 360f)] public float? zRotation;
/// <summary>
/// Whether to flip the spiral from left-curling to right-curling or vice versa. If specified, auto spiral will not touch this arc.
/// </summary>
public bool? mirror;
/// <summary> /// <summary>
/// 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. /// 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.
/// </summary> /// </summary>
[Obsolete("only used in old nomai text")] [Obsolete("only used in old nomai text")]
[DefaultValue(-1)] public int variation = -1; [DefaultValue(-1)] public int variation = -1;
/// <summary>
/// The z euler angle for this arc. If not specified, will use auto spiral generated value.
/// </summary>
[Range(0f, 360f)] public float? zRotation;
} }
[JsonObject] [JsonObject]

View File

@ -12,8 +12,8 @@ namespace NewHorizons.External.Modules.WarpPad
[DefaultValue(5f)] public float alignmentWindow = 5f; [DefaultValue(5f)] public float alignmentWindow = 5f;
/// <summary> /// <summary>
/// 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.
/// </summary> /// </summary>
public bool upsideDown = false; public bool flipAlignment;
} }
} }

View File

@ -1471,45 +1471,31 @@
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
"properties": { "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": { "type": {
"description": "The type of text to display.", "description": "The type of text to display.",
"default": "adult", "default": "adult",
"$ref": "#/definitions/NomaiTextArcType" "$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": { "zRotation": {
"type": [ "type": [
"null", "null",
"number" "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", "format": "float",
"maximum": 360.0, "maximum": 360.0,
"minimum": 0.0 "minimum": 0.0
}
}
},
"MVector2": {
"type": "object",
"additionalProperties": false,
"properties": {
"x": {
"type": "number",
"format": "float"
}, },
"y": { "mirror": {
"type": "number", "type": [
"format": "float" "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" "stranger"
] ]
}, },
"MVector2": {
"type": "object",
"additionalProperties": false,
"properties": {
"x": {
"type": "number",
"format": "float"
},
"y": {
"type": "number",
"format": "float"
}
}
},
"NomaiTextType": { "NomaiTextType": {
"type": "string", "type": "string",
"description": "", "description": "",
@ -2528,9 +2528,9 @@
"format": "float", "format": "float",
"default": 5.0 "default": 5.0
}, },
"upsideDown": { "flipAlignment": {
"type": "boolean", "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."
} }
} }
}, },