diff --git a/QSB/EchoesOfTheEye/LightSensorSync/Messages/LightSensorIlluminatedMessage.cs b/QSB/EchoesOfTheEye/LightSensorSync/Messages/LightSensorIlluminatedMessage.cs new file mode 100644 index 00000000..d39d865b --- /dev/null +++ b/QSB/EchoesOfTheEye/LightSensorSync/Messages/LightSensorIlluminatedMessage.cs @@ -0,0 +1,27 @@ +using QSB.EchoesOfTheEye.LightSensorSync.WorldObjects; +using QSB.Messaging; + +namespace QSB.EchoesOfTheEye.LightSensorSync.Messages; + +internal class LightSensorIlluminatedMessage : QSBWorldObjectMessage +{ + public LightSensorIlluminatedMessage(bool illuminated) : base(illuminated) { } + + public override void OnReceiveRemote() + { + if (WorldObject.AttachedObject._illuminated == Data) + { + return; + } + + WorldObject.AttachedObject._illuminated = Data; + if (Data) + { + WorldObject.AttachedObject.OnDetectLight.Invoke(); + } + else + { + WorldObject.AttachedObject.OnDetectDarkness.Invoke(); + } + } +}