fix cellevator

This commit is contained in:
JohnCorby 2022-08-15 14:24:48 -07:00
parent 3705ea45cc
commit 41013b62ed
2 changed files with 16 additions and 18 deletions

View File

@ -1,13 +1,10 @@
using QSB.EchoesOfTheEye.Prisoner.WorldObjects;
using QSB.Messaging;
using QSB.Patches;
namespace QSB.EchoesOfTheEye.Prisoner.Messages;
internal class CellevatorCallMessage : QSBWorldObjectMessage<QSBPrisonCellElevator, int>
{
public CellevatorCallMessage(int floorIndex) : base(floorIndex) { }
public override void OnReceiveRemote() =>
QSBPatch.RemoteCall(() => WorldObject.AttachedObject.CallElevatorToFloor(Data));
public override void OnReceiveRemote() => WorldObject.AttachedObject.CallElevatorToFloor(Data);
}

View File

@ -13,25 +13,26 @@ public class CellevatorPatches : QSBPatch
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
[HarmonyPrefix]
[HarmonyPatch(nameof(PrisonCellElevator.CallElevatorToFloor))]
public static void CallElevatorToFloor(PrisonCellElevator __instance, int floorIndex)
[HarmonyPatch(nameof(PrisonCellElevator.CallToTopFloor))]
public static void CallToTopFloor(PrisonCellElevator __instance)
{
if (Remote)
{
return;
}
if (__instance._targetFloorIndex == floorIndex)
{
return;
}
if (!QSBWorldSync.AllObjectsReady)
{
return;
}
__instance.GetWorldObject<QSBPrisonCellElevator>()
.SendMessage(new CellevatorCallMessage(floorIndex));
.SendMessage(new CellevatorCallMessage(1));
}
[HarmonyPrefix]
[HarmonyPatch(nameof(PrisonCellElevator.CallToBottomFloor))]
public static void CallToBottomFloor(PrisonCellElevator __instance)
{
if (!QSBWorldSync.AllObjectsReady)
{
return;
}
__instance.GetWorldObject<QSBPrisonCellElevator>()
.SendMessage(new CellevatorCallMessage(0));
}
}