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);
        }
        // Token: 0x06000011 RID: 17 RVA: 0x00002740 File Offset: 0x00000940
        public static void DrawCamoOverlay(Pawn pawn)
        {
            bool   flag = false;
            string text = "";

            if (CamoUtility.IsCamoActive(pawn, out Apparel apparel) && apparel != null)
            {
                float activeCamoEff = ThingCompUtility.TryGetComp <CompGearCamo>(apparel).Props.ActiveCamoEff;
                if (ThingCompUtility.TryGetComp <CompGearCamo>(apparel).Props.StealthCamoChance > 0 && activeCamoEff > 0f)
                {
                    text = "Mote_CASStealth";
                    flag = true;
                }
                else if (activeCamoEff > 0f)
                {
                    text = CamoDrawTools.GetMoteToUse(activeCamoEff);
                    flag = true;
                }
            }
            if (!flag && CamoGearUtility.GetCurCamoEff(pawn, out string text2, out float num) && num > 0f)
            {
                text = CamoDrawTools.GetMoteToUse(num);
                flag = true;
            }
            if (flag && text != "")
            {
                CamoDrawTools.DoCamoOverlay(pawn, text);
            }
        }
示例#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);
        }
 // 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);
             }
         }
     }
 }
        // Token: 0x06000011 RID: 17 RVA: 0x00002740 File Offset: 0x00000940
        public static void DrawCamoOverlay(Pawn pawn)
        {
            var b    = false;
            var text = "";

            if (CamoUtility.IsCamoActive(pawn, out var apparel) && apparel != null)
            {
                var activeCamoEff = apparel.TryGetComp <CompGearCamo>().Props.ActiveCamoEff;
                if (apparel.TryGetComp <CompGearCamo>().Props.StealthCamoChance > 0 && activeCamoEff > 0f)
                {
                    text = "Mote_CASStealth";
                    b    = true;
                }
                else if (activeCamoEff > 0f)
                {
                    text = GetMoteToUse(activeCamoEff);
                    b    = true;
                }
            }

            if (!b && CamoGearUtility.GetCurCamoEff(pawn, out _, out var num) && num > 0f)
            {
                text = GetMoteToUse(num);
                b    = true;
            }

            if (b && text != "")
            {
                DoCamoOverlay(pawn, text);
            }
        }
示例#6
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 == CamoPauseJobDef() || !seer.Spawned ||
                !target.Spawned || seer.Map == null || target.Map == null || seer.Map != target.Map)
            {
                return;
            }

            var mindState = seer.mindState;

            if (mindState?.meleeThreat != null)
            {
                return;
            }

            if (CanSeeSimply(seer, target))
            {
                if (CamoUtility.IsTargetHidden(target, seer))
                {
                    CorrectLordForCamo(seer, target);
                }
            }
            else
            {
                CorrectLordForCamo(seer, target);
            }
        }
        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);
        }
