コード例 #1
0
 public override void Interacted(Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks, out string letterText, out string letterLabel, out LetterDef letterDef, out LookTargets lookTargets)
 {
     if (Rand.Value < SuccessChance(initiator, recipient))
     {
         BreakLoverAndFianceRelations(initiator, out List <Pawn> oldLoversAndFiances);
         BreakLoverAndFianceRelations(recipient, out List <Pawn> oldLoversAndFiances2);
         for (int i = 0; i < oldLoversAndFiances.Count; i++)
         {
             TryAddCheaterThought(oldLoversAndFiances[i], initiator);
         }
         for (int j = 0; j < oldLoversAndFiances2.Count; j++)
         {
             TryAddCheaterThought(oldLoversAndFiances2[j], recipient);
         }
         initiator.relations.TryRemoveDirectRelation(PawnRelationDefOf.ExLover, recipient);
         initiator.relations.AddDirectRelation(PawnRelationDefOf.Lover, recipient);
         TaleRecorder.RecordTale(TaleDefOf.BecameLover, initiator, recipient);
         if (initiator.needs.mood != null)
         {
             initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.BrokeUpWithMe, recipient);
             initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.FailedRomanceAttemptOnMe, recipient);
             initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.FailedRomanceAttemptOnMeLowOpinionMood, recipient);
         }
         if (recipient.needs.mood != null)
         {
             recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.BrokeUpWithMe, initiator);
             recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.FailedRomanceAttemptOnMe, initiator);
             recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.FailedRomanceAttemptOnMeLowOpinionMood, initiator);
         }
         if (PawnUtility.ShouldSendNotificationAbout(initiator) || PawnUtility.ShouldSendNotificationAbout(recipient))
         {
             GetNewLoversLetter(initiator, recipient, oldLoversAndFiances, oldLoversAndFiances2, out letterText, out letterLabel, out letterDef, out lookTargets);
         }
         else
         {
             letterText  = null;
             letterLabel = null;
             letterDef   = null;
             lookTargets = null;
         }
         extraSentencePacks.Add(RulePackDefOf.Sentence_RomanceAttemptAccepted);
         LovePartnerRelationUtility.TryToShareBed(initiator, recipient);
     }
     else
     {
         if (initiator.needs.mood != null)
         {
             initiator.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.RebuffedMyRomanceAttempt, recipient);
         }
         if (recipient.needs.mood != null)
         {
             recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.FailedRomanceAttemptOnMe, initiator);
         }
         if (recipient.needs.mood != null && recipient.relations.OpinionOf(initiator) <= 0)
         {
             recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.FailedRomanceAttemptOnMeLowOpinionMood, initiator);
         }
         extraSentencePacks.Add(RulePackDefOf.Sentence_RomanceAttemptRejected);
         letterText  = null;
         letterLabel = null;
         letterDef   = null;
         lookTargets = null;
     }
 }
コード例 #2
0
 private static string <PopIntentRecruitDifficulty> m__5(float d, float pi)
 {
     return(PawnUtility.PopIntentAdjustedRecruitDifficulty(d, pi).ToStringPercent());
 }
コード例 #3
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            bool result;

            if (parms.target is Map)
            {
                result = IncidentDefOf.TravelerGroup.Worker.TryExecute(parms);
            }
            else
            {
                Caravan caravan = (Caravan)parms.target;
                Faction faction;
                if (!this.TryFindFaction(out faction))
                {
                    result = false;
                }
                else
                {
                    CameraJumper.TryJumpAndSelect(caravan);
                    List <Pawn> pawns      = this.GenerateCaravanPawns(faction);
                    Caravan     metCaravan = CaravanMaker.MakeCaravan(pawns, faction, -1, false);
                    string      text       = "CaravanMeeting".Translate(new object[]
                    {
                        caravan.Name,
                        faction.Name,
                        PawnUtility.PawnKindsToCommaList(metCaravan.PawnsListForReading, true)
                    }).CapitalizeFirst();
                    DiaNode diaNode = new DiaNode(text);
                    Pawn    bestPlayerNegotiator = BestCaravanPawnUtility.FindBestNegotiator(caravan);
                    if (metCaravan.CanTradeNow)
                    {
                        DiaOption diaOption = new DiaOption("CaravanMeeting_Trade".Translate());
                        diaOption.action = delegate()
                        {
                            Find.WindowStack.Add(new Dialog_Trade(bestPlayerNegotiator, metCaravan, false));
                            PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter_Send(metCaravan.Goods.OfType <Pawn>(), "LetterRelatedPawnsTradingWithOtherCaravan".Translate(new object[]
                            {
                                Faction.OfPlayer.def.pawnsPlural
                            }), LetterDefOf.NeutralEvent, false, true);
                        };
                        if (bestPlayerNegotiator == null)
                        {
                            diaOption.Disable("CaravanMeeting_TradeIncapable".Translate());
                        }
                        diaNode.options.Add(diaOption);
                    }
                    DiaOption diaOption2 = new DiaOption("CaravanMeeting_Attack".Translate());
                    diaOption2.action = delegate()
                    {
                        LongEventHandler.QueueLongEvent(delegate()
                        {
                            Pawn t                   = caravan.PawnsListForReading[0];
                            Faction faction2         = faction;
                            Faction ofPlayer         = Faction.OfPlayer;
                            FactionRelationKind kind = FactionRelationKind.Hostile;
                            string reason            = "GoodwillChangedReason_AttackedCaravan".Translate();
                            faction2.TrySetRelationKind(ofPlayer, kind, true, reason, new GlobalTargetInfo?(t));
                            Map map = CaravanIncidentUtility.GetOrGenerateMapForIncident(caravan, new IntVec3(100, 1, 100), WorldObjectDefOf.AttackedNonPlayerCaravan);
                            IntVec3 playerSpot;
                            IntVec3 enemySpot;
                            MultipleCaravansCellFinder.FindStartingCellsFor2Groups(map, out playerSpot, out enemySpot);
                            CaravanEnterMapUtility.Enter(caravan, map, (Pawn p) => CellFinder.RandomClosewalkCellNear(playerSpot, map, 12, null), CaravanDropInventoryMode.DoNotDrop, true);
                            List <Pawn> list = metCaravan.PawnsListForReading.ToList <Pawn>();
                            CaravanEnterMapUtility.Enter(metCaravan, map, (Pawn p) => CellFinder.RandomClosewalkCellNear(enemySpot, map, 12, null), CaravanDropInventoryMode.DoNotDrop, false);
                            LordMaker.MakeNewLord(faction, new LordJob_DefendAttackedTraderCaravan(list[0].Position), map, list);
                            Find.TickManager.CurTimeSpeed = TimeSpeed.Paused;
                            CameraJumper.TryJumpAndSelect(t);
                            PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter_Send(list, "LetterRelatedPawnsGroupGeneric".Translate(new object[]
                            {
                                Faction.OfPlayer.def.pawnsPlural
                            }), LetterDefOf.NeutralEvent, true, true);
                        }, "GeneratingMapForNewEncounter", false, null);
                    };
                    diaOption2.resolveTree = true;
                    diaNode.options.Add(diaOption2);
                    DiaOption diaOption3 = new DiaOption("CaravanMeeting_MoveOn".Translate());
                    diaOption3.action = delegate()
                    {
                        this.RemoveAllPawnsAndPassToWorld(metCaravan);
                    };
                    diaOption3.resolveTree = true;
                    diaNode.options.Add(diaOption3);
                    string text2 = "CaravanMeetingTitle".Translate(new object[]
                    {
                        caravan.Label
                    });
                    WindowStack windowStack        = Find.WindowStack;
                    DiaNode     nodeRoot           = diaNode;
                    Faction     faction3           = faction;
                    bool        delayInteractivity = true;
                    string      title = text2;
                    windowStack.Add(new Dialog_NodeTreeWithFactionInfo(nodeRoot, faction3, delayInteractivity, false, title));
                    Find.Archive.Add(new ArchivedDialog(diaNode.text, text2, faction));
                    result = true;
                }
            }
            return(result);
        }
コード例 #4
0
 public static float GetBaseManhunterOnDamageChance(Pawn pawn)
 {
     return(PawnUtility.GetBaseManhunterOnDamageChance(pawn.kindDef));
 }
コード例 #5
0
 public static float GetManhunterOnDamageChance(PawnKindDef kind)
 {
     return(PawnUtility.GetBaseManhunterOnDamageChance(kind) * Find.Storyteller.difficulty.manhunterChanceOnDamageFactor);
 }
