public IntGrid3(IntVector3 p, IntSize3 size) { m_x = p.X; m_y = p.Y; m_z = p.Z; m_columns = size.Width; m_rows = size.Height; m_depth = size.Depth; }
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(IntSize3.Parse(source)); }
public IntGrid3(IntSize3 size) : this(0, 0, 0, size.Width, size.Height, size.Depth) { }
public static void Calculate3(IntVector3 viewerLocation, int visionRange, VisionMap visibilityMap, IntSize3 mapSize, Func <IntVector3, bool> blockerDelegate) { visibilityMap.Clear(); if (blockerDelegate(viewerLocation) == true) { return; } var g = new IntGrid3(new IntVector3(), mapSize); g = g.Offset(-viewerLocation.X, -viewerLocation.Y, -viewerLocation.Z); var vr = new IntVector3(visionRange, visionRange, visionRange); g = g.Intersect(new IntGrid3(vr, -vr)); int visionRangeSquared = (visionRange + 1) * (visionRange + 1); // +1 to get a bit bigger view area foreach (var dst in g.Range()) { if (dst.LengthSquared > visionRangeSquared) { continue; } bool vis = FindLos3(viewerLocation, dst, blockerDelegate); visibilityMap[dst] = vis; // XXX Cheat a bit so that the floor will be visible if (vis && dst.Z == 0 && viewerLocation.Z > 1) { visibilityMap[dst.SetZ(dst.Z - 1)] = true; } } }