Beispiel #1
0
 static void Postfix(AAR_SalvageScreen __instance)
 {
     try {
         Settings settings = Helper.LoadSettings();
         Contract c        = (Contract)ReflectionHelper.GetPrivateField(__instance, "contract");
         if (Fields.missionNumber < Fields.alreadyRaised[c.GUID])
         {
             Contract newcon = GetNewContract(__instance.Sim, c);
             newcon.Override.disableNegotations  = true;
             newcon.Override.disableCancelButton = true;
             ReflectionHelper.InvokePrivateMethode(newcon, "set_InitialContractValue", new object[] { c.InitialContractValue });
             ReflectionHelper.InvokePrivateMethode(newcon, "set_SalvagePotential", new object[] { c.SalvagePotential });
             newcon.Override.negotiatedSalary  = c.PercentageContractValue;
             newcon.Override.negotiatedSalvage = c.PercentageContractSalvage;
             newcon.Override.targetTeam        = c.Override.targetTeam;
             newcon.Override.targetsAllyTeam   = c.Override.targetsAllyTeam;
             newcon.Override.employerTeam      = c.Override.employerTeam;
             __instance.Sim.ForceTakeContract(newcon, false);
             newcon.SetGuid(Guid.NewGuid().ToString());
             Fields.alreadyRaised.Add(newcon.GUID, Fields.alreadyRaised[c.GUID]);
             Fields.missionNumber++;
             Fields.alreadyRaised.Remove(c.GUID);
         }
         else
         {
             Fields.missionNumber = 1;
         }
     }
     catch (Exception e) {
         Logger.LogError(e);
     }
 }
Beispiel #2
0
 static void Postfix(AAR_SalvageScreen __instance)
 {
     try {
         if (Fields.Deployment)
         {
             Contract con = (Contract)ReflectionHelper.GetPrivateField(__instance, "contract");
             Fields.DeploymentContracts.Remove(con.Name);
             Fields.MissionsDoneCurrentMonth++;
         }
     }
     catch (Exception e) {
         Logger.LogError(e);
     }
 }
Beispiel #3
0
        public static void RefuseAction(AAR_SalvageScreen salvageScreen, int reputationModifier)
        {
            SimGameState sgs       = UnityGameInstance.BattleTechGame.Simulation;
            int          repBefore = sgs.GetRawReputation(ModState.Employer);

            sgs.AddReputation(ModState.Employer, reputationModifier, false);
            ModState.EmployerRepRaw = sgs.GetRawReputation(ModState.Employer);
            Mod.Log.Info($"Player refused holdback. {ModState.Employer} reputation {repBefore} + {reputationModifier} modifier = {ModState.EmployerRepRaw}.");

            // Roll up any remaining salvage and widget-tize it
            List <SalvageDef> rolledUpSalvage = Helper.RollupSalvage(ModState.PotentialSalvage);

            Helper.CalculateAndAddAvailableSalvage(salvageScreen, rolledUpSalvage);

            ModState.Reset();
        }
