Beispiel #1
0
        public static bool HostileTo(this Thing a, Thing b)
        {
            if (a.Destroyed || b.Destroyed || a == b)
            {
                return(false);
            }
            Pawn pawn  = a as Pawn;
            Pawn pawn2 = b as Pawn;

            if ((pawn != null && pawn.MentalState != null && pawn.MentalState.ForceHostileTo(b)) || (pawn2 != null && pawn2.MentalState != null && pawn2.MentalState.ForceHostileTo(a)))
            {
                return(true);
            }
            if (pawn != null && pawn2 != null && (IsPredatorHostileTo(pawn, pawn2) || IsPredatorHostileTo(pawn2, pawn)))
            {
                return(true);
            }
            if ((a.Faction != null && pawn2 != null && pawn2.HostFaction == a.Faction && (pawn == null || pawn.HostFaction == null) && PrisonBreakUtility.IsPrisonBreaking(pawn2)) || (b.Faction != null && pawn != null && pawn.HostFaction == b.Faction && (pawn2 == null || pawn2.HostFaction == null) && PrisonBreakUtility.IsPrisonBreaking(pawn)))
            {
                return(true);
            }
            if ((a.Faction != null && pawn2 != null && pawn2.HostFaction == a.Faction) || (b.Faction != null && pawn != null && pawn.HostFaction == b.Faction))
            {
                return(false);
            }
            if (pawn != null && pawn.IsPrisoner && pawn2 != null && pawn2.IsPrisoner)
            {
                return(false);
            }
            if (pawn != null && pawn2 != null && ((pawn.IsPrisoner && pawn.HostFaction == pawn2.HostFaction && !PrisonBreakUtility.IsPrisonBreaking(pawn)) || (pawn2.IsPrisoner && pawn2.HostFaction == pawn.HostFaction && !PrisonBreakUtility.IsPrisonBreaking(pawn2))))
            {
                return(false);
            }
            if (pawn != null && pawn2 != null && ((pawn.HostFaction != null && pawn2.Faction != null && !pawn.HostFaction.HostileTo(pawn2.Faction) && !PrisonBreakUtility.IsPrisonBreaking(pawn)) || (pawn2.HostFaction != null && pawn.Faction != null && !pawn2.HostFaction.HostileTo(pawn.Faction) && !PrisonBreakUtility.IsPrisonBreaking(pawn2))))
            {
                return(false);
            }
            if ((a.Faction != null && a.Faction.IsPlayer && pawn2 != null && pawn2.mindState.WillJoinColonyIfRescued) || (b.Faction != null && b.Faction.IsPlayer && pawn != null && pawn.mindState.WillJoinColonyIfRescued))
            {
                return(false);
            }
            if ((pawn != null && pawn.Faction == null && pawn.RaceProps.Humanlike && b.Faction != null && b.Faction.def.hostileToFactionlessHumanlikes) || (pawn2 != null && pawn2.Faction == null && pawn2.RaceProps.Humanlike && a.Faction != null && a.Faction.def.hostileToFactionlessHumanlikes))
            {
                return(true);
            }
            if (a.Faction == null || b.Faction == null)
            {
                return(false);
            }
            return(a.Faction.HostileTo(b.Faction));
        }
