mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-01 12:08:52 +00:00
VisionTorchProjectMessage
This commit is contained in:
parent
997576993e
commit
6322ea81ed
@ -0,0 +1,10 @@
|
||||
using QSB.EchoesOfTheEye.VisionTorch.WorldObjects;
|
||||
using QSB.Messaging;
|
||||
|
||||
namespace QSB.EchoesOfTheEye.VisionTorch.Messages;
|
||||
|
||||
public class VisionTorchProjectMessage : QSBWorldObjectMessage<QSBVisionTorchItem, bool>
|
||||
{
|
||||
public VisionTorchProjectMessage(bool projecting) : base(projecting) { }
|
||||
public override void OnReceiveRemote() => WorldObject.AttachedObject._mindProjectorTrigger.SetProjectorActive(Data);
|
||||
}
|
45
QSB/EchoesOfTheEye/VisionTorch/Patches/VisionTorchPatches.cs
Normal file
45
QSB/EchoesOfTheEye/VisionTorch/Patches/VisionTorchPatches.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using HarmonyLib;
|
||||
using QSB.EchoesOfTheEye.VisionTorch.Messages;
|
||||
using QSB.EchoesOfTheEye.VisionTorch.WorldObjects;
|
||||
using QSB.Messaging;
|
||||
using QSB.Patches;
|
||||
using QSB.WorldSync;
|
||||
|
||||
namespace QSB.EchoesOfTheEye.VisionTorch.Patches;
|
||||
|
||||
public class VisionTorchPatches : QSBPatch
|
||||
{
|
||||
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(VisionTorchItem), nameof(VisionTorchItem.Update))]
|
||||
private static bool Update(VisionTorchItem __instance)
|
||||
{
|
||||
if (!QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PlayerState.IsViewingProjector() && __instance._mindSlideProjector.mindSlideCollection.slideCollectionContainer.slideIndex == 1)
|
||||
{
|
||||
OWInput.ChangeInputMode(InputMode.None);
|
||||
__instance._mindSlideProjector.OnProjectionComplete += __instance.OnProjectionComplete;
|
||||
__instance.enabled = false;
|
||||
return false;
|
||||
}
|
||||
__instance._wasProjecting = __instance._isProjecting;
|
||||
__instance._isProjecting = OWInput.IsPressed(InputLibrary.toolActionPrimary, InputMode.Character);
|
||||
if (__instance._isProjecting && !__instance._wasProjecting)
|
||||
{
|
||||
__instance._mindProjectorTrigger.SetProjectorActive(true);
|
||||
__instance.GetWorldObject<QSBVisionTorchItem>().SendMessage(new VisionTorchProjectMessage(true));
|
||||
}
|
||||
else if (!__instance._isProjecting && __instance._wasProjecting)
|
||||
{
|
||||
__instance._mindProjectorTrigger.SetProjectorActive(false);
|
||||
__instance.GetWorldObject<QSBVisionTorchItem>().SendMessage(new VisionTorchProjectMessage(false));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,8 +1,13 @@
|
||||
using QSB.ItemSync.WorldObjects.Items;
|
||||
using QSB.EchoesOfTheEye.VisionTorch.Messages;
|
||||
using QSB.ItemSync.WorldObjects.Items;
|
||||
using QSB.Messaging;
|
||||
|
||||
namespace QSB.EchoesOfTheEye.VisionTorch.WorldObjects;
|
||||
|
||||
/// <summary>
|
||||
/// TODO: SYNC THIS SHIT LMAOOOOOO
|
||||
/// </summary>
|
||||
internal class QSBVisionTorchItem : QSBItem<VisionTorchItem> { }
|
||||
public class QSBVisionTorchItem : QSBItem<VisionTorchItem>
|
||||
{
|
||||
public override void SendInitialState(uint to)
|
||||
{
|
||||
this.SendMessage(new VisionTorchProjectMessage(AttachedObject._isProjecting) { To = to });
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user