Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better version of remove keepautoplacement #549

Merged
merged 18 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 24 additions & 16 deletions NewHorizons/Builder/Props/DetailBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -213,11 +214,16 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, P
/// <summary>
/// Fix components that have sectors. Has a specific fix if there is a VisionTorchItem on the object.
/// </summary>
/// <param name="component"></param>
/// <param name="sector"></param>
/// <param name="isTorch"></param>
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)
{
Expand All @@ -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)
Expand Down Expand Up @@ -264,7 +276,7 @@ private static void FixSectoredComponent(Component component, Sector sector, boo
/// </summary>
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;
Expand All @@ -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;
Expand Down Expand Up @@ -334,15 +351,6 @@ private static void FixComponent(Component component, GameObject planetGO)
else if (component is Renderer renderer && component.gameObject.GetComponent<ElectricityEffect>() == 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<AnglerfishController>() == null)
{
Expand Down
34 changes: 16 additions & 18 deletions NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using HarmonyLib;
using NewHorizons.External.Modules;
using NewHorizons.Handlers;
using NewHorizons.Utility;
Expand Down Expand Up @@ -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<NomaiCairn>()._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<NomaiCairn>()._rocks)
{
rock._returning = false;
rock._owCollider.SetActivation(true);
rock.enabled = false;
}
});

// So we can actually knock it over
cairnObject.GetComponent<CapsuleCollider>().enabled = true;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
}
}

Expand Down
2 changes: 2 additions & 0 deletions NewHorizons/Builder/Props/WarpPadBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ public static void Make(GameObject planetGO, Sector sector, NomaiWarpTransmitter

transmitter._alignmentWindow = info.alignmentWindow;

transmitter._upsideDown = info.flipAlignment;

transmitter.GetComponent<BoxShape>().enabled = true;

transmitterObject.SetActive(true);
Expand Down
22 changes: 11 additions & 11 deletions NewHorizons/External/Modules/PropModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -610,30 +610,30 @@ public enum NomaiTextArcType
}

/// <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>
public bool? mirror;

[DefaultValue("adult")] public NomaiTextArcType type = NomaiTextArcType.Adult;
/// <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>
public MVector2 position;

/// <summary>
/// The type of text to display.
/// The z euler angle for this arc. If specified, auto spiral will not touch this arc.
/// </summary>
[DefaultValue("adult")] public NomaiTextArcType type = NomaiTextArcType.Adult;
[Range(0f, 360f)] public float? zRotation;

/// <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.
/// Whether to flip the spiral from left-curling to right-curling or vice versa. If specified, auto spiral will not touch this arc.
/// </summary>
[Obsolete("only used in old nomai text")]
[DefaultValue(-1)] public int variation = -1;
public bool? mirror;

/// <summary>
/// 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.
/// </summary>
[Range(0f, 360f)] public float? zRotation;
[Obsolete("only used in old nomai text")]
[DefaultValue(-1)] public int variation = -1;
}

[JsonObject]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public class NomaiWarpTransmitterInfo : NomaiWarpPadInfo
[DefaultValue(5f)] public float alignmentWindow = 5f;

/// <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>
public bool upsideDown = false;
public bool flipAlignment;
}
}
54 changes: 27 additions & 27 deletions NewHorizons/Schemas/body_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
}
},
Expand All @@ -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": "",
Expand Down Expand Up @@ -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."
}
}
},
Expand Down