diff --git a/Fika.Core/Coop/GameMode/CoopGame.cs b/Fika.Core/Coop/GameMode/CoopGame.cs index 8170edbc..d624ae6c 100644 --- a/Fika.Core/Coop/GameMode/CoopGame.cs +++ b/Fika.Core/Coop/GameMode/CoopGame.cs @@ -138,7 +138,8 @@ internal static CoopGame Create(IInputTree inputTree, Profile profile, GameDateT coopGame.SetupCustomWeather(timeAndWeather); } - coopGame.func_1 = (Player player) => EftGamePlayerOwner.Create(player, inputTree, insurance, backEndSession, gameUI, coopGame.GameDateTime, location); + SetupGamePlayerOwnerHandler setupGamePlayerOwnerHandler = new(inputTree, insurance, backEndSession, gameUI, coopGame, location); + coopGame.func_1 = new Func(setupGamePlayerOwnerHandler.HandleSetup); Singleton.Create(coopGame); FikaEventDispatcher.DispatchEvent(new FikaGameCreatedEvent(coopGame)); @@ -162,6 +163,23 @@ internal static CoopGame Create(IInputTree inputTree, Profile profile, GameDateT return coopGame; } + private class SetupGamePlayerOwnerHandler(IInputTree inputTree, InsuranceCompanyClass insurance, ISession backEndSession, GameUI gameUI, CoopGame game, LocationSettingsClass.Location location) + { + private readonly IInputTree inputTree = inputTree; + private readonly InsuranceCompanyClass insurance = insurance; + private readonly ISession backEndSession = backEndSession; + private readonly GameUI gameUI = gameUI; + private readonly CoopGame game = game; + private readonly LocationSettingsClass.Location location = location; + + public EftGamePlayerOwner HandleSetup(Player player) + { + EftGamePlayerOwner gamePlayerOwner = EftGamePlayerOwner.Create(player, inputTree, insurance, backEndSession, gameUI, game.GameDateTime, location); + gamePlayerOwner.OnLeave += game.vmethod_3; + return gamePlayerOwner; + } + } + private void SetupCustomWeather(TimeAndWeatherSettings timeAndWeather) { if (WeatherController.Instance == null) @@ -193,6 +211,7 @@ public override void SetMatchmakerStatus(string status, float? progress = null) public Task CreateCoopHandler() { + Logger.LogInfo("Creating CoopHandler..."); CoopHandler coopHandler = CoopHandler.GetCoopHandler(); if (coopHandler != null) { @@ -707,7 +726,7 @@ private async Task SendOrReceiveSpawnPoint() } /// - /// Creating the EFT.LocalPlayer + /// /// /// /// @@ -725,20 +744,21 @@ private async Task SendOrReceiveSpawnPoint() /// /// /// + /// /// + /// public override async Task vmethod_2(int playerId, Vector3 position, Quaternion rotation, string layerName, string prefix, EPointOfView pointOfView, Profile profile, bool aiControl, EUpdateQueue updateQueue, Player.EUpdateMode armsUpdateMode, Player.EUpdateMode bodyUpdateMode, CharacterControllerSpawner.Mode characterControllerMode, Func getSensitivity, Func getAimingSensitivity, IStatisticsManager statisticsManager, AbstractQuestControllerClass questController, AbstractAchievementControllerClass achievementsController) { - Logger.LogInfo("Creating CoopHandler"); await CreateCoopHandler(); profile.SetSpawnedInSession(profile.Side == EPlayerSide.Savage); - LocalPlayer myPlayer = await CoopPlayer.Create(playerId, spawnPoint.Position, spawnPoint.Rotation, "Player", "Main_", EPointOfView.FirstPerson, profile, - false, UpdateQueue, armsUpdateMode, bodyUpdateMode, + LocalPlayer myPlayer = await CoopPlayer.Create(playerId, spawnPoint.Position, spawnPoint.Rotation, "Player", + "Main_", EPointOfView.FirstPerson, profile, false, UpdateQueue, armsUpdateMode, bodyUpdateMode, BackendConfigAbstractClass.Config.CharacterController.ClientPlayerMode, getSensitivity, getAimingSensitivity, new GClass1456(), isServer ? 0 : 1000, statisticsManager); @@ -746,7 +766,7 @@ public override async Task vmethod_2(int playerId, Vector3 position if (!CoopHandler.TryGetCoopHandler(out CoopHandler coopHandler)) { - Logger.LogDebug($"{nameof(vmethod_2)}:Unable to find {nameof(CoopHandler)}"); + Logger.LogError($"{nameof(vmethod_2)}:Unable to find {nameof(CoopHandler)}"); throw new MissingComponentException("CoopHandler was missing during CoopGame init"); } @@ -785,7 +805,8 @@ public override async Task vmethod_2(int playerId, Vector3 position UnityEngine.Events.UnityEvent newEvent = new(); newEvent.AddListener(() => { - Singleton.Instance.ShowCriticalErrorScreen("WARNING", message: "Backing out from this stage is currently experimental. It is recommended to ALT+F4 instead. Do you still want to continue?", + Singleton.Instance.ShowCriticalErrorScreen("WARNING", + message: "Backing out from this stage is currently experimental. It is recommended to ALT+F4 instead. Do you still want to continue?", ErrorScreen.EButtonType.OkButton, 15f, () => { StopFromError(myPlayer.ProfileId, ExitStatus.Runner); @@ -860,7 +881,7 @@ public async Task InitPlayer(BotControllerSettings botsSettings, string backendU } else { - Logger.LogError("Can't find event prefab in resources. Path : Prefabs/HALLOWEEN_CONTROLLER"); + Logger.LogError("Can't find event prefab in resources. Path: 'Prefabs/HALLOWEEN_CONTROLLER'"); } } ApplicationConfigClass config = BackendConfigAbstractClass.Config; @@ -910,7 +931,7 @@ private async Task CreateLocalPlayer() spawnPoints = GClass2949.CreateFromScene(new DateTime?(GClass1304.LocalDateTimeFromUnixTime(Location_0.UnixDateTime)), Location_0.SpawnPointParams); int spawnSafeDistance = (Location_0.SpawnSafeDistanceMeters > 0) ? Location_0.SpawnSafeDistanceMeters : 100; GStruct379 settings = new(Location_0.MinDistToFreePoint, Location_0.MaxDistToFreePoint, Location_0.MaxBotPerZone, spawnSafeDistance); - SpawnSystem = GClass2950.CreateSpawnSystem(settings, () => Time.time, Singleton.Instance, zones: botsController_0, spawnPoints); + SpawnSystem = GClass2950.CreateSpawnSystem(settings, new Func(Class1384.class1384_0.method_0), Singleton.Instance, zones: botsController_0, spawnPoints); if (isServer) { @@ -996,7 +1017,8 @@ private async Task WaitForPlayers() if (client.ServerConnection == null && connectionAttempts == 5) { - Singleton.Instance.ShowErrorScreen("Network Error", "Unable to connect to the raid server. Make sure ports are forwarded and/or UPnP is enabled and supported."); + Singleton.Instance.ShowErrorScreen("Network Error", + "Unable to connect to the raid server. Make sure ports are forwarded and/or UPnP is enabled and supported."); } } @@ -1322,7 +1344,7 @@ public override void vmethod_5() InfiltrationPoint = spawnPoint.Infiltration; Profile_0.Info.EntryPoint = InfiltrationPoint; - Logger.LogDebug("SpawnPoint: " + spawnPoint.Id + ", InfiltrationPoint: " + InfiltrationPoint); + Logger.LogInfo("SpawnPoint: " + spawnPoint.Id + ", InfiltrationPoint: " + InfiltrationPoint); if (!isServer) {