Ejemplo n.º 1
0
        static void Postfix(AAR_ContractObjectivesWidget __instance)
        {
            if (UnityGameInstance.BattleTechGame.Simulation != null)
            {
                if ((DropCostPerMech.Settings.BEXCE && UnityGameInstance.BattleTechGame.Simulation.Constants.Story.MaximumDebt != 42))
                {
                    return;
                }

                var consumedMilestones = Traverse.Create(UnityGameInstance.BattleTechGame.Simulation)
                                         .Field("ConsumedMilestones").GetValue <List <string> >();
                var consumed = consumedMilestones.Contains("milestone_111_talk_rentToOwn");

                if (consumed || UnityGameInstance.BattleTechGame.Simulation.IsCareerMode())
                {
                    try
                    {
                        var settings = DropCostPerMech.Settings;

                        string missionObjectiveResultString = $"DROP COSTS DEDUCTED: ¢{Fields.FormattedDropCost}";
                        if (settings.CostByTons && !settings.NewAlgorithm)
                        {
                            missionObjectiveResultString += $"{Environment.NewLine}AFTER {settings.freeTonnageAmount} TON CREDIT WORTH ¢{string.Format("{0:n0}", settings.freeTonnageAmount * settings.cbillsPerTon)}";
                        }
                        MissionObjectiveResult missionObjectiveResult = new MissionObjectiveResult(missionObjectiveResultString, "7facf07a-626d-4a3b-a1ec-b29a35ff1ac0", false, true, ObjectiveStatus.Succeeded, false);
                        ReflectionHelper.InvokePrivateMethode(__instance, "AddObjective", new object[] { missionObjectiveResult });
                    }
                    catch (Exception e)
                    {
                        Logger.Error(e);
                    }
                }
            }
        }
        static void Postfix(AAR_ContractObjectivesWidget __instance, Contract ___theContract)
        {
            try
            {
                List <Pilot> deployedPilots = ___theContract.PlayerUnitResults.Select(ur => ur.pilot).ToList();
                int          hazardPaySum   = 0;
                foreach (Pilot p in deployedPilots)
                {
                    CrewDetails details = ModState.GetCrewDetails(p.pilotDef);
                    hazardPaySum -= details.HazardPay;
                }
                Mod.Log.Debug?.Write($"Total hazard pay for mission is: {hazardPaySum}");

                string hazardPayTitleS = new Text(Mod.LocalizedText.Labels[ModText.LT_Contract_Hazard_Pay],
                                                  new object[] { SimGameState.GetCBillString(hazardPaySum) }).ToString();
                string guid = Guid.NewGuid().ToString();

                MissionObjectiveResult hazardPayObjective = new MissionObjectiveResult(hazardPayTitleS, guid, false, true, ObjectiveStatus.Succeeded, false);

                Traverse addObjective = Traverse.Create(__instance).Method("AddObjective", new Type[] { typeof(MissionObjectiveResult) });
                addObjective.GetValue(new object[] { hazardPayObjective });
            }
            catch (Exception e)
            {
                Mod.Log.Warn?.Write(e, "Failed to build hazard pay for contract!");
            }
        }
Ejemplo n.º 3
0
 static void Postfix(AAR_ContractObjectivesWidget __instance)
 {
     try {
         MissionObjectiveResult missionObjectiveResult = new MissionObjectiveResult("Operation Costs: " + Mathf.FloorToInt(Fields.cbill) + " ¢", "7facf07a-626d-4a3b-a1ec-b29a35ff1ac0", false, true, ObjectiveStatus.Succeeded, false);
         ReflectionHelper.InvokePrivateMethode(__instance, "AddObjective", new object[] { missionObjectiveResult });
     }
     catch (Exception e) {
         Logger.LogError(e);
     }
 }
