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

27 lines
890 B
C#

using QSB.EchoesOfTheEye.DreamLantern.WorldObjects;
using QSB.Messaging;
using QSB.Player;
using QSB.WorldSync;
using System.Collections.Generic;
using System.Linq;
namespace QSB.EchoesOfTheEye.LightSensorSync.Messages;
public class PlayerIlluminatingLanternsMessage : QSBMessage<(uint playerId, int[] lanterns)>
{
public PlayerIlluminatingLanternsMessage(uint playerId, IEnumerable<DreamLanternController> lanterns) :
base((
playerId,
lanterns.Select(x => x.GetWorldObject<QSBDreamLanternController>().ObjectId).ToArray()
)) { }
public override void OnReceiveRemote()
{
var lightSensor = (SingleLightSensor)QSBPlayerManager.GetPlayer(Data.playerId).LightSensor;
lightSensor._illuminatingDreamLanternList.Clear();
lightSensor._illuminatingDreamLanternList.AddRange(
Data.lanterns.Select(x => x.GetWorldObject<QSBDreamLanternController>().AttachedObject));
}
}