コード例 #6
0
 public static bool AnyPawnBlockingPathAt(IntVec3 c, Pawn forPawn, bool actAsIfHadCollideWithPawnsJob = false, bool collideOnlyWithStandingPawns = false, bool forPathFinder = false)
 {
     return(PawnUtility.PawnBlockingPathAt(c, forPawn, actAsIfHadCollideWithPawnsJob, collideOnlyWithStandingPawns, forPathFinder) != null);
 }
コード例 #7
0
        public static bool ShouldSendNotificationAbout(Pawn p)
        {
            bool result;

            if (Current.ProgramState != ProgramState.Playing)
            {
                result = false;
            }
            else if (PawnGenerator.IsBeingGenerated(p))
            {
                result = false;
            }
            else if (p.IsWorldPawn() && (!p.IsCaravanMember() || !p.GetCaravan().IsPlayerControlled) && !PawnUtility.IsTravelingInTransportPodWorldObject(p) && p.Corpse.DestroyedOrNull())
            {
                result = false;
            }
            else
            {
                if (p.Faction != Faction.OfPlayer)
                {
                    if (p.HostFaction != Faction.OfPlayer)
                    {
                        return(false);
                    }
                    if (p.RaceProps.Humanlike && p.guest.Released && !p.Downed && !p.InBed())
                    {
                        return(false);
                    }
                    if (p.CurJob != null && p.CurJob.exitMapOnArrival && !PrisonBreakUtility.IsPrisonBreaking(p))
                    {
                        return(false);
                    }
                }
                result = true;
            }
            return(result);
        }
コード例 #8
0
        public static Pawn PawnBlockingPathAt(IntVec3 c, Pawn forPawn, bool actAsIfHadCollideWithPawnsJob = false, bool collideOnlyWithStandingPawns = false)
        {
            List <Thing> thingList = c.GetThingList(forPawn.Map);

            if (thingList.Count == 0)
            {
                return(null);
            }
            bool flag = false;

            if (actAsIfHadCollideWithPawnsJob)
            {
                flag = true;
            }
            else
            {
                Job curJob = forPawn.CurJob;
                if (curJob != null && (curJob.collideWithPawns || curJob.def.collideWithPawns))
                {
                    flag = true;
                }
                else if (forPawn.Drafted && forPawn.pather.Moving)
                {
                    flag = true;
                }
            }
            for (int i = 0; i < thingList.Count; i++)
            {
                Pawn pawn = thingList[i] as Pawn;
                if (pawn != null && pawn != forPawn && !pawn.Downed && (!collideOnlyWithStandingPawns || (!pawn.pather.MovingNow && (!pawn.pather.Moving || !pawn.pather.MovedRecently(60)))) && !PawnUtility.PawnsCanShareCellBecauseOfBodySize(pawn, forPawn))
                {
                    if (pawn.HostileTo(forPawn))
                    {
                        return(pawn);
                    }
                    if (flag)
                    {
                        Job curJob2 = pawn.CurJob;
                        if (curJob2 != null && (curJob2.collideWithPawns || curJob2.def.collideWithPawns))
                        {
                            return(pawn);
                        }
                    }
                }
            }
            return(null);
        }
コード例 #9
0
        public static void DoTable_PopIntentRecruitDifficulty()
        {
            List <float> list = new List <float>();

            for (float num = -1f; num < 3.0; num = (float)(num + 0.10000000149011612))
            {
                list.Add(num);
            }
            List <float> list2 = new List <float>();

            list2.Add(0.1f);
            list2.Add(0.2f);
            list2.Add(0.3f);
            list2.Add(0.4f);
            list2.Add(0.5f);
            list2.Add(0.6f);
            list2.Add(0.7f);
            list2.Add(0.8f);
            list2.Add(0.9f);
            list2.Add(0.95f);
            list2.Add(0.99f);
            List <float> colValues = list2;

            DebugTables.MakeTablesDialog(colValues, (float d) => "d=" + d.ToString("F0"), list, (float rv) => rv.ToString("F1"), (float d, float pi) => PawnUtility.PopIntentAdjustedRecruitDifficulty(d, pi).ToStringPercent(), "intents");
        }
コード例 #10
0
        public static bool TryDevelopBondRelation(Pawn humanlike, Pawn animal, float baseChance)
        {
            if (!animal.RaceProps.Animal)
            {
                return(false);
            }
            if (animal.RaceProps.trainability.intelligenceOrder < TrainabilityDefOf.Intermediate.intelligenceOrder)
            {
                return(false);
            }
            if (humanlike.relations.DirectRelationExists(PawnRelationDefOf.Bond, animal))
            {
                return(false);
            }
            if (animal.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Bond, (Pawn x) => x.Spawned) != null)
            {
                return(false);
            }
            int num = 0;
            List <DirectPawnRelation> directRelations = animal.relations.DirectRelations;

            for (int i = 0; i < directRelations.Count; i++)
            {
                if (directRelations[i].def == PawnRelationDefOf.Bond && !directRelations[i].otherPawn.Dead)
                {
                    num++;
                }
            }
            int num2 = 0;
            List <DirectPawnRelation> directRelations2 = humanlike.relations.DirectRelations;

            for (int j = 0; j < directRelations2.Count; j++)
            {
                if (directRelations2[j].def == PawnRelationDefOf.Bond && !directRelations2[j].otherPawn.Dead)
                {
                    num2++;
                }
            }
            if (num > 0)
            {
                baseChance *= Mathf.Pow(0.2f, (float)num);
            }
            if (num2 > 0)
            {
                baseChance *= Mathf.Pow(0.55f, (float)num2);
            }
            if (Rand.Value < baseChance)
            {
                if (!humanlike.story.traits.HasTrait(TraitDefOf.Psychopath))
                {
                    humanlike.relations.AddDirectRelation(PawnRelationDefOf.Bond, animal);
                }
                if (humanlike.Faction == Faction.OfPlayer || animal.Faction == Faction.OfPlayer)
                {
                    TaleRecorder.RecordTale(TaleDefOf.BondedWithAnimal, new object[]
                    {
                        humanlike,
                        animal
                    });
                }
                bool   flag  = false;
                string value = null;
                if (animal.Name == null || animal.Name.Numerical)
                {
                    flag        = true;
                    value       = ((animal.Name != null) ? animal.Name.ToStringFull : animal.LabelIndefinite());
                    animal.Name = PawnBioAndNameGenerator.GeneratePawnName(animal, NameStyle.Full, null);
                }
                if (PawnUtility.ShouldSendNotificationAbout(humanlike) || PawnUtility.ShouldSendNotificationAbout(animal))
                {
                    string text;
                    if (flag)
                    {
                        text = "MessageNewBondRelationNewName".Translate(humanlike.LabelShort, value, animal.Name.ToStringFull, humanlike.Named("HUMAN"), animal.Named("ANIMAL")).AdjustedFor(animal, "PAWN").CapitalizeFirst();
                    }
                    else
                    {
                        text = "MessageNewBondRelation".Translate(humanlike.LabelShort, animal.LabelShort, humanlike.Named("HUMAN"), animal.Named("ANIMAL")).CapitalizeFirst();
                    }
                    Messages.Message(text, humanlike, MessageTypeDefOf.PositiveEvent, true);
                }
                return(true);
            }
            return(false);
        }
