2022-01-27 08:32:30 +00:00
|
|
|
|
using QSB.Messaging;
|
2022-01-13 02:43:18 +00:00
|
|
|
|
using QSB.Player;
|
2022-01-13 03:18:59 +00:00
|
|
|
|
using QSB.TriggerSync.WorldObjects;
|
2022-01-13 02:43:18 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
namespace QSB.TriggerSync.Messages;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// always sent by host
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class TriggerInitialStateMessage : QSBWorldObjectMessage<IQSBTrigger, uint[]>
|
2022-01-13 02:43:18 +00:00
|
|
|
|
{
|
2022-03-11 01:57:50 +00:00
|
|
|
|
public TriggerInitialStateMessage(IEnumerable<PlayerInfo> occupants) :
|
|
|
|
|
base(occupants.Select(x => x.PlayerId).ToArray()) { }
|
2022-01-13 02:43:18 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
public override void OnReceiveRemote()
|
|
|
|
|
{
|
|
|
|
|
var serverOccupants = Data.Select(QSBPlayerManager.GetPlayer).ToList();
|
2022-08-03 04:15:06 +00:00
|
|
|
|
foreach (var added in serverOccupants.Except(WorldObject.Occupants).ToList())
|
2022-02-25 06:04:54 +00:00
|
|
|
|
{
|
2022-03-03 03:46:33 +00:00
|
|
|
|
WorldObject.Enter(added);
|
|
|
|
|
}
|
2022-02-27 12:40:44 +00:00
|
|
|
|
|
2022-08-03 04:15:06 +00:00
|
|
|
|
foreach (var removed in WorldObject.Occupants.Except(serverOccupants).ToList())
|
2022-03-03 03:46:33 +00:00
|
|
|
|
{
|
|
|
|
|
WorldObject.Exit(removed);
|
2022-01-13 02:43:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-02-25 06:04:54 +00:00
|
|
|
|
}
|