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);
     }
 }
Exemple #2
0
 public MissionResult(Faction employer, Faction target, BattleTech.MissionResult result, string systemName, int difficulty, int awardedRep, int planetSupport)
 {
     this.awardedRep    = awardedRep;
     this.difficulty    = difficulty;
     this.employer      = employer;
     this.result        = result;
     this.systemName    = systemName;
     this.target        = target;
     this.planetSupport = planetSupport;
 }
Exemple #3
0
            public static void Postfix(Contract __instance, MissionResult result, bool isGoodFaithEffort)
            {
                try
                {
                    if (Globals.WarStatusTracker == null || Globals.Sim.IsCampaign && !Globals.Sim.CompanyTags.Contains("story_complete"))
                    {
                        return;
                    }

                    var system = Globals.WarStatusTracker.Systems.Find(x => x.Name == Globals.Sim.CurSystem.Name);
                    if (system.BonusCBills && Globals.WarStatusTracker.HotBox.IsHot(Globals.Sim.CurSystem.Name))
                    {
                        HotSpots.BonusMoney = (int)(__instance.MoneyResults * Globals.Settings.BonusCbillsFactor);
                        var newMoneyResults = Mathf.FloorToInt(__instance.MoneyResults + HotSpots.BonusMoney);
                        __instance.MoneyResults = newMoneyResults;
                    }

                    Globals.TeamFaction = __instance.GetTeamFaction("ecc8d4f2-74b4-465d-adf6-84445e5dfc230").Name;
                    if (Globals.Settings.GaW_PoliceSupport && Globals.TeamFaction == Globals.Settings.GaW_Police)
                    {
                        Globals.TeamFaction = Globals.WarStatusTracker.ComstarAlly;
                    }
                    Globals.EnemyFaction = __instance.GetTeamFaction("be77cadd-e245-4240-a93e-b99cc98902a5").Name;
                    if (Globals.Settings.GaW_PoliceSupport && Globals.EnemyFaction == Globals.Settings.GaW_Police)
                    {
                        Globals.EnemyFaction = Globals.WarStatusTracker.ComstarAlly;
                    }
                    Globals.Difficulty    = __instance.Difficulty;
                    Globals.MissionResult = result;
                    Globals.ContractType  = __instance.Override.ContractTypeValue.Name;
                    if (__instance.IsFlashpointContract || __instance.IsFlashpointCampaignContract)
                    {
                        Globals.IsFlashpointContract = true;
                    }
                    else
                    {
                        Globals.IsFlashpointContract = false;
                    }
                }
                catch (Exception ex)
                {
                    Error(ex);
                }
            }
 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);
     }
 }
 public MissionResult(FactionValue employer, FactionValue target, BattleTech.MissionResult result, string systemName, int difficulty, int awardedRep, int planetSupport, int mCount, string missionType, int cbCount, int state, string key, string salt, string data, float score, int con)
 {
     this.awardedRep    = awardedRep;
     this.difficulty    = difficulty;
     this.employer      = employer.Name;
     this.result        = result;
     this.systemName    = systemName;
     this.target        = target.Name;
     this.planetSupport = planetSupport;
     this.mCount        = mCount;
     this.missionType   = missionType;
     this.cbCount       = cbCount;
     this.rtState       = state;
     this.rtKey         = key;
     this.rtSalt        = salt;
     this.rtData        = data;
     this.cscore        = score;
     this.ccCount       = con;
 }