mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-20 15:41:01 +00:00
ignore cancel drag and slot collision if we dont have authority
This commit is contained in:
parent
83e6d26f44
commit
f5f473c059
@ -16,11 +16,11 @@ namespace QSB.OrbSync.Patches
|
||||
[HarmonyPatch(nameof(NomaiInterfaceOrb.StartDragFromPosition))]
|
||||
public static void StartDragFromPosition(NomaiInterfaceOrb __instance)
|
||||
{
|
||||
if (!__instance._isBeingDragged)
|
||||
if (!WorldObjectManager.AllObjectsReady)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!WorldObjectManager.AllObjectsReady)
|
||||
if (!__instance._isBeingDragged)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -30,46 +30,23 @@ namespace QSB.OrbSync.Patches
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(nameof(NomaiInterfaceOrb.CancelDrag))]
|
||||
public static void CancelDrag(NomaiInterfaceOrb __instance)
|
||||
public static bool CancelDrag(NomaiInterfaceOrb __instance)
|
||||
{
|
||||
if (!__instance._isBeingDragged)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!WorldObjectManager.AllObjectsReady)
|
||||
{
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
if (!__instance._isBeingDragged)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var qsbOrb = QSBWorldSync.GetWorldFromUnity<QSBOrb>(__instance);
|
||||
if (!qsbOrb.TransformSync.HasAuthority)
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
QSBEventManager.FireEvent(EventNames.QSBOrbDrag, qsbOrb, false);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(nameof(NomaiInterfaceOrb.MoveTowardPosition))]
|
||||
public static bool MoveTowardPosition(NomaiInterfaceOrb __instance)
|
||||
{
|
||||
if (!WorldObjectManager.AllObjectsReady)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
var qsbOrb = QSBWorldSync.GetWorldFromUnity<QSBOrb>(__instance);
|
||||
if (qsbOrb.TransformSync.HasAuthority)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var pointVelocity = __instance._parentBody.GetPointVelocity(__instance._orbBody.GetPosition());
|
||||
__instance._orbBody.SetVelocity(pointVelocity);
|
||||
if (!__instance._applyForcesWhileMoving)
|
||||
{
|
||||
__instance._forceApplier.SetApplyForces(false);
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
@ -83,7 +60,7 @@ namespace QSB.OrbSync.Patches
|
||||
var qsbOrb = QSBWorldSync.GetWorldFromUnity<QSBOrb>(__instance);
|
||||
if (!qsbOrb.TransformSync.HasAuthority)
|
||||
{
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (__instance._occupiedSlot == null)
|
||||
@ -117,5 +94,29 @@ namespace QSB.OrbSync.Patches
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(nameof(NomaiInterfaceOrb.MoveTowardPosition))]
|
||||
public static bool MoveTowardPosition(NomaiInterfaceOrb __instance)
|
||||
{
|
||||
if (!WorldObjectManager.AllObjectsReady)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
var qsbOrb = QSBWorldSync.GetWorldFromUnity<QSBOrb>(__instance);
|
||||
if (qsbOrb.TransformSync.HasAuthority)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var pointVelocity = __instance._parentBody.GetPointVelocity(__instance._orbBody.GetPosition());
|
||||
__instance._orbBody.SetVelocity(pointVelocity);
|
||||
if (!__instance._applyForcesWhileMoving)
|
||||
{
|
||||
__instance._forceApplier.SetApplyForces(false);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -233,6 +233,16 @@ namespace QSB
|
||||
{
|
||||
DebugLog.DebugWrite("OnServerDisconnect", MessageType.Info);
|
||||
|
||||
// revert authority from ship
|
||||
if (ShipTransformSync.LocalInstance)
|
||||
{
|
||||
var identity = ShipTransformSync.LocalInstance.NetIdentity;
|
||||
if (identity.ClientAuthorityOwner == conn)
|
||||
{
|
||||
identity.SetAuthority(QSBPlayerManager.LocalPlayerId);
|
||||
}
|
||||
}
|
||||
|
||||
// stop dragging for the orbs this player was dragging
|
||||
foreach (var qsbOrb in QSBWorldSync.GetWorldObjects<QSBOrb>())
|
||||
{
|
||||
@ -249,16 +259,6 @@ namespace QSB
|
||||
}
|
||||
}
|
||||
|
||||
// revert authority from ship
|
||||
if (ShipTransformSync.LocalInstance)
|
||||
{
|
||||
var identity = ShipTransformSync.LocalInstance.NetIdentity;
|
||||
if (identity.ClientAuthorityOwner == conn)
|
||||
{
|
||||
identity.SetAuthority(QSBPlayerManager.LocalPlayerId);
|
||||
}
|
||||
}
|
||||
|
||||
AuthorityManager.OnDisconnect(conn.GetPlayerId());
|
||||
|
||||
base.OnServerDisconnect(conn);
|
||||
|
Loading…
x
Reference in New Issue
Block a user