diff --git a/PTT-Plugin/Services/CustomExfilService.cs b/PTT-Plugin/Services/CustomExfilService.cs index f272a147..38c0d3b6 100644 --- a/PTT-Plugin/Services/CustomExfilService.cs +++ b/PTT-Plugin/Services/CustomExfilService.cs @@ -23,23 +23,23 @@ public static void ExtractTo(ExfiltrationPoint exfil, ExfilTarget exfilTarget) Player player = Singleton.Instance.MainPlayer; string customExtractName = exfilTarget.GetCustomExitName(exfil); - // TODO: log -> started extraction on customExtractName + Logger.Info($"started extraction on '{customExtractName}'"); if (localGame == null) { - // TODO: log error + Logger.Error($"cannot extract because no LocalGame found"); return; } if (player == null) { - // TODO: log error + Logger.Error($"cannot extract because no Player found"); return; } float delay = 0f; localGame.Stop(player.ProfileId, ExitStatus.Survived, customExtractName, delay); - // TODO: log -> local game stopped + Logger.Info($"local game stopped for profile '${player.ProfileId}'"); } public static void TransitTo(ExfiltrationPoint exfil, ExfilTarget exfilTarget) @@ -52,18 +52,18 @@ public static void TransitTo(ExfiltrationPoint exfil, ExfilTarget exfilTarget) TransitPoint transit = Transit.Create(exfil, exfilTarget); string customTransitName = transit.parameters.name; - // TODO: log -> started transit on customTransitName + Logger.Info($"started transit on '{customTransitName}'"); if (!TransitControllerAbstractClass.Exist(out GClass1642 vanillaTransitController)) { - // TODO: log error + Logger.Error($"cannot transit because no TransitControllerAbstractClass found"); return; } Player player = Singleton.Instance.MainPlayer; if (player == null) { - // TODO: log error + Logger.Error($"cannot transit because no player found"); return; } @@ -79,6 +79,6 @@ public static void TransitTo(ExfiltrationPoint exfil, ExfilTarget exfilTarget) int playersCount = 1; vanillaTransitController.Transit(transit, playersCount, transitHash, profiles, player); - // TODO: log -> transit done + Logger.Info($"transit done for profile '${player.ProfileId}'"); } } diff --git a/PTT-Plugin/Services/CustomExfilServiceFika.cs b/PTT-Plugin/Services/CustomExfilServiceFika.cs index 723d822f..842a1d9c 100644 --- a/PTT-Plugin/Services/CustomExfilServiceFika.cs +++ b/PTT-Plugin/Services/CustomExfilServiceFika.cs @@ -18,24 +18,24 @@ public static void ExtractTo(ExfiltrationPoint exfil, ExfilTarget exfilTarget) CoopPlayer coopPlayer = (CoopPlayer)Singleton.Instance.MainPlayer; string customExtractName = exfilTarget.GetCustomExitName(exfil); - // TODO: log -> started fika extraction on customExtractName + Logger.Info($"(FIKA) started extraction on '{customExtractName}'"); if (coopGame == null) { - // TODO: log error + Logger.Error($"(FIKA) cannot extract because no CoopGame found"); return; } if (coopPlayer == null) { - // TODO: log error + Logger.Error($"(FIKA) cannot extract because no CoopPlayer found"); return; } coopGame.ExitLocation = customExtractName; // not sure if it's needed coopGame.Extract(coopPlayer, exfil, null); + Logger.Info($"(FIKA) extraction done for profile {coopPlayer.ProfileId}"); - // TODO: log -> fika extraction done } public static void TransitTo(ExfiltrationPoint exfil, ExfilTarget exfilTarget) @@ -43,30 +43,36 @@ public static void TransitTo(ExfiltrationPoint exfil, ExfilTarget exfilTarget) CoopGame coopGame = (CoopGame)Singleton.Instance; CoopPlayer coopPlayer = (CoopPlayer)Singleton.Instance.MainPlayer; - string customExtractName = exfilTarget.GetCustomExitName(exfil); - // TODO: log -> started fika transit on customExtractName + string customTransitName = exfilTarget.GetCustomExitName(exfil); + Logger.Info($"started transit on '{customTransitName}'"); if (coopGame == null) { - // TODO: log error + Logger.Error($"(FIKA) cannot transit because no CoopGame found"); return; } if (coopPlayer == null) { - // TODO: log error + Logger.Error($"(FIKA) cannot transit because no CoopPlayer found"); return; } - if (!TransitControllerAbstractClass.Exist(out GClass1642 vanillaTransitController)) + if (!TransitControllerAbstractClass.Exist(out GClass1642 transitController)) { - // TODO: log errors + Logger.Error($"(FIKA) cannot transit because no TransitControllerAbstractClass found"); return; } TransitPoint transit = Transit.Create(exfil, exfilTarget); var localRaidSettings = LocalRaidSettingsRetriever.Settings; + if (localRaidSettings == null) + { + Logger.Error($"(FIKA) cannot transit because no LocalRaidSettings found"); + return; + } + // 1. set the transition status string location = transit.parameters.location; ERaidMode eraidMode = ERaidMode.Local; @@ -76,12 +82,24 @@ public static void TransitTo(ExfiltrationPoint exfil, ExfilTarget exfilTarget) } else { - // TODO: log errors + Logger.Error($"(FIKA) cannot transit because no TarkovApplication found"); return; } - // 2. prepare profiles + // 2. add the transitPayload + var transitPayload = CreateTransitPayload(location, transitController, coopPlayer); + transitController.alreadyTransits.Add(coopPlayer.ProfileId, transitPayload); + + // 3. trigger extract + coopGame.ExitLocation = customTransitName; // not sure if it's needed + coopGame.Extract(coopPlayer, null, transit); + Logger.Info($"(FIKA) transit done for profile '${coopPlayer.ProfileId}'"); + } + + private static GClass1926 CreateTransitPayload(string locationName, GClass1642 transitController, CoopPlayer coopPlayer) + { + // 1. create player profiles Dictionary profiles = new() { {coopPlayer.ProfileId, new() { @@ -92,25 +110,20 @@ public static void TransitTo(ExfiltrationPoint exfil, ExfilTarget exfilTarget) } }; - // 3. prepare transitPayload (TODO: refactor) + // 2. create the transit payload GClass1926 transitPayload = new() { hash = Guid.NewGuid().ToString(), playersCount = 1, ip = "", - location = location, + location = locationName, profiles = profiles, - transitionRaidId = vanillaTransitController.summonedTransits[coopPlayer.ProfileId].raidId, - raidMode = eraidMode, + transitionRaidId = transitController?.summonedTransits?[coopPlayer.ProfileId]?.raidId, + raidMode = ERaidMode.Local, side = coopPlayer.Side is EPlayerSide.Savage ? ESideType.Savage : ESideType.Pmc, - dayTime = localRaidSettings.timeVariant + dayTime = LocalRaidSettingsRetriever.Settings.timeVariant }; - // 4. add transitPayload - vanillaTransitController.alreadyTransits.Add(coopPlayer.ProfileId, transitPayload); - - // 5. trigger extract - coopGame.ExitLocation = customExtractName; // not sure if it's needed - coopGame.Extract(coopPlayer, null, transit); + return transitPayload; } }