Beispiel #4
0
        public static bool Prefix(AAR_SalvageScreen __instance, Contract ___contract)
        {
            if (UnityGameInstance.BattleTechGame.Simulation != null &&
                UnityGameInstance.BattleTechGame.Simulation.Constants.Story.MaximumDebt == 42)
            {
                Mod.Log.Debug("AAR_SS:CAAAS entered.");

                // Calculate potential salvage, which will be rolled up at this point (including mechs!)
                State.PotentialSalvage = ___contract.GetPotentialSalvage();

                // Sort by price, since other functions depend on it
                State.PotentialSalvage.Sort(new Helper.SalvageDefByCostDescendingComparer());

                // Check for holdback
                bool hasMechParts =
                    State.PotentialSalvage.FirstOrDefault(sd => sd.Type != SalvageDef.SalvageType.COMPONENT) != null;
                //bool canHoldback = SimGameState.DoesFactionGainReputation(State.Employer) && State.Employer != Faction.ComStar;
                bool  canHoldback   = State.Employer.DoesGainReputation;
                float triggerChance = Helper.GetHoldbackTriggerChance();
                float holdbackRoll  = LootMagnet.Random.Next(101);
                Mod.Log.Info(
                    $"Holdback roll:{holdbackRoll}% triggerChance:{triggerChance}% hasMechParts:{hasMechParts} canHoldback:{canHoldback}");

                if (canHoldback && hasMechParts && holdbackRoll <= triggerChance)
                {
                    Mod.Log.Info($"Holdback triggered, determining disputed mech parts.");
                    Helper.CalculateHoldback(State.PotentialSalvage);
                    Helper.CalculateCompensation(State.PotentialSalvage);
                }

                if (State.HeldbackParts.Count > 0)
                {
                    UIHelper.ShowHoldbackDialog(___contract, __instance);
                }
                else
                {
                    // Roll up any remaining salvage and widget-ize it
                    List <SalvageDef> rolledUpSalvage = Helper.RollupSalvage(State.PotentialSalvage);
                    Helper.CalculateAndAddAvailableSalvage(__instance, rolledUpSalvage);
                }
                return(false);
            }

            return(true);
        }
        public static bool Prefix(AAR_SalvageScreen __instance, Contract ___contract, ref int ___totalSalvageMadeAvailable)
        {
            Mod.Log.Debug?.Write("AAR_SS:CAAAS entered.");

            // Calculate potential salvage, which will be rolled up at this point (including mechs!)
            ModState.PotentialSalvage = ___contract.GetPotentialSalvage();

            // Sort by price, since other functions depend on it
            ModState.PotentialSalvage.Sort(new Helper.SalvageDefByCostDescendingComparer());

            // Check for holdback
            bool  hasMechParts  = ModState.PotentialSalvage.FirstOrDefault(sd => sd.Type != SalvageDef.SalvageType.COMPONENT) != null;
            bool  canHoldback   = Mod.Config.Holdback.Enabled && ModState.Employer.DoesGainReputation;
            float triggerChance = Helper.GetHoldbackTriggerChance();
            float holdbackRoll  = Mod.Random.Next(101);

            Mod.Log.Info?.Write($"Holdback roll:{holdbackRoll}% triggerChance:{triggerChance}% hasMechParts:{hasMechParts} canHoldback:{canHoldback}");

            if (canHoldback && hasMechParts && holdbackRoll <= triggerChance)
            {
                Mod.Log.Info?.Write($"Holdback triggered, determining disputed mech parts.");
                Helper.CalculateHoldback(ModState.PotentialSalvage);
                Helper.CalculateCompensation(ModState.PotentialSalvage);
            }

            ___totalSalvageMadeAvailable = ModState.PotentialSalvage.Count - ModState.HeldbackParts.Count;
            Mod.Log.Debug?.Write($"Setting totalSalvageMadeAvailable = potentialSalvage: {ModState.PotentialSalvage.Count} - heldbackParts: {ModState.HeldbackParts.Count}");

            if (ModState.HeldbackParts.Count > 0)
            {
                UIHelper.ShowHoldbackDialog(___contract, __instance);
            }
            else
            {
                // Roll up any remaining salvage and widget-ize it
                List <SalvageDef> rolledUpSalvage = Helper.RollupSalvage(ModState.PotentialSalvage);
                Helper.CalculateAndAddAvailableSalvage(__instance, rolledUpSalvage);
            }

            return(false);
        }
Beispiel #6
0
        public static void AcceptAction(AAR_SalvageScreen salvageScreen, int reputationModifier)
        {
            SimGameState sgs       = UnityGameInstance.BattleTechGame.Simulation;
            int          repBefore = sgs.GetRawReputation(ModState.Employer);

            sgs.AddReputation(ModState.Employer, reputationModifier, false);
            ModState.EmployerRepRaw = sgs.GetRawReputation(ModState.Employer);
            Mod.Log.Info($"Player accepted holdback. {ModState.Employer} reputation {repBefore} + {reputationModifier} modifier = {ModState.EmployerRepRaw}.");

            // Remove the disputed items
            Mod.Log.Debug("  -- Removing disputed items.");
            foreach (SalvageDef sDef in ModState.HeldbackParts)
            {
                Helper.RemoveSalvage(sDef);
            }

            // Update quantities of compensation parts
            Mod.Log.Debug("  -- Updating quantities on compensation parts.");
            foreach (SalvageDef compSDef in ModState.CompensationParts)
            {
                Mod.Log.Debug($"   compensation salvageDef:{compSDef.Description.Name} with quantity:{compSDef.Count}");
                foreach (SalvageDef sDef in ModState.PotentialSalvage)
                {
                    Mod.Log.Debug($"   salvageDef:{sDef.Description.Name} with quantity:{sDef.Count}");

                    if (compSDef.RewardID == sDef.RewardID)
                    {
                        Mod.Log.Info($"   Matched compensation target, updating quantity to: {compSDef.Count + sDef.Count}");
                        sDef.Count = sDef.Count + compSDef.Count;
                        break;
                    }
                }
            }

            // Roll up any remaining salvage and widget-tize it
            List <SalvageDef> rolledUpSalvage = Helper.RollupSalvage(ModState.PotentialSalvage);

            Helper.CalculateAndAddAvailableSalvage(salvageScreen, rolledUpSalvage);

            ModState.Reset();
        }
