Exemplo n.º 1
0
 private void SetAreaShopping(Area area)
 {
     foreach (var pawn in SelPawn.GetLord().ownedPawns)
     {
         pawn.GetComp <CompGuest>().ShoppingArea = area;
     }
 }
Exemplo n.º 2
0
 private void SetAreaRestriction(Area area)
 {
     foreach (var pawn in SelPawn.GetLord().ownedPawns)
     {
         pawn.GetComp <CompGuest>().GuestArea = area;
     }
 }
Exemplo n.º 3
0
        private void FillTabGuest(Listing_Standard listingStandard, Rect rect)
        {
            //ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.PrisonerTab, KnowledgeAmount.GuiFrame);

            var trust = SelPawn.RelativeTrust();

            {
                var tryImprove = SelPawn.ImproveRelationship();
                var tryRecruit = SelPawn.TryRecruit();

                listingStandard.ColumnWidth = size.x - 20;

                var comp = SelPawn.GetComp <CompGuest>();
                if (comp != null)
                {
                    listingStandard.Gap();

                    CheckboxLabeled(listingStandard, "ImproveRelationship".Translate(), ref tryImprove);
                    CheckboxLabeled(listingStandard, "ShouldTryToRecruit".Translate(), ref tryRecruit);

                    comp.chat    = tryImprove;
                    comp.recruit = tryRecruit;

                    listingStandard.Gap(50);

                    DrawSetDefaultButton(rect);
                }

                if (SelPawn.Faction != null)
                {
                    listingStandard.Label(txtRecruitmentPenalty + ": " + SelPawn.RecruitPenalty().ToString("##0"));
                    listingStandard.Label(txtFactionGoodwill + ": " + SelPawn.Faction.PlayerGoodwill.ToString("##0"));
                }
                listingStandard.Gap();

                // Will only have squadBrain while "checked in", becomes null again when guests leave
                var squadBrain = SelPawn.GetLord();
                if (squadBrain != null)
                {
                    listingStandard.Label(string.Format("{0}:", txtRecruitmentChance));
                    listingStandard.Slider(Mathf.Clamp(trust, 0, 100), 0, 100);
                    if (trust < 50)
                    {
                        var color = GUI.color;
                        GUI.color = Color.red;
                        listingStandard.Label("TrustTooLow".Translate().AdjustedFor(SelPawn));
                        GUI.color = color;
                    }

                    var lordToil = squadBrain.CurLordToil as LordToil_VisitPoint;
                    if (lordToil != null && SelPawn.Faction != null)
                    {
                        listingStandard.Label(txtHospitality + ":");
                        listingStandard.Slider(lordToil.GetVisitScore(SelPawn), 0f, 1f);
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void DrawSendHomeButton(Rect rect)
        {
            rect = new Rect(rect.xMax - sendHomeButtonSize.x - 20f - setDefaultButtonSize.x, 110f, sendHomeButtonSize.x, sendHomeButtonSize.y);
            if (Widgets.ButtonText(rect, txtSendAway))
            {
                SoundDefOf.DesignateDragStandardChanged.PlayOneShotOnCamera();

                SendHomeDialog(SelPawn.GetLord());
            }
        }
Exemplo n.º 5
0
        private void DoAreaRestriction(Listing_Standard listingStandard, CompGuest comp)
        {
            var areaRect = listingStandard.GetRect(24);

            if (SelPawn.playerSettings == null)
            {
                var savedArea = comp.GuestArea;
                SelPawn.playerSettings = new Pawn_PlayerSettings(SelPawn)
                {
                    AreaRestriction = savedArea
                };
            }

            var oldArea = SelPawn.playerSettings.AreaRestriction = comp.GuestArea;

            AreaAllowedGUI.DoAllowedAreaSelectors(areaRect, SelPawn, AllowedAreaMode.Humanlike);
            Text.Anchor = TextAnchor.UpperLeft;

            if (SelPawn.playerSettings.AreaRestriction != oldArea)
            {
                SetAreaRestriction(SelPawn.GetLord(), SelPawn.playerSettings.AreaRestriction);
            }
        }
Exemplo n.º 6
0
        private void FillTabGuest(Rect rect)
        {
            //ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.PrisonerTab, KnowledgeAmount.GuiFrame);
            var title            = SelPawn.royalty?.MostSeniorTitle;
            var isRoyal          = title != null;
            var friends          = isRoyal ? SelPawn.GetFriendsSeniorityInColony() : SelPawn.GetFriendsInColony();
            var friendsRequired  = isRoyal ? RequiredSeniority : RequiredFriends;
            var friendPercentage = 100f * friends / friendsRequired;


            var tryImprove     = SelPawn.ImproveRelationship();
            var tryMakeFriends = SelPawn.MakeFriends();

            listingStandard.ColumnWidth = size.x - 20;

            var comp = SelPawn.GetComp <CompGuest>();

            // If the lord is not on the map it's invalid!
            if (comp?.lord != null && comp.lord.ownedPawns.Contains(SelPawn) && SelPawn.Map.lordManager.lords.Contains(comp.lord))
            {
                listingStandard.Gap();
                string labelStay     = "AreaToStay".Translate();
                string labelBuy      = "AreaToBuy".Translate();
                var    rectStayLabel = listingStandard.GetRect(Text.CalcHeight(labelStay, listingStandard.ColumnWidth));
                var    rectStay      = listingStandard.GetRect(24);
                var    rectBuyLabel  = listingStandard.GetRect(Text.CalcHeight(labelBuy, listingStandard.ColumnWidth));
                var    rectBuy       = listingStandard.GetRect(24);

                LabelWithTooltip(labelStay, "AreaToStayTooltip".Translate(), rectStayLabel);
                GenericUtility.DoAreaRestriction(SelPawn, rectStay, comp.GuestArea, SetAreaRestriction, AreaUtility.AreaAllowedLabel_Area);
                LabelWithTooltip(labelBuy, "AreaToBuyTooltip".Translate(), rectBuyLabel);
                GenericUtility.DoAreaRestriction(SelPawn, rectBuy, comp.ShoppingArea, SetAreaShopping, GenericUtility.GetShoppingLabel);

                var rectImproveRelationship = listingStandard.GetRect(Text.LineHeight);
                CheckboxLabeled(listingStandard, "ImproveRelationship".Translate(), ref tryImprove, rectImproveRelationship, false, txtImproveTooltip);
                var rectMakeFriends = listingStandard.GetRect(Text.LineHeight);
                CheckboxLabeled(listingStandard, "MakeFriends".Translate(), ref tryMakeFriends, rectMakeFriends, false, txtMakeFriendsTooltip);

                comp.SetEntertain(tryImprove);
                comp.SetMakeFriends(tryMakeFriends);

                listingStandard.Gap(50);

                var mayRecruitAtAll = !SelPawn.InMentalState && comp.arrived;

                var rectSetDefault = new Rect(rect.xMax - buttonSize.x - 10, 160, buttonSize.x, buttonSize.y);
                var rectSendHome   = new Rect(rect.xMin - 10, 160, buttonSize.x, buttonSize.y);
                DrawButton(() => SetAllDefaults(SelPawn), txtMakeDefault, rectSetDefault, txtMakeDefaultTooltip);
                DrawButton(() => SendHomeDialog(SelPawn.GetLord()), txtSendAway, rectSendHome, txtSendAwayTooltip);
                if (mayRecruitAtAll)
                {
                    var rectRecruitButton = new Rect(rect.xMin - 10 + 10 + buttonSize.x, 160, buttonSize.x, buttonSize.y);
                    if (friends >= friendsRequired)
                    {
                        DrawButton(() => RecruitDialog(SelPawn, false), txtRecruit, rectRecruitButton, txtRecruitTooltip);
                    }
                    else if (!isRoyal)
                    {
                        DrawButton(() => RecruitDialog(SelPawn, true), txtForceRecruit, rectRecruitButton, txtForceRecruitTooltip);
                    }
                }

                // Highlight defaults
                if (Mouse.IsOver(rectSetDefault))
                {
                    Widgets.DrawHighlight(rectStay);
                    Widgets.DrawHighlight(rectStayLabel);
                    Widgets.DrawHighlight(rectBuy);
                    Widgets.DrawHighlight(rectBuyLabel);
                    Widgets.DrawHighlight(rectImproveRelationship);
                    Widgets.DrawHighlight(rectMakeFriends);
                }
            }

            if (SelPawn.Faction != null)
            {
                listingStandard.Label(txtRecruitmentPenalty.Translate(SelPawn.RecruitPenalty().ToString("##0"), SelPawn.ForcedRecruitPenalty().ToString("##0")));
                listingStandard.Label(txtFactionGoodwill + ": " + SelPawn.Faction.PlayerGoodwill.ToString("##0"));
            }

            listingStandard.Gap();

            if (isRoyal)
            {
                listingStandard.Label($"{"SeniorityRequirement".Translate(friends / 100, friendsRequired / 100)}:");
            }
            else
            {
                listingStandard.Label($"{"FriendsRequirement".Translate(friends, friendsRequired)}:");
            }

            listingStandard.Slider(Mathf.Clamp(friendPercentage, 0, 100), 0, 100);
            if (friendPercentage <= 99)
            {
                // Remove color from AdjustedFor and then Colorize
                listingStandard.Label(ColoredText.StripTags("NotEnoughFriends".Translate(SelPawn.GetMinRecruitOpinion()).AdjustedFor(SelPawn)).Colorize(Color.red));
            }
            else
            {
                listingStandard.Label("CanNowBeRecruited".Translate().AdjustedFor(SelPawn));
            }


            // Will only have score while "checked in", becomes 0 again when guest leaves
            if (SelPawn.GetVisitScore(out var score))
            {
                listingStandard.Label(txtHospitality + ":");
                listingStandard.Slider(score, 0f, 1f);
            }
        }
Exemplo n.º 7
0
        private void FillTabGuest(Rect rect)
        {
            //ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.PrisonerTab, KnowledgeAmount.GuiFrame);

            var   friends          = SelPawn.GetFriendsInColony();
            var   friendsRequired  = GuestUtility.FriendsRequired(SelPawn.MapHeld) + SelPawn.GetEnemiesInColony();
            float friendPercentage = 100f * friends / friendsRequired;

            {
                var mayBuy     = SelPawn.MayBuy();
                var tryImprove = SelPawn.ImproveRelationship();
                var tryRecruit = SelPawn.TryRecruit();

                listingStandard.ColumnWidth = size.x - 20;

                var comp = SelPawn.GetComp <CompGuest>();
                if (comp != null)
                {
                    listingStandard.Gap();

                    DoAreaRestriction(listingStandard, comp);

                    CheckboxLabeled(listingStandard, "MayBuy".Translate(), ref mayBuy);
                    CheckboxLabeled(listingStandard, "ImproveRelationship".Translate(), ref tryImprove);

                    CheckboxLabeled(listingStandard, "ShouldTryToRecruit".Translate(), ref tryRecruit);

                    comp.mayBuy  = mayBuy;
                    comp.chat    = tryImprove;
                    comp.recruit = tryRecruit;

                    listingStandard.Gap(50);

                    DrawSetDefaultButton(rect);
                    DrawSendHomeButton(rect);
                }

                if (SelPawn.Faction != null)
                {
                    listingStandard.Label(txtRecruitmentPenalty + ": " + SelPawn.RecruitPenalty().ToString("##0"));
                    listingStandard.Label(txtFactionGoodwill + ": " + SelPawn.Faction.PlayerGoodwill.ToString("##0"));
                }
                listingStandard.Gap();

                listingStandard.Label(string.Format("{0}:", "FriendsRequirement".Translate(friends, friendsRequired)));

                listingStandard.Slider(Mathf.Clamp(friendPercentage, 0, 100), 0, 100);
                if (friendPercentage <= 99)
                {
                    var color = GUI.color;
                    GUI.color = Color.red;
                    listingStandard.Label("NotEnoughFriends".Translate(SelPawn.GetMinRecruitOpinion()).AdjustedFor(SelPawn));
                    GUI.color = color;
                }
                else
                {
                    listingStandard.Label("CanNowBeRecruited".Translate().AdjustedFor(SelPawn));
                }


                // Will only have squadBrain while "checked in", becomes null again when guests leave
                var squadBrain = SelPawn.GetLord();
                if (squadBrain != null)
                {
                    var lordToil = squadBrain.CurLordToil as LordToil_VisitPoint;
                    if (lordToil != null && SelPawn.Faction != null)
                    {
                        listingStandard.Label(txtHospitality + ":");
                        listingStandard.Slider(lordToil.GetVisitScore(SelPawn), 0f, 1f);
                    }
                }
            }
        }