Ejemplo n.º 1
0
        private void ObserveSurroundingThings()
        {
            if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Sight) || pawn.needs.mood == null)
            {
                return;
            }
            Map map = pawn.Map;

            for (int i = 0; (float)i < 100f; i++)
            {
                IntVec3 intVec = pawn.Position + GenRadial.RadialPattern[i];
                if (!intVec.InBounds(map) || !GenSight.LineOfSight(intVec, pawn.Position, map, skipFirstCell: true))
                {
                    continue;
                }
                List <Thing> thingList = intVec.GetThingList(map);
                for (int j = 0; j < thingList.Count; j++)
                {
                    IThoughtGiver thoughtGiver = thingList[j] as IThoughtGiver;
                    if (thoughtGiver != null)
                    {
                        Thought_Memory thought_Memory = thoughtGiver.GiveObservedThought();
                        if (thought_Memory != null)
                        {
                            pawn.needs.mood.thoughts.memories.TryGainMemory(thought_Memory);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private void ObserveSurroundingThings()
 {
     if (this.pawn.health.capacities.CapableOf(PawnCapacityDefOf.Sight))
     {
         Map map = this.pawn.Map;
         int num = 0;
         while ((float)num < 100f)
         {
             IntVec3 intVec = this.pawn.Position + GenRadial.RadialPattern[num];
             if (intVec.InBounds(map))
             {
                 if (GenSight.LineOfSight(intVec, this.pawn.Position, map, true, null, 0, 0))
                 {
                     List <Thing> thingList = intVec.GetThingList(map);
                     for (int i = 0; i < thingList.Count; i++)
                     {
                         IThoughtGiver thoughtGiver = thingList[i] as IThoughtGiver;
                         if (thoughtGiver != null)
                         {
                             Thought_Memory thought_Memory = thoughtGiver.GiveObservedThought();
                             if (thought_Memory != null)
                             {
                                 this.pawn.needs.mood.thoughts.memories.TryGainMemory(thought_Memory, null);
                             }
                         }
                     }
                 }
             }
             num++;
         }
     }
 }
Ejemplo n.º 3
0
        // Token: 0x06000DC4 RID: 3524 RVA: 0x000456A8 File Offset: 0x000438A8
        internal static void _ObserveSurroundingThings(this PawnObserver _this)
        {
            Pawn pawn = _this.GetPawn();

            if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Sight))
            {
                return;
            }
            Room room = RoomQuery.RoomAt(pawn.Position);
            int  num  = 0;

            while ((float)num < 100f)
            {
                IntVec3 c = pawn.Position + GenRadial.RadialPattern[num];
                if (c.InBounds())
                {
                    if (RoomQuery.RoomAt(c) == room)
                    {
                        List <Thing> thingList = c.GetThingList();
                        for (int i = 0; i < thingList.Count; i++)
                        {
                            IThoughtGiver thoughtGiver = thingList[i] as IThoughtGiver;
                            if (thoughtGiver != null)
                            {
                                Thought_Memory thought_Memory = thoughtGiver.GiveObservedThought();
                                if (thought_Memory != null)
                                {
                                    if (thought_Memory.def == ThoughtDefOf.ObservedLayingCorpse)
                                    {
                                        if (!pawn.story.traits.HasTrait(TraitDefOfPsychology.BleedingHeart) && !pawn.story.traits.HasTrait(TraitDefOf.Psychopath) && !pawn.story.traits.HasTrait(TraitDefOf.Bloodlust))
                                        {
                                            if (((pawn.GetHashCode() ^ (GenDate.DayOfYear + GenDate.CurrentYear + (int)(GenDate.CurrentDayPercent * 5) * 60) * 391) % 1000) == 0)
                                            {
                                                pawn.story.traits.GainTrait(new Trait(TraitDefOfPsychology.Desensitized));
                                                pawn.needs.mood.thoughts.memories.TryGainMemoryThought(ThoughtDefOfPsychology.RecentlyDesensitized, (Pawn)null);
                                            }
                                        }
                                    }
                                    pawn.needs.mood.thoughts.memories.TryGainMemoryThought(thought_Memory, null);
                                }
                            }
                        }
                    }
                }
                num++;
            }
        }
Ejemplo n.º 4
0
        public static void DesensitizeViaCorpse(PawnObserver __instance)
        {
            Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();

            if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Sight))
            {
                return;
            }
            RoomGroup roomGroup = pawn.GetRoomGroup();
            Map       map       = pawn.Map;
            int       num       = 0;

            while ((float)num < 100f)
            {
                IntVec3 intVec = pawn.Position + GenRadial.RadialPattern[num];
                if (intVec.InBounds(map))
                {
                    if (intVec.GetRoomGroup(map) == roomGroup)
                    {
                        if (GenSight.LineOfSight(intVec, pawn.Position, map, true, null, 0, 0))
                        {
                            List <Thing> thingList = intVec.GetThingList(map);
                            for (int i = 0; i < thingList.Count; i++)
                            {
                                IThoughtGiver thoughtGiver = thingList[i] as IThoughtGiver;
                                if (thoughtGiver != null)
                                {
                                    Thought_Memory thought_Memory = thoughtGiver.GiveObservedThought();
                                    if (thought_Memory != null && thought_Memory.def == ThoughtDefOf.ObservedLayingCorpse)
                                    {
                                        if (!pawn.story.traits.HasTrait(TraitDefOfPsychology.BleedingHeart) && !pawn.story.traits.HasTrait(TraitDefOf.Psychopath) && !pawn.story.traits.HasTrait(TraitDefOf.Bloodlust) && !pawn.story.traits.HasTrait(TraitDefOfPsychology.Desensitized))
                                        {
                                            if (((pawn.GetHashCode() ^ (GenLocalDate.DayOfYear(pawn) + GenLocalDate.Year(pawn) + (int)(GenLocalDate.DayPercent(pawn) * 5) * 60) * 391) % 1000) == 0)
                                            {
                                                pawn.story.traits.GainTrait(new Trait(TraitDefOfPsychology.Desensitized));
                                                pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.RecentlyDesensitized, null);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                num++;
            }
        }
        public static void ObserveSurroundingThingsPostfix(PawnObserver __instance)
        {
            Traverse traverse = Traverse.Create(__instance);
            Pawn     pawn     = (Pawn)AvP_PawnObserver_ObserveSurroundingThings_Patch.pawn.GetValue(__instance);

            if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Sight))
            {
                return;
            }
            Map map = pawn.Map;
            int num = 0;

            while ((float)num < 100f)
            {
                IntVec3 intVec = pawn.Position + GenRadial.RadialPattern[num];
                if (intVec.InBounds(map))
                {
                    if (GenSight.LineOfSight(intVec, pawn.Position, map, true, null, 0, 0))
                    {
                        List <Thing> thingList = intVec.GetThingList(map).FindAll(x => x.TryGetComp <Comp_Xenomorph>() != null);
                        for (int i = 0; i < thingList.Count; i++)
                        {
                            IThoughtGiver thoughtGiver = thingList[i].TryGetComp <Comp_Xenomorph>() as IThoughtGiver;
                            if (thoughtGiver != null)
                            {
                                Thought_Memory thought_Memory = thoughtGiver.GiveObservedThought();
                                if (thought_Memory != null)
                                {
                                    pawn.needs.mood.thoughts.memories.TryGainMemory(thought_Memory, null);
                                }
                            }
                        }
                    }
                }
                num++;
            }
        }