From a823185d849e7ee68e5a2ff4f567b7916914cc18 Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Tue, 17 Dec 2024 13:09:20 +0100 Subject: [PATCH] Improve logic and add locales --- Fika.Core/Coop/GameMode/CoopGame.cs | 18 +++++++++--------- Fika.Core/Networking/FikaClient.cs | 5 ++--- Fika.Core/Utils/LocaleUtils.cs | 1 + 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Fika.Core/Coop/GameMode/CoopGame.cs b/Fika.Core/Coop/GameMode/CoopGame.cs index 1a7db391..f8fea22d 100644 --- a/Fika.Core/Coop/GameMode/CoopGame.cs +++ b/Fika.Core/Coop/GameMode/CoopGame.cs @@ -947,14 +947,15 @@ private GameObject CreateStartButton() //customButton.gameObject.transform.position = new(customButton.transform.position.x, customButton.transform.position.y - 20, customButton.transform.position.z); customButton.gameObject.SetActive(true); DefaultUIButton backButtonComponent = customButton.GetComponent(); - backButtonComponent.SetHeaderText("Start", 32); - backButtonComponent.SetEnabledTooltip("Starts the raid."); + backButtonComponent.SetHeaderText(LocaleUtils.UI_MM_START_BUTTON.Localized(), 32); + backButtonComponent.SetEnabledTooltip(LocaleUtils.UI_START_DESCRIPTION.Localized()); UnityEngine.Events.UnityEvent newEvent = new(); newEvent.AddListener(() => { if (isServer) { RaidStarted = true; + FikaBackendUtils.HostExpectedNumberOfPlayers = Singleton.Instance.NetServer.ConnectedPeersCount; return; } @@ -1406,13 +1407,16 @@ private async Task WaitForHostToStart() while (!RaidStarted) { - await Task.Delay(100); + await Task.Yield(); } if (startButton != null) { Destroy(startButton); } + + SetStatusModel status = new(FikaBackendUtils.GroupId, LobbyEntry.ELobbyStatus.IN_GAME); + await FikaRequestHandler.UpdateSetStatus(status); return; } @@ -1425,7 +1429,7 @@ private async Task WaitForHostToStart() client.SendData(ref packet, DeliveryMethod.ReliableUnordered); while (!RaidStarted) { - await Task.Delay(100); + await Task.Delay(250); client.SendData(ref packet, DeliveryMethod.ReliableUnordered); } @@ -1557,11 +1561,7 @@ public override async Task vmethod_1(BotControllerSettings controllerSettings, I botsController_0.EventsController.SpawnAction(); FikaPlugin.DynamicAI.SettingChanged += DynamicAI_SettingChanged; - FikaPlugin.DynamicAIRate.SettingChanged += DynamicAIRate_SettingChanged; - - SetStatusModel status = new(FikaBackendUtils.GroupId, LobbyEntry.ELobbyStatus.IN_GAME); - - await FikaRequestHandler.UpdateSetStatus(status); + FikaPlugin.DynamicAIRate.SettingChanged += DynamicAIRate_SettingChanged; } // Add FreeCamController to GameWorld GameObject diff --git a/Fika.Core/Networking/FikaClient.cs b/Fika.Core/Networking/FikaClient.cs index 03213706..d7f0e014 100644 --- a/Fika.Core/Networking/FikaClient.cs +++ b/Fika.Core/Networking/FikaClient.cs @@ -22,9 +22,7 @@ using Fika.Core.Coop.Utils; using Fika.Core.Modding; using Fika.Core.Modding.Events; -using Fika.Core.Networking.Packets; using Fika.Core.Utils; -using FlyingWormConsole3; using HarmonyLib; using LiteNetLib; using LiteNetLib.Utils; @@ -1062,7 +1060,8 @@ private void OnInformationPacketReceived(InformationPacket packet) CoopGame coopGame = CoopHandler.LocalGameInstance; if (coopGame != null) { - coopGame.RaidStarted = packet.RaidStarted; + coopGame.RaidStarted = packet.RaidStarted; + FikaBackendUtils.HostExpectedNumberOfPlayers = packet.ReadyPlayers; } ReadyClients = packet.ReadyPlayers; HostReady = packet.HostReady; diff --git a/Fika.Core/Utils/LocaleUtils.cs b/Fika.Core/Utils/LocaleUtils.cs index 3a95e70f..82b1bc74 100644 --- a/Fika.Core/Utils/LocaleUtils.cs +++ b/Fika.Core/Utils/LocaleUtils.cs @@ -155,6 +155,7 @@ public static bool IsBoss(WildSpawnType wildSpawnType, out string name) public const string UI_MM_LOADING_HEADER = "F_MMUI_LoadingScreenHeader"; public const string UI_MM_LOADING_DESCRIPTION = "F_MMUI_LoadingScreenDescription"; public const string UI_MM_JOIN_AS_SPECTATOR = "F_MMUI_JoinAsSpectator"; + public const string UI_START_DESCRIPTION = "F_UI_StartRaidDescription"; public const string UI_CANNOT_JOIN_RAID_OTHER_MAP = "F_UI_CannotJoinRaidOtherMap"; public const string UI_CANNOT_JOIN_RAID_OTHER_TIME = "F_UI_CannotJoinRaidOtherTime"; public const string UI_CANNOT_JOIN_RAID_SCAV_AS_PMC = "F_UI_CannotJoinRaidScavAsPMC";