Ejemplo n.º 1
0
        static protected List <int> CalculateAllowedDestCells(Map map, LocalTargetInfo dest, PathEndMode peMode, TraverseParms traverseParms)
        {
            CellIndices cellIndices      = map.cellIndices;
            List <int>  allowedDestCells = new List <int>();
            CellRect    targetArea;

            if (!dest.HasThing || peMode == PathEndMode.OnCell)
            {
                targetArea = CellRect.SingleCell(dest.Cell);
            }
            else
            {
                targetArea = dest.Thing.OccupiedRect();
            }
            if (peMode == PathEndMode.Touch)
            {
                targetArea = targetArea.ExpandedBy(1);
                allowedDestCells.AddRange(from c in targetArea.Cells select cellIndices.CellToIndex(c.x, c.z));
                int minX = targetArea.minX;
                int minZ = targetArea.minZ;
                int maxX = targetArea.maxX;
                int maxZ = targetArea.maxZ;
                if (!TouchPathEndModeUtility.IsCornerTouchAllowed(minX + 1, minZ + 1, minX + 1, minZ, minX, minZ + 1, map))
                {
                    allowedDestCells.Remove(cellIndices.CellToIndex(minX, minZ));
                }
                if (!TouchPathEndModeUtility.IsCornerTouchAllowed(minX + 1, maxZ - 1, minX + 1, maxZ, minX, maxZ - 1, map))
                {
                    allowedDestCells.Remove(cellIndices.CellToIndex(minX, maxZ));
                }
                if (!TouchPathEndModeUtility.IsCornerTouchAllowed(maxX - 1, maxZ - 1, maxX - 1, maxZ, maxX, maxZ - 1, map))
                {
                    allowedDestCells.Remove(cellIndices.CellToIndex(maxX, maxZ));
                }
                if (!TouchPathEndModeUtility.IsCornerTouchAllowed(maxX - 1, minZ + 1, maxX - 1, minZ, maxX, minZ + 1, map))
                {
                    allowedDestCells.Remove(cellIndices.CellToIndex(maxX, minZ));
                }
            }
            else
            {
                allowedDestCells.AddRange(from c in targetArea.Cells select cellIndices.CellToIndex(c.x, c.z));
            }

            return(allowedDestCells);
        }
Ejemplo n.º 2
0
 private static bool IsCornerTouchAllowed2(int cornerX, int cornerZ, int adjCardinal1X, int adjCardinal1Z, int adjCardinal2X, int adjCardinal2Z, Map map)
 {
     return(TouchPathEndModeUtility.IsCornerTouchAllowed(cornerX, cornerZ, adjCardinal1X, adjCardinal1Z, adjCardinal2X, adjCardinal2Z, map));
 }
 private bool IsCornerTouchAllowed(int cornerX, int cornerZ, int adjCardinal1X, int adjCardinal1Z, int adjCardinal2X, int adjCardinal2Z)
 {
     return(TouchPathEndModeUtility.IsCornerTouchAllowed(cornerX, cornerZ, adjCardinal1X, adjCardinal1Z, adjCardinal2X, adjCardinal2Z, this.map));
 }