2022-03-25 19:47:35 -07:00
|
|
|
|
using HarmonyLib;
|
2022-05-07 21:50:07 -07:00
|
|
|
|
using QSB.AuthoritySync;
|
2022-05-07 21:45:28 -07:00
|
|
|
|
using QSB.EchoesOfTheEye.DreamCandles.Patches;
|
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;
|
2022-05-07 21:50:07 -07:00
|
|
|
|
using QSB.EchoesOfTheEye.DreamRafts.WorldObjects;
|
2022-03-25 19:47:35 -07:00
|
|
|
|
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))]
|
2022-05-07 21:45:28 -07:00
|
|
|
|
private static void RespawnRaft_Prefix(DreamRaftProjector __instance)
|
2022-03-25 19:47:35 -07:00
|
|
|
|
{
|
|
|
|
|
if (Remote)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-25 23:27:46 -07:00
|
|
|
|
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-05-07 21:45:28 -07:00
|
|
|
|
|
|
|
|
|
// since respawning extinguishes all the candles, but we already have the above message
|
|
|
|
|
DreamCandlePatches.DontSendMessage = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HarmonyPostfix]
|
|
|
|
|
[HarmonyPatch(typeof(DreamRaftProjector), nameof(DreamRaftProjector.RespawnRaft))]
|
|
|
|
|
private static void RespawnRaft_Postfix(DreamRaftProjector __instance)
|
|
|
|
|
{
|
|
|
|
|
if (Remote)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!QSBWorldSync.AllObjectsReady)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DreamCandlePatches.DontSendMessage = false;
|
2022-03-25 22:52:53 -07:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-29 14:40:54 -07:00
|
|
|
|
/// <summary>
|
2022-03-29 14:51:54 -07:00
|
|
|
|
/// this is only called when:
|
|
|
|
|
/// - you exit the dream world
|
|
|
|
|
/// - the raft goes thru the warp volume with you not on it
|
|
|
|
|
///
|
2022-05-07 21:45:28 -07:00
|
|
|
|
/// this is to suspend the raft so it doesn't fall endlessly.
|
|
|
|
|
/// however, it's okay if it does that,
|
|
|
|
|
/// and we don't want it to extinguish with other players on it.
|
2022-03-29 14:40:54 -07:00
|
|
|
|
/// </summary>
|
2022-03-25 22:52:53 -07:00
|
|
|
|
[HarmonyPrefix]
|
2022-03-29 14:40:54 -07:00
|
|
|
|
[HarmonyPatch(typeof(DreamRaftProjector), nameof(DreamRaftProjector.ExtinguishImmediately))]
|
2022-05-07 21:50:07 -07:00
|
|
|
|
private static bool ExtinguishImmediately(DreamRaftProjector __instance)
|
|
|
|
|
{
|
|
|
|
|
if (!QSBWorldSync.AllObjectsReady)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// still release authority over the raft tho
|
|
|
|
|
__instance._dreamRaftProjection.GetWorldObject<QSBDreamRaft>()
|
|
|
|
|
.NetworkBehaviour.netIdentity.UpdateAuthQueue(AuthQueueAction.Remove);
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2022-03-11 16:39:53 -08:00
|
|
|
|
}
|