コード例 #11
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            if (parms.target is Map)
            {
                return(IncidentDefOf.TravelerGroup.Worker.TryExecute(parms));
            }
            Caravan caravan = (Caravan)parms.target;

            if (!TryFindFaction(out Faction faction))
            {
                return(false);
            }
            List <Pawn> list = GenerateCaravanPawns(faction);

            if (!list.Any())
            {
                Log.Error("IncidentWorker_CaravanMeeting could not generate any pawns.");
                return(false);
            }
            Caravan metCaravan = CaravanMaker.MakeCaravan(list, faction, -1, addToWorldPawnsIfNotAlready: false);

            CameraJumper.TryJumpAndSelect(caravan);
            DiaNode diaNode = new DiaNode((string)"CaravanMeeting".Translate(caravan.Name, faction.Name, PawnUtility.PawnKindsToLineList(metCaravan.PawnsListForReading.Select((Pawn x) => x.kindDef), "  - ")).CapitalizeFirst());
            Pawn    bestPlayerNegotiator = BestCaravanPawnUtility.FindBestNegotiator(caravan, faction, metCaravan.TraderKind);

            if (metCaravan.CanTradeNow)
            {
                DiaOption diaOption = new DiaOption("CaravanMeeting_Trade".Translate());
                diaOption.action = delegate
                {
                    Find.WindowStack.Add(new Dialog_Trade(bestPlayerNegotiator, metCaravan));
                    PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter_Send(metCaravan.Goods.OfType <Pawn>(), "LetterRelatedPawnsTradingWithOtherCaravan".Translate(Faction.OfPlayer.def.pawnsPlural), LetterDefOf.NeutralEvent);
                };
                if (bestPlayerNegotiator == null)
                {
                    if (metCaravan.TraderKind.permitRequiredForTrading != null && !caravan.pawns.Any((Pawn p) => p.royalty != null && p.royalty.HasPermit(metCaravan.TraderKind.permitRequiredForTrading, faction)))
                    {
                        RoyalTitleDef royalTitleDef = faction.def.RoyalTitlesAwardableInSeniorityOrderForReading.First((RoyalTitleDef t) => t.permits != null && t.permits.Contains(metCaravan.TraderKind.permitRequiredForTrading));
                        diaOption.Disable("CaravanMeeting_NoPermit".Translate(royalTitleDef.GetLabelForBothGenders(), faction).Resolve());
                    }
                    else
                    {
                        diaOption.Disable("CaravanMeeting_TradeIncapable".Translate());
                    }
                }
                diaNode.options.Add(diaOption);
            }
            DiaOption diaOption2 = new DiaOption("CaravanMeeting_Attack".Translate());

            diaOption2.action = delegate
            {
                LongEventHandler.QueueLongEvent(delegate
                {
                    Pawn t2 = caravan.PawnsListForReading[0];
                    faction.TrySetRelationKind(Faction.OfPlayer, FactionRelationKind.Hostile, canSendLetter: true, "GoodwillChangedReason_AttackedCaravan".Translate(), t2);
                    Map map            = CaravanIncidentUtility.GetOrGenerateMapForIncident(caravan, new IntVec3(100, 1, 100), WorldObjectDefOf.AttackedNonPlayerCaravan);
                    IntVec3 playerSpot = default(IntVec3);
                    IntVec3 enemySpot  = default(IntVec3);
                    MultipleCaravansCellFinder.FindStartingCellsFor2Groups(map, out playerSpot, out enemySpot);
                    CaravanEnterMapUtility.Enter(caravan, map, (Pawn p) => CellFinder.RandomClosewalkCellNear(playerSpot, map, 12), CaravanDropInventoryMode.DoNotDrop, draftColonists: true);
                    List <Pawn> list2 = metCaravan.PawnsListForReading.ToList();
                    CaravanEnterMapUtility.Enter(metCaravan, map, (Pawn p) => CellFinder.RandomClosewalkCellNear(enemySpot, map, 12));
                    LordMaker.MakeNewLord(faction, new LordJob_DefendAttackedTraderCaravan(list2[0].Position), map, list2);
                    Find.TickManager.Notify_GeneratedPotentiallyHostileMap();
                    CameraJumper.TryJumpAndSelect(t2);
                    PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter_Send(list2, "LetterRelatedPawnsGroupGeneric".Translate(Faction.OfPlayer.def.pawnsPlural), LetterDefOf.NeutralEvent, informEvenIfSeenBefore: true);
                }, "GeneratingMapForNewEncounter", doAsynchronously: false, null);
            };
            diaOption2.resolveTree = true;
            diaNode.options.Add(diaOption2);
            DiaOption diaOption3 = new DiaOption("CaravanMeeting_MoveOn".Translate());

            diaOption3.action = delegate
            {
                RemoveAllPawnsAndPassToWorld(metCaravan);
            };
            diaOption3.resolveTree = true;
            diaNode.options.Add(diaOption3);
            string title = "CaravanMeetingTitle".Translate(caravan.Label);

            Find.WindowStack.Add(new Dialog_NodeTreeWithFactionInfo(diaNode, faction, delayInteractivity: true, radioMode: false, title));
            Find.Archive.Add(new ArchivedDialog(diaNode.text, title, faction));
            return(true);
        }
コード例 #12
0
 public override void PostIngested(Pawn ingester)
 {
     if (this.Props.Addictive && ingester.RaceProps.IsFlesh)
     {
         HediffDef        addictionHediffDef = this.Props.chemical.addictionHediff;
         Hediff_Addiction hediff_Addiction   = AddictionUtility.FindAddictionHediff(ingester, this.Props.chemical);
         Hediff           hediff             = AddictionUtility.FindToleranceHediff(ingester, this.Props.chemical);
         float            num = (hediff == null) ? 0f : hediff.Severity;
         if (hediff_Addiction != null)
         {
             hediff_Addiction.Severity += this.Props.existingAddictionSeverityOffset;
         }
         else if (Rand.Value < this.Props.addictiveness)
         {
             if (num >= this.Props.minToleranceToAddict)
             {
                 ingester.health.AddHediff(addictionHediffDef, null, null, null);
                 if (PawnUtility.ShouldSendNotificationAbout(ingester))
                 {
                     Find.LetterStack.ReceiveLetter("LetterLabelNewlyAddicted".Translate(new object[]
                     {
                         this.Props.chemical.label
                     }).CapitalizeFirst(), "LetterNewlyAddicted".Translate(new object[]
                     {
                         ingester.LabelShort,
                         this.Props.chemical.label
                     }).AdjustedFor(ingester, "PAWN").CapitalizeFirst(), LetterDefOf.NegativeEvent, ingester, null, null);
                 }
                 AddictionUtility.CheckDrugAddictionTeachOpportunity(ingester);
             }
         }
         if (addictionHediffDef.causesNeed != null)
         {
             Need need = ingester.needs.AllNeeds.Find((Need x) => x.def == addictionHediffDef.causesNeed);
             if (need != null)
             {
                 float needLevelOffset = this.Props.needLevelOffset;
                 AddictionUtility.ModifyChemicalEffectForToleranceAndBodySize(ingester, this.Props.chemical, ref needLevelOffset);
                 need.CurLevel += needLevelOffset;
             }
         }
         Hediff firstHediffOfDef = ingester.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.DrugOverdose, false);
         float  num2             = (firstHediffOfDef == null) ? 0f : firstHediffOfDef.Severity;
         if (num2 < 0.9f && Rand.Value < this.Props.largeOverdoseChance)
         {
             float num3 = Rand.Range(0.85f, 0.99f);
             HealthUtility.AdjustSeverity(ingester, HediffDefOf.DrugOverdose, num3 - num2);
             if (ingester.Faction == Faction.OfPlayer)
             {
                 Messages.Message("MessageAccidentalOverdose".Translate(new object[]
                 {
                     ingester.LabelIndefinite(),
                     this.parent.LabelNoCount
                 }).CapitalizeFirst(), ingester, MessageTypeDefOf.NegativeHealthEvent, true);
             }
         }
         else
         {
             float num4 = this.Props.overdoseSeverityOffset.RandomInRange / ingester.BodySize;
             if (num4 > 0f)
             {
                 HealthUtility.AdjustSeverity(ingester, HediffDefOf.DrugOverdose, num4);
             }
         }
     }
     if (this.Props.isCombatEnhancingDrug && !ingester.Dead)
     {
         ingester.mindState.lastTakeCombatEnhancingDrugTick = Find.TickManager.TicksGame;
     }
     if (ingester.drugs != null)
     {
         ingester.drugs.Notify_DrugIngested(this.parent);
     }
 }
コード例 #13
0
 public static bool FianceReadyToStartCeremony(Pawn pawn)
 {
     return(MarriageCeremonyUtility.FianceCanContinueCeremony(pawn) && pawn.health.hediffSet.BleedRateTotal <= 0f && !HealthAIUtility.ShouldSeekMedicalRestUrgent(pawn) && !PawnUtility.WillSoonHaveBasicNeed(pawn) && !MarriageCeremonyUtility.IsCurrentlyMarryingSomeone(pawn) && pawn.GetLord() == null && (!pawn.Drafted && !pawn.InMentalState && pawn.Awake() && !pawn.IsBurning()) && !pawn.InBed());
 }