Beispiel #7
0
        public static void Reset()
        {
            // Reinitialize state to known values
            Employer       = null;
            EmployerRep    = SimGameReputation.INDIFFERENT;
            EmployerRepRaw = 0;
            IsEmployerAlly = false;
            MRBRating      = 0;

            Compensation = 0;

            PotentialSalvage.Clear();
            HeldbackParts.Clear();
            CompensationParts.Clear();

            Contract          = null;
            SimGameState      = null;
            AAR_SalvageScreen = null;
            SGCurrencyDisplay = null;
            HBSPopupRoot      = null;
            FloatieFont       = null;
        }
Beispiel #8
0
        // Replica of HBS code used once holdback has been decided
        public static void CalculateAndAddAvailableSalvage(AAR_SalvageScreen salvageScreen, List <SalvageDef> potentialSalvage)
        {
            Traverse salvageScreenT = Traverse.Create(salvageScreen);

            Mod.Log.Debug("CAAAS - created base traverse.");

            Traverse             salvageSelectT   = salvageScreenT.Field("salvageSelection");
            AAR_SalvageSelection salvageSelection = salvageSelectT.GetValue <AAR_SalvageSelection>();

            Mod.Log.Debug("CAAAS - found salvage selection.");

            foreach (SalvageDef item in potentialSalvage)
            {
                salvageScreen.AddNewSalvageEntryToWidget(item, salvageSelection.GetInventoryWidget());
            }
            Mod.Log.Debug("CAAAS - added all salvage entries.");

            Traverse allSalvageContT = salvageScreenT.Field("AllSalvageControllers");
            List <ListElementController_BASE_NotListView> allSalvageControllers =
                allSalvageContT.GetValue <List <ListElementController_BASE_NotListView> >();

            Mod.Log.Debug("CAAAS - found salvage controllers");

            Traverse totalSalvageT = salvageScreenT.Field("totalSalvageMadeAvailable");

            totalSalvageT.SetValue(allSalvageControllers.Count);
            Mod.Log.Debug("CAAAS - updated salvageController count");

            salvageSelection.ApplySalvageSorting();

            // Update the contract potential salvage
            Contract          contract = salvageScreenT.Field("contract").GetValue <Contract>();
            Traverse          finalPotentialSalvageT = Traverse.Create(contract).Field("finalPotentialSalvage");
            List <SalvageDef> finalPotentialSalvage  = finalPotentialSalvageT.GetValue <List <SalvageDef> >();

            finalPotentialSalvage.Clear();
            finalPotentialSalvage.AddRange(potentialSalvage);
        }
        public static void Postfix(AAR_SalvageChosen __instance, LocalizableText ___howManyReceivedText, AAR_SalvageScreen ___parent, SimGameState ___simState, Contract ___contract)
        {
            // Skip if the UI element isn't visible
            if (!__instance.Visible)
            {
                Mod.Log.Info?.Write("SalvageChosen not visible, but ConvertToFinalState called - this should not happen, skipping.");
                return;
            }

            // Set each of the items clickable
            foreach (InventoryItemElement_NotListView iie in __instance.LeftoverInventory)
            {
                if (iie.controller != null && iie.controller.salvageDef != null && iie.controller.salvageDef.Type != SalvageDef.SalvageType.MECH_PART)
                {
                    Mod.Log.Debug?.Write($"Enabling non-mechpart for clicking: {iie.controller.salvageDef.Description.Id}");
                    iie.SetClickable(true);
                }
            }

            // Update text with Quick Sell instructions
            string localText = new Text(Mod.Config.LocalizedText[ModConfig.LT_QUICK_SELL], new object[] { }).ToString();

            ___howManyReceivedText.SetText(string.Concat(___howManyReceivedText.text, localText));

            // Set the Mod state we'll rely upon
            ModState.AAR_SalvageScreen = ___parent;
            ModState.Contract          = ___contract;
            ModState.SimGameState      = ___simState;

            // Painful, full-context searches here
            ModState.HBSPopupRoot =
                GameObject.Find(ModConsts.HBSPopupRootGOName);
            ModState.FloatieFont =
                Resources.FindObjectsOfTypeAll <TMP_FontAsset>().First(x => x.name == "UnitedSansReg-Black SDF");
            ModState.SGCurrencyDisplay = (SGCurrencyDisplay)Object.FindObjectOfType(typeof(SGCurrencyDisplay));
        }
