// Token: 0x06000037 RID: 55 RVA: 0x00003D60 File Offset: 0x00001F60
        internal static void CalcAndSetCamoEff(Pawn pawn)
        {
            float num;
            float num2;
            float num3;
            float num4;
            float num5;
            float num6;
            float num7;

            if (StealthyBox.IsWearingStealthBox(pawn, out Apparel apparel))
            {
                CompGearCamo compGearCamo = ThingCompUtility.TryGetComp <CompGearCamo>(apparel);
                if (compGearCamo != null)
                {
                    num  = compGearCamo.Props.ArcticCamoEff;
                    num2 = compGearCamo.Props.DesertCamoEff;
                    num3 = compGearCamo.Props.JungleCamoEff;
                    num4 = compGearCamo.Props.StoneCamoEff;
                    num5 = compGearCamo.Props.WoodlandCamoEff;
                    num6 = compGearCamo.Props.UrbanCamoEff;
                    num7 = (compGearCamo.Props.ArcticCamoEff + compGearCamo.Props.DesertCamoEff + compGearCamo.Props.JungleCamoEff + compGearCamo.Props.StoneCamoEff + compGearCamo.Props.WoodlandCamoEff + compGearCamo.Props.UrbanCamoEff) / 6f;
                }
                else
                {
                    num  = 1f;
                    num2 = 1f;
                    num3 = 1f;
                    num4 = 1f;
                    num5 = 1f;
                    num6 = 1f;
                    num7 = 1f;
                }
            }
            else
            {
                CamoGearUtility.WearingCamoGear(pawn, out float num8, out float num9, out float num10, out float num11, out float num12, out float num13, out float num14);
                num  = num8;
                num2 = num9;
                num3 = num10;
                num4 = num11;
                num5 = num12;
                num6 = num13;
                num7 = num14;
            }
            float        pawnArcticCamo     = num;
            float        pawnDesertCamo     = num2;
            float        pawnJungleCamo     = num3;
            float        pawnStoneCamo      = num4;
            float        pawnWoodlandCamo   = num5;
            float        pawnUrbanCamo      = num6;
            float        pawnnotDefinedCamo = num7;
            PawnCamoData pawnCamoData       = ThingCompUtility.TryGetComp <PawnCamoData>(pawn);

            if (pawnCamoData != null)
            {
                pawnCamoData.PawnArcticCamo     = pawnArcticCamo;
                pawnCamoData.PawnDesertCamo     = pawnDesertCamo;
                pawnCamoData.PawnJungleCamo     = pawnJungleCamo;
                pawnCamoData.PawnStoneCamo      = pawnStoneCamo;
                pawnCamoData.PawnWoodlandCamo   = pawnWoodlandCamo;
                pawnCamoData.PawnUrbanCamo      = pawnUrbanCamo;
                pawnCamoData.PawnnotDefinedCamo = pawnnotDefinedCamo;
            }
        }
        // Token: 0x06000037 RID: 55 RVA: 0x00003D60 File Offset: 0x00001F60
        internal static void CalcAndSetCamoEff(Pawn pawn)
        {
            float num;
            float num2;
            float num3;
            float num4;
            float num5;
            float num6;
            float num7;

            if (StealthyBox.IsWearingStealthBox(pawn, out var apparel))
            {
                var compGearCamo = apparel.TryGetComp <CompGearCamo>();
                if (compGearCamo != null)
                {
                    num  = compGearCamo.Props.ArcticCamoEff;
                    num2 = compGearCamo.Props.DesertCamoEff;
                    num3 = compGearCamo.Props.JungleCamoEff;
                    num4 = compGearCamo.Props.StoneCamoEff;
                    num5 = compGearCamo.Props.WoodlandCamoEff;
                    num6 = compGearCamo.Props.UrbanCamoEff;
                    num7 = (compGearCamo.Props.ArcticCamoEff + compGearCamo.Props.DesertCamoEff +
                            compGearCamo.Props.JungleCamoEff + compGearCamo.Props.StoneCamoEff +
                            compGearCamo.Props.WoodlandCamoEff + compGearCamo.Props.UrbanCamoEff) / 6f;
                }
                else
                {
                    num  = 1f;
                    num2 = 1f;
                    num3 = 1f;
                    num4 = 1f;
                    num5 = 1f;
                    num6 = 1f;
                    num7 = 1f;
                }
            }
            else
            {
                WearingCamoGear(pawn, out var num8, out var num9, out var num10, out var num11, out var num12,
                                out var num13, out var num14);
                num  = num8;
                num2 = num9;
                num3 = num10;
                num4 = num11;
                num5 = num12;
                num6 = num13;
                num7 = num14;
            }

            var pawnArcticCamo     = num;
            var pawnDesertCamo     = num2;
            var pawnJungleCamo     = num3;
            var pawnStoneCamo      = num4;
            var pawnWoodlandCamo   = num5;
            var pawnUrbanCamo      = num6;
            var pawnnotDefinedCamo = num7;
            var pawnCamoData       = pawn.TryGetComp <PawnCamoData>();

            if (pawnCamoData == null)
            {
                return;
            }

            pawnCamoData.PawnArcticCamo     = pawnArcticCamo;
            pawnCamoData.PawnDesertCamo     = pawnDesertCamo;
            pawnCamoData.PawnJungleCamo     = pawnJungleCamo;
            pawnCamoData.PawnStoneCamo      = pawnStoneCamo;
            pawnCamoData.PawnWoodlandCamo   = pawnWoodlandCamo;
            pawnCamoData.PawnUrbanCamo      = pawnUrbanCamo;
            pawnCamoData.PawnnotDefinedCamo = pawnnotDefinedCamo;
        }
