Skip to content

Commit

Permalink
Merge pull request #275 from project-fika/season-rework
Browse files Browse the repository at this point in the history
Season rework
  • Loading branch information
Lacyway authored Jan 9, 2025
2 parents b307943 + c10640a commit 43c6f10
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 36 deletions.
76 changes: 42 additions & 34 deletions Fika.Core/Coop/GameMode/CoopGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,22 @@ namespace Fika.Core.Coop.GameMode
/// </summary>
public sealed class CoopGame : BaseLocalGame<EftGamePlayerOwner>, 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<string, Player> Bots = [];
public List<int> ExtractedPlayers { get; } = [];
public string SpawnId;
public bool InteractablesInitialized { get; set; } = false;
public bool HasReceivedLoot { get; set; } = false;
public List<ThrowWeapItemClass> 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<ThrowWeapItemClass> 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<int, int> botQueue = [];
private Coroutine extractRoutine;
Expand All @@ -85,11 +89,7 @@ public sealed class CoopGame : BaseLocalGame<EftGamePlayerOwner>, 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
Expand Down Expand Up @@ -131,6 +131,7 @@ public ESeason Season
{
season = value;
Logger.LogInfo($"Setting Season to: {value}");
WeatherReady = true;
}
}

Expand Down Expand Up @@ -1479,6 +1480,8 @@ private async Task SetStatus(LocalPlayer myPlayer, LobbyEntry.ELobbyStatus statu
/// <returns></returns>
public override async Task vmethod_1(BotControllerSettings controllerSettings, ISpawnSystem spawnSystem)
{
await GenerateWeathers();

GameWorld gameWorld = Singleton<GameWorld>.Instance;
gameWorld.RegisterRestrictableZones();

Expand Down Expand Up @@ -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<GClass1310> 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;
Expand All @@ -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<LocalClientTriggersModule>();
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)
Expand All @@ -1665,10 +1670,13 @@ private async Task GetWeather()
FikaClient client = Singleton<FikaClient>.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);
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions Fika.Core/Coop/GameMode/IFikaGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
}

0 comments on commit 43c6f10

Please sign in to comment.