コード例 #14
0
        public override void Interacted(Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks, out string letterText, out string letterLabel, out LetterDef letterDef)
        {
            float num   = this.AcceptanceChance(initiator, recipient);
            bool  flag  = Rand.Value < num;
            bool  flag2 = false;

            if (flag)
            {
                initiator.relations.RemoveDirectRelation(PawnRelationDefOf.Lover, recipient);
                initiator.relations.AddDirectRelation(PawnRelationDefOf.Fiance, recipient);
                initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.RejectedMyProposal, recipient);
                recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.RejectedMyProposal, initiator);
                initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.RejectedMyProposalMood, recipient);
                recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.RejectedMyProposalMood, initiator);
                initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.IRejectedTheirProposal, recipient);
                recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.IRejectedTheirProposal, initiator);
                extraSentencePacks.Add(RulePackDefOf.Sentence_MarriageProposalAccepted);
            }
            else
            {
                initiator.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.RejectedMyProposal, recipient);
                recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.IRejectedTheirProposal, initiator);
                extraSentencePacks.Add(RulePackDefOf.Sentence_MarriageProposalRejected);
                if (Rand.Value < 0.4f)
                {
                    initiator.relations.RemoveDirectRelation(PawnRelationDefOf.Lover, recipient);
                    initiator.relations.AddDirectRelation(PawnRelationDefOf.ExLover, recipient);
                    flag2 = true;
                    extraSentencePacks.Add(RulePackDefOf.Sentence_MarriageProposalRejectedBrokeUp);
                }
            }
            if (PawnUtility.ShouldSendNotificationAbout(initiator) || PawnUtility.ShouldSendNotificationAbout(recipient))
            {
                StringBuilder stringBuilder = new StringBuilder();
                if (flag)
                {
                    letterLabel = "LetterLabelAcceptedProposal".Translate();
                    letterDef   = LetterDefOf.PositiveEvent;
                    stringBuilder.AppendLine("LetterAcceptedProposal".Translate(new object[]
                    {
                        initiator,
                        recipient
                    }));
                }
                else
                {
                    letterLabel = "LetterLabelRejectedProposal".Translate();
                    letterDef   = LetterDefOf.NegativeEvent;
                    stringBuilder.AppendLine("LetterRejectedProposal".Translate(new object[]
                    {
                        initiator,
                        recipient
                    }));
                    if (flag2)
                    {
                        stringBuilder.AppendLine();
                        stringBuilder.AppendLine("LetterNoLongerLovers".Translate(new object[]
                        {
                            initiator,
                            recipient
                        }));
                    }
                }
                letterText = stringBuilder.ToString().TrimEndNewlines();
            }
            else
            {
                letterLabel = null;
                letterText  = null;
                letterDef   = null;
            }
        }
コード例 #15
0
        private static void AppendThoughts_ForHumanlike(Pawn victim, DamageInfo?dinfo, PawnDiedOrDownedThoughtsKind thoughtsKind, List <IndividualThoughtToAdd> outIndividualThoughts, List <ThoughtToAddToAll> outAllColonistsThoughts)
        {
            bool flag  = dinfo.HasValue && dinfo.Value.Def.execution;
            bool flag2 = victim.IsPrisonerOfColony && !victim.guilt.IsGuilty && !victim.InAggroMentalState;

            if (dinfo.HasValue && dinfo.Value.Def.ExternalViolenceFor(victim) && dinfo.Value.Instigator != null && dinfo.Value.Instigator is Pawn)
            {
                Pawn pawn = (Pawn)dinfo.Value.Instigator;
                if (!pawn.Dead && pawn.needs.mood != null && pawn.story != null && pawn != victim)
                {
                    if (thoughtsKind == PawnDiedOrDownedThoughtsKind.Died)
                    {
                        outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.KilledHumanlikeBloodlust, pawn));
                    }
                    if (thoughtsKind == PawnDiedOrDownedThoughtsKind.Died && victim.HostileTo(pawn) && victim.Faction != null && PawnUtility.IsFactionLeader(victim) && victim.Faction.HostileTo(pawn.Faction))
                    {
                        outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.DefeatedHostileFactionLeader, pawn, victim));
                    }
                }
            }
            if (thoughtsKind == PawnDiedOrDownedThoughtsKind.Died && !flag)
            {
                foreach (Pawn item in PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive)
                {
                    if (item != victim && item.needs != null && item.needs.mood != null && (item.MentalStateDef != MentalStateDefOf.SocialFighting || ((MentalState_SocialFighting)item.MentalState).otherPawn != victim))
                    {
                        if (Witnessed(item, victim))
                        {
                            bool flag3 = item.Faction == Faction.OfPlayer && victim.IsQuestLodger();
                            if (item.Faction == victim.Faction && !flag3)
                            {
                                outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.WitnessedDeathAlly, item));
                            }
                            else if ((victim.Faction == null || !victim.Faction.HostileTo(item.Faction)) | flag3)
                            {
                                outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.WitnessedDeathNonAlly, item));
                            }
                            if (item.relations.FamilyByBlood.Contains(victim))
                            {
                                outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.WitnessedDeathFamily, item));
                            }
                            outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.WitnessedDeathBloodlust, item));
                        }
                        else if (victim.Faction == Faction.OfPlayer && victim.Faction == item.Faction && victim.HostFaction != item.Faction && !victim.IsQuestLodger())
                        {
                            outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.KnowColonistDied, item, victim));
                        }
                        if (flag2 && item.Faction == Faction.OfPlayer && !item.IsPrisoner)
                        {
                            outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.KnowPrisonerDiedInnocent, item, victim));
                        }
                    }
                }
            }
            if (thoughtsKind == PawnDiedOrDownedThoughtsKind.Banished && victim.IsColonist)
            {
                outAllColonistsThoughts.Add(new ThoughtToAddToAll(ThoughtDefOf.ColonistBanished, victim));
            }
            if (thoughtsKind == PawnDiedOrDownedThoughtsKind.BanishedToDie)
            {
                if (victim.IsColonist)
                {
                    outAllColonistsThoughts.Add(new ThoughtToAddToAll(ThoughtDefOf.ColonistBanishedToDie, victim));
                }
                else if (victim.IsPrisonerOfColony)
                {
                    outAllColonistsThoughts.Add(new ThoughtToAddToAll(ThoughtDefOf.PrisonerBanishedToDie, victim));
                }
            }
            if (thoughtsKind == PawnDiedOrDownedThoughtsKind.Lost && victim.IsColonist && !victim.IsQuestLodger())
            {
                outAllColonistsThoughts.Add(new ThoughtToAddToAll(ThoughtDefOf.ColonistLost, victim));
            }
        }
コード例 #16
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            if (!TryFindSpawnSpot(map, out IntVec3 spawnSpot))
            {
                return(false);
            }
            if (!TryFindEnemyFaction(out Faction enemyFac))
            {
                return(false);
            }
            int           @int      = Rand.Int;
            IncidentParms raidParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, map);

            raidParms.forced             = true;
            raidParms.faction            = enemyFac;
            raidParms.raidStrategy       = RaidStrategyDefOf.ImmediateAttack;
            raidParms.raidArrivalMode    = PawnsArrivalModeDefOf.EdgeWalkIn;
            raidParms.spawnCenter        = spawnSpot;
            raidParms.points             = Mathf.Max(raidParms.points * RaidPointsFactorRange.RandomInRange, enemyFac.def.MinPointsToGeneratePawnGroup(PawnGroupKindDefOf.Combat));
            raidParms.pawnGroupMakerSeed = @int;
            PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, raidParms);

            defaultPawnGroupMakerParms.points = IncidentWorker_Raid.AdjustedRaidPoints(defaultPawnGroupMakerParms.points, raidParms.raidArrivalMode, raidParms.raidStrategy, defaultPawnGroupMakerParms.faction, PawnGroupKindDefOf.Combat);
            IEnumerable <PawnKindDef> pawnKinds = PawnGroupMakerUtility.GeneratePawnKindsExample(defaultPawnGroupMakerParms);
            PawnGenerationRequest     request   = new PawnGenerationRequest(PawnKindDefOf.SpaceRefugee, null, PawnGenerationContext.NonPlayer, -1, forceGenerateNewPawn: false, newborn: false, allowDead: false, allowDowned: false, canGeneratePawnRelations: true, mustBeCapableOfViolence: false, 20f);
            Pawn refugee = PawnGenerator.GeneratePawn(request);

            refugee.relations.everSeenByPlayer = true;
            string text = "RefugeeChasedInitial".Translate(refugee.Name.ToStringFull, refugee.story.Title, enemyFac.def.pawnsPlural, enemyFac.Name, refugee.ageTracker.AgeBiologicalYears, PawnUtility.PawnKindsToCommaList(pawnKinds, useAnd: true), refugee.Named("PAWN"));

            text = text.AdjustedFor(refugee);
            PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, refugee);
            DiaNode   diaNode   = new DiaNode(text);
            DiaOption diaOption = new DiaOption("RefugeeChasedInitial_Accept".Translate());

            diaOption.action = delegate
            {
                GenSpawn.Spawn(refugee, spawnSpot, map);
                refugee.SetFaction(Faction.OfPlayer);
                CameraJumper.TryJump(refugee);
                QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDefOf.RaidEnemy, null, raidParms), Find.TickManager.TicksGame + RaidDelay.RandomInRange);
                Find.Storyteller.incidentQueue.Add(qi);
            };
            diaOption.resolveTree = true;
            diaNode.options.Add(diaOption);
            string    text2      = "RefugeeChasedRejected".Translate(refugee.LabelShort, refugee);
            DiaNode   diaNode2   = new DiaNode(text2);
            DiaOption diaOption2 = new DiaOption("OK".Translate());

            diaOption2.resolveTree = true;
            diaNode2.options.Add(diaOption2);
            DiaOption diaOption3 = new DiaOption("RefugeeChasedInitial_Reject".Translate());

            diaOption3.action = delegate
            {
                Find.WorldPawns.PassToWorld(refugee);
            };
            diaOption3.link = diaNode2;
            diaNode.options.Add(diaOption3);
            string title = "RefugeeChasedTitle".Translate(map.Parent.Label);

            Find.WindowStack.Add(new Dialog_NodeTreeWithFactionInfo(diaNode, enemyFac, delayInteractivity: true, radioMode: true, title));
            Find.Archive.Add(new ArchivedDialog(diaNode.text, title, enemyFac));
            return(true);
        }
