Exemplo n.º 1
0
        private static bool TryFindAdjustedCoverInCell(IntVec3 shooterLoc, IntVec3 targetLoc, IntVec3 adjCell, Map map, out CoverInfo result)
        {
            Thing cover = adjCell.GetCover(map);
            float num2;

            if (cover != null && !(shooterLoc == targetLoc))
            {
                float angleFlat  = (shooterLoc - targetLoc).AngleFlat;
                float angleFlat2 = (adjCell - targetLoc).AngleFlat;
                float num        = GenGeo.AngleDifferenceBetween(angleFlat2, angleFlat);
                if (!targetLoc.AdjacentToCardinal(adjCell))
                {
                    num = (float)(num * 1.75);
                }
                num2 = cover.def.BaseBlockChance();
                if (num < 15.0)
                {
                    num2 = (float)(num2 * 1.0);
                    goto IL_010b;
                }
                if (num < 27.0)
                {
                    num2 = (float)(num2 * 0.800000011920929);
                    goto IL_010b;
                }
                if (num < 40.0)
                {
                    num2 = (float)(num2 * 0.60000002384185791);
                    goto IL_010b;
                }
                if (num < 52.0)
                {
                    num2 = (float)(num2 * 0.40000000596046448);
                    goto IL_010b;
                }
                if (num < 65.0)
                {
                    num2 = (float)(num2 * 0.20000000298023224);
                    goto IL_010b;
                }
                result = CoverInfo.Invalid;
                return(false);
            }
            result = CoverInfo.Invalid;
            return(false);

IL_010b:
            float lengthHorizontal = (shooterLoc - adjCell).LengthHorizontal;

            if (lengthHorizontal < 1.8999999761581421)
            {
                num2 = (float)(num2 * 0.33329999446868896);
            }
            else if (lengthHorizontal < 2.9000000953674316)
            {
                num2 = (float)(num2 * 0.66666001081466675);
            }
            result = new CoverInfo(cover, num2);
            return(true);
        }
Exemplo n.º 2
0
        private static bool TryFindAdjustedCoverInCell(IntVec3 shooterLoc, LocalTargetInfo target, IntVec3 adjCell, Map map, out CoverInfo result)
        {
            IntVec3 cell  = target.Cell;
            Thing   cover = adjCell.GetCover(map);
            bool    result2;

            if (cover == null || cover == target.Thing || shooterLoc == cell)
            {
                result  = CoverInfo.Invalid;
                result2 = false;
            }
            else
            {
                float angleFlat  = (shooterLoc - cell).AngleFlat;
                float angleFlat2 = (adjCell - cell).AngleFlat;
                float num        = GenGeo.AngleDifferenceBetween(angleFlat2, angleFlat);
                if (!cell.AdjacentToCardinal(adjCell))
                {
                    num *= 1.75f;
                }
                float num2 = cover.def.BaseBlockChance();
                if (num < 15f)
                {
                    num2 *= 1f;
                }
                else if (num < 27f)
                {
                    num2 *= 0.8f;
                }
                else if (num < 40f)
                {
                    num2 *= 0.6f;
                }
                else if (num < 52f)
                {
                    num2 *= 0.4f;
                }
                else
                {
                    if (num >= 65f)
                    {
                        result = CoverInfo.Invalid;
                        return(false);
                    }
                    num2 *= 0.2f;
                }
                float lengthHorizontal = (shooterLoc - adjCell).LengthHorizontal;
                if (lengthHorizontal < 1.9f)
                {
                    num2 *= 0.3333f;
                }
                else if (lengthHorizontal < 2.9f)
                {
                    num2 *= 0.66666f;
                }
                result  = new CoverInfo(cover, num2);
                result2 = true;
            }
            return(result2);
        }
Exemplo n.º 3
0
        public static float TotalSurroundingCoverScore(IntVec3 c, Map map)
        {
            float num = 0f;

            for (int i = 0; i < 8; i++)
            {
                IntVec3 c2 = c + GenAdj.AdjacentCells[i];
                if (c2.InBounds(map))
                {
                    Thing cover = c2.GetCover(map);
                    if (cover != null)
                    {
                        num += cover.BaseBlockChance();
                    }
                }
            }
            return(num);
        }