98 lines
1.9 KiB
C#
Raw Normal View History

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]
[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;
}
if (!QSBWorldSync.AllObjectsReady)
{
return;
}
2022-03-25 19:47:35 -07:00
if (__instance._lit == lit)
{
return;
}
__instance.GetWorldObject<QSBDreamRaftProjector>()
2022-03-25 19:47:35 -07:00
.SendMessage(new SetLitMessage(lit));
}
[HarmonyPrefix]
[HarmonyPatch(typeof(DreamRaftProjector), nameof(DreamRaftProjector.RespawnRaft))]
private static void RespawnRaft(DreamRaftProjector __instance)
{
if (Remote)
{
return;
}
if (!QSBWorldSync.AllObjectsReady)
{
return;
}
__instance.GetWorldObject<QSBDreamRaftProjector>()
.SendMessage(new RespawnRaftMessage());
}
[HarmonyPrefix]
[HarmonyPatch(typeof(DreamRaftProjector), nameof(DreamRaftProjector.ExtinguishImmediately))]
private static void ExtinguishImmediately(DreamRaftProjector __instance)
{
if (Remote)
{
return;
}
if (!QSBWorldSync.AllObjectsReady)
{
return;
}
if (!__instance._lit)
{
return;
}
__instance.GetWorldObject<QSBDreamRaftProjector>()
.SendMessage(new ExtinguishImmediatelyMessage());
}
[HarmonyPrefix]
2022-03-25 23:30:37 -07:00
[HarmonyPatch(typeof(DreamRaftProjection), nameof(DreamRaftProjection.UpdateVisibility))]
private static void UpdateVisibility(DreamRaftProjection __instance,
bool immediate = false)
{
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-11 16:39:53 -08:00
}