2020-12-14 16:24:52 +00:00
|
|
|
|
using QSB.Events;
|
2020-12-14 16:26:38 +00:00
|
|
|
|
using QSB.Messages;
|
2020-11-03 22:29:23 +00:00
|
|
|
|
using QSB.SectorSync;
|
2020-08-22 19:21:13 +00:00
|
|
|
|
using QSB.Utility;
|
2020-12-11 22:42:21 +00:00
|
|
|
|
using QSB.WorldSync;
|
2020-08-15 13:22:56 +00:00
|
|
|
|
using System.Linq;
|
2020-08-10 13:40:06 +00:00
|
|
|
|
|
2020-11-03 21:33:48 +00:00
|
|
|
|
namespace QSB.Player.Events
|
2020-08-10 13:40:06 +00:00
|
|
|
|
{
|
2020-12-02 21:23:01 +00:00
|
|
|
|
public class PlayerStatesRequestEvent : QSBEvent<PlayerMessage>
|
|
|
|
|
{
|
|
|
|
|
public override EventType Type => EventType.PlayerStatesRequest;
|
2020-08-10 13:40:06 +00:00
|
|
|
|
|
2020-12-02 21:23:01 +00:00
|
|
|
|
public override void SetupListener() => GlobalMessenger.AddListener(EventNames.QSBPlayerStatesRequest, Handler);
|
|
|
|
|
public override void CloseListener() => GlobalMessenger.RemoveListener(EventNames.QSBPlayerStatesRequest, Handler);
|
2020-08-15 19:32:58 +00:00
|
|
|
|
|
2020-12-02 21:23:01 +00:00
|
|
|
|
private void Handler() => SendEvent(CreateMessage());
|
2020-08-15 19:52:43 +00:00
|
|
|
|
|
2020-12-02 21:23:01 +00:00
|
|
|
|
private PlayerMessage CreateMessage() => new PlayerMessage
|
|
|
|
|
{
|
2020-12-14 16:12:44 +00:00
|
|
|
|
AboutId = LocalPlayerId,
|
|
|
|
|
OnlySendToServer = true
|
2020-12-02 21:23:01 +00:00
|
|
|
|
};
|
2020-08-10 16:17:54 +00:00
|
|
|
|
|
2020-12-11 22:42:21 +00:00
|
|
|
|
public override void OnReceiveRemote(bool server, PlayerMessage message)
|
2020-12-02 21:23:01 +00:00
|
|
|
|
{
|
2020-12-11 22:42:21 +00:00
|
|
|
|
DebugLog.DebugWrite($"Get state request from {message.FromId}");
|
2020-12-02 21:23:01 +00:00
|
|
|
|
GlobalMessenger.FireEvent(EventNames.QSBServerSendPlayerStates);
|
|
|
|
|
foreach (var item in QSBPlayerManager.GetSyncObjects<TransformSync.TransformSync>()
|
|
|
|
|
.Where(x => x != null && x.IsReady && x.ReferenceSector != null))
|
|
|
|
|
{
|
|
|
|
|
GlobalMessenger<uint, QSBSector>.FireEvent(EventNames.QSBSectorChange, item.NetId.Value, item.ReferenceSector);
|
|
|
|
|
}
|
2020-12-11 22:42:21 +00:00
|
|
|
|
|
|
|
|
|
foreach (var condition in QSBWorldSync.DialogueConditions)
|
|
|
|
|
{
|
|
|
|
|
GlobalMessenger<string, bool>.FireEvent(EventNames.DialogueCondition, condition.Key, condition.Value);
|
|
|
|
|
}
|
2020-12-02 21:23:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-03 08:28:05 +00:00
|
|
|
|
}
|