Beispiel #10
0
        public static void ShowHoldbackDialog(Contract contract, AAR_SalvageScreen salvageScreen)
        {
            List <string> heldbackItemsDesc = new List <string>();

            foreach (SalvageDef sDef in ModState.HeldbackParts)
            {
                string localItemName        = new Text(sDef.Description.Name).ToString();
                string localItemAndQuantity =
                    new Text(
                        Mod.Config.DialogText[ModConfig.DT_ITEM_AND_QUANTITY], new object[] { localItemName, sDef.Count }
                        ).ToString();
                localItemAndQuantity = AppendExistingPartialCount(localItemAndQuantity, sDef);
                heldbackItemsDesc.Add(localItemAndQuantity);
            }
            string heldbackDescs = " -" + string.Join("\n -", heldbackItemsDesc.ToArray());

            List <string> compItemsDesc = new List <string>();

            foreach (SalvageDef sDef in ModState.CompensationParts)
            {
                string localItemName        = new Text(sDef.Description.Name).ToString();
                string localItemAndQuantity =
                    new Text(
                        Mod.Config.DialogText[ModConfig.DT_ITEM_AND_QUANTITY], new object[] { localItemName, sDef.Count }
                        ).ToString();
                compItemsDesc.Add(localItemAndQuantity);
            }
            string compDescs = " -" + string.Join("\n -", compItemsDesc.ToArray());

            int acceptRepMod  = LootMagnet.Random.Next(Mod.Config.Holdback.ReputationRange[0], Mod.Config.Holdback.ReputationRange[1]);
            int refuseRepMod  = LootMagnet.Random.Next(Mod.Config.Holdback.ReputationRange[0], Mod.Config.Holdback.ReputationRange[1]);
            int disputeRepMod = LootMagnet.Random.Next(Mod.Config.Holdback.ReputationRange[0], Mod.Config.Holdback.ReputationRange[1]);

            Mod.Log.Debug($"Reputation modifiers - accept:{acceptRepMod} refuse:{refuseRepMod} dispute:{disputeRepMod}");

            Dispute dispute = new Dispute(contract.InitialContractValue, contract.Name);

            void acceptAction()
            {
                AcceptAction(salvageScreen, acceptRepMod);
            }

            void refuseAction()
            {
                RefuseAction(salvageScreen, refuseRepMod);
            }

            void disputeAction()
            {
                DisputeAction(contract, salvageScreen, dispute);
            }

            string localDialogTitle = new Text(Mod.Config.DialogText[ModConfig.DT_DISPUTE_TITLE]).ToString();
            string localDialogText  = new Text(
                Mod.Config.DialogText[ModConfig.DT_DISPUTE_TEXT], new object[] {
                ModState.Employer, heldbackDescs, compDescs, refuseRepMod, acceptRepMod,
                SimGameState.GetCBillString(dispute.MRBFees), dispute.SuccessChance,
                Mod.Config.Holdback.DisputePicks[0], Mod.Config.Holdback.DisputePicks[1],
                (100 - dispute.SuccessChance),
                Mod.Config.Holdback.DisputePicks[0], Mod.Config.Holdback.DisputePicks[1],
            }
                ).ToString();
            string       localButtonRefuse  = new Text(Mod.Config.DialogText[ModConfig.DT_BUTTON_REFUSE]).ToString();
            string       localButtonAccept  = new Text(Mod.Config.DialogText[ModConfig.DT_BUTTON_ACCEPT]).ToString();
            string       localButtonDispute = new Text(Mod.Config.DialogText[ModConfig.DT_BUTTON_DISPUTE]).ToString();
            GenericPopup gp = GenericPopupBuilder.Create(localDialogTitle, localDialogText)
                              .AddButton(localButtonRefuse, refuseAction, true, null)
                              .AddButton(localButtonAccept, acceptAction, true, null)
                              .AddButton(localButtonDispute, disputeAction, true, null)
                              .Render();

            TextMeshProUGUI contentText = (TextMeshProUGUI)Traverse.Create(gp).Field("_contentText").GetValue();

            contentText.alignment = TextAlignmentOptions.Left;
        }
