quantum-space-buddies/QSB/EchoesOfTheEye/LightSensorSync/Messages/PlayerSetIlluminatedMessage.cs
2023-07-28 19:30:57 +01:00

30 lines
686 B
C#

using QSB.Messaging;
using QSB.Player;
namespace QSB.EchoesOfTheEye.LightSensorSync.Messages;
public class PlayerSetIlluminatedMessage : QSBMessage<(uint playerId, bool illuminated)>
{
public PlayerSetIlluminatedMessage(uint playerId, bool illuminated) : base((playerId, illuminated)) { }
public override void OnReceiveRemote()
{
var lightSensor = (SingleLightSensor)QSBPlayerManager.GetPlayer(Data.playerId).LightSensor;
if (lightSensor._illuminated == Data.illuminated)
{
return;
}
lightSensor._illuminated = Data.illuminated;
if (Data.illuminated)
{
lightSensor.OnDetectLight.Invoke();
}
else
{
lightSensor.OnDetectDarkness.Invoke();
}
}
}