Beispiel #2
0
        public static bool HostileTo(this Thing a, Thing b)
        {
            if (a.Destroyed || b.Destroyed || a == b)
            {
                return(false);
            }
            Pawn pawn  = a as Pawn;
            Pawn pawn2 = b as Pawn;

            return((pawn != null && pawn.MentalState != null && pawn.MentalState.ForceHostileTo(b)) || (pawn2 != null && pawn2.MentalState != null && pawn2.MentalState.ForceHostileTo(a)) || (pawn != null && pawn2 != null && (GenHostility.IsPredatorHostileTo(pawn, pawn2) || GenHostility.IsPredatorHostileTo(pawn2, pawn))) || ((a.Faction != null && pawn2 != null && pawn2.HostFaction == a.Faction && (pawn == null || pawn.HostFaction == null) && PrisonBreakUtility.IsPrisonBreaking(pawn2)) || (b.Faction != null && pawn != null && pawn.HostFaction == b.Faction && (pawn2 == null || pawn2.HostFaction == null) && PrisonBreakUtility.IsPrisonBreaking(pawn))) || ((a.Faction == null || pawn2 == null || pawn2.HostFaction != a.Faction) && (b.Faction == null || pawn == null || pawn.HostFaction != b.Faction) && (pawn == null || !pawn.IsPrisoner || pawn2 == null || !pawn2.IsPrisoner) && (pawn == null || pawn2 == null || ((!pawn.IsPrisoner || pawn.HostFaction != pawn2.HostFaction || PrisonBreakUtility.IsPrisonBreaking(pawn)) && (!pawn2.IsPrisoner || pawn2.HostFaction != pawn.HostFaction || PrisonBreakUtility.IsPrisonBreaking(pawn2)))) && (pawn == null || pawn2 == null || ((pawn.HostFaction == null || pawn2.Faction == null || pawn.HostFaction.HostileTo(pawn2.Faction) || PrisonBreakUtility.IsPrisonBreaking(pawn)) && (pawn2.HostFaction == null || pawn.Faction == null || pawn2.HostFaction.HostileTo(pawn.Faction) || PrisonBreakUtility.IsPrisonBreaking(pawn2)))) && a.Faction != null && b.Faction != null && a.Faction.HostileTo(b.Faction)));
        }
 public static bool CanParticipateInPrisonBreak(Pawn pawn)
 {
     return(!pawn.Downed && pawn.IsPrisoner && !PrisonBreakUtility.IsPrisonBreaking(pawn));
 }