Beispiel #11
0
        public static void DisputeAction(Contract contract, AAR_SalvageScreen salvageScreen, Dispute dispute)
        {
            Mod.Log.Info($"Player disputed holdback.");

            SimGameState sgs = UnityGameInstance.BattleTechGame.Simulation;

            Mod.Log.Info($"  Dispute legal fees:{dispute.MRBFees}");
            sgs.AddFunds(dispute.MRBFees, $"MRB Legal Fees re: {contract.Name}", false);

            Dispute.Outcome outcome = dispute.GetOutcome();
            if (outcome == Dispute.Outcome.SUCCESS)
            {
                Mod.Log.Info($"DISPUTE SUCCESS: Player keeps disputed salvage and gains {dispute.Picks} items from compensation pool.");

                // Update quantities of compensation parts
                Mod.Log.Debug("  -- Updating quantities on compensation parts.");
                List <string> compItemsDesc = new List <string>();
                int           loopCount     = 0;
                foreach (SalvageDef compSDef in ModState.CompensationParts)
                {
                    if (loopCount < dispute.Picks)
                    {
                        loopCount++;
                    }
                    else
                    {
                        break;
                    }

                    Mod.Log.Debug($"   compensation salvageDef:{compSDef.Description.Name} with quantity:{compSDef.Count}");
                    foreach (SalvageDef sDef in ModState.PotentialSalvage)
                    {
                        Mod.Log.Debug($"   salvageDef:{sDef.Description.Name} with quantity:{sDef.Count}");

                        if (compSDef.RewardID == sDef.RewardID)
                        {
                            Mod.Log.Debug($"   Matched compensation target, updating quantity to: {compSDef.Count + sDef.Count}");

                            string localItemName        = new Text(compSDef.Description.Name).ToString();
                            string localItemAndQuantity =
                                new Text(
                                    Mod.Config.DialogText[ModConfig.DT_ITEM_AND_QUANTITY], new object[] { localItemName, compSDef.Count }
                                    ).ToString();
                            compItemsDesc.Add(localItemAndQuantity);
                            sDef.Count = sDef.Count + compSDef.Count;
                            break;
                        }
                    }
                }
                string compDescs = " -" + string.Join("\n -", compItemsDesc.ToArray());

                // Display the confirmation screen
                string localDialogTitle = new Text(Mod.Config.DialogText[ModConfig.DT_SUCCESS_TITLE]).ToString();
                string localDialogText  = new Text(
                    Mod.Config.DialogText[ModConfig.DT_SUCCESS_TEXT], new object[] { compDescs }
                    ).ToString();
                string localButtonOk = new Text(Mod.Config.DialogText[ModConfig.DT_BUTTON_OK]).ToString();
                GenericPopupBuilder.Create(localDialogTitle, localDialogText)
                .AddButton("OK")
                .Render();
            }
            else
            {
                Mod.Log.Info($"DISPUTE FAILURE: Player loses disputed items, and {dispute.Picks} items from the salvage pool.");

                // Remove the disputed items
                Mod.Log.Debug("  -- Removing disputed items.");
                foreach (SalvageDef sDef in ModState.HeldbackParts)
                {
                    Helper.RemoveSalvage(sDef);
                }

                // Update quantities of compensation parts
                Mod.Log.Debug("  -- Determining dispute failure picks.");
                List <SalvageDef> disputePicks = new List <SalvageDef>();
                List <SalvageDef> components   = ModState.PotentialSalvage.Where(sd => sd.Type == SalvageDef.SalvageType.COMPONENT).ToList();
                components.Sort(new Helper.SalvageDefByCostDescendingComparer());
                int loopCount = 0;
                foreach (SalvageDef compDef in components)
                {
                    if (loopCount < dispute.Picks)
                    {
                        loopCount++;
                    }
                    else
                    {
                        break;
                    }

                    Mod.Log.Debug($"   dispute fail salvageDef:{compDef.Description.Name} with quantity:{compDef.Count}");
                    disputePicks.Add(compDef);
                    ModState.PotentialSalvage.Remove(compDef);
                }

                List <string> heldbackItemsDesc = new List <string>();
                foreach (SalvageDef sDef in ModState.HeldbackParts)
                {
                    heldbackItemsDesc.Add($"{sDef.Description.Name} [QTY:{sDef.Count}]");
                }
                string heldbackDescs = " -" + string.Join("\n -", heldbackItemsDesc.ToArray());

                List <string> disputeDesc = new List <string>();
                foreach (SalvageDef sDef in disputePicks)
                {
                    disputeDesc.Add($"{sDef.Description.Name} [QTY:{sDef.Count}]");
                }
                string disputeDescs = " -" + string.Join("\n -", disputeDesc.ToArray());

                // Display the configmration screen
                string localDialogTitle = new Text(Mod.Config.DialogText[ModConfig.DT_FAILED_TITLE]).ToString();
                string localDialogText  = new Text(
                    Mod.Config.DialogText[ModConfig.DT_FAILED_TEXT], new object[] {
                    ModState.Employer, sgs.CompanyName, heldbackDescs, disputeDescs
                }).ToString();
                string localButtonOk = new Text(Mod.Config.DialogText[ModConfig.DT_BUTTON_OK]).ToString();
                GenericPopupBuilder.Create(localDialogTitle, localDialogText)
                .AddButton(localButtonOk)
                .Render();
            }

            // Roll up any remaining salvage and widget-tize it
            List <SalvageDef> rolledUpSalvage = Helper.RollupSalvage(ModState.PotentialSalvage);

            Helper.CalculateAndAddAvailableSalvage(salvageScreen, rolledUpSalvage);

            ModState.Reset();
        }
