/// <summary> /// Initializes a new instance of the <see cref="EdgePartPosition" /> struct. /// </summary> /// <param name="part">The edge part.</param> /// <param name="start">The part start position.</param> /// <param name="end">The pert end position.</param> /// <exception cref="System.ArgumentNullException"></exception> public EdgePartPosition([NotNull] EdgePart part, Vector2 start, Vector2 end) { if (part == null) throw new ArgumentNullException(nameof(part)); Part = part; Start = start; End = end; }
public static void SetAdjacent( [NotNull] TileBase tileA, [NotNull] EdgePart edgePartA, [NotNull] TileBase tileB, [NotNull] EdgePart edgePartB) { if (tileA == null) { throw new ArgumentNullException(nameof(tileA)); } if (edgePartA == null) { throw new ArgumentNullException(nameof(edgePartA)); } if (tileB == null) { throw new ArgumentNullException(nameof(tileB)); } if (edgePartB == null) { throw new ArgumentNullException(nameof(edgePartB)); } tileA._adjacentTiles[edgePartA] = tileB; tileB._adjacentTiles[edgePartB] = tileA; }
private TileBase CreateNewTile([NotNull] TileBase tile, [NotNull] EdgePart part) { Debug.Assert(tile != null, "tile != null"); Debug.Assert(part != null, "part != null"); // get adjacent part for the part with the tiles label Labeled <EdgePart> adjacent; if (!Definition.AdjacentParts.TryGetAdjacent(part.WithLabel(tile.Label), out adjacent)) { throw new InvalidOperationException(); } Debug.Assert(adjacent.Value != null, "adjacent.Value != null"); Tile adjTile; if (!_tileByEdgePart.TryGetValue(adjacent.Value, out adjTile)) { throw new InvalidOperationException(); } Debug.Assert(adjTile != null, "adjTile != null"); // Create transformed tile return(new TileInstance( adjTile, adjacent.Label, adjTile.GetEdgePartPosition(adjacent.Value) .GetTransformTo(tile.GetEdgePartPosition(part)))); }
/// <summary> /// Initializes a new instance of the <see cref="AdjTiles" /> class. /// </summary> /// <param name="tileA">The tile a.</param> /// <param name="partA">The part a.</param> public AdjTiles([NotNull] TileBase tileA, [NotNull] EdgePart partA) { Debug.Assert(tileA != null, "tileA != null"); Debug.Assert(partA != null, "partA != null"); TileA = tileA; PartA = partA; }
/// <summary> /// Initializes a new instance of the <see cref="EdgePartPosition" /> struct. /// </summary> /// <param name="part">The edge part.</param> /// <param name="start">The part start position.</param> /// <param name="end">The pert end position.</param> /// <exception cref="System.ArgumentNullException"></exception> public EdgePartPosition([NotNull] EdgePart part, Vector2 start, Vector2 end) { if (part == null) { throw new ArgumentNullException(nameof(part)); } Part = part; Start = start; End = end; }
public AdjTiles Add([NotNull] TileBase tile, [NotNull] EdgePart part) { if (TileB != null) { throw new InvalidOperationException("The tile has already been set."); } Debug.Assert(tile != null, "tile != null"); Debug.Assert(part != null, "part != null"); TileB = tile; PartB = part; TileBase.SetAdjacent(TileA, PartA, TileB, PartB); return(this); }
/// <summary> /// Initializes a new instance of the <see cref="EdgePartShape" /> class. /// </summary> /// <param name="part">The part.</param> /// <param name="edge">The edge.</param> /// <param name="lines">The lines.</param> public EdgePartShape([NotNull] EdgePart part, [NotNull] Edge edge, [NotNull] ShapeLines lines) { if (part == null) { throw new ArgumentNullException(nameof(part)); } if (edge == null) { throw new ArgumentNullException(nameof(edge)); } if (lines == null) { throw new ArgumentNullException(nameof(lines)); } Part = part; Edge = edge; Lines = lines; }
/// <summary> /// Creates a new <see cref="EdgePartPosition" /> from an edge part, shape and transform. /// </summary> /// <param name="edgePart">The edge part.</param> /// <param name="shape">The shape.</param> /// <param name="transform">The transform.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException"> /// <paramref name="edgePart" /> or <paramref name="shape" /> was <see langword="null" />. /// </exception> public static EdgePartPosition Create([NotNull] EdgePart edgePart, [NotNull] Shape shape, Matrix3x2 transform) { if (edgePart == null) { throw new ArgumentNullException(nameof(edgePart)); } if (shape == null) { throw new ArgumentNullException(nameof(shape)); } Edge edge = shape.GetEdge(edgePart.EdgePattern.EdgeName); Vector2 startPoint = edge.GetPointOnEdge(edgePart.StartAmount); Vector2 endPoint = edge.GetPointOnEdge(edgePart.StartAmount + edgePart.Amount); if (!transform.IsIdentity) { startPoint = Vector2.Transform(startPoint, transform); endPoint = Vector2.Transform(endPoint, transform); } return(new EdgePartPosition(edgePart, startPoint, endPoint)); }
public EdgePartPosition GetEdgePartPosition([NotNull] EdgePart edgePart) => EdgePartPosition.Create(edgePart, Shape, Transform);
public static EdgePartPosition Create([NotNull] EdgePart edgePart, [NotNull] Shape shape) => Create(edgePart, shape, Matrix3x2.Identity);