示例#8
0
 // Token: 0x0600001E RID: 30 RVA: 0x000033E8 File Offset: 0x000015E8
 internal static float GetGunFlashEff(Pawn pawn, Pawn seer)
 {
     if (pawn != null && (pawn?.Map) != null && seer != null && (seer?.Map) != null && (pawn?.Map) == (seer?.Map))
     {
         Verb verb = pawn?.CurrentEffectiveVerb;
         if (verb != null && !verb.IsMeleeAttack)
         {
             float muzzleFlashScale = verb.verbProps.muzzleFlashScale;
             if (muzzleFlashScale > 0f)
             {
                 int burstShotCount = verb.verbProps.burstShotCount;
                 if (burstShotCount > 0)
                 {
                     bool flag;
                     if (pawn == null)
                     {
                         flag = (null != null);
                     }
                     else
                     {
                         Pawn_StanceTracker stances = pawn.stances;
                         flag = ((stances?.curStance) != null);
                     }
                     if (flag && pawn.stances.curStance is Stance_Cooldown)
                     {
                         float num  = 1f;
                         float num2 = Mathf.Lerp(1f, 1.25f, Math.Min(1f, muzzleFlashScale / 7f)) * num;
                         float num3 = Mathf.Lerp(1f, 1.15f, (float)(Math.Min(burstShotCount, 5) / 5));
                         if (CamoUtility.IsDebugMode())
                         {
                             string text = string.Concat(new string[]
                             {
                                 "RF: ",
                                 num.ToString("F2"),
                                 ", FF: ",
                                 num2.ToString("F2"),
                                 " BF: ",
                                 num3.ToString("F2")
                             });
                             text = string.Concat(new string[]
                             {
                                 text,
                                 "flash: MFS: ",
                                 muzzleFlashScale.ToString("F2"),
                                 ", maxburst: ",
                                 burstShotCount.ToString()
                             });
                             Log.Message(text, false);
                         }
                         return(1f * num2 * num3);
                     }
                 }
             }
         }
     }
     return(1f);
 }
 public static void PostFix(ref bool __result, Thing seer, Thing target, Func <IntVec3, bool> validator = null)
 {
     if (__result && target != null && seer != null && target.Spawned && seer.Spawned && target.Map != null &&
         seer.Map != null && target.Map == seer.Map && target is Pawn pawn && seer is Pawn seer1 &&
         CamoUtility.IsTargetHidden(pawn, seer1))
     {
         __result = false;
     }
 }
        // Token: 0x06000064 RID: 100 RVA: 0x00006618 File Offset: 0x00004818
        public override string CompInspectStringExtra()
        {
            if (CamoUtility.IsCamoActive(Pawn, out var apparel))
            {
                if (apparel == null)
                {
                    return(null);
                }

                var    activeCamoEff = apparel.TryGetComp <CompGearCamo>().Props.ActiveCamoEff;
                string text          = "CompCamo.Active".Translate();
                if (apparel.TryGetComp <CompGearCamo>().Props.StealthCamoChance > 0 && activeCamoEff > 0f)
                {
                    text = "CompCamo.Stealth".Translate();
                }

                return("CompCamo.CamouflageDesc".Translate(text, activeCamoEff.ToStringPercent()));
            }

            if (!CamoGearUtility.GetCurCamoEff(Pawn, out var a, out var num))
            {
                return(null);
            }

            string text2 = "CompCamo.Undefined".Translate();

            switch (a)
            {
            case "Arctic":
                text2 = "CompCamo.Arctic".Translate();
                break;

            case "Desert":
                text2 = "CompCamo.Desert".Translate();
                break;

            case "Jungle":
                text2 = "CompCamo.Jungle".Translate();
                break;

            case "Stone":
                text2 = "CompCamo.Stone".Translate();
                break;

            case "Urban":
                text2 = "CompCamo.Urban".Translate();
                break;

            case "Woodland":
                text2 = "CompCamo.Woodland".Translate();
                break;
            }

            return("CompCamo.CamouflageDesc".Translate(text2, num.ToStringPercent()));
        }
        public static void PostFix(ref IAttackTarget __result, IAttackTargetSearcher searcher)
        {
            if (__result is not Pawn pawn)
            {
                return;
            }

            if (searcher is Pawn pawn2 && CamoUtility.IsTargetHidden(pawn, pawn2))
            {
                __result = 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);
        }
示例#13
0
 // Token: 0x06000014 RID: 20 RVA: 0x00002890 File Offset: 0x00000A90
 public static bool IsCamoActive(Pawn target, out Apparel ACItem)
 {
     ACItem = null;
     if (!CamoGearUtility.IsWearingActiveCamo(target, out Apparel apparel))
     {
         return(false);
     }
     if (apparel != null && CamoUtility.ActiveCamoIsActive(apparel))
     {
         ACItem = apparel;
         return(true);
     }
     return(false);
 }
示例#14
0
 public static void PostFix(ref IAttackTarget __result, IAttackTargetSearcher searcher, TargetScanFlags flags, Predicate <Thing> validator = null, float minDist = 0f, float maxDist = 9999f, IntVec3 locus = default(IntVec3), float maxTravelRadiusFromLocus = 3.40282347E+38f, bool canBash = false, bool canTakeTargetsCloserThanEffectiveMinRange = true)
 {
     if (__result != null)
     {
         Pawn pawn = __result as Pawn;
         if (pawn != null && pawn != null)
         {
             Pawn pawn2 = searcher as Pawn;
             if (pawn2 != null && pawn2 != null && CamoUtility.IsTargetHidden(pawn, pawn2))
             {
                 __result = null;
             }
         }
     }
 }
示例#15
0
        public static void PostFix(ref Verb __instance, ref bool __result, IntVec3 root, LocalTargetInfo targ)
        {
            if (!__result || !targ.HasThing)
            {
                return;
            }

            var thing  = targ.Thing;
            var caster = __instance.caster;

            if (thing is Pawn pawn && caster is Pawn pawn1 &&
                (pawn1.IsColonist && Controller.Settings.AllowNPCCamo || !pawn1.IsColonist) &&
                CamoUtility.IsTargetHidden(pawn, pawn1))
            {
                __result = false;
            }
        }
