mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
debugging Awake failure
This commit is contained in:
parent
76ade8d238
commit
7124834232
@ -1,3 +1,4 @@
|
||||
using HarmonyLib;
|
||||
using NewHorizons.External.Configs;
|
||||
using NewHorizons.External.Modules;
|
||||
using OWML.Common;
|
||||
@ -55,14 +56,14 @@ namespace NewHorizons.Builder.Props
|
||||
quantumObject._socketRoot = groupRoot;
|
||||
quantumObject._socketList = sockets;
|
||||
|
||||
if (prop.GetComponentInChildren<VisibilityTracker>() != null) continue;
|
||||
if (prop.GetComponentInChildren<ShapeVisibilityTracker>() != null) continue;
|
||||
|
||||
var boxBounds = GetBoundsOfSelfAndChildMeshes(prop);
|
||||
var boxShape = prop.AddComponent<BoxShape>();
|
||||
boxShape.center = boxBounds.center;
|
||||
boxShape.extents = boxBounds.size;
|
||||
|
||||
prop.AddComponent<VisibilityTracker>();
|
||||
prop.AddComponent<ShapeVisibilityTracker>();
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,14 +82,14 @@ namespace NewHorizons.Builder.Props
|
||||
var state = prop.AddComponent<QuantumState>();
|
||||
states.Add(state);
|
||||
|
||||
if (prop.GetComponentInChildren<VisibilityTracker>() != null) continue;
|
||||
if (prop.GetComponentInChildren<ShapeVisibilityTracker>() != null) continue;
|
||||
|
||||
var boxBounds = GetBoundsOfSelfAndChildMeshes(prop);
|
||||
var boxShape = prop.AddComponent<BoxShape>();
|
||||
boxShape.center = boxBounds.center;
|
||||
boxShape.extents = boxBounds.size;
|
||||
|
||||
prop.AddComponent<VisibilityTracker>();
|
||||
prop.AddComponent<ShapeVisibilityTracker>();
|
||||
}
|
||||
|
||||
if (quantumGroup.hasEmptyState)
|
||||
@ -105,7 +106,7 @@ namespace NewHorizons.Builder.Props
|
||||
boxShape.center = boxBounds.center;
|
||||
boxShape.extents = boxBounds.size;
|
||||
|
||||
empty.AddComponent<VisibilityTracker>();
|
||||
empty.AddComponent<ShapeVisibilityTracker>();
|
||||
}
|
||||
|
||||
var multiState = groupRoot.AddComponent<MultiStateQuantumObject>();
|
||||
@ -124,16 +125,16 @@ namespace NewHorizons.Builder.Props
|
||||
|
||||
var shuffle = shuffleParent.AddComponent<QuantumShuffleObject>();
|
||||
shuffle._shuffledObjects = propsInGroup.Select(p => p.transform).ToArray();
|
||||
shuffle.Awake(); // this doesn't get called on its own for some reason
|
||||
|
||||
var boxBounds = GetBoundsOfSelfAndChildMeshes(shuffleParent);
|
||||
var boxBounds = GetBoundsOfSelfAndChildMeshes(shuffleParent); // TODO: add a box shape to each prop instead of to the parent
|
||||
var boxShape = shuffleParent.AddComponent<BoxShape>();
|
||||
boxShape.center = boxBounds.center;
|
||||
boxShape.extents = boxBounds.size;
|
||||
|
||||
shuffleParent.AddComponent<VisibilityTracker>();
|
||||
shuffleParent.AddComponent<ShapeVisibilityTracker>();
|
||||
}
|
||||
|
||||
|
||||
public static Bounds GetBoundsOfSelfAndChildMeshes(GameObject g)
|
||||
{
|
||||
var meshFilters = g.GetComponentsInChildren<MeshFilter>();
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using HarmonyLib;
|
||||
using HarmonyLib;
|
||||
using NewHorizons.Builder.Props;
|
||||
using NewHorizons.Components;
|
||||
using NewHorizons.External;
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
using HarmonyLib;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NewHorizons.Patches
|
||||
{
|
||||
[HarmonyPatch]
|
||||
public static class TemporaryDebugOnlyPatchesDeleteBeforePR
|
||||
{
|
||||
// This is some dark magic
|
||||
// this creates a method called base_DropItem that basically just calls OWItem.PickUpItem whenever it (VisionTorchItemPatches.base_PickUpItem) is called
|
||||
[HarmonyReversePatch]
|
||||
[HarmonyPatch(typeof(QuantumObject), nameof(QuantumObject.Awake))]
|
||||
private static void base_Awake(QuantumObject __instance) { }
|
||||
|
||||
|
||||
// Make the vision torch droppable. In the base game you can only drop it if you're in the dream world.
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(QuantumShuffleObject), nameof(QuantumShuffleObject.Awake))]
|
||||
public static bool QuantumShuffleObject_Awake(QuantumShuffleObject __instance)
|
||||
{
|
||||
base_Awake(__instance);
|
||||
__instance._indexList = new List<int>(__instance._shuffledObjects.Length);
|
||||
__instance._localPositions = new Vector3[__instance._shuffledObjects.Length];
|
||||
for (int i = 0; i < __instance._shuffledObjects.Length; i++)
|
||||
{
|
||||
__instance._localPositions[i] = __instance._shuffledObjects[i].localPosition;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user