Ejemplo n.º 4
0
        static void Prefix(AAR_ContractObjectivesWidget __instance, Contract ___theContract)
        {
            int repairCost = (int)Math.Ceiling(State.CombatDamage) * Mod.Config.LeopardRepairCostPerDamage;

            if (repairCost != 0)
            {
                Mod.Log.Debug($"AAR_COW:FIO adding repair cost objective:{repairCost}");
                string objectiveLabel = $"LEOPARD REPAIR COSTS: {SimGameState.GetCBillString(repairCost)}";
                MissionObjectiveResult missionObjectiveResult = new MissionObjectiveResult(objectiveLabel, "7facf07a-626d-4a3b-a1ec-b29a35ff1ac0", false, true, ObjectiveStatus.Succeeded, false);
                ___theContract.MissionObjectiveResultList.Add(missionObjectiveResult);
            }
        }
Ejemplo n.º 5
0
 static void Postfix(AAR_ContractObjectivesWidget __instance)
 {
     try {
         Contract contract = (Contract)ReflectionHelper.GetPrivateField(__instance, "theContract");
         if (contract.TheMissionResult == MissionResult.Victory && Fields.missionNumber > 1)
         {
             Settings settings = Helper.LoadSettings();
             MissionObjectiveResult missionObjectiveResult = new MissionObjectiveResult("Multi Mission Bonus: " + settings.bonusFactorPerExtraMission * 100 + "%", "7facf07a-626d-4a3b-a1ec-b29a35ff1ac0", false, true, ObjectiveStatus.Succeeded, true);
             ReflectionHelper.InvokePrivateMethode(__instance, "AddObjective", new object[] { missionObjectiveResult });
         }
     }
     catch (Exception e) {
         Logger.LogError(e);
     }
 }
Ejemplo n.º 6
0
        static void Postfix(AAR_ContractObjectivesWidget __instance)
        {
            try {
                Settings settings = Helper.LoadSettings();

                string missionObjectiveResultString = $"DROP COSTS DEDUCTED: ¢{Fields.FormattedDropCost}";
                if (settings.CostByTons)
                {
                    missionObjectiveResultString += $"{Environment.NewLine}AFTER {settings.freeTonnageAmount} TON CREDIT WORTH ¢{string.Format("{0:n0}", settings.freeTonnageAmount * settings.cbillsPerTon)}";
                }
                MissionObjectiveResult missionObjectiveResult = new MissionObjectiveResult(missionObjectiveResultString, "7facf07a-626d-4a3b-a1ec-b29a35ff1ac0", false, true, ObjectiveStatus.Succeeded, false);
                ReflectionHelper.InvokePrivateMethode(__instance, "AddObjective", new object[] { missionObjectiveResult });
            }
            catch (Exception e) {
                Logger.LogError(e);
            }
        }
        private static void Postfix(AAR_ContractObjectivesWidget __instance)
        {
            try {
                Flareup  flareup  = Utilities.currentFlareup();
                Contract contract = Traverse.Create(__instance).Field("theContract").GetValue <Contract>();

                if (flareup == null || flareup.currentContractName != contract.Name)
                {
                    return;
                }

                Settings s = WIIC.settings;

                int    bonus           = flareup.type == "Attack" ? s.attackBonusPerHalfSkull : s.raidBonusPerHalfSkull;
                int    bonusMoney      = bonus * contract.Difficulty;
                int    bonusSalvage    = flareup.type == "Attack" ? s.attackBonusSalvage : s.raidBonusSalvage;
                string loss            = Utilities.forcesToString(flareup.currentContractForceLoss);
                string objectiveString = Strings.T("{0} takes {1} point loss in Flareup\n¢{2:n0} bonus, {3} additional salvage", flareup.target.FactionDef.ShortName, loss, bonusMoney, bonusSalvage);
                WIIC.modLog.Debug?.Write(objectiveString);

                bool won = contract.State == Contract.ContractState.Complete;
                if ((flareup.employer == flareup.attacker && won) || (flareup.employer == flareup.target && !won))
                {
                    flareup.defenderStrength -= flareup.currentContractForceLoss;
                    WIIC.modLog.Debug?.Write($"defenderStrength -= {flareup.currentContractForceLoss}");
                }
                else
                {
                    flareup.attackerStrength -= flareup.currentContractForceLoss;
                    WIIC.modLog.Debug?.Write($"attackerStrength -= {flareup.currentContractForceLoss}");
                }

                MissionObjectiveResult objective = new MissionObjectiveResult(objectiveString, GUID, false, true, ObjectiveStatus.Ignored, false);
                Traverse.Create(__instance).Method("AddObjective", objective).GetValue();

                WIIC.modLog.Info?.Write($"MoneyResults from ARR: {contract.MoneyResults}, funds: {WIIC.sim.Funds}");

                flareup.playerDrops += 1;
                flareup.currentContractForceLoss = 0;
                flareup.currentContractName      = "";
            } catch (Exception e) {
                WIIC.modLog.Error?.Write(e);
            }
        }
            public static void Postfix(AAR_ContractObjectivesWidget __instance)
            {
                if (SpecHolder.HolderInstance.totalBounty != 0)
                {
                    var addObjectiveMethod = Traverse.Create(__instance).Method("AddObjective", new Type[] { typeof(MissionObjectiveResult) });

                    var bountyResults = $"Bounty Payouts: {SpecHolder.HolderInstance.kills} kills x {SpecHolder.HolderInstance.bounty} = ¢{SpecHolder.HolderInstance.totalBounty}";

                    var bountyPayouts = new MissionObjectiveResult(bountyResults, Guid.NewGuid().ToString(), false, true, ObjectiveStatus.Succeeded, false);

                    addObjectiveMethod.GetValue(bountyPayouts);

                    ModInit.modLog.LogMessage($"{SpecHolder.HolderInstance.totalBounty} in bounties awarded.");
                }

                else
                {
                    ModInit.modLog.LogMessage($"No bounties awarded.");
                }
            }
 static void Postfix(AAR_ContractObjectivesWidget __instance)
 {
     try {
         Traverse addObjective = Traverse.Create(__instance).Method("AddObjective", new Type[] { typeof(MissionObjectiveResult) });
         if (DCECore.settings.enableDropCosts)
         {
             addObjective.GetValue(new object[] { DropCostManager.Instance.GetObjectiveResult() });
         }
         if (DCECore.settings.enableAmmoCosts)
         {
             addObjective.GetValue(new object[] { AmmoCostManager.Instance.GetObjectiveResult() });
         }
         if (DCECore.settings.enableHeatCosts)
         {
             addObjective.GetValue(new object[] { HeatCostManager.Instance.GetObjectiveResult() });
         }
     }
     catch (Exception e) {
         DCECore.modLog.Error?.Write(e);
     }
 }