示例#16
0
        // Token: 0x0600001A RID: 26 RVA: 0x00002E4C File Offset: 0x0000104C
        public static bool CamoEffectWorked(Pawn target, Thing seer, Apparel ACApparel, float CamoEff, bool isActive, bool isStealth, int StealthCamoChance, out int chance, out float scaler)
        {
            float bestChance = Controller.Settings.bestChance;
            int   num        = 0;
            float num2       = IntVec3Utility.DistanceTo(target.Position, seer.Position);
            float num3       = 0.1f;
            float num4       = 0.2f;

            if (!isActive)
            {
                if (num2 >= CamoUtility.minCamoDist)
                {
                    if (num2 > CamoUtility.maxCamoDist)
                    {
                        scaler = 1f;
                    }
                    else
                    {
                        scaler = Mathf.Lerp(num3, 1f, Math.Max(0f, (num2 - CamoUtility.minCamoDist) / (CamoUtility.maxCamoDist - CamoUtility.minCamoDist)));
                    }
                }
                else
                {
                    scaler = 0f;
                }
            }
            else if (num2 >= CamoUtility.ACminCamoDist)
            {
                if (num2 > CamoUtility.ACmaxCamoDist)
                {
                    scaler = 1f;
                }
                else
                {
                    scaler = Mathf.Lerp(num4, 1f, Math.Max(0f, (num2 - CamoUtility.ACminCamoDist) / (CamoUtility.ACmaxCamoDist - CamoUtility.ACminCamoDist)));
                }
            }
            else
            {
                scaler = 0f;
            }
            float num5 = Math.Max(0f, Math.Min(1f, CamoEff));

            if (num5 > 0f)
            {
                scaler *= num5;
            }
            if (isActive)
            {
                scaler *= 0.95f + 0.05f * (Controller.Settings.RelPct / 100f);
            }
            else
            {
                scaler *= 0.85f + 0.1f * (Controller.Settings.RelPct / 100f);
            }
            if (scaler < 0f)
            {
                scaler = 0f;
            }
            if (scaler > 1f)
            {
                scaler = 1f;
            }
            int num6 = 0;

            if (StealthyBox.IsWearingStealthBox(target, out _))
            {
                num6 += 25;
            }
            int num7 = 0;

            if (isActive && ACApparel != null)
            {
                num7 = CamoUtility.GetQualOffset(ACApparel);
            }
            if (isActive)
            {
                if (isStealth)
                {
                    chance = StealthCamoChance;
                    num    = (int)Mathf.Lerp(Math.Min(bestChance, bestChance - (float)num7), Math.Max(1f, 1f - (float)num7), scaler);
                }
                else
                {
                    chance = (int)Mathf.Lerp(Math.Min(bestChance, bestChance - (float)num7), Math.Max(1f, 1f - (float)num7), scaler);
                }
            }
            else
            {
                chance = (int)Mathf.Lerp(bestChance, 1f, scaler);
            }
            int num8 = chance;

            if (!(seer is Pawn))
            {
                return(false);
            }
            if ((seer as Pawn).health.capacities.CapableOf(PawnCapacityDefOf.Sight))
            {
                float level = (seer as Pawn).health.capacities.GetLevel(PawnCapacityDefOf.Sight);
                if (Controller.Settings.DoCheckFlash)
                {
                    float gunFlashEff = CamoUtility.GetGunFlashEff(target, seer as Pawn);
                    if (gunFlashEff > 1f)
                    {
                        int num9 = chance;
                        if (isStealth)
                        {
                            num9 = num;
                        }
                        chance = Math.Min((int)bestChance, (int)((float)num9 * gunFlashEff));
                    }
                }
                int num10 = chance;
                if (chance > 0)
                {
                    float miscFactor = CamoUtility.GetMiscFactor(target, seer as Pawn, false);
                    chance = Math.Min((int)bestChance, (int)((float)chance * level * miscFactor));
                }
                int num11 = chance;
                if (CamoUtility.IsDebugMode())
                {
                    Log.Message("Base: " + num8.ToString() + ", Flash: " + num10.ToString() + ", Sight: " + num11.ToString(), false);
                }
                return(chance < 100 && (chance < 1 || CamoUtility.Rnd100() + num6 > chance));
            }
            return(true);
        }
 public static void PostFix(ref Verb __instance, ref bool __result, IntVec3 root, LocalTargetInfo targ)
 {
     if (__result && targ.HasThing)
     {
         Thing thing  = targ.Thing;
         Thing caster = __instance.caster;
         if (thing is Pawn && caster is Pawn && (((caster as Pawn).IsColonist && Controller.Settings.AllowNPCCamo) || !(caster as Pawn).IsColonist) && CamoUtility.IsTargetHidden(thing as Pawn, caster as Pawn))
         {
             __result = false;
         }
     }
 }
