From 820e4f41ae454e7a0d791cd4f9653eb49ad3501e Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Thu, 9 Jan 2025 08:24:20 +0100 Subject: [PATCH] Change fetching to earlier stage --- Fika.Core/Coop/GameMode/CoopGame.cs | 36 +++++++++++++---------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/Fika.Core/Coop/GameMode/CoopGame.cs b/Fika.Core/Coop/GameMode/CoopGame.cs index 28776fd1..e6c5d428 100644 --- a/Fika.Core/Coop/GameMode/CoopGame.cs +++ b/Fika.Core/Coop/GameMode/CoopGame.cs @@ -55,15 +55,15 @@ public sealed class CoopGame : BaseLocalGame, IBotGame, IFik { public string InfiltrationPoint; public ExitStatus ExitStatus { get; set; } = ExitStatus.Survived; - public string ExitLocation { get; set; } = null; + public string ExitLocation { get; set; } public ISpawnSystem SpawnSystem; public Dictionary Bots = []; public List ExtractedPlayers { get; } = []; public string SpawnId; - public bool InteractablesInitialized { get; set; } = false; - public bool HasReceivedLoot { get; set; } = false; + public bool InteractablesInitialized { get; set; } + public bool HasReceivedLoot { get; set; } public List ThrownGrenades; - public bool WeatherReady; + public bool WeatherReady { get; internal set; } public bool RaidStarted { get; set; } private readonly Dictionary botQueue = []; @@ -1479,6 +1479,8 @@ private async Task SetStatus(LocalPlayer myPlayer, LobbyEntry.ELobbyStatus statu /// public override async Task vmethod_1(BotControllerSettings controllerSettings, ISpawnSystem spawnSystem) { + await GenerateWeathers(); + GameWorld gameWorld = Singleton.Instance; gameWorld.RegisterRestrictableZones(); @@ -1599,7 +1601,7 @@ public override async Task vmethod_1(BotControllerSettings controllerSettings, I GameWorld_0.RegisterBorderZones(); } - public override IEnumerator vmethod_5(Action runCallback) + private async Task GenerateWeathers() { if (WeatherController.Instance != null) { @@ -1607,12 +1609,7 @@ public override IEnumerator vmethod_5(Action runCallback) Logger.LogInfo("Generating and initializing weather..."); if (isServer) { - Task weatherTask = iSession.WeatherRequest(); - while (!weatherTask.IsCompleted) - { - yield return new WaitForEndOfFrame(); - } - GClass1310 weather = weatherTask.Result; + GClass1310 weather = await iSession.WeatherRequest(); Season = weather.Season; SeasonsSettings = weather.SeasonsSettings; if (!OfflineRaidSettingsMenuPatch_Override.UseCustomWeather) @@ -1623,28 +1620,27 @@ public override IEnumerator vmethod_5(Action runCallback) } else { - Task getWeather = GetWeather(); - while (!getWeather.IsCompleted) - { - yield return new WaitForEndOfFrame(); - } + await GetWeather(); WeatherController.Instance.method_0(WeatherClasses); } } + WeatherReady = true; + OfflineRaidSettingsMenuPatch_Override.UseCustomWeather = false; + } + + public override IEnumerator vmethod_5(Action runCallback) + { SetMatchmakerStatus(LocaleUtils.UI_FINISHING_RAID_INIT.Localized()); GameWorld_0.TriggersModule = gameObject.AddComponent(); GameWorld_0.FillLampControllers(); - WeatherReady = true; - OfflineRaidSettingsMenuPatch_Override.UseCustomWeather = false; - Class442 seasonController = new(); GameWorld_0.GInterface29_0 = seasonController; #if DEBUG - Logger.LogWarning("Running season handler"); + Logger.LogWarning($"Running season handler for season: {Season}"); #endif Task runSeason = seasonController.Run(Season, SeasonsSettings); while (!runSeason.IsCompleted)