public static void BestPawnToHuntForPredator(Pawn predator, bool forceScanWholeMap, ref Pawn __result)
 {
     if (predator.isNeomorph())
     {
         Comp_Neomorph _Neomorph = predator.TryGetComp <Comp_Neomorph>();
         __result = _Neomorph.BestPawnToHuntForPredator(predator, forceScanWholeMap);
     }
     if (predator.isXenomorph())
     {
         Comp_Xenomorph _Xenomorph = predator.TryGetComp <Comp_Xenomorph>();
         __result = _Xenomorph.BestPawnToHuntForPredator(predator, forceScanWholeMap);
     }
 }
Beispiel #2
0
 public static void BestPawnToHuntForPredator(Pawn predator, bool forceScanWholeMap, ref Pawn __result)
 {
     if (predator.isNeomorph())
     {
         Comp_Neomorph _Neomorph = predator.TryGetComp <Comp_Neomorph>();
         __result = _Neomorph.BestPawnToHuntForPredator(predator, forceScanWholeMap);
     }
     if (predator.isXenomorph())
     {
         if (predator.ageTracker.CurLifeStage == XenomorphDefOf.RRY_XenomorphFullyFormed)
         {
             Comp_Xenomorph _Xenomorph = predator.TryGetComp <Comp_Xenomorph>();
             __result = _Xenomorph.BestPawnToHuntForPredator(predator, forceScanWholeMap);
         }
     }
 }
 public override void Tick()
 {
     if (Hidden)
     {
         if (!hidden)
         {
             MakeInvisible();
             hidden = true;
         }
         if (!pawn.Spawned)
         {
             pawn.health.RemoveHediff(this);
         }
         if (pawn.Downed || pawn.Dead || (pawn.pather != null && pawn.pather.WillCollideWithPawnOnNextPathCell()))
         {
             pawn.health.RemoveHediff(this);
             if (pawn.pather != null)
             {
                 AlertXenomorph(pawn, pawn.pather.nextCell.GetFirstPawn(pawn.Map));
             }
             else
             {
                 AlertXenomorph(pawn, null);
             }
         }
         if (pawn.pather != null && GetLastCell(pawn.pather).GetDoor(pawn.Map) != null)
         {
             GetLastCell(pawn.pather).GetDoor(pawn.Map).StartManualCloseBy(pawn);
         }
         if (pawn.Map != null && lastSpottedTick < Find.TickManager.TicksGame - 125)
         {
             lastSpottedTick = Find.TickManager.TicksGame;
             int num = 0;
             while (num < 20)
             {
                 IntVec3 c    = pawn.Position + GenRadial.RadialPattern[num];
                 Room    room = RegionAndRoomQuery.RoomAt(c, pawn.Map);
                 if (c.InBounds(pawn.Map))
                 {
                     if (RegionAndRoomQuery.RoomAt(c, pawn.Map) == room)
                     {
                         List <Thing> thingList = c.GetThingList(pawn.Map);
                         foreach (Thing thing in thingList)
                         {
                             Pawn observer = thing as Pawn;
                             if (observer != null && observer != pawn && observer.Faction != null && (observer.Faction.IsPlayer || observer.Faction.HostileTo(pawn.Faction)))
                             {
                                 float observerSight = observer.health.capacities.GetLevel(PawnCapacityDefOf.Sight);
                                 observerSight *= 0.805f + (pawn.Map.glowGrid.GameGlowAt(pawn.Position) / 4);
                                 if (observer.RaceProps.Animal)
                                 {
                                     observerSight *= 0.9f;
                                 }
                                 observerSight = Math.Min(2f, observerSight);
                                 float thiefMoving = pawn.health.capacities.GetLevel(PawnCapacityDefOf.Moving);
                                 float spotChance  = 0.8f * thiefMoving / observerSight;
                                 if (Rand.Value > spotChance)
                                 {
                                     if (pawn.isXenomorph())
                                     {
                                         Comp_Xenomorph _Xenomorph = pawn.TryGetComp <Comp_Xenomorph>();
                                         _Xenomorph.Hidden = false;
                                     }
                                     if (pawn.isNeomorph())
                                     {
                                         Comp_Neomorph _Nenomorph = pawn.TryGetComp <Comp_Neomorph>();
                                         _Nenomorph.Hidden = false;
                                     }
                                     //pawn.health.RemoveHediff(this);
                                     AlertXenomorph(pawn, observer);
                                 }
                             }
                             else if (observer == null)
                             {
                                 if (thing is Building_Turret turret && turret.Faction != null && turret.Faction.IsPlayer)
                                 {
                                     float thiefMoving = pawn.health.capacities.GetLevel(PawnCapacityDefOf.Moving);
                                     float spotChance  = 0.99f * thiefMoving;
                                     if (Rand.Value > spotChance)
                                     {
                                         if (pawn.isXenomorph())
                                         {
                                             Comp_Xenomorph _Xenomorph = pawn.TryGetComp <Comp_Xenomorph>();
                                             _Xenomorph.Hidden = false;
                                         }
                                         if (pawn.isNeomorph())
                                         {
                                             Comp_Neomorph _Nenomorph = pawn.TryGetComp <Comp_Neomorph>();
                                             _Nenomorph.Hidden = false;
                                         }
                                         //pawn.health.RemoveHediff(this);
                                         AlertXenomorph(pawn, turret);
                                     }
                                 }
                             }
                         }
                     }
                 }
                 num++;
             }
             Thing holding = pawn.carryTracker.CarriedThing;
             if (lastCarried != holding)
             {
                 if (lastCarried != null)
                 {
                     SetGraphicInt(lastCarried, lastCarriedGraphic);
                 }
                 if (holding != null)
                 {
                     lastCarried        = holding;
                     lastCarriedGraphic = holding.Graphic;
                     SetGraphicInt(lastCarried, new Graphic_Invisible());
                 }
             }
         }
     }
     else
     {
         if (hidden)
         {
             MakeVisible();
             hidden = false;
         }
     }
 }