Exemplo n.º 3
0
        // Token: 0x0600001C RID: 28 RVA: 0x000031E8 File Offset: 0x000013E8
        internal static float GetMiscFactor(Pawn target, Pawn seer, bool ActiveCamo)
        {
            var num = 1f;

            if (StealthyBox.IsWearingStealthBox(target, out _))
            {
                num *= 0.5f;
            }

            bool b;

            if (target == null)
            {
                b = false;
            }
            else
            {
                var stances = target.stances;
                b = stances?.curStance != null;
            }

            if (b)
            {
                if (!target.Downed)
                {
                    if (target.stances.curStance is Stance_Mobile)
                    {
                        if (StealthyBox.IsWearingStealthBox(target, out _))
                        {
                            num *= 1.5f;
                        }
                        else
                        {
                            num *= 1.1f;
                        }

                        if (IsInsectoid(seer))
                        {
                            num *= 1.25f;
                        }
                    }
                    else if (target.stances.curStance is Stance_Cooldown || target.stances.curStance is Stance_Warmup)
                    {
                        num *= 0.95f;
                        if (IsInsectoid(seer))
                        {
                            num *= 0.75f;
                        }
                    }
                }
                else
                {
                    num *= 0.5f;
                    if (IsInsectoid(seer))
                    {
                        num *= 0.75f;
                    }
                }
            }

            if (Controller.Settings.DoCheckWeather && target?.Map != null)
            {
                var accuracyMultiplier = target.Map.weatherManager.curWeather.accuracyMultiplier;
                if (accuracyMultiplier != 1f)
                {
                    num *= accuracyMultiplier;
                }
            }

            if (Controller.Settings.DoCheckLight && !ActiveCamo)
            {
                if (target != null)
                {
                    var psychGlow = target.Map.glowGrid.PsychGlowAt(target.Position);
                    if (psychGlow == PsychGlow.Overlit)
                    {
                        num *= 1.15f;
                    }
                    else
                    {
                        num *= 0.8f;
                    }
                }

                var psychGlow2 = seer.Map.glowGrid.PsychGlowAt(seer.Position);
                if (psychGlow2 == PsychGlow.Overlit)
                {
                    num *= 0.85f;
                }
                else
                {
                    num *= 1.2f;
                }
            }

            if (!Controller.Settings.DoCheckTemp)
            {
                return(num);
            }

            if (target == null)
            {
                return(num);
            }

            var temperature = target.Position.GetTemperature(target.Map);
            var num2        = 21f;

            if (temperature > num2)
            {
                num *= Mathf.Lerp(1f, 0.85f, (temperature - num2) / temperature);
            }

            return(num);
        }
Exemplo n.º 4
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)
        {
            var bestChance = Controller.Settings.bestChance;
            var num        = 0;
            var num2       = target.Position.DistanceTo(seer.Position);
            var num3       = 0.1f;
            var num4       = 0.2f;

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

            var 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;
            }

            var num6 = 0;

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

            var num7 = 0;

            if (isActive && ACApparel != null)
            {
                num7 = GetQualOffset(ACApparel);
            }

            if (isActive)
            {
                if (isStealth)
                {
                    chance = StealthCamoChance;
                    num    = (int)Mathf.Lerp(Math.Min(bestChance, bestChance - num7), Math.Max(1f, 1f - num7), scaler);
                }
                else
                {
                    chance = (int)Mathf.Lerp(Math.Min(bestChance, bestChance - num7), Math.Max(1f, 1f - num7), scaler);
                }
            }
            else
            {
                chance = (int)Mathf.Lerp(bestChance, 1f, scaler);
            }

            var num8 = chance;

            if (!(seer is Pawn))
            {
                return(false);
            }

            if (!((Pawn)seer).health.capacities.CapableOf(PawnCapacityDefOf.Sight))
            {
                return(true);
            }

            var level = ((Pawn)seer).health.capacities.GetLevel(PawnCapacityDefOf.Sight);

            if (Controller.Settings.DoCheckFlash)
            {
                var gunFlashEff = GetGunFlashEff(target, (Pawn)seer);
                if (gunFlashEff > 1f)
                {
                    var num9 = chance;
                    if (isStealth)
                    {
                        num9 = num;
                    }

                    chance = Math.Min((int)bestChance, (int)(num9 * gunFlashEff));
                }
            }

            var num10 = chance;

            if (chance > 0)
            {
                var miscFactor = GetMiscFactor(target, (Pawn)seer, false);
                chance = Math.Min((int)bestChance, (int)(chance * level * miscFactor));
            }

            var num11 = chance;

            if (IsDebugMode())
            {
                Log.Message("Base: " + num8 + ", Flash: " + num10 + ", Sight: " + num11);
            }

            return(chance < 100 && (chance < 1 || Rnd100() + num6 > chance));
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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);
        }