コード例 #17
0
        private static void AppendThoughts_Relations(Pawn victim, DamageInfo?dinfo, PawnDiedOrDownedThoughtsKind thoughtsKind, List <IndividualThoughtToAdd> outIndividualThoughts, List <ThoughtToAddToAll> outAllColonistsThoughts)
        {
            if (thoughtsKind == PawnDiedOrDownedThoughtsKind.Banished && victim.RaceProps.Animal)
            {
                List <DirectPawnRelation> directRelations = victim.relations.DirectRelations;
                for (int i = 0; i < directRelations.Count; i++)
                {
                    if (directRelations[i].otherPawn.needs != null && directRelations[i].otherPawn.needs.mood != null && PawnUtility.ShouldGetThoughtAbout(directRelations[i].otherPawn, victim) && directRelations[i].def == PawnRelationDefOf.Bond)
                    {
                        outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.BondedAnimalBanished, directRelations[i].otherPawn, victim));
                    }
                }
            }
            if (thoughtsKind != 0 && thoughtsKind != PawnDiedOrDownedThoughtsKind.BanishedToDie && thoughtsKind != PawnDiedOrDownedThoughtsKind.Lost)
            {
                return;
            }
            bool flag = thoughtsKind == PawnDiedOrDownedThoughtsKind.Lost;

            foreach (Pawn potentiallyRelatedPawn in victim.relations.PotentiallyRelatedPawns)
            {
                if (potentiallyRelatedPawn.needs != null && potentiallyRelatedPawn.needs.mood != null && PawnUtility.ShouldGetThoughtAbout(potentiallyRelatedPawn, victim))
                {
                    PawnRelationDef mostImportantRelation = potentiallyRelatedPawn.GetMostImportantRelation(victim);
                    if (mostImportantRelation != null)
                    {
                        ThoughtDef thoughtDef = flag ? mostImportantRelation.GetGenderSpecificLostThought(victim) : mostImportantRelation.GetGenderSpecificDiedThought(victim);
                        if (thoughtDef != null)
                        {
                            outIndividualThoughts.Add(new IndividualThoughtToAdd(thoughtDef, potentiallyRelatedPawn, victim));
                        }
                    }
                }
            }
            if (dinfo.HasValue && thoughtsKind != PawnDiedOrDownedThoughtsKind.Lost)
            {
                Pawn pawn = dinfo.Value.Instigator as Pawn;
                if (pawn != null && pawn != victim)
                {
                    foreach (Pawn potentiallyRelatedPawn2 in victim.relations.PotentiallyRelatedPawns)
                    {
                        if (pawn != potentiallyRelatedPawn2 && potentiallyRelatedPawn2.needs != null && potentiallyRelatedPawn2.needs.mood != null)
                        {
                            PawnRelationDef mostImportantRelation2 = potentiallyRelatedPawn2.GetMostImportantRelation(victim);
                            if (mostImportantRelation2 != null)
                            {
                                ThoughtDef genderSpecificKilledThought = mostImportantRelation2.GetGenderSpecificKilledThought(victim);
                                if (genderSpecificKilledThought != null)
                                {
                                    outIndividualThoughts.Add(new IndividualThoughtToAdd(genderSpecificKilledThought, potentiallyRelatedPawn2, pawn));
                                }
                            }
                            if (potentiallyRelatedPawn2.RaceProps.IsFlesh)
                            {
                                int num = potentiallyRelatedPawn2.relations.OpinionOf(victim);
                                if (num >= 20)
                                {
                                    outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.KilledMyFriend, potentiallyRelatedPawn2, pawn, 1f, victim.relations.GetFriendDiedThoughtPowerFactor(num)));
                                }
                                else if (num <= -20)
                                {
                                    outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.KilledMyRival, potentiallyRelatedPawn2, pawn, 1f, victim.relations.GetRivalDiedThoughtPowerFactor(num)));
                                }
                            }
                        }
                    }
                }
            }
            ThoughtDef thoughtDef2 = (thoughtsKind == PawnDiedOrDownedThoughtsKind.Lost) ? ThoughtDefOf.PawnWithGoodOpinionLost : ThoughtDefOf.PawnWithGoodOpinionDied;
            ThoughtDef thoughtDef3 = (thoughtsKind == PawnDiedOrDownedThoughtsKind.Lost) ? ThoughtDefOf.PawnWithBadOpinionLost : ThoughtDefOf.PawnWithBadOpinionDied;

            if (victim.RaceProps.Humanlike)
            {
                foreach (Pawn item in PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive)
                {
                    if (item.needs != null && item.RaceProps.IsFlesh && item.needs.mood != null && PawnUtility.ShouldGetThoughtAbout(item, victim))
                    {
                        int num2 = item.relations.OpinionOf(victim);
                        if (num2 >= 20)
                        {
                            outIndividualThoughts.Add(new IndividualThoughtToAdd(thoughtDef2, item, victim, victim.relations.GetFriendDiedThoughtPowerFactor(num2)));
                        }
                        else if (num2 <= -20)
                        {
                            outIndividualThoughts.Add(new IndividualThoughtToAdd(thoughtDef3, item, victim, victim.relations.GetRivalDiedThoughtPowerFactor(num2)));
                        }
                    }
                }
            }
        }
コード例 #18
0
            internal bool <> m__0(Thing t)
            {
                Pawn pawn = t as Pawn;

                return(!pawn.Downed && pawn.CanCasuallyInteractNow(false) && !pawn.IsForbidden(this.pawn) && pawn.Faction == this.pawn.Faction && PawnUtility.FertileMateTarget(this.pawn, pawn));
            }
