コード例 #1
0
 // Token: 0x0600000C RID: 12 RVA: 0x00002524 File Offset: 0x00000724
 public static void CorrectJob(Pawn seer, Pawn target)
 {
     if (seer != null && target != null && (seer?.Map) != null && (target?.Map) != null && seer.Map == target.Map)
     {
         bool flag;
         if (seer == null)
         {
             flag = (null != null);
         }
         else
         {
             Pawn_MindState mindState = seer.mindState;
             flag = ((mindState?.meleeThreat) != null);
         }
         if (!flag && ThingCompUtility.TryGetComp <PawnCamoData>(seer).LastCamoCorrectTick + 120 <= Find.TickManager.TicksGame && seer.Spawned && target.Spawned)
         {
             bool flag2;
             if (seer == null)
             {
                 flag2 = (null != null);
             }
             else
             {
                 Pawn_JobTracker jobs = seer.jobs;
                 flag2 = ((jobs?.curJob) != null);
             }
             if (flag2 && seer.jobs.curJob.def != CamoAIUtility.CamoPauseJobDef() && seer.jobs.curJob.AnyTargetIs(target))
             {
                 ThingCompUtility.TryGetComp <PawnCamoData>(seer).LastCamoCorrectTick = Find.TickManager.TicksGame;
                 CamoAIUtility.RemoveTarget(seer, target);
             }
         }
     }
 }
コード例 #2
0
 // Token: 0x0600000A RID: 10 RVA: 0x000023A8 File Offset: 0x000005A8
 public static void JobFailIfHid(Pawn seer, Pawn target, Job cur)
 {
     if (seer != null && target != null && cur != null && cur.def != CamoAIUtility.CamoPauseJobDef() && seer.Spawned && target.Spawned && (seer?.Map) != null && (target?.Map) != null && seer.Map == target.Map)
     {
         bool flag;
         if (seer == null)
         {
             flag = (null != null);
         }
         else
         {
             Pawn_MindState mindState = seer.mindState;
             flag = ((mindState?.meleeThreat) != null);
         }
         if (!flag)
         {
             if (CamoAIUtility.CanSeeSimply(seer, target))
             {
                 if (CamoUtility.IsTargetHidden(target, seer))
                 {
                     CamoAIUtility.CorrectLordForCamo(seer, target);
                     return;
                 }
             }
             else
             {
                 CamoAIUtility.CorrectLordForCamo(seer, target);
             }
         }
     }
 }
コード例 #3
0
        public static bool PreFix(ref bool __result, CastPositionRequest newReq, out IntVec3 dest)
        {
            dest = IntVec3.Invalid;
            var caster = newReq.caster;

            if (caster == null || newReq.target is not Pawn pawn)
            {
                return(true);
            }

            var jobs = caster.jobs;

            if (jobs?.curJob != null && CamoAIUtility.JobIsCastException(caster.jobs.curJob.def))
            {
                return(true);
            }

            if (!CamoUtility.IsTargetHidden(pawn, caster))
            {
                return(true);
            }

            __result = false;
            return(false);
        }
        public static bool PreFix(ref bool __result, CastPositionRequest newReq, out IntVec3 dest)
        {
            dest = IntVec3.Invalid;
            Pawn caster = newReq.caster;
            Pawn pawn   = newReq.target as Pawn;

            if (caster != null && pawn != null && caster != null && pawn != null)
            {
                bool flag;
                if (caster == null)
                {
                    flag = (null != null);
                }
                else
                {
                    Pawn_JobTracker jobs = caster.jobs;
                    flag = ((jobs?.curJob) != null);
                }
                if (flag && CamoAIUtility.JobIsCastException(caster.jobs.curJob.def))
                {
                    return(true);
                }
                if (CamoUtility.IsTargetHidden(pawn, caster))
                {
                    __result = false;
                    return(false);
                }
            }
            return(true);
        }
コード例 #5
0
        public static bool PreFix(ref Toil __result, TargetIndex ind, PathEndMode peMode)
        {
            Toil toil = new Toil();

            toil.initAction = delegate()
            {
                Pawn actor = toil.actor;
                actor.pather.StartPath(actor.jobs.curJob.GetTarget(ind), peMode);
            };
            toil.AddPreTickAction(delegate()
            {
                Pawn actor = toil.actor;
                if (Gen.IsHashIntervalTick(actor, 240) && actor.jobs.curJob.GetTarget(ind).HasThing)
                {
                    Thing thing = actor.jobs.curJob.GetTarget(ind).Thing;
                    if (thing is Pawn && GenHostility.HostileTo(actor, thing as Pawn))
                    {
                        CamoAIUtility.JobFailIfHid(actor, thing as Pawn, actor.jobs.curJob);
                    }
                }
            });
            toil.defaultCompleteMode = ToilCompleteMode.PatherArrival;
            __result = toil;
            return(false);
        }
        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);
        }
