OpenRA.Map.Contains C# (CSharp) Method

Contains() public method

public Contains ( OpenRA.CPos cell ) : bool
cell OpenRA.CPos
return bool
        public bool Contains(CPos cell)
        {
            // .ToMPos() returns the same result if the X and Y coordinates
            // are switched. X < Y is invalid in the RectangularIsometric coordinate system,
            // so we pre-filter these to avoid returning the wrong result
            if (Grid.Type == MapGridType.RectangularIsometric && cell.X < cell.Y)
                return false;

            return Contains(cell.ToMPos(this));
        }

Same methods

Map::Contains ( MPos uv ) : bool
Map::Contains ( OpenRA.PPos puv ) : bool

Usage Example

Example #1
0
		static int ObserverShroudedEdges(Map map, CPos p, bool useExtendedIndex)
		{
			var u = 0;
			if (!map.Contains(p + new CVec(0, -1))) u |= 0x13;
			if (!map.Contains(p + new CVec(1, 0))) u |= 0x26;
			if (!map.Contains(p + new CVec(0, 1))) u |= 0x4C;
			if (!map.Contains(p + new CVec(-1, 0))) u |= 0x89;

			var uside = u & 0x0F;
			if (!map.Contains(p + new CVec(-1, -1))) u |= 0x01;
			if (!map.Contains(p + new CVec(1, -1))) u |= 0x02;
			if (!map.Contains(p + new CVec(1, 1))) u |= 0x04;
			if (!map.Contains(p + new CVec(-1, 1))) u |= 0x08;

			return useExtendedIndex ? u ^ uside : u & 0x0F;
		}