mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-03-10 16:14:45 +00:00
fix #597
This commit is contained in:
parent
7611711206
commit
8cc6769cf4
@ -18,6 +18,8 @@ public class SocketedQuantumObjectPatches : QSBPatch
|
||||
{
|
||||
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
||||
|
||||
public static bool TestSocketMove = false;
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(nameof(SocketedQuantumObject.ChangeQuantumState))]
|
||||
public static bool ChangeQuantumState(
|
||||
@ -33,6 +35,10 @@ public class SocketedQuantumObjectPatches : QSBPatch
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach (var socket in __instance._childSockets)
|
||||
{
|
||||
@ -77,9 +83,15 @@ public class SocketedQuantumObjectPatches : QSBPatch
|
||||
for (var i = 0; i < 20; i++)
|
||||
{
|
||||
var index = Random.Range(0, list.Count);
|
||||
TestSocketMove = true;
|
||||
__instance.MoveToSocket(list[index]);
|
||||
TestSocketMove = false;
|
||||
if (skipInstantVisibilityCheck)
|
||||
{
|
||||
if (__instance.GetWorldObject<QSBSocketedQuantumObject>().ControllingPlayer == QSBPlayerManager.LocalPlayerId)
|
||||
{
|
||||
__instance.GetWorldObject<QSBSocketedQuantumObject>().SendMessage(new SocketStateChangeMessage(list[index].GetWorldObject<QSBQuantumSocket>().ObjectId, __instance.transform.localRotation));
|
||||
}
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
@ -104,12 +116,16 @@ public class SocketedQuantumObjectPatches : QSBPatch
|
||||
else
|
||||
{
|
||||
// socket not suitable if player is inside object
|
||||
socketNotSuitable = playersEntangled.Any(x => __instance.CheckPointInside(x.CameraBody.transform.position));
|
||||
socketNotSuitable = QSBPlayerManager.PlayerList.Any(x => __instance.CheckPointInside(x.CameraBody.transform.position));
|
||||
}
|
||||
}
|
||||
|
||||
if (!socketNotSuitable)
|
||||
{
|
||||
if (__instance.GetWorldObject<QSBSocketedQuantumObject>().ControllingPlayer == QSBPlayerManager.LocalPlayerId)
|
||||
{
|
||||
__instance.GetWorldObject<QSBSocketedQuantumObject>().SendMessage(new SocketStateChangeMessage(list[index].GetWorldObject<QSBQuantumSocket>().ObjectId, __instance.transform.localRotation));
|
||||
}
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
@ -121,7 +137,9 @@ public class SocketedQuantumObjectPatches : QSBPatch
|
||||
}
|
||||
}
|
||||
|
||||
TestSocketMove = true;
|
||||
__instance.MoveToSocket(occupiedSocket);
|
||||
TestSocketMove = false;
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
@ -135,6 +153,11 @@ public class SocketedQuantumObjectPatches : QSBPatch
|
||||
return;
|
||||
}
|
||||
|
||||
if (TestSocketMove)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (socket == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - Trying to move {__instance.name} to a null socket!", MessageType.Error);
|
||||
|
@ -1,5 +1,6 @@
|
||||
using HarmonyLib;
|
||||
using QSB.Patches;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.QuantumSync.Patches.Common.Visibility;
|
||||
|
||||
@ -23,4 +24,21 @@ public class VisibilityShapeVisibilityTrackerPatches : QSBPatch
|
||||
__result = QuantumManager.IsVisible(__instance, false);
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(nameof(ShapeVisibilityTracker.IsInFrustum))]
|
||||
public static bool IsInFrustum(ShapeVisibilityTracker __instance, Plane[] frustumPlanes, out bool __result)
|
||||
{
|
||||
foreach (var shape in __instance._shapes)
|
||||
{
|
||||
if (shape.IsVisible(frustumPlanes))
|
||||
{
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user