quantum-space-buddies/QSB/EchoesOfTheEye/LightSensorSync/Messages/PlayerIlluminatedByMessage.cs
2022-07-24 11:24:42 -07:00

29 lines
842 B
C#

using QSB.Messaging;
using QSB.Player;
using System.Linq;
namespace QSB.EchoesOfTheEye.LightSensorSync.Messages;
/// <summary>
/// always sent by host
/// </summary>
internal class PlayerIlluminatedByMessage : QSBMessage<(uint playerId, uint[] illuminatedBy)>
{
public PlayerIlluminatedByMessage(uint playerId, uint[] illuminatedBy) : base((playerId, illuminatedBy)) { }
public override void OnReceiveRemote()
{
var qsbPlayerLightSensor = QSBPlayerManager.GetPlayer(Data.playerId).QSBPlayerLightSensor;
foreach (var added in Data.illuminatedBy.Except(qsbPlayerLightSensor._illuminatedBy).ToList())
{
qsbPlayerLightSensor.SetIlluminated(added, true);
}
foreach (var removed in qsbPlayerLightSensor._illuminatedBy.Except(Data.illuminatedBy).ToList())
{
qsbPlayerLightSensor.SetIlluminated(removed, false);
}
}
}