Beispiel #4
0
 public void Notify_MemberTookDamage(Pawn member, DamageInfo dinfo)
 {
     if (dinfo.Instigator != null && !IsPlayer)
     {
         Pawn pawn = dinfo.Instigator as Pawn;
         if (pawn != null && pawn.CurJob != null && pawn.CurJob.def == JobDefOf.PredatorHunt)
         {
             TookDamageFromPredator(pawn);
         }
         if (dinfo.Instigator.Faction != null && dinfo.Def.ExternalViolenceFor(member) && !this.HostileTo(dinfo.Instigator.Faction) && !member.InAggroMentalState && (pawn == null || !pawn.InAggroMentalState) && (!member.InMentalState || !member.MentalStateDef.IsExtreme || member.MentalStateDef.category != MentalStateCategory.Malicious || PlayerRelationKind != FactionRelationKind.Ally) && (dinfo.Instigator.Faction != OfPlayer || (!PrisonBreakUtility.IsPrisonBreaking(member) && !member.IsQuestHelper())) && dinfo.Instigator.Faction == OfPlayer && !IsMutuallyHostileCrossfire(dinfo))
         {
             float num            = Mathf.Min(100f, dinfo.Amount);
             int   goodwillChange = (int)(-1.3f * num);
             TryAffectGoodwillWith(dinfo.Instigator.Faction, goodwillChange, canSendMessage: true, canSendHostilityLetter: true, "GoodwillChangedReason_AttackedPawn".Translate(member.LabelShort, member), member);
         }
     }
 }
        protected override void FillTab()
        {
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.PrisonerTab, KnowledgeAmount.FrameDisplayed);
            Text.Font = GameFont.Small;
            Rect             rect = new Rect(0f, 0f, size.x, size.y).ContractedBy(10f);
            bool             isPrisonerOfColony = base.SelPawn.IsPrisonerOfColony;
            bool             flag             = base.SelPawn.IsWildMan();
            Listing_Standard listing_Standard = new Listing_Standard();

            listing_Standard.maxOneColumn = true;
            listing_Standard.Begin(rect);
            Rect rect2 = listing_Standard.GetRect(28f);

            rect2.width = 140f;
            MedicalCareUtility.MedicalCareSetter(rect2, ref base.SelPawn.playerSettings.medCare);
            listing_Standard.Gap(4f);
            if (isPrisonerOfColony)
            {
                if (!flag)
                {
                    Rect rect3 = listing_Standard.Label("RecruitmentDifficulty".Translate() + ": " + base.SelPawn.RecruitDifficulty(Faction.OfPlayer).ToStringPercent());
                    if (base.SelPawn.royalty != null)
                    {
                        RoyalTitle title2 = base.SelPawn.royalty.MostSeniorTitle;
                        if (title2 != null && Mouse.IsOver(rect3))
                        {
                            string valueString = title2.def.recruitmentDifficultyOffset.ToStringByStyle(ToStringStyle.PercentOne, ToStringNumberSense.Offset);
                            TooltipHandler.TipRegion(rect3, () => "RecruitmentValueOffsetRoyal".Translate() + " (" + title2.def.GetLabelCapFor(base.SelPawn) + ")" + ": " + valueString, 947584751);
                            Widgets.DrawHighlight(rect3);
                        }
                    }
                    string value  = RecruitUtility.RecruitChanceFactorForRecruitDifficulty(base.SelPawn, Faction.OfPlayer).ToStringPercent();
                    string value2 = RecruitUtility.RecruitChanceFactorForMood(base.SelPawn).ToStringPercent();
                    string text   = base.SelPawn.RecruitChanceFinalByFaction(Faction.OfPlayer).ToStringPercent();
                    Rect   rect4  = listing_Standard.Label("RecruitmentChance".Translate() + ": " + text);
                    if (Mouse.IsOver(rect4))
                    {
                        string recruitmentChanceTooltip = null;
                        recruitmentChanceTooltip = "RecruitmentChanceExplanation".Translate(value, value2, text);
                        if (!base.SelPawn.guest.lastRecruiterName.NullOrEmpty())
                        {
                            recruitmentChanceTooltip += "RecruitmentChanceWithLastRecruiterExplanationPart".Translate().Formatted(value, value2, text, base.SelPawn.guest.lastRecruiterName, base.SelPawn.guest.lastRecruiterNegotiationAbilityFactor.ToStringPercent(), base.SelPawn.guest.lastRecruiterOpinionChanceFactor.ToStringPercent(), base.SelPawn.guest.hasOpinionOfLastRecruiter ? base.SelPawn.guest.lastRecruiterOpinion.ToStringWithSign() : "-", base.SelPawn.guest.lastRecruiterFinalChance.ToStringPercent(), base.SelPawn.guest.lastRecruiterResistanceReduce.ToString("0.0"));
                            if (base.SelPawn.guest.lastRecruiterResistanceReduce > 0f)
                            {
                                recruitmentChanceTooltip += "RecruitmentLastRecruiterResistanceReduceExplanationPart".Translate(base.SelPawn.guest.lastRecruiterResistanceReduce.ToString("0.0"));
                            }
                        }
                        TooltipHandler.TipRegion(rect4, () => recruitmentChanceTooltip, 947584753);
                    }
                    Widgets.DrawHighlightIfMouseover(rect4);
                    Rect rect5 = listing_Standard.Label("RecruitmentResistance".Translate() + ": " + base.SelPawn.guest.resistance.ToString("F1"));
                    if (base.SelPawn.royalty != null)
                    {
                        RoyalTitle title = base.SelPawn.royalty.MostSeniorTitle;
                        if (title != null && Mouse.IsOver(rect5))
                        {
                            TooltipHandler.TipRegion(rect5, delegate
                            {
                                StringBuilder stringBuilder = new StringBuilder();
                                if (title.def.recruitmentResistanceOffset != 1f)
                                {
                                    stringBuilder.AppendLine("RecruitmentValueFactorRoyal".Translate() + " (" + title.def.GetLabelCapFor(base.SelPawn) + ")" + ": " + title.def.recruitmentResistanceFactor.ToStringPercent());
                                }
                                if (title.def.recruitmentResistanceOffset != 0f)
                                {
                                    string t2 = title.def.recruitmentDifficultyOffset.ToStringByStyle(ToStringStyle.FloatMaxOne, ToStringNumberSense.Offset);
                                    stringBuilder.AppendLine("RecruitmentValueOffsetRoyal".Translate() + " (" + title.def.GetLabelCapFor(base.SelPawn) + ")" + ": " + t2);
                                }
                                return(stringBuilder.ToString().TrimEndNewlines());
                            }, 947584755);
                            Widgets.DrawHighlight(rect5);
                        }
                    }
                }
                listing_Standard.Label("SlavePrice".Translate() + ": " + base.SelPawn.GetStatValue(StatDefOf.MarketValue).ToStringMoney());
                TaggedString t;
                if (base.SelPawn.Faction == null || base.SelPawn.Faction.IsPlayer || !base.SelPawn.Faction.CanChangeGoodwillFor(Faction.OfPlayer, 1))
                {
                    t = "None".Translate();
                }
                else
                {
                    bool isHealthy;
                    int  goodwillGainForPrisonerRelease = base.SelPawn.Faction.GetGoodwillGainForPrisonerRelease(base.SelPawn, out isHealthy);
                    t = ((!isHealthy) ? ("None".Translate() + " (" + "UntendedInjury".Translate().ToLower() + ")") : (base.SelPawn.Faction.NameColored + " " + goodwillGainForPrisonerRelease.ToStringWithSign()));
                }
                TooltipHandler.TipRegionByKey(listing_Standard.Label("PrisonerReleasePotentialRelationGains".Translate() + ": " + t), "PrisonerReleaseRelationGainsDesc");
                if (base.SelPawn.guilt.IsGuilty)
                {
                    listing_Standard.Label("ConsideredGuilty".Translate(base.SelPawn.guilt.TicksUntilInnocent.ToStringTicksToPeriod().Colorize(ColoredText.DateTimeColor)));
                }
                int    num   = (int)PrisonBreakUtility.InitiatePrisonBreakMtbDays(base.SelPawn);
                string text2 = "PrisonBreakMTBDays".Translate() + ": ";
                text2 = ((!base.SelPawn.Awake()) ? ((string)(text2 + "NotWhileAsleep".Translate())) : ((num >= 0) ? (text2 + "PeriodDays".Translate(num).ToString().Colorize(ColoredText.DateTimeColor)) : ((string)(text2 + "Never".Translate()))));
                TooltipHandler.TipRegionByKey(listing_Standard.Label(text2), "PrisonBreakMTBDaysDescription");
                Rect rect6 = listing_Standard.GetRect(160f).Rounded();
                Widgets.DrawMenuSection(rect6);
                Rect position = rect6.ContractedBy(10f);
                GUI.BeginGroup(position);
                Rect rect7 = new Rect(0f, 0f, position.width, 30f);
                foreach (PrisonerInteractionModeDef item in DefDatabase <PrisonerInteractionModeDef> .AllDefs.OrderBy((PrisonerInteractionModeDef pim) => pim.listOrder))
                {
                    if (!flag || item.allowOnWildMan)
                    {
                        if (Widgets.RadioButtonLabeled(rect7, item.LabelCap, base.SelPawn.guest.interactionMode == item))
                        {
                            base.SelPawn.guest.interactionMode = item;
                            if (item == PrisonerInteractionModeDefOf.Execution && base.SelPawn.MapHeld != null && !ColonyHasAnyWardenCapableOfViolence(base.SelPawn.MapHeld))
                            {
                                Messages.Message("MessageCantDoExecutionBecauseNoWardenCapableOfViolence".Translate(), base.SelPawn, MessageTypeDefOf.CautionInput, historical: false);
                            }
                        }
                        rect7.y += 28f;
                    }
                }
                GUI.EndGroup();
            }
            listing_Standard.End();
            size = new Vector2(280f, listing_Standard.CurHeight + 10f + 24f);
        }
