public void FinishCeremony(Pawn pawn)
        {
            lord.ReceiveMemo("CeremonyFinished");
            RoyalTitleDef currentTitle             = target.royalty.GetCurrentTitle(bestower.Faction);
            RoyalTitleDef titleAwardedWhenUpdating = target.royalty.GetTitleAwardedWhenUpdating(bestower.Faction, target.royalty.GetFavor(bestower.Faction));

            Pawn_RoyaltyTracker.MakeLetterTextForTitleChange(target, bestower.Faction, currentTitle, titleAwardedWhenUpdating, out var headline, out var body);
            if (pawn.royalty != null)
            {
                pawn.royalty.TryUpdateTitle_NewTemp(bestower.Faction, sendLetter: false, titleAwardedWhenUpdating);
            }
            Hediff_Psylink     mainPsylinkSource  = target.GetMainPsylinkSource();
            List <AbilityDef>  abilitiesPreUpdate = ((mainPsylinkSource == null) ? new List <AbilityDef>() : pawn.abilities.abilities.Select((Ability a) => a.def).ToList());
            ThingOwner <Thing> innerContainer     = bestower.inventory.innerContainer;

            for (int i = pawn.GetPsylinkLevel(); i < pawn.GetMaxPsylinkLevelByTitle(); i++)
            {
                for (int num = innerContainer.Count - 1; num >= 0; num--)
                {
                    if (innerContainer[num].def == ThingDefOf.PsychicAmplifier)
                    {
                        Thing thing = innerContainer[num];
                        innerContainer.RemoveAt(num);
                        thing.Destroy();
                        break;
                    }
                }
                pawn.ChangePsylinkLevel(1, sendLetter: false);
            }
            mainPsylinkSource = target.GetMainPsylinkSource();
            List <AbilityDef> newAbilities = ((mainPsylinkSource == null) ? new List <AbilityDef>() : (from a in pawn.abilities.abilities
                                                                                                       select a.def into def
                                                                                                       where !abilitiesPreUpdate.Contains(def)
                                                                                                       select def).ToList());
            string str = headline;

            str = str + "\n\n" + Hediff_Psylink.MakeLetterTextNewPsylinkLevel(target, pawn.GetPsylinkLevel(), newAbilities);
            str = str + "\n\n" + body;
            Find.LetterStack.ReceiveLetter("LetterLabelGainedRoyalTitle".Translate(titleAwardedWhenUpdating.GetLabelCapFor(pawn).Named("TITLE"), pawn.Named("PAWN")), str, LetterDefOf.PositiveEvent, pawn, bestower.Faction);
        }
예제 #2
0
        public static DiaNode FactionDialogFor(Pawn negotiator, Faction faction)
        {
            Map    map = negotiator.Map;
            Pawn   pawn;
            string value;

            if (faction.leader != null)
            {
                pawn  = faction.leader;
                value = faction.leader.Name.ToStringFull.Colorize(ColoredText.NameColor);
            }
            else
            {
                Log.Error("Faction " + faction + " has no leader.");
                pawn  = negotiator;
                value = faction.Name;
            }
            DiaNode root;

            if (faction.PlayerRelationKind == FactionRelationKind.Hostile)
            {
                string key = (faction.def.permanentEnemy || !"FactionGreetingHostileAppreciative".CanTranslate()) ? "FactionGreetingHostile" : "FactionGreetingHostileAppreciative";
                root = new DiaNode(key.Translate(value).AdjustedFor(pawn));
            }
            else if (faction.PlayerRelationKind == FactionRelationKind.Neutral)
            {
                root = new DiaNode("FactionGreetingWary".Translate(value, negotiator.LabelShort, negotiator.Named("NEGOTIATOR"), pawn.Named("LEADER")).AdjustedFor(pawn));
            }
            else
            {
                root = new DiaNode("FactionGreetingWarm".Translate(value, negotiator.LabelShort, negotiator.Named("NEGOTIATOR"), pawn.Named("LEADER")).AdjustedFor(pawn));
            }
            if (map != null && map.IsPlayerHome)
            {
                AddAndDecorateOption(RequestTraderOption(map, faction, negotiator), needsSocial: true);
                AddAndDecorateOption(RequestMilitaryAidOption(map, faction, negotiator), needsSocial: true);
                Pawn_RoyaltyTracker royalty = negotiator.royalty;
                if (royalty != null && royalty.HasAnyTitleIn(faction))
                {
                    foreach (RoyalTitle item in royalty.AllTitlesInEffectForReading)
                    {
                        if (item.def.permits != null)
                        {
                            foreach (RoyalTitlePermitDef permit in item.def.permits)
                            {
                                IEnumerable <DiaOption> factionCommDialogOptions = permit.Worker.GetFactionCommDialogOptions(map, negotiator, faction);
                                if (factionCommDialogOptions != null)
                                {
                                    foreach (DiaOption item2 in factionCommDialogOptions)
                                    {
                                        AddAndDecorateOption(item2, needsSocial: true);
                                    }
                                }
                            }
                        }
                    }
                    if (royalty.GetCurrentTitle(faction).canBeInherited&& !negotiator.IsQuestLodger())
                    {
                        AddAndDecorateOption(RequestRoyalHeirChangeOption(map, faction, pawn, negotiator), needsSocial: false);
                    }
                }
                if (DefDatabase <ResearchProjectDef> .AllDefsListForReading.Any((ResearchProjectDef rp) => rp.HasTag(ResearchProjectTagDefOf.ShipRelated) && rp.IsFinished))
                {
                    AddAndDecorateOption(RequestAICoreQuest(map, faction, negotiator), needsSocial: true);
                }
            }
            if (Prefs.DevMode)
            {
                foreach (DiaOption item3 in DebugOptions(faction, negotiator))
                {
                    AddAndDecorateOption(item3, needsSocial: false);
                }
            }
            AddAndDecorateOption(new DiaOption("(" + "Disconnect".Translate() + ")")
            {
                resolveTree = true
            }, needsSocial: false);
            return(root);

            void AddAndDecorateOption(DiaOption opt, bool needsSocial)
            {
                if (needsSocial && negotiator.skills.GetSkill(SkillDefOf.Social).TotallyDisabled)
                {
                    opt.Disable("WorkTypeDisablesOption".Translate(SkillDefOf.Social.label));
                }
                root.options.Add(opt);
            }
        }