Beispiel #12
0
        public static void DisputeAction(Contract contract, AAR_SalvageScreen salvageScreen, Dispute dispute)
        {
            Mod.Log.Info($"Player disputed holdback.");

            SimGameState sgs = UnityGameInstance.BattleTechGame.Simulation;

            Mod.Log.Info($"  Dispute legal fees:{dispute.MRBFees}");
            sgs.AddFunds(dispute.MRBFees, $"MRB Legal Fees re: {contract.Name}", false);

            Dispute.Outcome outcome = dispute.GetOutcome();
            if (outcome == Dispute.Outcome.SUCCESS)
            {
                Mod.Log.Info($"DISPUTE SUCCESS: Player keeps disputed salvage and gains {dispute.Picks} items from compensation pool.");

                // Update quantities of compensation parts
                Mod.Log.Debug("  -- Updating quantities on compensation parts.");
                List <string> compItemsDesc = new List <string>();
                int           loopCount     = 0;
                foreach (SalvageDef compSDef in State.CompensationParts)
                {
                    if (loopCount < dispute.Picks)
                    {
                        loopCount++;
                    }
                    else
                    {
                        break;
                    }

                    Mod.Log.Debug($"   compensation salvageDef:{compSDef.Description.Name} with quantity:{compSDef.Count}");
                    foreach (SalvageDef sDef in State.PotentialSalvage)
                    {
                        Mod.Log.Debug($"   salvageDef:{sDef.Description.Name} with quantity:{sDef.Count}");

                        if (compSDef.RewardID == sDef.RewardID)
                        {
                            Mod.Log.Debug($"   Matched compensation target, updating quantity to: {compSDef.Count + sDef.Count}");
                            compItemsDesc.Add($"{compSDef.Description.Name} [QTY:{compSDef.Count}]");
                            sDef.Count = sDef.Count + compSDef.Count;
                            break;
                        }
                    }
                }
                string compDescs = " -" + string.Join("\n -", compItemsDesc.ToArray());

                // Display the confirmation screen
                GenericPopupBuilder.Create(
                    "SUCCESSFUL DISPUTE",
                    $"<b>Cause 193 of the negotiated mercenary contract clearly states...</b>\n\n" +
                    $"Your laywer deftly defend your claim with the MRB. You keep your salvage, and gain the following compensation items:" +
                    $"\n\n{compDescs}\n\n"
                    )
                .AddButton("OK")
                .Render();
            }
            else
            {
                Mod.Log.Info($"DISPUTE FAILURE: Player loses disputed items, and {dispute.Picks} items from the salvage pool.");

                // Remove the disputed items
                Mod.Log.Debug("  -- Removing disputed items.");
                foreach (SalvageDef sDef in State.HeldbackParts)
                {
                    Helper.RemoveSalvage(sDef);
                }

                // Update quantities of compensation parts
                Mod.Log.Debug("  -- Determining dispute failure picks.");
                List <SalvageDef> disputePicks = new List <SalvageDef>();
                List <SalvageDef> components   = State.PotentialSalvage.Where(sd => sd.Type == SalvageDef.SalvageType.COMPONENT).ToList();
                components.Sort(new Helper.SalvageDefByCostDescendingComparer());
                int loopCount = 0;
                foreach (SalvageDef compDef in components)
                {
                    if (loopCount < dispute.Picks)
                    {
                        loopCount++;
                    }
                    else
                    {
                        break;
                    }

                    Mod.Log.Debug($"   dispute fail salvageDef:{compDef.Description.Name} with quantity:{compDef.Count}");
                    disputePicks.Add(compDef);
                    State.PotentialSalvage.Remove(compDef);
                }

                List <string> heldbackItemsDesc = new List <string>();
                foreach (SalvageDef sDef in State.HeldbackParts)
                {
                    heldbackItemsDesc.Add($"{sDef.Description.Name} [QTY:{sDef.Count}]");
                }
                string heldbackDescs = " -" + string.Join("\n -", heldbackItemsDesc.ToArray());

                List <string> disputeDesc = new List <string>();
                foreach (SalvageDef sDef in disputePicks)
                {
                    disputeDesc.Add($"{sDef.Description.Name} [QTY:{sDef.Count}]");
                }
                string disputeDescs = " -" + string.Join("\n -", disputeDesc.ToArray());

                // Display the configmration screen
                GenericPopupBuilder.Create(
                    "FAILED DISPUTE",
                    $"<b>Judge</b>: Counselor, what evidence do you offer for this new plea of insanity?\n\n" +
                    $"<b>Attorney</b>: Well, for one, they done hired me to represent them.\n\n" +
                    $"<b>Judge</b>: Insanity plea is accepted.\n\n" +
                    $"{State.Employer}'s legal team completely ran away with the proceeding, painting {sgs.CompanyName} in the worst possible light." +
                    $"You lose salvage rights to all of the following:" +
                    $"\n\n{heldbackDescs}\n\n" +
                    $"In addition they claim the following as compensation for legal fees:" +
                    $"\n\n{disputeDescs}\n\n"
                    )
                .AddButton("OK")
                .Render();
            }

            // Roll up any remaining salvage and widget-tize it
            List <SalvageDef> rolledUpSalvage = Helper.RollupSalvage(State.PotentialSalvage);

            Helper.CalculateAndAddAvailableSalvage(salvageScreen, rolledUpSalvage);

            State.Reset();
        }
