removed patches made for debugging, fixed exit pairing

This commit is contained in:
FreezeDriedMangoes 2022-06-30 17:49:42 -04:00
parent 3b25c5cf20
commit 8c9c6d3e31
2 changed files with 98 additions and 96 deletions

View File

@ -74,14 +74,11 @@ namespace NewHorizons.Builder.Body
intr.name = "Interactibles"; intr.name = "Interactibles";
GameObject.Destroy(intr); GameObject.Destroy(intr);
// set up warps
var outerFogWarpVolume = exitWarps.GetComponent<OuterFogWarpVolume>(); var outerFogWarpVolume = exitWarps.GetComponent<OuterFogWarpVolume>();
outerFogWarpVolume._senderWarps.Clear(); outerFogWarpVolume._senderWarps.Clear();
outerFogWarpVolume._linkedInnerWarpVolume = null; outerFogWarpVolume._linkedInnerWarpVolume = null;
outerFogWarpVolume._name = OuterFogWarpVolume.Name.None; outerFogWarpVolume._name = OuterFogWarpVolume.Name.None;
//outerFogWarpVolume._sector = dimensionSector.GetComponent<Sector>();
//outerFogWarpVolume.Awake(); // I can't spawn this game object disabled, but Awake needs to run after _sector is set. That means I need to call Awake myself
// TODO if I need to: set "exitWarps/ExitPoint", "exitWarp/ExitPoint (1)", ... "exitWarp/ExitPoint (5)"
PairExit(config.linksTo, outerFogWarpVolume); PairExit(config.linksTo, outerFogWarpVolume);
@ -90,13 +87,14 @@ namespace NewHorizons.Builder.Body
public static void PairExit(string exitName, OuterFogWarpVolume warpController) public static void PairExit(string exitName, OuterFogWarpVolume warpController)
{ {
Logger.Log($"attempting to pair exit {exitName}");
if (!BrambleNodeBuilder.namedNodes.ContainsKey(exitName)) if (!BrambleNodeBuilder.namedNodes.ContainsKey(exitName))
{ {
if (!unpairedDimensions.ContainsKey(exitName)) unpairedDimensions[exitName] = new(); if (!unpairedDimensions.ContainsKey(exitName)) unpairedDimensions[exitName] = new();
unpairedDimensions[exitName].Add(warpController); unpairedDimensions[exitName].Add(warpController);
return; return;
} }
Logger.Log($"pairing exit {exitName}");
warpController._linkedInnerWarpVolume = BrambleNodeBuilder.namedNodes[exitName]; warpController._linkedInnerWarpVolume = BrambleNodeBuilder.namedNodes[exitName];
} }
@ -110,7 +108,7 @@ namespace NewHorizons.Builder.Body
PairExit(nodeName, dimensionWarpController); PairExit(nodeName, dimensionWarpController);
} }
unpairedDimensions.Remove(nodeName); //unpairedDimensions.Remove(nodeName);
} }
} }

View File