コード例 #7
0
        // Token: 0x06000006 RID: 6 RVA: 0x000021CC File Offset: 0x000003CC
        private static void GiveWaitJob(Pawn pawn, int period)
        {
            ThingCompUtility.TryGetComp <PawnCamoData>(pawn).LastCamoCorrectTick = Find.TickManager.TicksGame;
            Job job = new Job(CamoAIUtility.CamoPauseJobDef())
            {
                expiryInterval        = period,
                checkOverrideOnExpire = true
            };

            pawn.jobs.jobQueue.EnqueueFirst(job, null);
        }
        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);
        }
コード例 #9
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);
     }
 }
コード例 #10
0
        public static bool PreFix(ref Toil __result, TargetIndex ind, PathEndMode peMode)
        {
            var toil = new Toil();

            toil.initAction = delegate
            {
                var actor = toil.actor;
                actor.pather.StartPath(actor.jobs.curJob.GetTarget(ind), peMode);
            };
            toil.AddPreTickAction(delegate
            {
                var actor = toil.actor;
                if (!actor.IsHashIntervalTick(240) || !actor.jobs.curJob.GetTarget(ind).HasThing)
                {
                    return;
                }

                var thing = actor.jobs.curJob.GetTarget(ind).Thing;
                if (thing is Pawn pawn && actor.HostileTo(pawn))
                {
                    CamoAIUtility.JobFailIfHid(actor, pawn, actor.jobs.curJob);
                }
            });
コード例 #11
0
 // Token: 0x06000001 RID: 1 RVA: 0x00002050 File Offset: 0x00000250
 public static void CorrectLordForCamo(Pawn seer, Pawn target)
 {
     if (seer == null || target == null || (seer?.Map) == null || (target?.Map) == null || seer.Map != target.Map || seer.IsColonist)
     {
         return;
     }
     if (seer.RaceProps.IsMechanoid)
     {
         return;
     }
     if (!WildManUtility.AnimalOrWildMan(seer) || seer.RaceProps.FleshType != FleshTypeDefOf.Insectoid)
     {
         CamoAIUtility.CorrectLordForCamoAction(seer, target, seer.Map.IsPlayerHome);
         return;
     }
     if (seer != null)
     {
         Pawn_MindState mindState = seer.mindState;
         if (mindState != null)
         {
             _ = mindState.duty;
         }
     }
 }
コード例 #12
0
 // Token: 0x06000004 RID: 4 RVA: 0x000021B5 File Offset: 0x000003B5
 public static void StopCurJobAndWait(Pawn pawn)
 {
     CamoAIUtility.ClearAllJobs(pawn);
     CamoAIUtility.GiveWaitJob(pawn, 117);
 }
コード例 #13
0
        // Token: 0x0600000B RID: 11 RVA: 0x0000244C File Offset: 0x0000064C
        public static void RemoveTarget(Pawn seer, Pawn target)
        {
            if (seer.pather.Moving)
            {
                bool flag;
                if (seer == null)
                {
                    flag = (null != null);
                }
                else
                {
                    Pawn_JobTracker jobs = seer.jobs;
                    flag = ((jobs?.curJob) != null);
                }
                if (flag && seer.jobs.curJob.AnyTargetIs(target))
                {
                    seer.jobs.curDriver.Notify_PatherFailed();
                    bool flag2;
                    if (seer == null)
                    {
                        flag2 = (null != null);
                    }
                    else
                    {
                        Pawn_PathFollower pather = seer.pather;
                        flag2 = ((pather?.curPath) != null);
                    }
                    if (flag2)
                    {
                        seer.pather.ResetToCurrentPosition();
                        seer.pather.curPath.ReleaseToPool();
                    }
                }
            }
            bool flag3;

            if (seer == null)
            {
                flag3 = (null != null);
            }
            else
            {
                Pawn_MindState mindState = seer.mindState;
                flag3 = ((mindState?.enemyTarget) != null);
            }
            if (flag3)
            {
                seer.mindState.enemyTarget = null;
            }
            bool flag4;

            if (seer == null)
            {
                flag4 = (null != null);
            }
            else
            {
                Pawn_MindState mindState2 = seer.mindState;
                flag4 = ((mindState2?.meleeThreat) != null);
            }
            if (!flag4)
            {
                CamoAIUtility.StopCurJobAndWait(seer);
            }
        }
コード例 #14
0
        // Token: 0x06000016 RID: 22 RVA: 0x000028CC File Offset: 0x00000ACC
        public static bool IsTargetHidden(Pawn target, Pawn seer)
        {
            if (target == null || seer == null)
            {
                Log.Message("Target/Seer Null");
                return(false);
            }

            if (target == seer)
            {
                return(false);
            }

            if (TryGetCamoHidValue(seer, target, out var result))
            {
                return(result);
            }

            if (!target.Spawned)
            {
                return(false);
            }

            var     isCamoActive = false;
            Apparel apparel      = null;

            if (!IsDebugMode() || !Controller.Settings.forcePassive)
            {
                isCamoActive = IsCamoActive(target, out var apparel2);
                if (apparel2 != null)
                {
                    apparel = apparel2;
                }
            }

            if ((!isCamoActive || seer.CurrentEffectiveVerb.IsMeleeAttack) && SimplyTooClose(seer, target))
            {
                TryAddCamoHidValue(seer, target, false);
                return(false);
            }

            if (isCamoActive || IsDebugMode() && Controller.Settings.forceActive)
            {
                if (!seer.Spawned)
                {
                    return(false);
                }

                if (target.Map == null || seer.Map == null || target.Map != seer.Map ||
                    seer.InMentalState && target.InMentalState)
                {
                    TryAddCamoHidValue(seer, target, false);
                    return(false);
                }

                if (!GenSight.LineOfSight(seer.Position, target.Position, seer.Map))
                {
                    return(true);
                }

                var  num  = 0.75f;
                var  num2 = 0;
                bool settingsForceStealth;
                if (IsDebugMode() && Controller.Settings.forceActive)
                {
                    apparel = null;
                    settingsForceStealth = Controller.Settings.forceStealth;
                    if (settingsForceStealth)
                    {
                        num2 = 5;
                    }
                }
                else
                {
                    num  = apparel.TryGetComp <CompGearCamo>().Props.ActiveCamoEff;
                    num2 = apparel.TryGetComp <CompGearCamo>().Props.StealthCamoChance;
                    settingsForceStealth = num2 > 0 && num > 0f;
                }

                if (CamoEffectWorked(target, seer, apparel, num, true, settingsForceStealth, num2, out var chance,
                                     out var scaler))
                {
                    DoCamoMote(seer, target, true, chance, num, scaler);
                    TryAddCamoHidValue(seer, target, true);
                    CamoAIUtility.CorrectLordForCamo(seer, target);
                    return(true);
                }

                DoCamoMote(seer, target, false, chance, num, scaler);
                TryAddCamoHidValue(seer, target, false);
                return(false);
            }

            if (!seer.Spawned)
            {
                return(false);
            }

            if (!CamoGearUtility.GetCurCamoEff(target, out var str, out var camoEff))
            {
                TryAddCamoHidValue(seer, target, false);
                return(false);
            }

            if (IsDebugMode())
            {
                if (Controller.Settings.forcePassive)
                {
                    camoEff = 0.75f;
                }

                Log.Message("Camo: " + str + " : " + camoEff.ToString("F2"));
            }

            if (target.Map == null || seer.Map == null || target.Map != seer.Map ||
                seer.InMentalState && target.InMentalState)
            {
                TryAddCamoHidValue(seer, target, false);
                return(false);
            }

            if (!GenSight.LineOfSight(seer.Position, target.Position, seer.Map))
            {
                return(true);
            }

            if (CamoEffectWorked(target, seer, null, camoEff, false, false, 0, out var chance2,
                                 out var scaler2))
            {
                DoCamoMote(seer, target, true, chance2, camoEff, scaler2);
                TryAddCamoHidValue(seer, target, true);
                CamoAIUtility.CorrectLordForCamo(seer, target);
                return(true);
            }

            DoCamoMote(seer, target, false, chance2, camoEff, scaler2);
            TryAddCamoHidValue(seer, target, false);
            return(false);
        }
コード例 #15
0
 // Token: 0x06000016 RID: 22 RVA: 0x000028CC File Offset: 0x00000ACC
 public static bool IsTargetHidden(Pawn target, Pawn seer)
 {
     if (target == null || seer == null)
     {
         Log.Message("Target/Seer Null", false);
         return(false);
     }
     if (target != null && seer != null)
     {
         if (target == seer)
         {
             return(false);
         }
         if (CamoUtility.TryGetCamoHidValue(seer, target, out bool result))
         {
             return(result);
         }
     }
     if (target != null && target.Spawned)
     {
         bool    flag    = false;
         Apparel apparel = null;
         if (!CamoUtility.IsDebugMode() || !Controller.Settings.forcePassive)
         {
             flag = CamoUtility.IsCamoActive(target, out Apparel apparel2);
             if (apparel2 != null)
             {
                 apparel = apparel2;
             }
         }
         if ((!flag || (flag && seer.CurrentEffectiveVerb.IsMeleeAttack)) && CamoUtility.SimplyTooClose(seer, target))
         {
             CamoUtility.TryAddCamoHidValue(seer, target, false);
             return(false);
         }
         if (flag || (CamoUtility.IsDebugMode() && Controller.Settings.forceActive))
         {
             if (seer == null || !seer.Spawned)
             {
                 return(false);
             }
             if ((target?.Map) == null || (seer?.Map) == null || target.Map != seer.Map || (seer.InMentalState && target.InMentalState))
             {
                 CamoUtility.TryAddCamoHidValue(seer, target, false);
                 return(false);
             }
             if (!GenSight.LineOfSight(seer.Position, target.Position, seer.Map, false, null, 0, 0))
             {
                 return(true);
             }
             float num  = 0.75f;
             int   num2 = 0;
             bool  flag2;
             if (CamoUtility.IsDebugMode() && Controller.Settings.forceActive)
             {
                 apparel = null;
                 flag2   = Controller.Settings.forceStealth;
                 if (flag2)
                 {
                     num2 = 5;
                 }
             }
             else
             {
                 num   = ThingCompUtility.TryGetComp <CompGearCamo>(apparel).Props.ActiveCamoEff;
                 num2  = ThingCompUtility.TryGetComp <CompGearCamo>(apparel).Props.StealthCamoChance;
                 flag2 = (num2 > 0 && num > 0f);
             }
             if (CamoUtility.CamoEffectWorked(target, seer, apparel, num, true, flag2, num2, out int chance, out float scaler))
             {
                 CamoUtility.DoCamoMote(seer, target, true, chance, num, scaler);
                 CamoUtility.TryAddCamoHidValue(seer, target, true);
                 CamoAIUtility.CorrectLordForCamo(seer, target);
                 return(true);
             }
             CamoUtility.DoCamoMote(seer, target, false, chance, num, scaler);
             CamoUtility.TryAddCamoHidValue(seer, target, false);
             return(false);
         }
         else if (seer != null && seer.Spawned)
         {
             if (!CamoGearUtility.GetCurCamoEff(target, out string str, out float camoEff))
             {
                 CamoUtility.TryAddCamoHidValue(seer, target, false);
                 return(false);
             }
             if (CamoUtility.IsDebugMode())
             {
                 if (Controller.Settings.forcePassive)
                 {
                     camoEff = 0.75f;
                 }
                 Log.Message("Camo: " + str + " : " + camoEff.ToString("F2"), false);
             }
             if ((target?.Map) == null || (seer?.Map) == null || target.Map != seer.Map || (seer.InMentalState && target.InMentalState))
             {
                 CamoUtility.TryAddCamoHidValue(seer, target, false);
                 return(false);
             }
             if (!GenSight.LineOfSight(seer.Position, target.Position, seer.Map, false, null, 0, 0))
             {
                 return(true);
             }
             if (CamoUtility.CamoEffectWorked(target, seer, null, camoEff, false, false, 0, out int chance2, out float scaler2))
             {
                 CamoUtility.DoCamoMote(seer, target, true, chance2, camoEff, scaler2);
                 CamoUtility.TryAddCamoHidValue(seer, target, true);
                 CamoAIUtility.CorrectLordForCamo(seer, target);
                 return(true);
             }
             CamoUtility.DoCamoMote(seer, target, false, chance2, camoEff, scaler2);
             CamoUtility.TryAddCamoHidValue(seer, target, false);
             return(false);
         }
     }
     return(false);
 }