quantum-space-buddies/QSB/EchoesOfTheEye/LightSensorSync/Messages/SetIlluminatedMessage.cs
2022-08-16 16:27:56 -07:00

28 lines
613 B
C#

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()
{
if (WorldObject.AttachedObject._illuminated == Data)
{
return;
}
WorldObject.AttachedObject._illuminated = Data;
if (Data)
{
WorldObject.AttachedObject.OnDetectLight.Invoke();
}
else
{
WorldObject.AttachedObject.OnDetectDarkness.Invoke();
}
}
}