mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2024-12-29 03:28:26 +00:00
add a silly little patch
This commit is contained in:
parent
80e1629fb6
commit
735b375f23
43
QSB/GetAttachedOWRigidbodyPatch.cs
Normal file
43
QSB/GetAttachedOWRigidbodyPatch.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using HarmonyLib;
|
||||
using QSB.Patches;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB;
|
||||
|
||||
/// <summary>
|
||||
/// TODO: TEST THIS. see if things horribly break. this could be huge.
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(OWExtensions))]
|
||||
public class GetAttachedOWRigidbodyPatch : QSBPatch
|
||||
{
|
||||
public override QSBPatchTypes Type => QSBPatchTypes.OnModStart;
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(nameof(OWExtensions.GetAttachedOWRigidbody), typeof(GameObject), typeof(bool))]
|
||||
private static bool GetAttachedOWRigidbody(GameObject obj, bool ignoreThisTransform, out OWRigidbody __result)
|
||||
{
|
||||
OWRigidbody owrigidbody = null;
|
||||
var transform = obj.transform;
|
||||
if (ignoreThisTransform)
|
||||
{
|
||||
transform = obj.transform.parent;
|
||||
}
|
||||
while (owrigidbody == null)
|
||||
{
|
||||
owrigidbody = transform.GetComponent<OWRigidbody>();
|
||||
/*
|
||||
if (owrigidbody != null && !owrigidbody.gameObject.activeInHierarchy)
|
||||
{
|
||||
owrigidbody = null;
|
||||
}
|
||||
*/
|
||||
if ((transform == obj.transform.root && owrigidbody == null) || owrigidbody != null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
transform = transform.parent;
|
||||
}
|
||||
__result = owrigidbody;
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user