This commit is contained in:
Mister_Nebula 2022-03-29 23:20:41 +01:00
commit 86a177bae4
9 changed files with 34 additions and 76 deletions

View File

@ -30,12 +30,6 @@ internal class ProjectorPatches : QSBPatch
return;
}
// todo remove after removing QSBDreamRaftProjector
if (__instance is DreamRaftProjector)
{
return;
}
__instance.GetWorldObject<QSBDreamObjectProjector>()
.SendMessage(new ProjectorLitMessage(false));
}

View File

@ -11,5 +11,5 @@ internal class ProjectorManager : WorldObjectManager
public override bool DlcOnly => true;
public override async UniTask BuildWorldObjects(OWScene scene, CancellationToken ct)
=> QSBWorldSync.Init<QSBDreamObjectProjector, DreamObjectProjector>(typeof(DreamRaftProjector) /*todo remove after removing QSBDreamRaftProjector*/);
=> QSBWorldSync.Init<QSBDreamObjectProjector, DreamObjectProjector>();
}

View File

@ -14,8 +14,5 @@ public class DreamRaftManager : WorldObjectManager
{
QSBWorldSync.Init<QSBDreamRaft, DreamRaftController>();
QSBWorldSync.Init<QSBSealRaft, SealRaftController>();
QSBWorldSync.Init<QSBDreamRaftProjector, DreamRaftProjector>();
QSBWorldSync.Init<QSBDreamRaftProjection, DreamRaftProjection>();
}
}

View File

@ -1,11 +0,0 @@
using QSB.EchoesOfTheEye.DreamRafts.WorldObjects;
using QSB.Messaging;
using QSB.Patches;
namespace QSB.EchoesOfTheEye.DreamRafts.Messages;
public class ExtinguishMessage : QSBWorldObjectMessage<QSBDreamRaftProjection>
{
public override void OnReceiveRemote() =>
QSBPatch.RemoteCall(() => WorldObject.AttachedObject.SetVisible(false));
}

View File

@ -0,0 +1,14 @@
using QSB.EchoesOfTheEye.DreamObjectProjectors.WorldObject;
using QSB.Messaging;
using QSB.Patches;
namespace QSB.EchoesOfTheEye.DreamRafts.Messages;
public class RespawnRaftMessage : QSBWorldObjectMessage<QSBDreamObjectProjector>
{
public override void OnReceiveRemote()
{
var attachedObject = (DreamRaftProjector)WorldObject.AttachedObject;
QSBPatch.RemoteCall(attachedObject.RespawnRaft);
}
}

View File

@ -1,11 +0,0 @@
using QSB.EchoesOfTheEye.DreamRafts.WorldObjects;
using QSB.Messaging;
using QSB.Patches;
namespace QSB.EchoesOfTheEye.DreamRafts.Messages;
public class SpawnRaftMessage : QSBWorldObjectMessage<QSBDreamRaftProjector>
{
public override void OnReceiveRemote() =>
QSBPatch.RemoteCall(WorldObject.AttachedObject.RespawnRaft);
}

View File

@ -1,10 +1,9 @@
using HarmonyLib;
using QSB.EchoesOfTheEye.DreamObjectProjectors.WorldObject;
using QSB.EchoesOfTheEye.DreamRafts.Messages;
using QSB.EchoesOfTheEye.DreamRafts.WorldObjects;
using QSB.Messaging;
using QSB.Patches;
using QSB.WorldSync;
using System.Linq;
namespace QSB.EchoesOfTheEye.DreamRafts.Patches;
@ -13,8 +12,8 @@ public class DreamRaftPatches : QSBPatch
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
[HarmonyPrefix]
[HarmonyPatch(typeof(DreamRaftProjector), nameof(DreamRaftProjector.SpawnRaft))]
private static void SpawnRaft(DreamRaftProjector __instance)
[HarmonyPatch(typeof(DreamRaftProjector), nameof(DreamRaftProjector.RespawnRaft))]
private static void RespawnRaft(DreamRaftProjector __instance)
{
if (Remote)
{
@ -26,30 +25,30 @@ public class DreamRaftPatches : QSBPatch
return;
}
__instance.GetWorldObject<QSBDreamRaftProjector>()
.SendMessage(new SpawnRaftMessage());
__instance.GetWorldObject<QSBDreamObjectProjector>()
.SendMessage(new RespawnRaftMessage());
}
/// <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.
/// </summary>
[HarmonyPrefix]
[HarmonyPatch(typeof(DreamRaftProjection), nameof(DreamRaftProjection.OnCandleLitStateChanged))]
private static bool OnCandleLitStateChanged(DreamRaftProjection __instance)
[HarmonyPatch(typeof(DreamRaftProjector), nameof(DreamRaftProjector.ExtinguishImmediately))]
private static bool ExtinguishImmediately(DreamRaftProjector __instance)
{
if (!__instance._visible)
if (!__instance._lit)
{
return false;
}
if (__instance._candles.Any(x => x.IsLit()))
{
return false;
}
__instance.SetVisible(false);
if (!Remote && QSBWorldSync.AllObjectsReady)
{
__instance.GetWorldObject<QSBDreamRaftProjection>()
.SendMessage(new ExtinguishMessage());
}
var projection = __instance._dreamRaftProjection;
projection._body.Suspend();
projection._waitingToSuspend = false;
return false;
}

View File

@ -1,8 +0,0 @@
using QSB.WorldSync;
namespace QSB.EchoesOfTheEye.DreamRafts.WorldObjects;
public class QSBDreamRaftProjection : WorldObject<DreamRaftProjection>
{
public override void SendInitialState(uint to) { }
}

View File

@ -1,16 +0,0 @@
using QSB.EchoesOfTheEye.DreamRafts.Messages;
using QSB.Messaging;
using QSB.WorldSync;
namespace QSB.EchoesOfTheEye.DreamRafts.WorldObjects;
public class QSBDreamRaftProjector : WorldObject<DreamRaftProjector>
{
public override void SendInitialState(uint to)
{
if (AttachedObject._lit)
{
this.SendMessage(new SpawnRaftMessage { To = to });
}
}
}