/// <summary> /// /// </summary> /// <param name="source"></param> /// <param name="loc"></param> /// <param name="ab"></param> public void OnClick(MapViewWindow source, Location loc, Point ab) { if (anchor == Unplaced) { if (remover) { if (null == WorldDefinition.World[loc] as HalfDividedVoxel) { return; } } else { if (!HalfVoxelContribution.CanBeBuilt(loc)) { return; } } anchor = loc; currentPos = loc; curSide = getSide(ab); sameLevelDisambiguator = new SameLevelDisambiguator(anchor.z); } else { if (!currentPos.Equals(anchor)) { OnVoxelSelected(anchor, front, currentSide); } WorldDefinition.World.OnVoxelUpdated(anchor); anchor = Unplaced; } }
/// <summary> /// Converts the (A,B) coordinates to (X,Y,Z) coordinates. /// </summary> public Location fromABToXYZ(int a, int b, IModalController controller) { int t = 2 * b - 16; int x = (a - t) >> 5; int y = (a + t) >> 5; x += (world.Size.y - 1) / 2; // (x,y,0) is the base location. disambiguate the location. // TODO: use height-cut here to force the specified z-level if (controller != null) { ILocationDisambiguator disambiguator = controller.Disambiguator; for (int z = HeightCutHeight; z >= 0; z--) { Location loc = new Location(x - z, y + z, z); if (disambiguator != null && disambiguator.IsSelectable(loc)) { return(loc); } } } return(new Location(x, y, 0)); }