@ -12,103 +12,102 @@ using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Builder.Props namespace NewHorizons.Builder.Props
{ {
// Issue: these nodes aren't getting added to the list PlayerFogWarpDetector._warpVolumes
// debugging: try overriding FogWarpDetector.TrackFogWarpVolume(FogWarpVolume volume) to see if it's even getting added to this list at all // [HarmonyPatch]
[HarmonyPatch] //public static class FogDebuggingPatches
public static class FogDebuggingPatches //{
{
[HarmonyPrefix] // [HarmonyPrefix]
[HarmonyPatch(typeof(FogWarpVolume), nameof(FogWarpVolume.WarpDetector))] // [HarmonyPatch(typeof(FogWarpVolume), nameof(FogWarpVolume.WarpDetector))]
public static bool FogWarpVolume_WarpDetector(FogWarpVolume __instance, FogWarpDetector detector, FogWarpVolume linkedWarpVolume) // public static bool FogWarpVolume_WarpDetector(FogWarpVolume __instance, FogWarpDetector detector, FogWarpVolume linkedWarpVolume)
{ // {
bool flag = detector.CompareName(FogWarpDetector.Name.Player); // bool flag = detector.CompareName(FogWarpDetector.Name.Player);
bool flag2 = detector.CompareName(FogWarpDetector.Name.Ship); // bool flag2 = detector.CompareName(FogWarpDetector.Name.Ship);
if (!flag || !PlayerState.IsInsideShip()) // if (!flag || !PlayerState.IsInsideShip())
{ // {
OWRigidbody oWRigidbody = detector.GetOWRigidbody(); // OWRigidbody oWRigidbody = detector.GetOWRigidbody();
if (flag && PlayerState.IsAttached()) // if (flag && PlayerState.IsAttached())
{ // {
oWRigidbody = detector.GetOWRigidbody().transform.parent.GetComponentInParent<OWRigidbody>(); // oWRigidbody = detector.GetOWRigidbody().transform.parent.GetComponentInParent<OWRigidbody>();
MonoBehaviour.print("body to warp: " + oWRigidbody.name); // MonoBehaviour.print("body to warp: " + oWRigidbody.name);
} // }
Vector3 localRelVelocity = __instance.transform.InverseTransformDirection(oWRigidbody.GetVelocity() - __instance._attachedBody.GetVelocity()); // Vector3 localRelVelocity = __instance.transform.InverseTransformDirection(oWRigidbody.GetVelocity() - __instance._attachedBody.GetVelocity());
Vector3 localPos = __instance.transform.InverseTransformPoint(oWRigidbody.transform.position); // Vector3 localPos = __instance.transform.InverseTransformPoint(oWRigidbody.transform.position);
Quaternion localRot = Quaternion.Inverse(__instance.transform.rotation) * oWRigidbody.transform.rotation; // Quaternion localRot = Quaternion.Inverse(__instance.transform.rotation) * oWRigidbody.transform.rotation;
if (flag2 && PlayerState.IsInsideShip()) // if (flag2 && PlayerState.IsInsideShip())
{ // {
__instance._sector.GetTriggerVolume().RemoveObjectFromVolume(Locator.GetPlayerDetector()); // __instance._sector.GetTriggerVolume().RemoveObjectFromVolume(Locator.GetPlayerDetector());
__instance._sector.GetTriggerVolume().RemoveObjectFromVolume(Locator.GetPlayerCameraDetector()); // __instance._sector.GetTriggerVolume().RemoveObjectFromVolume(Locator.GetPlayerCameraDetector());
} // }
if (flag || (flag2 && PlayerState.IsInsideShip())) // if (flag || (flag2 && PlayerState.IsInsideShip()))
{ // {
GlobalMessenger.FireEvent("PlayerFogWarp"); // GlobalMessenger.FireEvent("PlayerFogWarp");
} // }
__instance._sector.GetTriggerVolume().RemoveObjectFromVolume(detector.gameObject); // __instance._sector.GetTriggerVolume().RemoveObjectFromVolume(detector.gameObject);
linkedWarpVolume.ReceiveWarpedDetector(detector, localRelVelocity, localPos, localRot); // linkedWarpVolume.ReceiveWarpedDetector(detector, localRelVelocity, localPos, localRot);
//if (__instance.OnWarpDetector != null) // //if (__instance.OnWarpDetector != null)
//{ // //{
// __instance.OnWarpDetector(detector); // // __instance.OnWarpDetector(detector);
//} // //}
} // }
return false; // return false;
} // }
[HarmonyPrefix] // [HarmonyPrefix]
[HarmonyPatch(typeof(FogWarpVolume), nameof(FogWarpVolume.OnOccupantEnterSector))] // [HarmonyPatch(typeof(FogWarpVolume), nameof(FogWarpVolume.OnOccupantEnterSector))]
private static bool FogWarpVolume_OnOccupantEnterSector(FogWarpVolume __instance, SectorDetector detector) // private static bool FogWarpVolume_OnOccupantEnterSector(FogWarpVolume __instance, SectorDetector detector)
{ // {
Logger.LogWarning($"Warp volume {__instance.name} is attempting to get sector detector {detector.name} to register it"); // Logger.LogWarning($"Warp volume {__instance.name} is attempting to get sector detector {detector.name} to register it");
FogWarpDetector component = detector.GetComponent<FogWarpDetector>(); // FogWarpDetector component = detector.GetComponent<FogWarpDetector>();
if (component != null) // if (component != null)
{ // {
Logger.LogWarning("FogWarpDetector component was found"); // Logger.LogWarning("FogWarpDetector component was found");
component.TrackFogWarpVolume(__instance); // component.TrackFogWarpVolume(__instance);
} // }
return false; // return false;
} // }
[HarmonyPrefix] // [HarmonyPrefix]
[HarmonyPatch(typeof(FogWarpDetector), nameof(FogWarpDetector.TrackFogWarpVolume))] // [HarmonyPatch(typeof(FogWarpDetector), nameof(FogWarpDetector.TrackFogWarpVolume))]
public static bool FogWarpDetector_TrackFogWarpVolume(FogWarpDetector __instance, FogWarpVolume volume) // public static bool FogWarpDetector_TrackFogWarpVolume(FogWarpDetector __instance, FogWarpVolume volume)
{ // {
Logger.LogWarning($"Detector {__instance.name} is attempting to track fog warp volume {volume.name}"); // Logger.LogWarning($"Detector {__instance.name} is attempting to track fog warp volume {volume.name}");
bool flag = false; // bool flag = false;
if (!__instance._warpVolumes.SafeAdd(volume)) // if (!__instance._warpVolumes.SafeAdd(volume))
{ // {
Logger.LogError("Failed to add warp volume to tracking list"); // Logger.LogError("Failed to add warp volume to tracking list");
return false; // return false;
} // }
__instance.enabled = true; // __instance.enabled = true;
if (volume.IsOuterWarpVolume()) // if (volume.IsOuterWarpVolume())
{ // {
if (__instance._outerWarpVolume != null) // if (__instance._outerWarpVolume != null)
{ // {
Logger.LogError("Entering an outer warp volume before leaving the old one!"); // Logger.LogError("Entering an outer warp volume before leaving the old one!");
//Debug.Break(); // //Debug.Break();
} // }
if (__instance._outerWarpVolume != volume) // if (__instance._outerWarpVolume != volume)
{ // {
flag = true; // flag = true;
} // }
__instance._outerWarpVolume = (OuterFogWarpVolume)volume; // __instance._outerWarpVolume = (OuterFogWarpVolume)volume;
} // }
//if (__instance.OnTrackFogWarpVolume != null) // //if (__instance.OnTrackFogWarpVolume != null)
//{ // //{
// __instance.OnTrackFogWarpVolume(volume); // // __instance.OnTrackFogWarpVolume(volume);
//} // //}
//if (flag && __instance.OnOuterFogWarpVolumeChange != null) // //if (flag && __instance.OnOuterFogWarpVolumeChange != null)
//{ // //{
// __instance.OnOuterFogWarpVolumeChange(__instance._outerWarpVolume); // // __instance.OnOuterFogWarpVolumeChange(__instance._outerWarpVolume);
//} // //}
return false; // return false;
} // }
} //}
public static class BrambleNodeBuilder public static class BrambleNodeBuilder
{ {
@ -238,7 +237,12 @@ namespace NewHorizons.Builder.Props
// //
// Cleanup for dimension exits // Cleanup for dimension exits
// //
if (config.name != null) BrambleDimensionBuilder.FinishPairingDimensionsForExitNode(config.name); if (config.name != null)
{
namedNodes[config.name] = warpController;
BrambleDimensionBuilder.FinishPairingDimensionsForExitNode(config.name);
}
// Done! // Done!
return brambleNode; return brambleNode;