コード例 #19
0
        public static Pawn PawnBlockingPathAt(IntVec3 c, Pawn forPawn, bool actAsIfHadCollideWithPawnsJob = false, bool collideOnlyWithStandingPawns = false, bool forPathFinder = false)
        {
            List <Thing> thingList = c.GetThingList(forPawn.Map);
            Pawn         result;

            if (thingList.Count == 0)
            {
                result = null;
            }
            else
            {
                bool flag = false;
                if (actAsIfHadCollideWithPawnsJob)
                {
                    flag = true;
                }
                else
                {
                    Job curJob = forPawn.CurJob;
                    if (curJob != null && (curJob.collideWithPawns || curJob.def.collideWithPawns || forPawn.jobs.curDriver.collideWithPawns))
                    {
                        flag = true;
                    }
                    else if (!forPawn.Drafted || forPawn.pather.Moving)
                    {
                    }
                }
                for (int i = 0; i < thingList.Count; i++)
                {
                    Pawn pawn = thingList[i] as Pawn;
                    if (pawn != null && pawn != forPawn && !pawn.Downed)
                    {
                        if (collideOnlyWithStandingPawns)
                        {
                            if (pawn.pather.MovingNow)
                            {
                                goto IL_1BA;
                            }
                            if (pawn.pather.Moving && pawn.pather.MovedRecently(60))
                            {
                                goto IL_1BA;
                            }
                        }
                        if (!PawnUtility.PawnsCanShareCellBecauseOfBodySize(pawn, forPawn))
                        {
                            if (pawn.HostileTo(forPawn))
                            {
                                return(pawn);
                            }
                            if (flag)
                            {
                                if (forPathFinder || !forPawn.Drafted || !pawn.RaceProps.Animal)
                                {
                                    Job curJob2 = pawn.CurJob;
                                    if (curJob2 != null && (curJob2.collideWithPawns || curJob2.def.collideWithPawns || pawn.jobs.curDriver.collideWithPawns))
                                    {
                                        return(pawn);
                                    }
                                }
                            }
                        }
                    }
                    IL_1BA :;
                }
                result = null;
            }
            return(result);
        }
コード例 #20
0
ファイル: RCellFinder.cs プロジェクト: wensincai/RW-Decompile
        private static bool CanWanderToCell(IntVec3 c, Pawn pawn, IntVec3 root, Func <Pawn, IntVec3, IntVec3, bool> validator, int tryIndex, Danger maxDanger)
        {
            bool flag = UnityData.isDebugBuild && DebugViewSettings.drawDestSearch;

            if (!c.Walkable(pawn.Map))
            {
                if (flag)
                {
                    pawn.Map.debugDrawer.FlashCell(c, 0f, "walk", 50);
                }
                return(false);
            }
            if (c.IsForbidden(pawn))
            {
                if (flag)
                {
                    pawn.Map.debugDrawer.FlashCell(c, 0.25f, "forbid", 50);
                }
                return(false);
            }
            if (tryIndex < 10 && !c.Standable(pawn.Map))
            {
                if (flag)
                {
                    pawn.Map.debugDrawer.FlashCell(c, 0.25f, "stand", 50);
                }
                return(false);
            }
            if (!pawn.CanReach(c, PathEndMode.OnCell, maxDanger, false, TraverseMode.ByPawn))
            {
                if (flag)
                {
                    pawn.Map.debugDrawer.FlashCell(c, 0.6f, "reach", 50);
                }
                return(false);
            }
            if (PawnUtility.KnownDangerAt(c, pawn.Map, pawn))
            {
                if (flag)
                {
                    pawn.Map.debugDrawer.FlashCell(c, 0.1f, "trap", 50);
                }
                return(false);
            }
            if (tryIndex < 10)
            {
                if (c.GetTerrain(pawn.Map).avoidWander)
                {
                    if (flag)
                    {
                        pawn.Map.debugDrawer.FlashCell(c, 0.39f, "terr", 50);
                    }
                    return(false);
                }
                if (pawn.Map.pathGrid.PerceivedPathCostAt(c) > 20)
                {
                    if (flag)
                    {
                        pawn.Map.debugDrawer.FlashCell(c, 0.4f, "pcost", 50);
                    }
                    return(false);
                }
                if (c.GetDangerFor(pawn, pawn.Map) > Danger.None)
                {
                    if (flag)
                    {
                        pawn.Map.debugDrawer.FlashCell(c, 0.4f, "danger", 50);
                    }
                    return(false);
                }
            }
            else if (tryIndex < 15 && c.GetDangerFor(pawn, pawn.Map) == Danger.Deadly)
            {
                if (flag)
                {
                    pawn.Map.debugDrawer.FlashCell(c, 0.4f, "deadly", 50);
                }
                return(false);
            }
            if (!pawn.Map.pawnDestinationReservationManager.CanReserve(c, pawn, false))
            {
                if (flag)
                {
                    pawn.Map.debugDrawer.FlashCell(c, 0.75f, "resvd", 50);
                }
                return(false);
            }
            if (validator != null && !validator(pawn, c, root))
            {
                if (flag)
                {
                    pawn.Map.debugDrawer.FlashCell(c, 0.15f, "valid", 50);
                }
                return(false);
            }
            if (c.GetDoor(pawn.Map) != null)
            {
                if (flag)
                {
                    pawn.Map.debugDrawer.FlashCell(c, 0.32f, "door", 50);
                }
                return(false);
            }
            if (c.ContainsStaticFire(pawn.Map))
            {
                if (flag)
                {
                    pawn.Map.debugDrawer.FlashCell(c, 0.9f, "fire", 50);
                }
                return(false);
            }
            return(true);
        }
コード例 #21
0
        public static void PopIntentRecruitDifficulty()
        {
            List <float> list = new List <float>();

            for (float num = -1f; num < 3f; num += 0.1f)
            {
                list.Add(num);
            }
            List <float> colValues = new List <float>
            {
                0.1f,
                0.2f,
                0.3f,
                0.4f,
                0.5f,
                0.6f,
                0.7f,
                0.8f,
                0.9f,
                0.95f,
                0.99f
            };

            DebugTables.MakeTablesDialog <float, float>(colValues, (float d) => "d=" + d.ToString("F0"), list, (float rv) => rv.ToString("F1"), (float d, float pi) => PawnUtility.PopIntentAdjustedRecruitDifficulty(d, pi).ToStringPercent(), "intents");
        }
コード例 #22
0
        // Token: 0x06002D42 RID: 11586 RVA: 0x000FD888 File Offset: 0x000FBA88
        protected override Job TryGiveJob(Pawn pawn)
        {
            if (pawn.gender != Gender.Male || !pawn.ageTracker.CurLifeStage.reproductive)
            {
                return(null);
            }
            Predicate <Thing> validator = delegate(Thing t)
            {
                Pawn pawn3 = t as Pawn;
                if (pawn.Faction != null && pawn3.Faction != null || pawn.Faction != pawn3.Faction)
                {
                    return(!pawn3.Downed && pawn3.CanCasuallyInteractNow(false) && !pawn3.IsForbidden(pawn) && PawnUtility.FertileMateTarget(pawn, pawn3));
                }
                else
                {
                    return(false);
                }
            };
            Pawn pawn2 = (Pawn)GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, ThingRequest.ForDef(pawn.def), PathEndMode.Touch, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), 30f, validator, null, 0, -1, false, RegionType.Set_Passable, false);

            if (pawn2 == null)
            {
                return(null);
            }
            return(JobMaker.MakeJob(JobDefOf.Mate, pawn2));
        }
コード例 #23
0
        public static float GetManhunterOnDamageChance(Pawn pawn, float distance)
        {
            float manhunterOnDamageChance = PawnUtility.GetManhunterOnDamageChance(pawn.kindDef);

            return(manhunterOnDamageChance * GenMath.LerpDoubleClamped(1f, 30f, 3f, 1f, distance));
        }
