56 lines
1.3 KiB
C#
Raw Normal View History

2022-03-25 19:47:35 -07:00
using HarmonyLib;
2022-03-29 14:44:50 -07:00
using QSB.EchoesOfTheEye.DreamObjectProjectors.WorldObject;
2022-03-25 19:47:35 -07:00
using QSB.EchoesOfTheEye.DreamRafts.Messages;
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-29 14:40:54 -07:00
[HarmonyPatch(typeof(DreamRaftProjector), nameof(DreamRaftProjector.RespawnRaft))]
private static void RespawnRaft(DreamRaftProjector __instance)
2022-03-25 19:47:35 -07:00
{
if (Remote)
{
return;
}
if (!QSBWorldSync.AllObjectsReady)
{
return;
}
2022-03-29 14:44:50 -07:00
__instance.GetWorldObject<QSBDreamObjectProjector>()
2022-03-29 14:40:54 -07:00
.SendMessage(new RespawnRaftMessage());
}
2022-03-29 14:40:54 -07:00
/// <summary>
/// this is only called when:
/// - you exit the dream world
/// - the raft goes thru the warp volume with you not on it
///
/// we ignore both of these.
/// we DO still suspend the raft so it's not visible.
2022-03-29 14:40:54 -07:00
/// </summary>
[HarmonyPrefix]
2022-03-29 14:40:54 -07:00
[HarmonyPatch(typeof(DreamRaftProjector), nameof(DreamRaftProjector.ExtinguishImmediately))]
private static bool ExtinguishImmediately(DreamRaftProjector __instance)
{
2022-03-29 14:40:54 -07:00
if (!__instance._lit)
{
return false;
}
var projection = __instance._dreamRaftProjection;
projection._body.Suspend();
projection._waitingToSuspend = false;
return false;
}
2022-03-11 16:39:53 -08:00
}