mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-03 17:38:30 +00:00
when you
This commit is contained in:
parent
a03c97984d
commit
1a9cb4fd22
@ -14,23 +14,50 @@ namespace QSB.OrbSync.Patches
|
||||
{
|
||||
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(nameof(NomaiInterfaceOrb.StartDragFromPosition))]
|
||||
private static void StartDragFromPosition(NomaiInterfaceOrb __instance, bool __result)
|
||||
private static bool StartDragFromPosition(NomaiInterfaceOrb __instance, ref bool __result,
|
||||
Vector3 manipPos)
|
||||
{
|
||||
if (!__result)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
var qsbOrb = __instance.GetWorldObject<QSBOrb>();
|
||||
qsbOrb.SendMessage(new OrbDragMessage(true));
|
||||
qsbOrb.TransformSync.netIdentity.UpdateAuthQueue(AuthQueueAction.Force);
|
||||
if (__instance._orbBody.IsSuspended() || __instance._isBeingDragged)
|
||||
{
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (__instance.RecentlyEnteredSlot())
|
||||
{
|
||||
__instance._loseFocusToStartDrag = true;
|
||||
}
|
||||
|
||||
if (Vector3.Distance(manipPos, __instance.transform.position) < __instance._startDragDist)
|
||||
{
|
||||
if (!__instance._loseFocusToStartDrag)
|
||||
{
|
||||
__instance._isBeingDragged = true;
|
||||
__instance._interactibleCollider.enabled = false;
|
||||
if (__instance._orbAudio != null)
|
||||
{
|
||||
__instance._orbAudio.PlayStartDragClip();
|
||||
}
|
||||
|
||||
var qsbOrb = __instance.GetWorldObject<QSBOrb>();
|
||||
qsbOrb.SendMessage(new OrbDragMessage(true));
|
||||
qsbOrb.TransformSync.netIdentity.UpdateAuthQueue(AuthQueueAction.Force);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance._loseFocusToStartDrag = false;
|
||||
}
|
||||
|
||||
__result = __instance._isBeingDragged;
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
@ -42,6 +69,11 @@ namespace QSB.OrbSync.Patches
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!__instance._isBeingDragged)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var qsbOrb = __instance.GetWorldObject<QSBOrb>();
|
||||
if (!qsbOrb.TransformSync.hasAuthority)
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
using QSB.AuthoritySync;
|
||||
using QSB.OrbSync.WorldObjects;
|
||||
using QSB.Syncs.Unsectored.Transforms;
|
||||
using QSB.Utility;
|
||||
using QSB.WorldSync;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@ -16,8 +15,8 @@ namespace QSB.OrbSync.TransformSync
|
||||
/// </summary>
|
||||
protected override bool CheckValid() => AttachedTransform && base.CheckValid();
|
||||
|
||||
protected override bool UseInterpolation => false;
|
||||
protected override bool OnlyApplyOnDeserialize => true;
|
||||
protected override bool UseInterpolation => true;
|
||||
protected override float DistanceLeeway => 1f;
|
||||
|
||||
protected override Transform InitLocalTransform() => _qsbOrb.AttachedObject.transform;
|
||||
protected override Transform InitRemoteTransform() => _qsbOrb.AttachedObject.transform;
|
||||
@ -81,7 +80,11 @@ namespace QSB.OrbSync.TransformSync
|
||||
private void OnUnsuspend(OWRigidbody suspendedBody) => netIdentity.UpdateAuthQueue(AuthQueueAction.Add);
|
||||
private void OnSuspend(OWRigidbody suspendedBody) => netIdentity.UpdateAuthQueue(AuthQueueAction.Remove);
|
||||
|
||||
protected override void ApplyToAttached() =>
|
||||
_qsbOrb.AttachedObject.SetTargetPosition(ReferenceTransform.FromRelPos(transform.position));
|
||||
protected override void ApplyToAttached()
|
||||
{
|
||||
base.ApplyToAttached();
|
||||
|
||||
_qsbOrb.AttachedObject.SetTargetPosition(AttachedTransform.position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,8 +51,6 @@ namespace QSB.OrbSync.WorldObjects
|
||||
return;
|
||||
}
|
||||
|
||||
DebugLog.DebugWrite($"{this} dragging = {value}");
|
||||
|
||||
if (value)
|
||||
{
|
||||
AttachedObject._isBeingDragged = true;
|
||||
@ -67,8 +65,6 @@ namespace QSB.OrbSync.WorldObjects
|
||||
AttachedObject._isBeingDragged = false;
|
||||
AttachedObject._interactibleCollider.enabled = true;
|
||||
}
|
||||
|
||||
DebugLog.DebugWrite($"{this} interactible collider enabled = {AttachedObject._interactibleCollider.enabled}");
|
||||
}
|
||||
|
||||
public void SetSlot(int slotIndex, bool playAudio)
|
||||
|
Loading…
Reference in New Issue
Block a user