private void UpdateCache(Pawn pawn)
        {
            var isRoyal = pawn.royalty?.MostSeniorTitle != null;

            friendsShortCache         = isRoyal ? pawn.GetFriendsSeniorityInColony() / 100 : pawn.GetFriendsInColony();
            friendsRequiredShortCache = isRoyal ? (GuestUtility.RoyalFriendsSeniorityRequired(pawn) + pawn.GetRoyalEnemiesSeniorityInColony()) / 100 : GuestUtility.FriendsRequired(pawn.MapHeld) + pawn.GetEnemiesInColony();
        }
Beispiel #2
0
        public override void DoCell(Rect rect, Pawn pawn, PawnTable table)
        {
            if (!pawn.IsGuest())
            {
                return;
            }

            // Store cache
            friendsShortCache         = pawn.GetFriendsInColony();
            friendsRequiredShortCache = GuestUtility.FriendsRequired(pawn.MapHeld) + pawn.GetEnemiesInColony();

            base.DoCell(rect, pawn, table);

            // Use cache - only get comp when we have enough friends
            if (friendsShortCache >= friendsRequiredShortCache && MayRecruitAtAll(pawn))
            {
                var rect2 = rect;
                rect2.x -= 4;
                if (Widgets.ButtonText(rect2, txtRecruit))
                {
                    ITab_Pawn_Guest.RecruitDialog(pawn, false);
                }
            }
            else
            {
                base.DoCell(rect, pawn, table);
            }
        }
Beispiel #3
0
            public static void ShowWandererJoinDialog(Pawn pawn, IntVec3 spawnSpot, Map map)
            {
                // Added option to reject wanderer

                string textAsk = "WandererInitial".Translate(pawn.Faction.Name, pawn.GetTitle().ToLower(), GenText.ToCommaList(pawn.story.traits.allTraits.Select(t => t.Label)));

                textAsk = textAsk.AdjustedFor(pawn);
                PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref textAsk, pawn);
                DiaNode nodeAsk    = new DiaNode(textAsk);
                var     textAccept = "RescuedInitial_Accept".Translate();

                textAccept = textAccept.AdjustedFor(pawn);

                DiaOption optionAccept = new DiaOption(textAccept);

                optionAccept.action = () =>
                {
                    if (Find.WorldPawns.Contains(pawn))
                    {
                        Find.WorldPawns.RemovePawn(pawn);
                    }
                    GenSpawn.Spawn(pawn, spawnSpot, map);
                    if (pawn.Faction != Faction.OfPlayer)
                    {
                        if (pawn.Faction != null && pawn == pawn.Faction.leader)
                        {
                            pawn.Faction.GenerateNewLeader();
                        }
                        pawn.SetFaction(Faction.OfPlayer);
                    }

                    CameraJumper.TryJump(pawn);
                };
                optionAccept.resolveTree = true;
                nodeAsk.options.Add(optionAccept);

                var textReject = "RescuedInitial_Reject".Translate();

                textReject = textReject.AdjustedFor(pawn);

                DiaOption optionReject = new DiaOption(textReject);

                optionReject.action      = () => { GuestUtility.BreakupRelations(pawn); };
                optionReject.resolveTree = true;

                nodeAsk.options.Add(optionReject);
                Find.WindowStack.Add(new Dialog_NodeTree(nodeAsk, true));
            }
Beispiel #4
0
        private int GetValueToCompare(Pawn pawn)
        {
            // Can't use cache here

            // Changed check
            if (!pawn.IsGuest())
            {
                return(-2147483648);
            }

            friendsShortCache         = pawn.GetFriendsInColony();
            friendsRequiredShortCache = GuestUtility.FriendsRequired(pawn.MapHeld) + pawn.GetEnemiesInColony();

            if (friendsRequiredShortCache == 0)
            {
                return(-2147483648);
            }
            return((int)(100f * friendsShortCache / friendsRequiredShortCache));
        }