コード例 #1
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();
        }
コード例 #2
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();
        }
コード例 #3
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();
        }