public static bool PreFix(ref Toil __result, TargetIndex targetInd, Action hitAction)
        {
            var followAndAttack = new Toil();

            followAndAttack.tickAction = delegate
            {
                var actor     = followAndAttack.actor;
                var curJob    = actor.jobs.curJob;
                var curDriver = actor.jobs.curDriver;
                var thing     = curJob.GetTarget(targetInd).Thing;
                var pawn      = thing as Pawn;
                if (thing.Spawned && !actor.CanReachImmediate(pawn, PathEndMode.Touch))
                {
                    bool b;
                    if (actor == null)
                    {
                        b = false;
                    }
                    else
                    {
                        var mindState = actor.mindState;
                        b = mindState?.meleeThreat != null;
                    }

                    if (!b && pawn != null && CamoUtility.IsTargetHidden(pawn, actor))
                    {
                        CamoAIUtility.CorrectJob(actor, pawn);
                    }
                }

                if (!thing.Spawned)
                {
                    curDriver.ReadyForNextToil();
                    return;
                }

                if (thing != actor.pather.Destination.Thing ||
                    !actor.pather.Moving && !actor.CanReachImmediate(thing, PathEndMode.Touch))
                {
                    actor.pather.StartPath(thing, PathEndMode.Touch);
                    return;
                }

                if (!actor.CanReachImmediate(thing, PathEndMode.Touch))
                {
                    return;
                }

                if (pawn != null && pawn.Downed && !curJob.killIncappedTarget)
                {
                    curDriver.ReadyForNextToil();
                    return;
                }

                hitAction();
            };
            followAndAttack.defaultCompleteMode = ToilCompleteMode.Never;
            __result = followAndAttack;
            return(false);
        }
        public static bool PreFix(ref Toil __result, TargetIndex targetInd, Action hitAction)
        {
            Toil followAndAttack = new Toil();

            followAndAttack.tickAction = delegate()
            {
                Pawn      actor     = followAndAttack.actor;
                Job       curJob    = actor.jobs.curJob;
                JobDriver curDriver = actor.jobs.curDriver;
                Thing     thing     = curJob.GetTarget(targetInd).Thing;
                Pawn      pawn      = thing as Pawn;
                if (thing.Spawned && !ReachabilityImmediate.CanReachImmediate(actor, pawn, PathEndMode.Touch))
                {
                    bool flag;
                    if (actor == null)
                    {
                        flag = (null != null);
                    }
                    else
                    {
                        Pawn_MindState mindState = actor.mindState;
                        flag = ((mindState?.meleeThreat) != null);
                    }
                    if (!flag && pawn != null && pawn != null && CamoUtility.IsTargetHidden(pawn, actor))
                    {
                        CamoAIUtility.CorrectJob(actor, pawn);
                    }
                }
                if (!thing.Spawned)
                {
                    curDriver.ReadyForNextToil();
                    return;
                }
                if (thing != actor.pather.Destination.Thing || (!actor.pather.Moving && !ReachabilityImmediate.CanReachImmediate(actor, thing, PathEndMode.Touch)))
                {
                    actor.pather.StartPath(thing, PathEndMode.Touch);
                    return;
                }
                if (ReachabilityImmediate.CanReachImmediate(actor, thing, PathEndMode.Touch))
                {
                    if (pawn != null && pawn.Downed && !curJob.killIncappedTarget)
                    {
                        curDriver.ReadyForNextToil();
                        return;
                    }
                    hitAction();
                }
            };
            followAndAttack.defaultCompleteMode = ToilCompleteMode.Never;
            __result = followAndAttack;
            return(false);
        }
コード例 #3
0
 // Token: 0x06000002 RID: 2 RVA: 0x000020F0 File Offset: 0x000002F0
 public static void CorrectLordForCamoAction(Pawn seer, Pawn target, bool playerMap)
 {
     if ((seer?.mindState.duty) != null && !CamoAIUtility.HasFleeingDuty(seer))
     {
         if (!playerMap)
         {
             seer.mindState.duty = new PawnDuty(DutyDefOf.DefendBase, CamoAIUtility.GetNearestBaseItem(seer), -1f);
         }
         if (!CamoAIUtility.IsMeleeProcess(seer, target))
         {
             CamoAIUtility.CorrectJob(seer, target);
             return;
         }
     }
     else if (!CamoAIUtility.IsMeleeProcess(seer, target))
     {
         CamoAIUtility.CorrectJob(seer, target);
     }
 }