This commit is contained in:
_nebula 2023-09-20 18:12:46 +01:00
parent 7611711206
commit 8cc6769cf4
2 changed files with 42 additions and 1 deletions

View File

@ -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);

View File

@ -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;
}
}