public static DiaNode RebuffNode()
        {
            TravelingIncidentCaravan caravan = DialogUtilities.tempCaravan;
            Pawn pawn = DialogUtilities.tempPawn;
            InterceptedIncident_HumanCrowd_RaidEnemy incident = caravan.incident as InterceptedIncident_HumanCrowd_RaidEnemy;

            if (incident == null)
            {
                return(null);
            }
            if (incident.raidGoalType == RaidGoalType.Smite)
            {
                return(null);
            }
            StringBuilder sb = new StringBuilder("PES_RaidNeg_Rebuff_Confirmation".Translate());

            sb.AppendLine();
            if (incident.raidGoalType == RaidGoalType.Rescue)
            {
                Log.Message(incident.raidGoalType.ToString());
                sb.AppendLine("PES_RaidNeg_Rebuff_Confirmation_Rescue".Translate());
                RaidingGoal_Rescue goal = incident.goal as RaidingGoal_Rescue;
                foreach (var p in goal.Prisoners)
                {
                    sb.AppendLine("    " + p.Name.ToStringShort);
                }
            }
            sb.AppendLine();
            sb.Append(@"<i>");
            sb.Append("PES_RaidNeg_Rebuff_Explanation".Translate(pawn.Name.ToStringShort));
            sb.Append(@"</i>");
            DiaNode diaNode = new DiaNode(sb.ToString());

            void rebuffAction()
            {
                RaidingGoalUtility.RebuffDemandAndSmiteThePlayer(caravan, pawn);
            }

            DiaOption option = new DiaOption("PES_SimpleConfirm".Translate());

            option.action      = rebuffAction;
            option.resolveTree = true;
            //if (pawn.story.WorkTagIsDisabled(WorkTags.Violent))	//Lt. Bob: 1.1 - Replaced with below
            if (pawn.WorkTagIsDisabled(WorkTags.Violent))                       //Lt. Bob: 1.1
            {
                option.Disable("PES_RaidNeg_Rebuff_Rescue_Fail".Translate());
            }
            diaNode.options.Add(option);
            diaNode.options.Add(DialogUtilities.CurtOption("PES_Cancel", null, null, true));
            return(diaNode);
        }
Exemple #2
0
        public static DiaNode NegotiateDeepNode()
        {
            TravelingIncidentCaravan caravan = DialogUtilities.tempCaravan;
            Pawn pawn = DialogUtilities.tempPawn;
            InterceptedIncident_HumanCrowd_RaidEnemy incident = caravan.incident as InterceptedIncident_HumanCrowd_RaidEnemy;
            RaidingGoal goal = incident.goal;

            if (incident == null)
            {
                return(null);
            }
            if (incident.raidGoalType == RaidGoalType.Smite)
            {
                return(null);
            }

            DiaNode       diaNode = new DiaNode("PES_RaidNeg_NegDeeper_Prolog".Translate());
            DiaOption     option;
            StringBuilder sb;
            string        failReason;

            //surrender
            option = new DiaOption("PES_RaidNeg_NegDeeper_Surrender".Translate() + "\n");
            if (!goal.IsAchievable(out failReason))
            {
                option.disabled       = true;
                option.disabledReason = failReason;
            }
            else
            {
                DiaNode surrenderConfirmation()
                {
                    DiaNode cnode = new DiaNode("PES_RaidNeg_NegDeeper_Surrender_Comfirmation".Translate());

                    cnode.options.Add(DialogUtilities.CurtOption("PES_SimpleConfirm", null, () => { goal.Achieve(); }, true));
                    cnode.options.Add(DialogUtilities.CurtOption("PES_Cancel", null, null, true));
                    return(cnode);
                }

                option.link = surrenderConfirmation();
            }
            diaNode.options.Add(option);

            //bargain
            option = new DiaOption("PES_RaidNeg_NegDeeper_Bargain".Translate() + "\n");
            if (!goal.CanBargain(out failReason))
            {
                option.disabled       = true;
                option.disabledReason = failReason;
            }
            else if (caravan.negotiateCoolDownTick > 0)
            {
                option.Disable("PES_RaidNeg_NegCoolDown".Translate(GenDate.ToStringTicksToPeriod(caravan.negotiateCoolDownTick)));
            }
            else
            {
                DiaNode BargainNode()
                {
                    DiaNode bNode = new DiaNode("PES_RaidNeg_NegDeeper_Bargain_Intro".Translate());

                    foreach (var x in goal.BargainChoices())
                    {
                        bNode.options.Add(x);
                    }
                    bNode.options.Add(DialogUtilities.CurtOption("PES_Cancel", null, null, true));
                    return(bNode);
                }

                option.link = BargainNode();
            }
            diaNode.options.Add(option);

            //Remedy
            option = new DiaOption("PES_RaidNeg_NegDeeper_Remedy".Translate());
            if (caravan.negotiateCoolDownTick > 0)
            {
                option.Disable("PES_RaidNeg_NegCoolDown".Translate(GenDate.ToStringTicksToPeriod(caravan.negotiateCoolDownTick)));
            }
            else
            {
                DiaNode RemedyNode()
                {
                    DiaNode   rNode = new DiaNode("PES_RaidNeg_Sub_Intro".Translate());
                    DiaOption rOption;

                    if (incident.raidGoalType != RaidGoalType.Rescue)
                    {
                        rOption = new DiaOption("PES_RaidNeg_Sub_Rescue".Translate());
                        if (!RaidingGoal_Rescue.IsAvailableToIncident(incident, out failReason))
                        {
                            rOption.Disable(failReason);
                        }
                        rOption.link = RemedyDetail(() => { (new RaidingGoal_Rescue()).ApplyToIncident(incident); });
                        rNode.options.Add(rOption);
                    }

                    if (incident.raidGoalType != RaidGoalType.Extortion)
                    {
                        rOption      = new DiaOption("PES_RaidNeg_Sub_Extortion".Translate());
                        rOption.link = RemedyDetail(() => { (new RaidingGoal_Extortion()).ApplyToIncident(incident); });
                        rNode.options.Add(rOption);
                        rNode.options.Add(DialogUtilities.CurtOption("PES_Cancel", null, null, true));
                    }
                    rNode.options.Add(DialogUtilities.CurtOption("PES_Cancel", null, null, true));
                    return(rNode);
                }

                option.link = RemedyNode();
            }
            diaNode.options.Add(option);

            diaNode.options.Add(DialogUtilities.CurtOption("PES_Cancel", null, null, true));

            return(diaNode);
        }