示例#18
0
 // Token: 0x06000064 RID: 100 RVA: 0x00006618 File Offset: 0x00004818
 public override string CompInspectStringExtra()
 {
     if (CamoUtility.IsCamoActive(this.Pawn, out Apparel apparel))
     {
         if (apparel != null)
         {
             float  activeCamoEff = ThingCompUtility.TryGetComp <CompGearCamo>(apparel).Props.ActiveCamoEff;
             string text          = Translator.Translate("CompCamo.Active");
             if (ThingCompUtility.TryGetComp <CompGearCamo>(apparel).Props.StealthCamoChance > 0 && activeCamoEff > 0f)
             {
                 text = Translator.Translate("CompCamo.Stealth");
             }
             return(TranslatorFormattedStringExtensions.Translate("CompCamo.CamouflageDesc", text, GenText.ToStringPercent(activeCamoEff)));
         }
     }
     else if (CamoGearUtility.GetCurCamoEff(this.Pawn, out string a, out float num))
     {
         string text2 = Translator.Translate("CompCamo.Undefined");
         if (!(a == "Arctic"))
         {
             if (!(a == "Desert"))
             {
                 if (!(a == "Jungle"))
                 {
                     if (!(a == "Stone"))
                     {
                         if (!(a == "Urban"))
                         {
                             if (a == "Woodland")
                             {
                                 text2 = Translator.Translate("CompCamo.Woodland");
                             }
                         }
                         else
                         {
                             text2 = Translator.Translate("CompCamo.Urban");
                         }
                     }
                     else
                     {
                         text2 = Translator.Translate("CompCamo.Stone");
                     }
                 }
                 else
                 {
                     text2 = Translator.Translate("CompCamo.Jungle");
                 }
             }
             else
             {
                 text2 = Translator.Translate("CompCamo.Desert");
             }
         }
         else
         {
             text2 = Translator.Translate("CompCamo.Arctic");
         }
         return(TranslatorFormattedStringExtensions.Translate("CompCamo.CamouflageDesc", text2, GenText.ToStringPercent(num)));
     }
     return(null);
 }
示例#19
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);
 }
示例#20
0
        // Token: 0x0600001C RID: 28 RVA: 0x000031E8 File Offset: 0x000013E8
        internal static float GetMiscFactor(Pawn target, Pawn seer, bool ActiveCamo)
        {
            float num  = 1f;
            bool  flag = StealthyBox.IsWearingStealthBox(target, out _);

            if (flag)
            {
                num *= 0.5f;
            }
            bool flag2;

            if (target == null)
            {
                flag2 = (null != null);
            }
            else
            {
                Pawn_StanceTracker stances = target.stances;
                flag2 = ((stances?.curStance) != null);
            }
            if (flag2)
            {
                if (!target.Downed)
                {
                    if (target.stances.curStance is Stance_Mobile)
                    {
                        if (flag)
                        {
                            num *= 1.5f;
                        }
                        else
                        {
                            num *= 1.1f;
                        }
                        if (CamoUtility.IsInsectoid(seer))
                        {
                            num *= 1.25f;
                        }
                    }
                    else if (target.stances.curStance is Stance_Cooldown || target.stances.curStance is Stance_Warmup)
                    {
                        num *= 0.95f;
                        if (CamoUtility.IsInsectoid(seer))
                        {
                            num *= 0.75f;
                        }
                    }
                }
                else
                {
                    num *= 0.5f;
                    if (CamoUtility.IsInsectoid(seer))
                    {
                        num *= 0.75f;
                    }
                }
            }
            if (Controller.Settings.DoCheckWeather && (target?.Map) != null)
            {
                float accuracyMultiplier = target.Map.weatherManager.curWeather.accuracyMultiplier;
                if (accuracyMultiplier != 1f)
                {
                    num *= accuracyMultiplier;
                }
            }
            if (Controller.Settings.DoCheckLight && !ActiveCamo)
            {
                PsychGlow psychGlow = target.Map.glowGrid.PsychGlowAt(target.Position);
                if (psychGlow == PsychGlow.Overlit)
                {
                    num *= 1.15f;
                }
                else
                {
                    num *= 0.8f;
                }
                PsychGlow psychGlow2 = seer.Map.glowGrid.PsychGlowAt(seer.Position);
                if (psychGlow2 == PsychGlow.Overlit)
                {
                    num *= 0.85f;
                }
                else
                {
                    num *= 1.2f;
                }
            }
            if (Controller.Settings.DoCheckTemp)
            {
                float temperature = GridsUtility.GetTemperature(target.Position, target.Map);
                float num2        = 21f;
                if (temperature > num2)
                {
                    num *= Mathf.Lerp(1f, 0.85f, (temperature - num2) / temperature);
                }
            }
            return(num);
        }
