mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-04 02:47:22 +00:00
SetIlluminatedMessage
This commit is contained in:
parent
aaee2ded3a
commit
99e7ff986c
@ -14,12 +14,6 @@ internal class IlluminatingLanternsMessage : QSBWorldObjectMessage<QSBLightSenso
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
if (WorldObject.AttachedObject.enabled)
|
||||
{
|
||||
// sensor is enabled, so this will already be synced
|
||||
return;
|
||||
}
|
||||
|
||||
WorldObject.AttachedObject._illuminatingDreamLanternList.Clear();
|
||||
WorldObject.AttachedObject._illuminatingDreamLanternList.AddRange(
|
||||
Data.Select(x => x.GetWorldObject<QSBDreamLantern>().AttachedObject));
|
||||
|
@ -0,0 +1,22 @@
|
||||
using QSB.EchoesOfTheEye.LightSensorSync.WorldObjects;
|
||||
using QSB.Messaging;
|
||||
|
||||
namespace QSB.EchoesOfTheEye.LightSensorSync.Messages;
|
||||
|
||||
internal class SetIlluminatedMessage : QSBWorldObjectMessage<QSBLightSensor, bool>
|
||||
{
|
||||
public SetIlluminatedMessage(bool illuminated) : base(illuminated) { }
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
WorldObject.AttachedObject._illuminated = Data;
|
||||
if (Data)
|
||||
{
|
||||
WorldObject.AttachedObject.OnDetectLight.Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
WorldObject.AttachedObject.OnDetectDarkness.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
using HarmonyLib;
|
||||
using QSB.AuthoritySync;
|
||||
using QSB.EchoesOfTheEye.LightSensorSync.Messages;
|
||||
using QSB.EchoesOfTheEye.LightSensorSync.WorldObjects;
|
||||
using QSB.Messaging;
|
||||
using QSB.Patches;
|
||||
using QSB.Player;
|
||||
using QSB.Utility;
|
||||
@ -112,16 +114,18 @@ internal class LightSensorPatches : QSBPatch
|
||||
if (!illuminated && __instance._illuminated)
|
||||
{
|
||||
__instance.OnDetectLight.Invoke();
|
||||
qsbLightSensor.SendMessage(new SetIlluminatedMessage(true));
|
||||
return false;
|
||||
}
|
||||
if (illuminated && !__instance._illuminated)
|
||||
{
|
||||
__instance.OnDetectDarkness.Invoke();
|
||||
qsbLightSensor.SendMessage(new SetIlluminatedMessage(false));
|
||||
}
|
||||
if (__instance._illuminatingDreamLanternList != null &&
|
||||
!__instance._illuminatingDreamLanternList.SequenceEqual(_illuminatingDreamLanternList))
|
||||
{
|
||||
// todo send a message about it
|
||||
qsbLightSensor.SendMessage(new IlluminatingLanternsMessage(__instance._illuminatingDreamLanternList));
|
||||
}
|
||||
}
|
||||
if (!locallyIlluminated && qsbLightSensor._locallyIlluminated)
|
||||
|
Loading…
Reference in New Issue
Block a user