2022-01-21 21:54:58 +00:00
|
|
|
|
using HarmonyLib;
|
|
|
|
|
using QSB.EchoesOfTheEye.SlideProjectors.Messages;
|
|
|
|
|
using QSB.EchoesOfTheEye.SlideProjectors.WorldObjects;
|
|
|
|
|
using QSB.Messaging;
|
|
|
|
|
using QSB.Patches;
|
|
|
|
|
using QSB.WorldSync;
|
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
namespace QSB.EchoesOfTheEye.SlideProjectors.Patches;
|
|
|
|
|
|
2022-03-02 20:47:32 -08:00
|
|
|
|
[HarmonyPatch(typeof(SlideProjector))]
|
2023-07-28 19:30:57 +01:00
|
|
|
|
public class SlideProjectorPatches : QSBPatch
|
2022-01-21 21:54:58 +00:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
2022-01-21 21:54:58 +00:00
|
|
|
|
|
2022-08-20 11:51:44 -07:00
|
|
|
|
[HarmonyPrefix]
|
2022-03-02 20:47:32 -08:00
|
|
|
|
[HarmonyPatch(nameof(SlideProjector.OnPressInteract))]
|
2022-08-20 11:51:44 -07:00
|
|
|
|
public static void OnPressInteract(SlideProjector __instance)
|
|
|
|
|
{
|
|
|
|
|
if (!QSBWorldSync.AllObjectsReady)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
__instance.GetWorldObject<QSBSlideProjector>().SendMessage(new UseSlideProjectorMessage(true));
|
|
|
|
|
}
|
2022-01-21 21:54:58 +00:00
|
|
|
|
|
2022-08-20 11:51:44 -07:00
|
|
|
|
[HarmonyPrefix]
|
2022-03-02 20:47:32 -08:00
|
|
|
|
[HarmonyPatch(nameof(SlideProjector.CancelInteraction))]
|
2022-08-20 11:51:44 -07:00
|
|
|
|
public static void CancelInteraction(SlideProjector __instance)
|
|
|
|
|
{
|
|
|
|
|
if (!QSBWorldSync.AllObjectsReady)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
__instance.GetWorldObject<QSBSlideProjector>().SendMessage(new UseSlideProjectorMessage(false));
|
|
|
|
|
}
|
2022-01-21 21:54:58 +00:00
|
|
|
|
|
2022-08-20 11:51:44 -07:00
|
|
|
|
[HarmonyPrefix]
|
2022-03-02 20:47:32 -08:00
|
|
|
|
[HarmonyPatch(nameof(SlideProjector.NextSlide))]
|
2022-08-20 11:51:44 -07:00
|
|
|
|
public static void NextSlide(SlideProjector __instance)
|
|
|
|
|
{
|
|
|
|
|
if (Remote)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!QSBWorldSync.AllObjectsReady)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
__instance.GetWorldObject<QSBSlideProjector>().SendMessage(new NextSlideMessage());
|
|
|
|
|
}
|
2022-01-21 21:54:58 +00:00
|
|
|
|
|
2022-08-20 11:51:44 -07:00
|
|
|
|
[HarmonyPrefix]
|
2022-03-02 20:47:32 -08:00
|
|
|
|
[HarmonyPatch(nameof(SlideProjector.PreviousSlide))]
|
2022-08-20 11:51:44 -07:00
|
|
|
|
public static void PreviousSlide(SlideProjector __instance)
|
|
|
|
|
{
|
|
|
|
|
if (Remote)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!QSBWorldSync.AllObjectsReady)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
__instance.GetWorldObject<QSBSlideProjector>().SendMessage(new PreviousSlideMessage());
|
|
|
|
|
}
|
2022-03-02 20:47:32 -08:00
|
|
|
|
}
|