private HashSet <Vector3Int> RecenterLowerLeft(ICollection <Vector3Int> positions) { Vector3Int origin = TilemapExtras.GetLowerLeft(positions); List <Vector3Int> converted = new List <Vector3Int>(positions).ConvertAll((p) => p - origin); return(new HashSet <Vector3Int>(converted)); }
public Shape(List <Vector3Int> positions, Sprite sprite) { this.sprite = sprite; HashSet <Vector3Int> converted = RecenterLowerLeft(positions); this.rightBounds = TilemapExtras.GetBounds(converted); this.right = converted; foreach (Vector3Int pos in converted) { left.Add(new Vector3Int(-pos.x, -pos.y, 0)); up.Add(new Vector3Int(-pos.y, pos.x, 0)); down.Add(new Vector3Int(pos.y, -pos.x, 0)); } left = RecenterLowerLeft(left); up = RecenterLowerLeft(up); down = RecenterLowerLeft(down); }