2022-03-25 19:47:35 -07:00
|
|
|
|
using HarmonyLib;
|
|
|
|
|
using QSB.EchoesOfTheEye.DreamRafts.Messages;
|
|
|
|
|
using QSB.EchoesOfTheEye.DreamRafts.WorldObjects;
|
|
|
|
|
using QSB.Messaging;
|
|
|
|
|
using QSB.Patches;
|
|
|
|
|
using QSB.WorldSync;
|
2022-03-11 16:39:53 -08:00
|
|
|
|
|
|
|
|
|
namespace QSB.EchoesOfTheEye.DreamRafts.Patches;
|
|
|
|
|
|
|
|
|
|
public class DreamRaftPatches : QSBPatch
|
|
|
|
|
{
|
|
|
|
|
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
2022-03-25 19:47:35 -07:00
|
|
|
|
|
|
|
|
|
[HarmonyPrefix]
|
2022-03-25 23:27:46 -07:00
|
|
|
|
[HarmonyPatch(typeof(DreamRaftProjector), nameof(DreamRaftProjector.SetLit))]
|
|
|
|
|
private static void SetLit(DreamRaftProjector __instance,
|
2022-03-25 19:47:35 -07:00
|
|
|
|
bool lit)
|
|
|
|
|
{
|
|
|
|
|
if (Remote)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-25 23:27:46 -07:00
|
|
|
|
if (!QSBWorldSync.AllObjectsReady)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-25 19:47:35 -07:00
|
|
|
|
if (__instance._lit == lit)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-25 23:27:46 -07:00
|
|
|
|
__instance.GetWorldObject<QSBDreamRaftProjector>()
|
2022-03-25 19:47:35 -07:00
|
|
|
|
.SendMessage(new SetLitMessage(lit));
|
|
|
|
|
}
|
2022-03-25 22:52:53 -07:00
|
|
|
|
|
|
|
|
|
[HarmonyPrefix]
|
|
|
|
|
[HarmonyPatch(typeof(DreamRaftProjector), nameof(DreamRaftProjector.RespawnRaft))]
|
|
|
|
|
private static void RespawnRaft(DreamRaftProjector __instance)
|
|
|
|
|
{
|
|
|
|
|
if (Remote)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-25 23:27:46 -07:00
|
|
|
|
if (!QSBWorldSync.AllObjectsReady)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
__instance.GetWorldObject<QSBDreamRaftProjector>()
|
2022-03-25 22:52:53 -07:00
|
|
|
|
.SendMessage(new RespawnRaftMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HarmonyPrefix]
|
|
|
|
|
[HarmonyPatch(typeof(DreamRaftProjector), nameof(DreamRaftProjector.ExtinguishImmediately))]
|
|
|
|
|
private static void ExtinguishImmediately(DreamRaftProjector __instance)
|
|
|
|
|
{
|
|
|
|
|
if (Remote)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-25 23:27:46 -07:00
|
|
|
|
if (!QSBWorldSync.AllObjectsReady)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-26 20:50:46 -07:00
|
|
|
|
if (!__instance._lit)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-25 23:27:46 -07:00
|
|
|
|
__instance.GetWorldObject<QSBDreamRaftProjector>()
|
2022-03-25 22:52:53 -07:00
|
|
|
|
.SendMessage(new ExtinguishImmediatelyMessage());
|
|
|
|
|
}
|
2022-03-25 23:27:46 -07:00
|
|
|
|
|
|
|
|
|
[HarmonyPrefix]
|
2022-03-25 23:30:37 -07:00
|
|
|
|
[HarmonyPatch(typeof(DreamRaftProjection), nameof(DreamRaftProjection.UpdateVisibility))]
|
|
|
|
|
private static void UpdateVisibility(DreamRaftProjection __instance,
|
|
|
|
|
bool immediate = false)
|
2022-03-25 23:27:46 -07:00
|
|
|
|
{
|
|
|
|
|
if (Remote)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!QSBWorldSync.AllObjectsReady)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
__instance.GetWorldObject<QSBDreamRaftProjection>()
|
2022-03-25 23:30:37 -07:00
|
|
|
|
.SendMessage(new UpdateVisibilityMessage(__instance._visible, immediate));
|
2022-03-25 23:27:46 -07:00
|
|
|
|
}
|
2022-03-11 16:39:53 -08:00
|
|
|
|
}
|