mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-30 12:32:55 +00:00
lol
This commit is contained in:
parent
2cc3e54386
commit
b072895958
@ -0,0 +1,27 @@
|
|||||||
|
using QSB.Utility;
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace QSB.EchoesOfTheEye.DreamRafts.WorldObjects;
|
||||||
|
|
||||||
|
public class EnableDisableDetector : MonoBehaviour
|
||||||
|
{
|
||||||
|
public static void Add(GameObject go, object linkedObject) =>
|
||||||
|
go.AddComponent<EnableDisableDetector>()._linkedObject = linkedObject;
|
||||||
|
|
||||||
|
private object _linkedObject;
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
var body = this.GetAttachedOWRigidbody();
|
||||||
|
if (body)
|
||||||
|
{
|
||||||
|
DebugLog.DebugWrite($"{_linkedObject} suspended = {body.IsSuspended()}");
|
||||||
|
body.OnSuspendOWRigidbody += _ => DebugLog.DebugWrite($"{_linkedObject} suspend\n{Environment.StackTrace}");
|
||||||
|
body.OnPreUnsuspendOWRigidbody += _ => DebugLog.DebugWrite($"{_linkedObject} unsuspend\n{Environment.StackTrace}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnEnable() => DebugLog.DebugWrite($"{_linkedObject} enable");
|
||||||
|
private void OnDisable() => DebugLog.DebugWrite($"{_linkedObject} disable");
|
||||||
|
}
|
@ -1,9 +1,6 @@
|
|||||||
using Cysharp.Threading.Tasks;
|
using Cysharp.Threading.Tasks;
|
||||||
using QSB.Utility;
|
|
||||||
using QSB.WorldSync;
|
using QSB.WorldSync;
|
||||||
using System;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace QSB.EchoesOfTheEye.DreamRafts.WorldObjects;
|
namespace QSB.EchoesOfTheEye.DreamRafts.WorldObjects;
|
||||||
|
|
||||||
@ -14,44 +11,3 @@ public class QSBDreamRaftController : WorldObject<DreamRaftController>
|
|||||||
public override async UniTask Init(CancellationToken ct) =>
|
public override async UniTask Init(CancellationToken ct) =>
|
||||||
EnableDisableDetector.Add(AttachedObject.gameObject, this);
|
EnableDisableDetector.Add(AttachedObject.gameObject, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class QSBSealRaftController : WorldObject<SealRaftController>
|
|
||||||
{
|
|
||||||
public override void SendInitialState(uint to) { }
|
|
||||||
|
|
||||||
public override async UniTask Init(CancellationToken ct) =>
|
|
||||||
EnableDisableDetector.Add(AttachedObject.gameObject, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class EnableDisableDetector : MonoBehaviour
|
|
||||||
{
|
|
||||||
public static void Add(GameObject go, object linkedObject)
|
|
||||||
{
|
|
||||||
if (go.activeSelf)
|
|
||||||
{
|
|
||||||
go.SetActive(false);
|
|
||||||
go.AddComponent<EnableDisableDetector>()._linkedObject = linkedObject;
|
|
||||||
go.SetActive(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
go.AddComponent<EnableDisableDetector>()._linkedObject = linkedObject;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private object _linkedObject;
|
|
||||||
|
|
||||||
private void Awake()
|
|
||||||
{
|
|
||||||
var body = this.GetAttachedOWRigidbody();
|
|
||||||
if (body)
|
|
||||||
{
|
|
||||||
DebugLog.DebugWrite($"{_linkedObject} suspended = {body.IsSuspended()}");
|
|
||||||
body.OnSuspendOWRigidbody += _ => DebugLog.DebugWrite($"{_linkedObject} suspend\n{Environment.StackTrace}");
|
|
||||||
body.OnPreUnsuspendOWRigidbody += _ => DebugLog.DebugWrite($"{_linkedObject} unsuspend\n{Environment.StackTrace}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnEnable() => DebugLog.DebugWrite($"{_linkedObject} enable");
|
|
||||||
private void OnDisable() => DebugLog.DebugWrite($"{_linkedObject} disable");
|
|
||||||
}
|
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
using Cysharp.Threading.Tasks;
|
||||||
|
using QSB.WorldSync;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace QSB.EchoesOfTheEye.DreamRafts.WorldObjects;
|
||||||
|
|
||||||
|
public class QSBSealRaftController : WorldObject<SealRaftController>
|
||||||
|
{
|
||||||
|
public override void SendInitialState(uint to) { }
|
||||||
|
|
||||||
|
public override async UniTask Init(CancellationToken ct) =>
|
||||||
|
EnableDisableDetector.Add(AttachedObject.gameObject, this);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user