quantum-space-buddies/QSB/EchoesOfTheEye/LightSensorSync/Messages/IlluminatedByMessage.cs

27 lines
660 B
C#
Raw Normal View History

2022-05-28 16:58:19 +00:00
using QSB.EchoesOfTheEye.LightSensorSync.WorldObjects;
using QSB.Messaging;
using System.Linq;
namespace QSB.EchoesOfTheEye.LightSensorSync.Messages;
/// <summary>
/// always sent by host
/// </summary>
internal class IlluminatedByMessage : QSBWorldObjectMessage<QSBLightSensor, uint[]>
{
public IlluminatedByMessage(uint[] illuminatedBy) : base(illuminatedBy) { }
public override void OnReceiveRemote()
{
foreach (var added in Data.Except(WorldObject._illuminatedBy))
{
WorldObject.SetIlluminated(added, true);
}
foreach (var removed in WorldObject._illuminatedBy.Except(Data))
{
WorldObject.SetIlluminated(removed, false);
}
}
}