2022-01-13 23:38:45 -08:00
|
|
|
|
using Mirror;
|
|
|
|
|
using OWML.Common;
|
2021-12-22 17:38:08 -08:00
|
|
|
|
using QSB.ClientServerStateSync;
|
2023-02-12 18:41:40 +00:00
|
|
|
|
using QSB.HUD;
|
2021-08-08 20:04:15 +01:00
|
|
|
|
using QSB.Messaging;
|
2021-12-22 17:38:08 -08:00
|
|
|
|
using QSB.Utility;
|
2020-05-19 19:31:54 +02:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
namespace QSB.Player.Messages;
|
|
|
|
|
|
|
|
|
|
public class PlayerInformationMessage : QSBMessage
|
2020-05-19 19:31:54 +02:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
private string PlayerName;
|
|
|
|
|
private bool IsReady;
|
|
|
|
|
private bool FlashlightActive;
|
|
|
|
|
private bool SuitedUp;
|
2023-10-31 17:51:00 +00:00
|
|
|
|
private bool HelmetOn;
|
2022-04-16 10:08:59 +01:00
|
|
|
|
private bool LocalProbeLauncherEquipped;
|
2022-03-02 19:46:33 -08:00
|
|
|
|
private bool SignalscopeEquipped;
|
|
|
|
|
private bool TranslatorEquipped;
|
|
|
|
|
private bool ProbeActive;
|
|
|
|
|
private ClientState ClientState;
|
2023-01-21 11:09:24 +00:00
|
|
|
|
private float FieldOfView;
|
2023-01-23 13:06:04 +00:00
|
|
|
|
private bool IsInShip;
|
2023-02-12 18:41:40 +00:00
|
|
|
|
private HUDIcon HUDIcon;
|
2023-09-28 23:50:22 +01:00
|
|
|
|
private string SkinType;
|
|
|
|
|
private string JetpackType;
|
2021-12-22 17:38:08 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
public PlayerInformationMessage()
|
|
|
|
|
{
|
|
|
|
|
var player = QSBPlayerManager.LocalPlayer;
|
|
|
|
|
PlayerName = player.Name;
|
|
|
|
|
IsReady = player.IsReady;
|
|
|
|
|
FlashlightActive = player.FlashlightActive;
|
|
|
|
|
SuitedUp = player.SuitedUp;
|
2023-10-31 17:51:00 +00:00
|
|
|
|
HelmetOn = Locator.GetPlayerSuit() != null && Locator.GetPlayerSuit().IsWearingHelmet();
|
2022-04-16 10:08:59 +01:00
|
|
|
|
LocalProbeLauncherEquipped = player.LocalProbeLauncherEquipped;
|
2022-03-02 19:46:33 -08:00
|
|
|
|
SignalscopeEquipped = player.SignalscopeEquipped;
|
|
|
|
|
TranslatorEquipped = player.TranslatorEquipped;
|
|
|
|
|
ProbeActive = player.ProbeActive;
|
|
|
|
|
ClientState = player.State;
|
2023-01-21 11:09:24 +00:00
|
|
|
|
FieldOfView = PlayerData.GetGraphicSettings().fieldOfView;
|
2023-01-23 13:06:04 +00:00
|
|
|
|
IsInShip = player.IsInShip;
|
2023-03-03 15:58:03 +00:00
|
|
|
|
HUDIcon = player.HUDBox == null ? HUDIcon.UNKNOWN : player.HUDBox.PlanetIcon;
|
2023-09-28 23:50:22 +01:00
|
|
|
|
SkinType = QSBCore.SkinVariation;
|
|
|
|
|
JetpackType = QSBCore.JetpackVariation;
|
2022-03-02 19:46:33 -08:00
|
|
|
|
}
|
2021-12-22 17:38:08 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
public override void Serialize(NetworkWriter writer)
|
|
|
|
|
{
|
|
|
|
|
base.Serialize(writer);
|
|
|
|
|
writer.Write(PlayerName);
|
|
|
|
|
writer.Write(IsReady);
|
|
|
|
|
writer.Write(FlashlightActive);
|
|
|
|
|
writer.Write(SuitedUp);
|
2023-10-31 17:51:00 +00:00
|
|
|
|
writer.Write(HelmetOn);
|
2022-04-16 10:08:59 +01:00
|
|
|
|
writer.Write(LocalProbeLauncherEquipped);
|
2022-03-02 19:46:33 -08:00
|
|
|
|
writer.Write(SignalscopeEquipped);
|
|
|
|
|
writer.Write(TranslatorEquipped);
|
|
|
|
|
writer.Write(ProbeActive);
|
|
|
|
|
writer.Write(ClientState);
|
2023-01-21 11:09:24 +00:00
|
|
|
|
writer.Write(FieldOfView);
|
2023-01-23 13:06:04 +00:00
|
|
|
|
writer.Write(IsInShip);
|
2023-02-12 18:41:40 +00:00
|
|
|
|
writer.Write(HUDIcon);
|
2023-09-28 23:50:22 +01:00
|
|
|
|
writer.Write(SkinType);
|
|
|
|
|
writer.Write(JetpackType);
|
2022-03-02 19:46:33 -08:00
|
|
|
|
}
|
2022-02-24 22:04:54 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
public override void Deserialize(NetworkReader reader)
|
|
|
|
|
{
|
|
|
|
|
base.Deserialize(reader);
|
|
|
|
|
PlayerName = reader.ReadString();
|
|
|
|
|
IsReady = reader.Read<bool>();
|
|
|
|
|
FlashlightActive = reader.Read<bool>();
|
|
|
|
|
SuitedUp = reader.Read<bool>();
|
2023-10-31 17:51:00 +00:00
|
|
|
|
HelmetOn = reader.Read<bool>();
|
2022-04-16 10:08:59 +01:00
|
|
|
|
LocalProbeLauncherEquipped = reader.Read<bool>();
|
2022-03-02 19:46:33 -08:00
|
|
|
|
SignalscopeEquipped = reader.Read<bool>();
|
|
|
|
|
TranslatorEquipped = reader.Read<bool>();
|
|
|
|
|
ProbeActive = reader.Read<bool>();
|
|
|
|
|
ClientState = reader.Read<ClientState>();
|
2023-01-21 11:09:24 +00:00
|
|
|
|
FieldOfView = reader.ReadFloat();
|
2023-01-23 13:06:04 +00:00
|
|
|
|
IsInShip = reader.ReadBool();
|
2023-02-12 18:41:40 +00:00
|
|
|
|
HUDIcon = reader.Read<HUDIcon>();
|
2023-09-28 23:50:22 +01:00
|
|
|
|
SkinType = reader.ReadString();
|
|
|
|
|
JetpackType = reader.ReadString();
|
2022-03-02 19:46:33 -08:00
|
|
|
|
}
|
2022-02-27 04:40:44 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
public override void OnReceiveRemote()
|
|
|
|
|
{
|
|
|
|
|
RequestStateResyncMessage._waitingForEvent = false;
|
|
|
|
|
if (QSBPlayerManager.PlayerExists(From))
|
2022-02-24 22:04:54 -08:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
var player = QSBPlayerManager.GetPlayer(From);
|
|
|
|
|
player.Name = PlayerName;
|
|
|
|
|
player.IsReady = IsReady;
|
|
|
|
|
player.FlashlightActive = FlashlightActive;
|
|
|
|
|
player.SuitedUp = SuitedUp;
|
2023-10-31 17:51:00 +00:00
|
|
|
|
|
2022-04-16 10:08:59 +01:00
|
|
|
|
player.LocalProbeLauncherEquipped = LocalProbeLauncherEquipped;
|
2022-03-02 19:46:33 -08:00
|
|
|
|
player.SignalscopeEquipped = SignalscopeEquipped;
|
|
|
|
|
player.TranslatorEquipped = TranslatorEquipped;
|
|
|
|
|
player.ProbeActive = ProbeActive;
|
2023-01-23 13:06:04 +00:00
|
|
|
|
player.IsInShip = IsInShip;
|
2023-10-31 17:51:00 +00:00
|
|
|
|
|
|
|
|
|
Delay.RunWhen(() => player.IsReady && QSBPlayerManager.LocalPlayer.IsReady, () =>
|
2022-02-27 04:40:44 -08:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
player.UpdateObjectsFromStates();
|
2023-10-31 17:51:00 +00:00
|
|
|
|
player.HelmetAnimator.SetHelmetInstant(HelmetOn);
|
2023-11-13 21:59:46 +00:00
|
|
|
|
player.Camera.fieldOfView = FieldOfView;
|
|
|
|
|
});
|
2023-09-28 23:50:22 +01:00
|
|
|
|
|
2023-11-13 21:59:46 +00:00
|
|
|
|
Delay.RunWhen(() => player.Body != null, () =>
|
|
|
|
|
{
|
2023-09-28 23:50:22 +01:00
|
|
|
|
var REMOTE_Traveller_HEA_Player_v2 = player.Body.transform.Find("REMOTE_Traveller_HEA_Player_v2");
|
2023-10-31 17:51:00 +00:00
|
|
|
|
BodyCustomization.BodyCustomizer.Instance.CustomizeRemoteBody(REMOTE_Traveller_HEA_Player_v2.gameObject, player.HelmetAnimator.FakeHead.gameObject, SkinType, JetpackType);
|
|
|
|
|
});
|
2023-01-21 11:09:24 +00:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
player.State = ClientState;
|
2023-02-10 12:01:31 +00:00
|
|
|
|
|
2023-03-03 15:58:03 +00:00
|
|
|
|
Delay.RunWhen(() => player.HUDBox != null, () =>
|
2023-02-10 12:01:31 +00:00
|
|
|
|
{
|
|
|
|
|
player.HUDBox.PlayerName.text = PlayerName.ToUpper();
|
2023-02-12 18:41:40 +00:00
|
|
|
|
player.HUDBox.UpdateIcon(HUDIcon);
|
2023-03-03 15:58:03 +00:00
|
|
|
|
});
|
2022-03-02 19:46:33 -08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DebugLog.ToConsole($"Warning - got player information message about player that doesnt exist!", MessageType.Warning);
|
2021-12-22 17:38:08 -08:00
|
|
|
|
}
|
2020-12-02 21:23:01 +00:00
|
|
|
|
}
|
2022-02-24 22:04:54 -08:00
|
|
|
|
}
|