static void Postfix(Contract __instance, BattleTech.MissionResult result) { try { if (!__instance.IsFlashpointContract) { GameInstance game = LazySingletonBehavior <UnityGameInstance> .Instance.Game; if (game.Simulation.IsFactionAlly(__instance.Override.employerTeam.faction)) { if (Fields.cheater) { PersistentMapClient.Logger.Log("cheated save, skipping war upload"); return; } if (Fields.skipmission) { Fields.skipmission = false; SimGameInterruptManager interruptQueue = (SimGameInterruptManager)AccessTools.Field(typeof(SimGameState), "interruptQueue").GetValue(game.Simulation); interruptQueue.QueueGenericPopup_NonImmediate("Invalid Mission!", "Something went wrong with your mission, result not uploaded.", true); return; } bool updated = false; StarSystem system = game.Simulation.StarSystems.Find(x => x.ID == __instance.TargetSystem); foreach (StarSystem potential in game.Simulation.StarSystems) { if (Helper.IsCapital(system, __instance.Override.employerTeam.faction) || (!potential.Name.Equals(system.Name) && potential.Owner == __instance.Override.employerTeam.faction && Helper.GetDistanceInLY(potential.Position.x, potential.Position.y, system.Position.x, system.Position.y) <= game.Simulation.Constants.Travel.MaxJumpDistance)) { int planetSupport = Helper.CalculatePlanetSupport(game.Simulation, system, __instance.Override.employerTeam.faction, __instance.Override.targetTeam.faction); float num8 = (float)__instance.GetNegotiableReputationBaseValue(game.Simulation.Constants) * __instance.PercentageContractReputation; float num9 = Convert.ToSingle(__instance.GameContext.GetObject(GameContextObjectTagEnum.ContractBonusEmployerReputation)); float num10 = (float)__instance.GetBaseReputationValue(game.Simulation.Constants); float num11 = num8 + num9 + num10; int repchange = Mathf.RoundToInt(num11); PersistentMapAPI.MissionResult mresult = new PersistentMapAPI.MissionResult(__instance.Override.employerTeam.faction, __instance.Override.targetTeam.faction, result, system.Name, __instance.Difficulty, repchange, planetSupport); bool postSuccessfull = Web.PostMissionResult(mresult, game.Simulation.Player1sMercUnitHeraldryDef.Description.Name); if (!postSuccessfull) { SimGameInterruptManager interruptQueue = (SimGameInterruptManager)AccessTools.Field(typeof(SimGameState), "interruptQueue").GetValue(game.Simulation); interruptQueue.QueueGenericPopup_NonImmediate("Connection Failure", "Result could not be transfered", true); } updated = true; break; } } if (!updated) { SimGameInterruptManager interruptQueue = (SimGameInterruptManager)AccessTools.Field(typeof(SimGameState), "interruptQueue").GetValue(game.Simulation); interruptQueue.QueueGenericPopup_NonImmediate("You are surrounded!", "There is no more neighbor system in your factions control, so you didnt earn any influence here.", true); } } } return; } catch (Exception e) { PersistentMapClient.Logger.LogError(e); } }
static void Postfix(Contract __instance, BattleTech.MissionResult result) { try { GameInstance game = LazySingletonBehavior <UnityGameInstance> .Instance.Game; StarSystem system = game.Simulation.StarSystems.Find(x => x.ID == __instance.TargetSystem); int planetSupport = Helper.CalculatePlanetSupport(game.Simulation, system, __instance.Override.employerTeam.faction, __instance.Override.targetTeam.faction); PersistentMapAPI.MissionResult mresult = new PersistentMapAPI.MissionResult(__instance.Override.employerTeam.faction, __instance.Override.targetTeam.faction, result, system.Name, __instance.Difficulty, Mathf.RoundToInt(__instance.InitialContractReputation * __instance.PercentageContractReputation), planetSupport); bool postSuccessfull = Web.PostMissionResult(mresult, game.Simulation.Player1sMercUnitHeraldryDef.Description.Name); if (!postSuccessfull) { SimGameInterruptManager interruptQueue = (SimGameInterruptManager)AccessTools.Field(typeof(SimGameState), "interruptQueue").GetValue(game.Simulation); interruptQueue.QueueGenericPopup_NonImmediate("Connection Failure", "Result could not be transfered", true); } return; } catch (Exception e) { Logger.LogError(e); } }