diff --git a/Fika.Core/Coop/GameMode/CoopGame.cs b/Fika.Core/Coop/GameMode/CoopGame.cs index 28776fd1..ccb1c700 100644 --- a/Fika.Core/Coop/GameMode/CoopGame.cs +++ b/Fika.Core/Coop/GameMode/CoopGame.cs @@ -53,18 +53,22 @@ namespace Fika.Core.Coop.GameMode /// public sealed class CoopGame : BaseLocalGame, IBotGame, IFikaGame { - public string InfiltrationPoint; + public string InfiltrationPoint { get; internal set; } public ExitStatus ExitStatus { get; set; } = ExitStatus.Survived; - public string ExitLocation { get; set; } = null; - public ISpawnSystem SpawnSystem; + public string ExitLocation { get; set; } + public ISpawnSystem SpawnSystem { get; internal set; } public Dictionary Bots = []; public List ExtractedPlayers { get; } = []; - public string SpawnId; - public bool InteractablesInitialized { get; set; } = false; - public bool HasReceivedLoot { get; set; } = false; - public List ThrownGrenades; - public bool WeatherReady; - public bool RaidStarted { get; set; } + public string SpawnId { get; internal set; } + public bool InteractablesInitialized { get; internal set; } + public bool HasReceivedLoot { get; internal set; } + public List ThrownGrenades { get; internal set; } + public bool WeatherReady { get; internal set; } + public bool RaidStarted { get; internal set; } + public FikaDynamicAI DynamicAI { get; private set; } + public RaidSettings RaidSettings { get; private set; } + public byte[] HostLootItems { get; private set; } + public GClass1315 LootItems { get; internal set; } = []; private readonly Dictionary botQueue = []; private Coroutine extractRoutine; @@ -85,11 +89,7 @@ public sealed class CoopGame : BaseLocalGame, IBotGame, IFik private TimeSpan? sessionTime; private BotStateManager botStateManager; private ESeason season; - - public FikaDynamicAI DynamicAI { get; private set; } - public RaidSettings RaidSettings { get; private set; } - public byte[] HostLootItems { get; private set; } - public GClass1315 LootItems { get; internal set; } = []; + BossSpawnScenario IBotGame.BossSpawnScenario { get @@ -131,6 +131,7 @@ public ESeason Season { season = value; Logger.LogInfo($"Setting Season to: {value}"); + WeatherReady = true; } } @@ -1479,6 +1480,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,22 +1602,26 @@ public override async Task vmethod_1(BotControllerSettings controllerSettings, I GameWorld_0.RegisterBorderZones(); } - public override IEnumerator vmethod_5(Action runCallback) + private async Task GenerateWeathers() { + if (Location_0.Id == "laboratory") + { + Logger.LogInfo("Location is 'Laboratory', skipping weather generation"); + Season = ESeason.Summer; + OfflineRaidSettingsMenuPatch_Override.UseCustomWeather = false; + + return; + } + if (WeatherController.Instance != null) { SetMatchmakerStatus(LocaleUtils.UI_INIT_WEATHER.Localized()); Logger.LogInfo("Generating and initializing weather..."); if (isServer) { - Task weatherTask = iSession.WeatherRequest(); - while (!weatherTask.IsCompleted) - { - yield return new WaitForEndOfFrame(); - } - GClass1310 weather = weatherTask.Result; - Season = weather.Season; - SeasonsSettings = weather.SeasonsSettings; + GClass1310 weather = await iSession.WeatherRequest(); + Season = iSession.Season; + SeasonsSettings = iSession.SeasonsSettings; if (!OfflineRaidSettingsMenuPatch_Override.UseCustomWeather) { WeatherClasses = weather.Weathers; @@ -1623,28 +1630,26 @@ 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); } } + 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) @@ -1665,10 +1670,13 @@ private async Task GetWeather() FikaClient client = Singleton.Instance; client.SendData(ref packet, DeliveryMethod.ReliableUnordered); - while (WeatherClasses == null) + while (!WeatherReady) { await Task.Delay(1000); - client.SendData(ref packet, DeliveryMethod.ReliableUnordered); + if (!WeatherReady) + { + client.SendData(ref packet, DeliveryMethod.ReliableUnordered); + } } } diff --git a/Fika.Core/Coop/GameMode/IFikaGame.cs b/Fika.Core/Coop/GameMode/IFikaGame.cs index 6590d86c..0e59f447 100644 --- a/Fika.Core/Coop/GameMode/IFikaGame.cs +++ b/Fika.Core/Coop/GameMode/IFikaGame.cs @@ -16,8 +16,8 @@ public interface IFikaGame public void Stop(string profileId, ExitStatus exitStatus, string exitName, float delay = 0f); - public ESeason Season { get; set; } + public ESeason Season { get; internal set; } - public SeasonsSettingsClass SeasonsSettings { get; set; } + public SeasonsSettingsClass SeasonsSettings { get; internal set; } } }