alarm totems: idk

This commit is contained in:
JohnCorby 2022-04-01 02:23:59 -07:00
parent 1d7839abdf
commit 13a36bd56c
5 changed files with 94 additions and 0 deletions

View File

@ -0,0 +1,15 @@
using Cysharp.Threading.Tasks;
using QSB.EchoesOfTheEye.AlarmTotemSync.WorldObjects;
using QSB.WorldSync;
using System.Threading;
namespace QSB.EchoesOfTheEye.AlarmTotemSync;
public class SarcophagusManager : WorldObjectManager
{
public override WorldObjectScene WorldObjectScene => WorldObjectScene.SolarSystem;
public override bool DlcOnly => true;
public override async UniTask BuildWorldObjects(OWScene scene, CancellationToken ct) =>
QSBWorldSync.Init<QSBAlarmTotem, AlarmTotem>();
}

View File

@ -0,0 +1,17 @@
using QSB.EchoesOfTheEye.AlarmTotemSync.WorldObjects;
using QSB.Messaging;
using QSB.Patches;
namespace QSB.EchoesOfTheEye.AlarmTotemSync.Messages;
public class SetEnabledMessage : QSBWorldObjectMessage<QSBAlarmTotem, bool>
{
public SetEnabledMessage(bool data) : base(data) { }
public override void OnReceiveRemote()
{
if (!Data && )
QSBPatch.RemoteCall(() => WorldObject.AttachedObject.SetFaceOpen(Data));
}
}

View File

@ -0,0 +1,13 @@
using QSB.EchoesOfTheEye.AlarmTotemSync.WorldObjects;
using QSB.Messaging;
using QSB.Patches;
namespace QSB.EchoesOfTheEye.AlarmTotemSync.Messages;
public class SetFaceOpenMessage : QSBWorldObjectMessage<QSBAlarmTotem, bool>
{
public SetFaceOpenMessage(bool data) : base(data) { }
public override void OnReceiveRemote() =>
QSBPatch.RemoteCall(() => WorldObject.AttachedObject.SetFaceOpen(Data));
}

View File

@ -0,0 +1,36 @@
using HarmonyLib;
using QSB.EchoesOfTheEye.AlarmTotemSync.Messages;
using QSB.EchoesOfTheEye.AlarmTotemSync.WorldObjects;
using QSB.Messaging;
using QSB.Patches;
using QSB.WorldSync;
namespace QSB.EchoesOfTheEye.AlarmTotemSync.Patches;
public class AlarmTotemPatches : QSBPatch
{
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
[HarmonyPrefix]
[HarmonyPatch(typeof(AlarmTotem), nameof(AlarmTotem.SetFaceOpen))]
private static void SetFaceOpen(AlarmTotem __instance, bool open)
{
if (Remote)
{
return;
}
if (__instance._isFaceOpen == open)
{
return;
}
if (!QSBWorldSync.AllObjectsReady)
{
return;
}
__instance.GetWorldObject<QSBAlarmTotem>()
.SendMessage(new SetFaceOpenMessage(open));
}
}

View File

@ -0,0 +1,13 @@
using QSB.EchoesOfTheEye.AlarmTotemSync.Messages;
using QSB.Messaging;
using QSB.WorldSync;
namespace QSB.EchoesOfTheEye.AlarmTotemSync.WorldObjects;
public class QSBAlarmTotem : WorldObject<AlarmTotem>
{
public override void SendInitialState(uint to)
{
this.SendMessage(new SetFaceOpenMessage(AttachedObject._isFaceOpen) { To = to });
}
}