コード例 #24
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            base.AddFinishAction(delegate
            {
                this.Map.attackTargetsCache.UpdateTarget(this.pawn);
            });
            Toil prepareToEatCorpse = new Toil();

            prepareToEatCorpse.initAction = delegate()
            {
                Pawn   actor  = prepareToEatCorpse.actor;
                Corpse corpse = this.Corpse;
                if (corpse == null)
                {
                    Pawn prey = this.Prey;
                    if (prey == null)
                    {
                        actor.jobs.EndCurrentJob(JobCondition.Incompletable, true);
                        return;
                    }
                    corpse = prey.Corpse;
                    if (corpse == null || !corpse.Spawned)
                    {
                        actor.jobs.EndCurrentJob(JobCondition.Incompletable, true);
                        return;
                    }
                }
                if (actor.Faction == Faction.OfPlayer)
                {
                    corpse.SetForbidden(false, false);
                }
                else
                {
                    corpse.SetForbidden(true, false);
                }
                actor.CurJob.SetTarget(TargetIndex.A, corpse);
            };
            yield return(Toils_General.DoAtomic(delegate
            {
                this.Map.attackTargetsCache.UpdateTarget(this.pawn);
            }));

            Action onHitAction = delegate()
            {
                Pawn prey           = this.Prey;
                bool surpriseAttack = this.firstHit && !prey.IsColonist;
                if (this.pawn.meleeVerbs.TryMeleeAttack(prey, this.job.verbToUse, surpriseAttack))
                {
                    if (!this.notifiedPlayerAttacked && PawnUtility.ShouldSendNotificationAbout(prey))
                    {
                        this.notifiedPlayerAttacked = true;
                        Messages.Message("MessageAttackedByPredator".Translate(new object[]
                        {
                            prey.LabelShort,
                            this.pawn.LabelIndefinite()
                        }).CapitalizeFirst(), prey, MessageTypeDefOf.ThreatSmall, true);
                    }
                    this.Map.attackTargetsCache.UpdateTarget(this.pawn);
                }
                this.firstHit = false;
            };
            Toil followAndAttack = Toils_Combat.FollowAndMeleeAttack(TargetIndex.A, onHitAction).JumpIfDespawnedOrNull(TargetIndex.A, prepareToEatCorpse).JumpIf(() => this.Corpse != null, prepareToEatCorpse).FailOn(() => Find.TickManager.TicksGame > this.startTick + 5000 && (float)(this.job.GetTarget(TargetIndex.A).Cell - this.pawn.Position).LengthHorizontalSquared > 4f);

            followAndAttack.AddPreTickAction(new Action(this.CheckWarnPlayer));
            yield return(followAndAttack);

            yield return(prepareToEatCorpse);

            Toil gotoCorpse = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch);

            yield return(gotoCorpse);

            float durationMultiplier = 1f / this.pawn.GetStatValue(StatDefOf.EatingSpeed, true);

            yield return(Toils_Ingest.ChewIngestible(this.pawn, durationMultiplier, TargetIndex.A, TargetIndex.None).FailOnDespawnedOrNull(TargetIndex.A).FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch));

            yield return(Toils_Ingest.FinalizeIngest(this.pawn, TargetIndex.A));

            yield return(Toils_Jump.JumpIf(gotoCorpse, () => this.pawn.needs.food.CurLevelPercentage < 0.9f));

            yield break;
        }
コード例 #25
0
 public static float GetManhunterOnTameFailChance(Pawn pawn)
 {
     return(PawnUtility.GetManhunterOnTameFailChance(pawn.kindDef));
 }
コード例 #26
0
ファイル: Need_Rest.cs プロジェクト: sachdevs/RW-Decompile
 public override void NeedInterval()
 {
     if (!base.IsFrozen)
     {
         if (this.Resting)
         {
             this.CurLevel += 0.00571428565f * this.lastRestEffectiveness;
         }
         else
         {
             this.CurLevel -= this.RestFallPerTick * 150f;
         }
     }
     if (this.CurLevel < 0.0001f)
     {
         this.ticksAtZero += 150;
     }
     else
     {
         this.ticksAtZero = 0;
     }
     if (this.ticksAtZero > 1000 && this.pawn.Spawned)
     {
         float mtb;
         if (this.ticksAtZero < 15000)
         {
             mtb = 0.25f;
         }
         else if (this.ticksAtZero < 30000)
         {
             mtb = 0.125f;
         }
         else if (this.ticksAtZero < 45000)
         {
             mtb = 0.0833333358f;
         }
         else
         {
             mtb = 0.0625f;
         }
         if (Rand.MTBEventOccurs(mtb, 60000f, 150f) && (this.pawn.CurJob == null || this.pawn.CurJob.def != JobDefOf.LayDown))
         {
             this.pawn.jobs.StartJob(new Job(JobDefOf.LayDown, this.pawn.Position), JobCondition.InterruptForced, null, false, true, null, new JobTag?(JobTag.SatisfyingNeeds), false);
             if (this.pawn.InMentalState)
             {
                 this.pawn.mindState.mentalStateHandler.CurState.RecoverFromState();
             }
             if (PawnUtility.ShouldSendNotificationAbout(this.pawn))
             {
                 Messages.Message("MessageInvoluntarySleep".Translate(new object[]
                 {
                     this.pawn.LabelShort
                 }), this.pawn, MessageTypeDefOf.NegativeEvent);
             }
             TaleRecorder.RecordTale(TaleDefOf.Exhausted, new object[]
             {
                 this.pawn
             });
         }
     }
 }
コード例 #27
0
 protected override string GetTextFor(Pawn pawn)
 {
     return(PawnUtility.GetManhunterOnDamageChance(pawn, null).ToStringPercent());
 }
コード例 #28
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            if (parms.target is Map)
            {
                return(IncidentDefOf.TravelerGroup.Worker.TryExecute(parms));
            }
            Caravan caravan = (Caravan)parms.target;
            Faction faction;

            if (!(from x in Find.FactionManager.AllFactionsListForReading
                  where !x.IsPlayer && !x.HostileTo(Faction.OfPlayer) && !x.def.hidden && x.def.humanlikeFaction && x.def.caravanTraderKinds.Any()
                  select x).TryRandomElement <Faction>(out faction))
            {
                return(false);
            }
            CameraJumper.TryJumpAndSelect(caravan);
            List <Pawn> pawns                = this.GenerateCaravanPawns(faction);
            Caravan     metCaravan           = CaravanMaker.MakeCaravan(pawns, faction, -1, false);
            string      text                 = "CaravanMeeting".Translate(faction.Name, PawnUtility.PawnKindsToCommaList(metCaravan.PawnsListForReading));
            DiaNode     diaNode              = new DiaNode(text);
            Pawn        bestPlayerNegotiator = BestCaravanPawnUtility.FindBestNegotiator(caravan);

            if (metCaravan.CanTradeNow)
            {
                DiaOption diaOption = new DiaOption("CaravanMeeting_Trade".Translate());
                diaOption.action = delegate
                {
                    Find.WindowStack.Add(new Dialog_Trade(bestPlayerNegotiator, metCaravan));
                    string empty  = string.Empty;
                    string empty2 = string.Empty;
                    PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(metCaravan.Goods.OfType <Pawn>(), ref empty, ref empty2, "LetterRelatedPawnsTradingWithOtherCaravan".Translate(), false, true);
                    if (!empty2.NullOrEmpty())
                    {
                        Find.LetterStack.ReceiveLetter(empty, empty2, LetterDefOf.NeutralEvent, new GlobalTargetInfo(caravan.Tile), null);
                    }
                };
                if (bestPlayerNegotiator == null)
                {
                    diaOption.Disable("CaravanMeeting_TradeIncapable".Translate());
                }
                diaNode.options.Add(diaOption);
            }
            DiaOption diaOption2 = new DiaOption("CaravanMeeting_Attack".Translate());

            diaOption2.action = delegate
            {
                LongEventHandler.QueueLongEvent(delegate
                {
                    if (!faction.HostileTo(Faction.OfPlayer))
                    {
                        faction.SetHostileTo(Faction.OfPlayer, true);
                    }
                    Pawn t  = caravan.PawnsListForReading[0];
                    Map map = CaravanIncidentUtility.GetOrGenerateMapForIncident(caravan, new IntVec3(100, 1, 100), WorldObjectDefOf.AttackedCaravan);
                    IntVec3 playerSpot;
                    IntVec3 enemySpot;
                    MultipleCaravansCellFinder.FindStartingCellsFor2Groups(map, out playerSpot, out enemySpot);
                    CaravanEnterMapUtility.Enter(caravan, map, (Pawn p) => CellFinder.RandomClosewalkCellNear(playerSpot, map, 12, null), CaravanDropInventoryMode.DoNotDrop, true);
                    List <Pawn> list = metCaravan.PawnsListForReading.ToList();
                    CaravanEnterMapUtility.Enter(metCaravan, map, (Pawn p) => CellFinder.RandomClosewalkCellNear(enemySpot, map, 12, null), CaravanDropInventoryMode.DoNotDrop, false);
                    LordMaker.MakeNewLord(faction, new LordJob_DefendAttackedTraderCaravan(list[0].Position), map, list);
                    Find.TickManager.CurTimeSpeed = TimeSpeed.Paused;
                    CameraJumper.TryJumpAndSelect(t);
                    Messages.Message("MessageAttackedCaravanIsNowHostile".Translate(faction.Name), new GlobalTargetInfo(list[0].Position, list[0].Map, false), MessageTypeDefOf.ThreatBig);
                }, "GeneratingMapForNewEncounter", false, null);
            };
            diaOption2.resolveTree = true;
            diaNode.options.Add(diaOption2);
            DiaOption diaOption3 = new DiaOption("CaravanMeeting_MoveOn".Translate());

            diaOption3.action = delegate
            {
                this.RemoveAllPawnsAndPassToWorld(metCaravan);
            };
            diaOption3.resolveTree = true;
            diaNode.options.Add(diaOption3);
            string      text2              = "CaravanMeetingTitle".Translate(caravan.Label);
            WindowStack windowStack        = Find.WindowStack;
            DiaNode     nodeRoot           = diaNode;
            bool        delayInteractivity = true;
            string      title              = text2;

            windowStack.Add(new Dialog_NodeTree(nodeRoot, delayInteractivity, false, title));
            return(true);
        }
