Exemple #1
0
            internal void <> m__1()
            {
                Pawn actor = this.toil.actor;
                Pawn pawn  = (Pawn)((Thing)actor.CurJob.GetTarget(this.target));
                Map  map   = actor.Map;

                if (InteractionUtility.IsGoodPositionForInteraction(actor, pawn) && actor.Position.InHorDistOf(pawn.Position, (float)Mathf.CeilToInt(3f)) && (!actor.pather.Moving || actor.pather.nextCell.GetDoor(map) == null))
                {
                    actor.pather.StopDead();
                    actor.jobs.curDriver.ReadyForNextToil();
                }
                else if (!actor.pather.Moving)
                {
                    IntVec3 intVec = IntVec3.Invalid;
                    for (int i = 0; i < 8; i++)
                    {
                        IntVec3 intVec2 = pawn.Position + GenAdj.AdjacentCells[i];
                        if (intVec2.InBounds(map) && intVec2.Standable(map) && intVec2 != actor.Position && InteractionUtility.IsGoodPositionForInteraction(intVec2, pawn.Position, map) && actor.CanReach(intVec2, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn) && (!intVec.IsValid || actor.Position.DistanceToSquared(intVec2) < actor.Position.DistanceToSquared(intVec)))
                        {
                            intVec = intVec2;
                        }
                    }
                    if (intVec.IsValid)
                    {
                        actor.pather.StartPath(intVec, PathEndMode.OnCell);
                    }
                    else
                    {
                        actor.jobs.curDriver.EndJobWith(JobCondition.Incompletable);
                    }
                }
            }
Exemple #2
0
        public static Toil GotoInteractablePosition(TargetIndex target)
        {
            Toil toil = new Toil();

            toil.initAction = delegate
            {
                Pawn actor = toil.actor;
                Pawn pawn  = (Pawn)((Thing)actor.CurJob.GetTarget(target));
                if (InteractionUtility.IsGoodPositionForInteraction(actor, pawn))
                {
                    actor.jobs.curDriver.ReadyForNextToil();
                }
                else
                {
                    actor.pather.StartPath(pawn, PathEndMode.Touch);
                }
            };
            toil.tickAction = delegate
            {
                Pawn actor = toil.actor;
                Pawn pawn  = (Pawn)((Thing)actor.CurJob.GetTarget(target));
                Map  map   = actor.Map;
                if (InteractionUtility.IsGoodPositionForInteraction(actor, pawn) && actor.Position.InHorDistOf(pawn.Position, (float)Mathf.CeilToInt(3f)) && (!actor.pather.Moving || actor.pather.nextCell.GetDoor(map) == null))
                {
                    actor.pather.StopDead();
                    actor.jobs.curDriver.ReadyForNextToil();
                }
                else if (!actor.pather.Moving)
                {
                    IntVec3 intVec = IntVec3.Invalid;
                    for (int i = 0; i < 9; i++)
                    {
                        if (i == 8 && intVec.IsValid)
                        {
                            break;
                        }
                        IntVec3 intVec2 = pawn.Position + GenAdj.AdjacentCellsAndInside[i];
                        if (intVec2.InBounds(map) && intVec2.Walkable(map) && intVec2 != actor.Position && InteractionUtility.IsGoodPositionForInteraction(intVec2, pawn.Position, map) && actor.CanReach(intVec2, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn) && (!intVec.IsValid || actor.Position.DistanceToSquared(intVec2) < actor.Position.DistanceToSquared(intVec)))
                        {
                            intVec = intVec2;
                        }
                    }
                    if (intVec.IsValid)
                    {
                        actor.pather.StartPath(intVec, PathEndMode.OnCell);
                    }
                    else
                    {
                        actor.jobs.curDriver.EndJobWith(JobCondition.Incompletable);
                    }
                }
            };
            toil.socialMode          = RandomSocialMode.Off;
            toil.defaultCompleteMode = ToilCompleteMode.Never;
            return(toil);
        }
Exemple #3
0
            internal void <> m__0()
            {
                Pawn actor = this.toil.actor;
                Pawn pawn  = (Pawn)((Thing)actor.CurJob.GetTarget(this.target));

                if (InteractionUtility.IsGoodPositionForInteraction(actor, pawn))
                {
                    actor.jobs.curDriver.ReadyForNextToil();
                }
                else
                {
                    actor.pather.StartPath(pawn, PathEndMode.Touch);
                }
            }
Exemple #4
0
 public bool CanInteractNowWith(Pawn recipient, InteractionDef interactionDef = null)
 {
     if (!recipient.Spawned)
     {
         return(false);
     }
     if (!InteractionUtility.IsGoodPositionForInteraction(pawn, recipient))
     {
         return(false);
     }
     if (!InteractionUtility.CanInitiateInteraction(pawn, interactionDef) || !InteractionUtility.CanReceiveInteraction(recipient, interactionDef))
     {
         return(false);
     }
     return(true);
 }
Exemple #5
0
 public bool CanInteractNowWith(Pawn recipient)
 {
     if (!recipient.Spawned)
     {
         return(false);
     }
     if (!InteractionUtility.IsGoodPositionForInteraction(this.pawn, recipient))
     {
         return(false);
     }
     if (InteractionUtility.CanInitiateInteraction(this.pawn) && InteractionUtility.CanReceiveInteraction(recipient))
     {
         return(true);
     }
     return(false);
 }
Exemple #6
0
 public static bool IsGoodPositionForInteraction(Pawn p, Pawn recipient)
 {
     return(InteractionUtility.IsGoodPositionForInteraction(p.Position, recipient.Position, p.Map));
 }
 public bool CanInteractNowWith(Pawn recipient)
 {
     return(recipient.Spawned && InteractionUtility.IsGoodPositionForInteraction(this.pawn, recipient) && InteractionUtility.CanInitiateInteraction(this.pawn) && InteractionUtility.CanReceiveInteraction(recipient));
 }