Beispiel #13
0
        public static void ShowHoldbackDialog(Contract contract, AAR_SalvageScreen salvageScreen)
        {
            List <string> heldbackItemsDesc = new List <string>();

            foreach (SalvageDef sDef in State.HeldbackParts)
            {
                heldbackItemsDesc.Add($"{sDef.Description.Name} [QTY:{sDef.Count}]");
            }
            string heldbackDescs = " -" + string.Join("\n -", heldbackItemsDesc.ToArray());

            List <string> compItemsDesc = new List <string>();

            foreach (SalvageDef sDef in State.CompensationParts)
            {
                compItemsDesc.Add($"{sDef.Description.Name} [QTY:{sDef.Count}]");
            }
            string compDescs = " -" + string.Join("\n -", compItemsDesc.ToArray());

            int acceptRepMod  = LootMagnet.Random.Next(Mod.Config.Holdback.ReputationRange[0], Mod.Config.Holdback.ReputationRange[1]);
            int refuseRepMod  = LootMagnet.Random.Next(Mod.Config.Holdback.ReputationRange[0], Mod.Config.Holdback.ReputationRange[1]);
            int disputeRepMod = LootMagnet.Random.Next(Mod.Config.Holdback.ReputationRange[0], Mod.Config.Holdback.ReputationRange[1]);

            Mod.Log.Debug($"Reputation modifiers - accept:{acceptRepMod} refuse:{refuseRepMod} dispute:{disputeRepMod}");

            Dispute dispute = new Dispute(contract);

            void acceptAction()
            {
                AcceptAction(salvageScreen, acceptRepMod);
            }

            void refuseAction()
            {
                RefuseAction(salvageScreen, refuseRepMod);
            }

            void disputeAction()
            {
                DisputeAction(contract, salvageScreen, dispute);
            }

            GenericPopup gp = GenericPopupBuilder.Create(
                "DISPUTED SALVAGE",
                $"<b>I'm sorry commander, but Section A, Sub-Section 3, Paragraph ii...</b>\n\n" +
                $"As the salvage crew picks over the battlefield, you are contacted by the {State.Employer} representative. " +
                $"They insist the contract terms allows them first rights to the following items:" +
                $"\n\n{heldbackDescs}\n\n" +
                $"They offer to add the following to the <b>salvage pool</b> in exchange:" +
                $"\n\n{compDescs}\n\n" +
                $"You may choose to:\n" +
                $"<b>Refuse</b>: the disputed salvage is retained, you <b>lose</b> <color=#FF0000>{refuseRepMod}</color> rep.\n" +
                $"<b>Accept</b>: the disputed salvage is lost, exchanged items are added to the <b>salvage pool</b>, " +
                $"you gain <b>gain</b> <color=#00FF00>{acceptRepMod:+0}</color> rep.\n" +
                $"<b>Dispute</b>: you pay <color=#FF0000>{SimGameState.GetCBillString(dispute.MRBFees)}</color> in legal fees, and have:\n" +
                $"<line-indent=2px> - {dispute.SuccessChance}% to keep the disputed salvage, and the salvage pool" +
                $"gains {Mod.Config.Holdback.DisputePicks[0]}-{Mod.Config.Holdback.DisputePicks[1]} from the compensation offer.\n" +
                $"<line-indent=2px> - {100 - dispute.SuccessChance}% to lose the disputed salvage, and " +
                $"an additional {Mod.Config.Holdback.DisputePicks[0]}-{Mod.Config.Holdback.DisputePicks[1]} selections in the salvage pool.\n"
                )
                              .AddButton("Refuse", refuseAction, true, null)
                              .AddButton("Accept", acceptAction, true, null)
                              .AddButton("Dispute", disputeAction, true, null)
                              .Render();

            TextMeshProUGUI contentText = (TextMeshProUGUI)Traverse.Create(gp).Field("_contentText").GetValue();

            contentText.alignment = TextAlignmentOptions.Left;
        }
Beispiel #14
0
 public static void Postfix(AAR_SalvageScreen __instance, Contract ___contract)
 {
     Mod.Log.Debug("AAR_SS:CAAAS entered.");
 }
 public static bool HasAllPriority(AAR_SalvageChosen __instance, Contract ___contract, AAR_SalvageScreen ___parent, ref bool __result)
 {
     try
     {
         int negotiated = ___contract.FinalPrioritySalvageCount;
         int totalSalvageMadeAvailable = ___parent.TotalSalvageMadeAvailable;
         int count = __instance.PriorityInventory.Count;
         int num   = negotiated;
         if (num > totalSalvageMadeAvailable)
         {
             num = totalSalvageMadeAvailable;
         }
         if (num > 7)
         {
             num = 7;
         }
         LogDebug(string.Format("HasAllPriority :negotiated {0} :available {1} :selected {2} :clamped {3}", negotiated, totalSalvageMadeAvailable, count, num));
         __result = count >= num;
         return(false);
     } catch (Exception e)
     {
         LogException(e);
         return(true);
     }
 }