コード例 #29
0
        public static bool TryFindWalkPath(Pawn pawn, IntVec3 root, out List <IntVec3> result)
        {
            List <IntVec3> list = new List <IntVec3>();

            list.Add(root);
            IntVec3 intVec = root;

            for (int i = 0; i < 8; i++)
            {
                IntVec3 intVec2 = IntVec3.Invalid;
                float   num     = -1f;
                for (int j = WalkPathFinder.StartRadialIndex; j > WalkPathFinder.EndRadialIndex; j -= WalkPathFinder.RadialIndexStride)
                {
                    IntVec3 intVec3 = intVec + GenRadial.RadialPattern[j];
                    if (intVec3.InBounds(pawn.Map) && intVec3.Standable(pawn.Map) && !intVec3.IsForbidden(pawn) && GenSight.LineOfSight(intVec, intVec3, pawn.Map, false, null, 0, 0) && !intVec3.Roofed(pawn.Map) && !PawnUtility.KnownDangerAt(intVec3, pawn))
                    {
                        float num2 = 10000f;
                        for (int k = 0; k < list.Count; k++)
                        {
                            num2 += (float)(list[k] - intVec3).LengthManhattan;
                        }
                        float num3 = (float)(intVec3 - root).LengthManhattan;
                        if (num3 > 40f)
                        {
                            num2 *= Mathf.InverseLerp(70f, 40f, num3);
                        }
                        if (list.Count >= 2)
                        {
                            float num4      = (list[list.Count - 1] - list[list.Count - 2]).AngleFlat;
                            float angleFlat = (intVec3 - intVec).AngleFlat;
                            float num5;
                            if (angleFlat > num4)
                            {
                                num5 = angleFlat - num4;
                            }
                            else
                            {
                                num4 -= 360f;
                                num5  = angleFlat - num4;
                            }
                            if (num5 > 110f)
                            {
                                num2 *= 0.01f;
                            }
                        }
                        if (list.Count >= 4 && (intVec - root).LengthManhattan < (intVec3 - root).LengthManhattan)
                        {
                            num2 *= 1E-05f;
                        }
                        if (num2 > num)
                        {
                            intVec2 = intVec3;
                            num     = num2;
                        }
                    }
                }
                if (num < 0f)
                {
                    result = null;
                    return(false);
                }
                list.Add(intVec2);
                intVec = intVec2;
            }
            list.Add(root);
            result = list;
            return(true);
        }
コード例 #30
0
 private static void AppendThoughts_Relations(Pawn victim, DamageInfo?dinfo, PawnDiedOrDownedThoughtsKind thoughtsKind, List <IndividualThoughtToAdd> outIndividualThoughts, List <ThoughtDef> outAllColonistsThoughts)
 {
     if (thoughtsKind == PawnDiedOrDownedThoughtsKind.Banished && victim.RaceProps.Animal)
     {
         List <DirectPawnRelation> directRelations = victim.relations.DirectRelations;
         for (int i = 0; i < directRelations.Count; i++)
         {
             if (!directRelations[i].otherPawn.Dead && directRelations[i].otherPawn.needs.mood != null && PawnUtility.ShouldGetThoughtAbout(directRelations[i].otherPawn, victim) && directRelations[i].def == PawnRelationDefOf.Bond)
             {
                 outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.BondedAnimalBanished, directRelations[i].otherPawn, victim, 1f, 1f));
             }
         }
     }
     if (thoughtsKind != 0 && thoughtsKind != PawnDiedOrDownedThoughtsKind.BanishedToDie)
     {
         return;
     }
     foreach (Pawn potentiallyRelatedPawn in victim.relations.PotentiallyRelatedPawns)
     {
         if (!potentiallyRelatedPawn.Dead && potentiallyRelatedPawn.needs.mood != null && PawnUtility.ShouldGetThoughtAbout(potentiallyRelatedPawn, victim))
         {
             PawnRelationDef mostImportantRelation = potentiallyRelatedPawn.GetMostImportantRelation(victim);
             if (mostImportantRelation != null)
             {
                 ThoughtDef genderSpecificDiedThought = mostImportantRelation.GetGenderSpecificDiedThought(victim);
                 if (genderSpecificDiedThought != null)
                 {
                     outIndividualThoughts.Add(new IndividualThoughtToAdd(genderSpecificDiedThought, potentiallyRelatedPawn, victim, 1f, 1f));
                 }
             }
         }
     }
     if (dinfo.HasValue)
     {
         Pawn pawn = dinfo.Value.Instigator as Pawn;
         if (pawn != null && pawn != victim)
         {
             foreach (Pawn potentiallyRelatedPawn2 in victim.relations.PotentiallyRelatedPawns)
             {
                 if (pawn != potentiallyRelatedPawn2 && !potentiallyRelatedPawn2.Dead && potentiallyRelatedPawn2.needs.mood != null)
                 {
                     PawnRelationDef mostImportantRelation2 = potentiallyRelatedPawn2.GetMostImportantRelation(victim);
                     if (mostImportantRelation2 != null)
                     {
                         ThoughtDef genderSpecificKilledThought = mostImportantRelation2.GetGenderSpecificKilledThought(victim);
                         if (genderSpecificKilledThought != null)
                         {
                             outIndividualThoughts.Add(new IndividualThoughtToAdd(genderSpecificKilledThought, potentiallyRelatedPawn2, pawn, 1f, 1f));
                         }
                     }
                     if (potentiallyRelatedPawn2.RaceProps.IsFlesh)
                     {
                         int num = potentiallyRelatedPawn2.relations.OpinionOf(victim);
                         if (num >= 20)
                         {
                             ThoughtDef killedMyFriend = ThoughtDefOf.KilledMyFriend;
                             Pawn       addTo          = potentiallyRelatedPawn2;
                             Pawn       otherPawn      = pawn;
                             float      friendDiedThoughtPowerFactor = victim.relations.GetFriendDiedThoughtPowerFactor(num);
                             outIndividualThoughts.Add(new IndividualThoughtToAdd(killedMyFriend, addTo, otherPawn, 1f, friendDiedThoughtPowerFactor));
                         }
                         else if (num <= -20)
                         {
                             ThoughtDef killedMyFriend = ThoughtDefOf.KilledMyRival;
                             Pawn       otherPawn      = potentiallyRelatedPawn2;
                             Pawn       addTo          = pawn;
                             float      friendDiedThoughtPowerFactor = victim.relations.GetRivalDiedThoughtPowerFactor(num);
                             outIndividualThoughts.Add(new IndividualThoughtToAdd(killedMyFriend, otherPawn, addTo, 1f, friendDiedThoughtPowerFactor));
                         }
                     }
                 }
             }
         }
     }
     if (victim.RaceProps.Humanlike)
     {
         foreach (Pawn allMapsCaravansAndTravelingTransportPod in PawnsFinder.AllMapsCaravansAndTravelingTransportPods)
         {
             if (!allMapsCaravansAndTravelingTransportPod.Dead && allMapsCaravansAndTravelingTransportPod.RaceProps.IsFlesh && allMapsCaravansAndTravelingTransportPod.needs.mood != null && PawnUtility.ShouldGetThoughtAbout(allMapsCaravansAndTravelingTransportPod, victim))
             {
                 int num2 = allMapsCaravansAndTravelingTransportPod.relations.OpinionOf(victim);
                 if (num2 >= 20)
                 {
                     outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.PawnWithGoodOpinionDied, allMapsCaravansAndTravelingTransportPod, victim, victim.relations.GetFriendDiedThoughtPowerFactor(num2), 1f));
                 }
                 else if (num2 <= -20)
                 {
                     outIndividualThoughts.Add(new IndividualThoughtToAdd(ThoughtDefOf.PawnWithBadOpinionDied, allMapsCaravansAndTravelingTransportPod, victim, victim.relations.GetRivalDiedThoughtPowerFactor(num2), 1f));
                 }
             }
         }
     }
 }