public static void Calculate(IntVector2 viewerLocation, int visionRange, Grid2D <bool> visibilityMap, IntSize2 mapSize, Func <IntVector2, bool> blockerDelegate) { visibilityMap.Clear(); if (blockerDelegate(viewerLocation) == true) { return; } var g = new IntGrid2(new IntVector2(), mapSize); g = g.Offset(-viewerLocation.X, -viewerLocation.Y); var vr = new IntVector2(visionRange, visionRange); g = g.Intersect(new IntGrid2(vr, -vr)); int visionRangeSquared = (visionRange + 1) * (visionRange + 1); // +1 to get a bit bigger view area foreach (var dst in g.Range()) { if (dst.X * dst.X + dst.Y * dst.Y > visionRangeSquared) { continue; } bool vis = FindLos(viewerLocation, dst, blockerDelegate); visibilityMap[dst] = vis; } }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value == null) { throw base.GetConvertFromException(value); } string source = value as string; if (source == null) { return(base.ConvertFrom(context, culture, value)); } return(IntGrid2.Parse(source)); }
public IntGrid2Z(IntGrid2 rect, int z) { m_grid = rect; m_z = z; }
public IntGrid2Z(IntVector2 point1, IntVector2 point2, int z) { m_grid = new IntGrid2(point1, point2); m_z = z; }
public IntGrid2Z(int x, int y, int columns, int rows, int z) { m_grid = new IntGrid2(x, y, columns, rows); m_z = z; }
public IntGrid3(IntGrid2 rect, int z) : this(rect.X, rect.Y, z, rect.Columns, rect.Rows, 1) { }