Beispiel #6
0
        public static bool HostileTo(this Thing t, Faction fac)
        {
            bool result;

            if (t.Destroyed)
            {
                result = false;
            }
            else
            {
                Pawn pawn = t as Pawn;
                if (pawn != null)
                {
                    MentalState mentalState = pawn.MentalState;
                    if (mentalState != null && mentalState.ForceHostileTo(fac))
                    {
                        return(true);
                    }
                    if (GenHostility.IsPredatorHostileTo(pawn, fac))
                    {
                        return(true);
                    }
                    if (pawn.HostFaction == fac && PrisonBreakUtility.IsPrisonBreaking(pawn))
                    {
                        return(true);
                    }
                    if (pawn.HostFaction == fac)
                    {
                        return(false);
                    }
                    if (pawn.HostFaction != null && !pawn.HostFaction.HostileTo(fac) && !PrisonBreakUtility.IsPrisonBreaking(pawn))
                    {
                        return(false);
                    }
                }
                result = (t.Faction != null && t.Faction.HostileTo(fac));
            }
            return(result);
        }
        protected override void FillTab()
        {
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.PrisonerTab, KnowledgeAmount.FrameDisplayed);
            Text.Font = GameFont.Small;
            Rect rect  = new Rect(0f, 0f, this.size.x, this.size.y);
            Rect rect2 = rect.ContractedBy(10f);

            rect2.yMin += 24f;
            bool             isPrisonerOfColony = base.SelPawn.IsPrisonerOfColony;
            Listing_Standard listing_Standard   = new Listing_Standard();

            listing_Standard.Begin(rect2);
            Rect rect3 = listing_Standard.GetRect(Text.LineHeight);

            rect3.width *= 0.75f;
            bool getsFood = base.SelPawn.guest.GetsFood;

            Widgets.CheckboxLabeled(rect3, "GetsFood".Translate(), ref getsFood, false);
            base.SelPawn.guest.GetsFood = getsFood;
            listing_Standard.Gap(12f);
            Rect rect4 = listing_Standard.GetRect(28f);

            rect4.width = 140f;
            MedicalCareUtility.MedicalCareSetter(rect4, ref base.SelPawn.playerSettings.medCare);
            listing_Standard.Gap(4f);
            if (isPrisonerOfColony)
            {
                listing_Standard.Label("RecruitmentDifficulty".Translate() + ": " + base.SelPawn.RecruitDifficulty(Faction.OfPlayer, false).ToStringPercent(), -1f);
                if (base.SelPawn.guilt.IsGuilty)
                {
                    listing_Standard.Label("ConsideredGuilty".Translate(new object[]
                    {
                        base.SelPawn.guilt.TicksUntilInnocent.ToStringTicksToPeriod(true, false, true)
                    }), -1f);
                }
                if (Prefs.DevMode)
                {
                    listing_Standard.Label("Dev: Prison break MTB days: " + (int)PrisonBreakUtility.InitiatePrisonBreakMtbDays(base.SelPawn), -1f);
                }
                Rect rect5 = listing_Standard.GetRect(200f).Rounded();
                Widgets.DrawMenuSection(rect5);
                Rect position = rect5.ContractedBy(10f);
                GUI.BeginGroup(position);
                Rect rect6 = new Rect(0f, 0f, position.width, 30f);
                foreach (PrisonerInteractionModeDef current in from pim in DefDatabase <PrisonerInteractionModeDef> .AllDefs
                         orderby pim.listOrder
                         select pim)
                {
                    if (Widgets.RadioButtonLabeled(rect6, current.LabelCap, base.SelPawn.guest.interactionMode == current))
                    {
                        base.SelPawn.guest.interactionMode = current;
                        if (current == PrisonerInteractionModeDefOf.Execution && base.SelPawn.MapHeld != null && !this.ColonyHasAnyWardenCapableOfViolence(base.SelPawn.MapHeld))
                        {
                            Messages.Message("MessageCantDoExecutionBecauseNoWardenCapableOfViolence".Translate(), base.SelPawn, MessageTypeDefOf.CautionInput);
                        }
                    }
                    rect6.y += 28f;
                }
                GUI.EndGroup();
            }
            listing_Standard.End();
        }