示例#21
0
 // Token: 0x0600001F RID: 31 RVA: 0x000035AF File Offset: 0x000017AF
 public static bool IsDebugMode()
 {
     return(Prefs.DevMode && Controller.Settings.useDebug && !CamoUtility.IsGamePaused());
 }
示例#22
0
        // Token: 0x06000021 RID: 33 RVA: 0x00003600 File Offset: 0x00001800
        internal static void DoCamoMote(Thing thing, Thing ghost, bool hidden, int chance, float camoEff, float scaler)
        {
            bool flag  = true;
            bool flag2 = false;

            if (CamoUtility.IsDebugMode() && Controller.Settings.ShowMoteMsgs && thing != null && (thing?.Map) != null && thing.Spawned)
            {
                if (flag)
                {
                    if (thing is Pawn)
                    {
                        flag2 = (ghost is Pawn && GenHostility.HostileTo(thing, ghost) && (!(thing.Position == ghost.Position) && !thing.Position.InHorDistOf(ghost.Position, CamoUtility.NotPossibleMinDist)));
                    }
                }
                else
                {
                    flag2 = true;
                }
                if (flag2 && CamoUtility.IsValidThingForCamo(thing))
                {
                    Vector3 vector = thing.Position.ToVector3();
                    _ = Color.cyan;
                    string text;
                    Color  color;
                    if (hidden)
                    {
                        text  = TranslatorFormattedStringExtensions.Translate("CompCamo.CannotSee", chance.ToString(), GenText.ToStringPercent(camoEff), GenText.ToStringPercent(scaler));
                        color = Color.green;
                    }
                    else
                    {
                        text  = TranslatorFormattedStringExtensions.Translate("CompCamo.CanSee", chance.ToString(), GenText.ToStringPercent(camoEff), GenText.ToStringPercent(scaler));
                        color = Color.red;
                    }
                    MoteMaker.ThrowText(vector, thing.Map, text, color, -1f);
                    if (CamoUtility.IsDebugMode())
                    {
                        string text2 = text;
                        bool   flag3;
                        if (!(thing is Pawn pawn))
                        {
                            flag3 = (null != null);
                        }
                        else
                        {
                            Pawn_JobTracker jobs = pawn.jobs;
                            flag3 = ((jobs?.curJob) != null);
                        }
                        if (flag3)
                        {
                            text2 = text2 + ", CJ: " + (thing as Pawn).jobs.curJob.def.defName;
                            string str  = text2;
                            string str2 = ", ET:";
                            bool   flag4;
                            if (!(thing is Pawn pawn2))
                            {
                                flag4 = (null != null);
                            }
                            else
                            {
                                Pawn_MindState mindState = pawn2.mindState;
                                flag4 = ((mindState?.enemyTarget) != null);
                            }
                            string str3;
                            if (!flag4)
                            {
                                str3 = "null";
                            }
                            else
                            {
                                Thing enemyTarget = (thing as Pawn).mindState.enemyTarget;
                                str3 = (enemyTarget?.LabelShortCap);
                            }
                            text2 = str + str2 + str3;
                            string str4 = text2;
                            string str5 = ", MT:";
                            bool   flag5;
                            if (!(thing is Pawn pawn3))
                            {
                                flag5 = (null != null);
                            }
                            else
                            {
                                Pawn_MindState mindState2 = pawn3.mindState;
                                flag5 = ((mindState2?.meleeThreat) != null);
                            }
                            string str6;
                            if (!flag5)
                            {
                                str6 = "null";
                            }
                            else
                            {
                                Pawn meleeThreat = (thing as Pawn).mindState.meleeThreat;
                                str6 = (meleeThreat?.LabelShortCap);
                            }
                            text2 = str4 + str5 + str6;
                        }
                        Log.Message(text2, false);
                    }