diff --git a/Components/MyGUIScreenMedicalsPatch.cs b/Components/MyGUIScreenMedicalsPatch.cs new file mode 100644 index 0000000..cc01c8b --- /dev/null +++ b/Components/MyGUIScreenMedicalsPatch.cs @@ -0,0 +1,62 @@ +using HarmonyLib; +using Sandbox.Game.GUI.HudViewers; +using Sandbox.Game.Localization; +using Sandbox.Graphics.GUI; +using SeamlessClient.Utilities; +using SpaceEngineers.Game.GUI; +using SpaceEngineers.Game.World; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +using VRage; +using VRage.Collections; + +namespace SeamlessClient.Components +{ + public class MyGUIScreenMedicalsPatch : ComponentBase + { + + + public override void Patch(Harmony patcher) + { + //var addSuit = PatchUtils.GetMethod(typeof(MyGuiScreenMedicals), "g__AddSuitRespawn|86_4"); + + var spawninsuit = PatchUtils.GetMethod(typeof(MyGuiScreenMedicals), "RefreshMedicalRooms"); + patcher.Patch(spawninsuit, postfix: new HarmonyMethod(Get(typeof(MyGUIScreenMedicalsPatch), nameof(RefreshMedicals)))); + + + + base.Patch(patcher); + } + + private static void RefreshMedicals(MyGuiScreenMedicals __instance, ListReader medicalRooms, object planetInfos) + { + if (!Seamless.isSeamlessServer) + return; + + MyGuiControlTable myGuiControlTable = (MyGuiControlTable)typeof(MyGuiScreenMedicals).GetField("m_respawnsTable", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(__instance); + string s = MyTexts.GetString(MySpaceTexts.SpawnInSpaceSuit); + foreach (var item in myGuiControlTable.Rows) + { + if (item.GetCell(0) == null) + continue; + + if (item.GetCell(0).Text.ToString().Contains(s)) + { + item.GetCell(0).Text.Clear(); + item.GetCell(0).Text.Append("Nexus Lobby"); + } + } + + + + + + } + + } +} diff --git a/Components/MyHudTimeTracker.cs b/Components/MyHudTimeTracker.cs index ed4527e..2eac119 100644 --- a/Components/MyHudTimeTracker.cs +++ b/Components/MyHudTimeTracker.cs @@ -16,9 +16,12 @@ namespace SeamlessClient.Components { public class MyHudTimeTracker : ComponentBase { - public override void Patch(Harmony patcher) { + + return; + + var AppendDistance = PatchUtils.GetMethod(typeof(MyHudMarkerRender), "AppendDistance"); patcher.Patch(AppendDistance, postfix: new HarmonyMethod(Get(typeof(MyHudTimeTracker), nameof(ApplyTimeToTarget)))); @@ -58,9 +61,6 @@ namespace SeamlessClient.Components stringBuilder.AppendLine($" [T-{FormatDuration(t)}]"); } - - - static string FormatDuration(double durationInSeconds) { if (durationInSeconds < 60) @@ -98,9 +98,5 @@ namespace SeamlessClient.Components return distance / velocity; } - - - - } } diff --git a/Components/PlayersWindowComponent.cs b/Components/PlayersWindowComponent.cs index 2dc7f12..eba39c5 100644 --- a/Components/PlayersWindowComponent.cs +++ b/Components/PlayersWindowComponent.cs @@ -25,9 +25,16 @@ namespace SeamlessClient.OnlinePlayersWindow } - public override void Initilized() + public override void Update() { - MyPerGameSettings.GUI.PlayersScreen = typeof(OnlineNexusPlayersWindow); + if (!Seamless.isSeamlessServer) + { + MyPerGameSettings.GUI.PlayersScreen = typeof(MyGuiScreenPlayers); + } + else + { + MyPerGameSettings.GUI.PlayersScreen = typeof(OnlineNexusPlayersWindow); + } } public static void ApplyRecievedPlayers(List servers, int CurrentServer) diff --git a/Components/ServerSwitcherComponent.cs b/Components/ServerSwitcherComponent.cs index 58710cc..5246712 100644 --- a/Components/ServerSwitcherComponent.cs +++ b/Components/ServerSwitcherComponent.cs @@ -8,6 +8,7 @@ using Sandbox.Game.Entities; using Sandbox.Game.Entities.Character; using Sandbox.Game.Gui; using Sandbox.Game.GUI; +using Sandbox.Game.GUI.HudViewers; using Sandbox.Game.Multiplayer; using Sandbox.Game.Replication; using Sandbox.Game.SessionComponents; @@ -375,6 +376,10 @@ namespace SeamlessClient.ServerSwitching ResetReplicationTime(false); + //Remove old signals + MyHud.GpsMarkers.Clear(); + + Seamless.TryShow($"2 Streaming: {clienta.HasPendingStreamingReplicables} - LastMessage: {clienta.LastMessageFromServer}"); Seamless.TryShow($"2 NexusMajor: {Seamless.NexusVersion.Major} - ConrolledEntity {MySession.Static.ControlledEntity == null} - HumanPlayer {MySession.Static.LocalHumanPlayer == null} - Character {MySession.Static.LocalCharacter == null}"); } @@ -504,11 +509,17 @@ namespace SeamlessClient.ServerSwitching SetWorldSettings(); InitComponents(); + + // Allow the game to start proccessing incoming messages in the buffer + MyMultiplayer.Static.StartProcessingClientMessages(); + StartEntitySync(); + //MyGuiSandbox.RemoveScreen(MyGuiScreenHudSpace.Static); + + - typeof(MySandboxGame).GetField("m_pauseStackCount", BindingFlags.Static | BindingFlags.NonPublic).SetValue(null, 0); @@ -517,20 +528,23 @@ namespace SeamlessClient.ServerSwitching MyHud.Chat.RegisterChat(MyMultiplayer.Static); //GpsRegisterChat.Invoke(MySession.Static.Gpss, new object[] { MyMultiplayer.Static }); + + //Recreate all controls... Will fix weird gui/paint/crap - MyGuiScreenHudSpace.Static?.RecreateControls(false); + //MyGuiScreenHudSpace.Static?.RecreateControls(true); + + + Seamless.TryShow($"6 NexusMajor: {Seamless.NexusVersion.Major} - ConrolledEntity {MySession.Static.ControlledEntity == null} - HumanPlayer {MySession.Static.LocalHumanPlayer == null} - Character {MySession.Static.LocalCharacter == null}"); Seamless.TryShow($"6 Streaming: {clienta.HasPendingStreamingReplicables} - LastMessage: {clienta.LastMessageFromServer}"); originalLocalCharacter?.Close(); ResetReplicationTime(true); + + - - // Allow the game to start proccessing incoming messages in the buffer - MyMultiplayer.Static.StartProcessingClientMessages(); - //Send Client Ready ClientReadyDataMsg clientReadyDataMsg = default(ClientReadyDataMsg); clientReadyDataMsg.ForcePlayoutDelayBuffer = MyFakes.ForcePlayoutDelayBuffer; @@ -540,7 +554,15 @@ namespace SeamlessClient.ServerSwitching ClientReadyDataMsg msg = clientReadyDataMsg; clienta.SendClientReady(ref msg); + Seamless.SendSeamlessVersion(); + + FieldInfo hudPoints = typeof(MyHudMarkerRender).GetField("m_pointsOfInterest", BindingFlags.Instance | BindingFlags.NonPublic); + IList points = (IList)hudPoints.GetValue(MyGuiScreenHudSpace.Static.MarkerRender); + + + //Sync.Players.RequestNewPlayer(Sync.MyId, 0, MyGameService.UserName, null, true, true); PauseClient.Invoke(MyMultiplayer.Static, new object[] { false }); + isSwitch = false; } @@ -588,7 +610,7 @@ namespace SeamlessClient.ServerSwitching } - MyRenderProxy.RebuildCullingStructure(); + //MyRenderProxy.RebuildCullingStructure(); //MySession.Static.Toolbars.LoadToolbars(checkpoint); Sync.Players.RespawnComponent.InitFromCheckpoint(TargetWorld.Checkpoint); @@ -659,8 +681,6 @@ namespace SeamlessClient.ServerSwitching { UpdateWorldGenerator(); } - - private void UpdateWorldGenerator() { //This will re-init the MyProceduralWorldGenerator. (Not doing this will result in asteroids not rendering in properly) @@ -787,5 +807,10 @@ namespace SeamlessClient.ServerSwitching Seamless.TryShow("Saving PlayerID: " + savingPlayerId.ToString()); Seamless.TryShow($"AFTER {MySession.Static.LocalHumanPlayer == null} - {MySession.Static.LocalCharacter == null}"); } + + + + + } } diff --git a/Seamless.cs b/Seamless.cs index ca18c26..c855360 100644 --- a/Seamless.cs +++ b/Seamless.cs @@ -1,5 +1,6 @@ using HarmonyLib; using NLog.Fluent; +using Sandbox.Game.Localization; using Sandbox.Game.World; using Sandbox.ModAPI; using SeamlessClient.Messages; @@ -31,10 +32,10 @@ namespace SeamlessClient private List allComps = new List(); private Assembly thisAssembly => typeof(Seamless).Assembly; private bool Initilized = false; - public static bool isSeamlessServer = false; - + public static bool isSeamlessServer { get; private set; } = false; public static bool isDebug = false; + public void Init(object gameInstance) @@ -121,13 +122,12 @@ namespace SeamlessClient if (!string.IsNullOrEmpty(msg.NexusVersion)) NexusVersion = Version.Parse(msg.NexusVersion); - + isSeamlessServer = true; switch (msg.MessageType) { case ClientMessageType.FirstJoin: Seamless.TryShow("Sending First Join!"); - ClientMessage response = new ClientMessage(SeamlessVersion.ToString()); - MyAPIGateway.Multiplayer?.SendMessageToServer(SeamlessClientNetId, MessageUtils.Serialize(response)); + SendSeamlessVersion(); break; case ClientMessageType.TransferServer: @@ -142,19 +142,32 @@ namespace SeamlessClient } } + public static void SendSeamlessVersion() + { + + + ClientMessage response = new ClientMessage(SeamlessVersion.ToString()); + MyAPIGateway.Multiplayer?.SendMessageToServer(SeamlessClientNetId, MessageUtils.Serialize(response)); + Seamless.TryShow("Sending Seamless request..."); + } + public void Dispose() { - + } public void Update() { - if (MyAPIGateway.Multiplayer == null) + if (MyAPIGateway.Multiplayer == null) + { + isSeamlessServer = false; + Initilized = false; return; + } if (!Initilized) { @@ -163,6 +176,8 @@ namespace SeamlessClient Initilized = true; } + + allComps.ForEach(x => x.Update()); } diff --git a/SeamlessClient.csproj b/SeamlessClient.csproj index 0d645be..62260cc 100644 --- a/SeamlessClient.csproj +++ b/SeamlessClient.csproj @@ -97,6 +97,7 @@ +