Ejemplo n.º 10
0
 static bool Prefix(AAR_ContractObjectivesWidget __instance)
 {
     try {
         if (Fields.Deployment)
         {
             Settings settings    = Helper.LoadSettings();
             Contract theContract = (Contract)AccessTools.Field(typeof(AAR_ContractObjectivesWidget), "theContract").GetValue(__instance);
             foreach (MissionObjectiveResult missionObjectiveResult in theContract.MissionObjectiveResultList)
             {
                 if (missionObjectiveResult.isPrimary)
                 {
                     foreach (SimGameEventResult result in missionObjectiveResult.simGameEventResultList)
                     {
                         result.Stats = null;
                     }
                     ReflectionHelper.InvokePrivateMethode(__instance, "AddObjective", new object[] { missionObjectiveResult });
                 }
                 else if (missionObjectiveResult.status == ObjectiveStatus.Succeeded)
                 {
                     int    Bonus = Mathf.RoundToInt(settings.BonusPercentage * Fields.DeploymentSalary);
                     string missionObjectiveResultString            = "Bonus For Secondary Objective: " + SimGameState.GetCBillString(Bonus);
                     MissionObjectiveResult missionObjectiveResult2 = new MissionObjectiveResult(missionObjectiveResultString, "7facf07a-626d-4a3b-a1ec-b29a35ff1ac0", false, true, ObjectiveStatus.Succeeded, false);
                     ReflectionHelper.InvokePrivateMethode(__instance, "AddObjective", new object[] { missionObjectiveResult2 });
                 }
                 else
                 {
                     ReflectionHelper.InvokePrivateMethode(__instance, "AddObjective", new object[] { missionObjectiveResult });
                 }
             }
             return(false);
         }
         return(true);
     }
     catch (Exception e) {
         Logger.LogError(e);
         return(true);
     }
 }