using UnityEngine;
using System.Collections.Generic;

using NetPoly = TriangleNet.Geometry.Polygon;
using NetVertex = TriangleNet.Geometry.Vertex;
using NetContour = TriangleNet.Geometry.Contour;
using NetTriangle = TriangleNet.Geometry.ITriangle;
using NetMesh = TriangleNet.Meshing.IMesh;

/*
 * A type of GamePolygon representing a region in the map
*/
public class MapPolygon : GamePolygon {

    private DTerrain terrain;

	public MapPolygon(SlicedPolygon slicedPolygon, DTerrain terrain) : base(slicedPolygon) {
        this.terrain = terrain;
    }

	public MapPolygon(Contour contour, DTerrain terrain) : this(new SlicedPolygon(contour), terrain) { }

    public override void addToGame() {
        base.addToGame();
        renderer.material = terrain.getMaterial();
    }

	public DTerrain getTerrain() {
        return terrain;
    }

    public void triangulate(Set<TerrainVertex> terrainVertices, Set<TerrainSegment> terrainSegments, Set<TerrainTriangle> terrainTriangles) {
        Triangulation.triangulateForTerrain(this, terrainVertices, terrainSegments, terrainTriangles);
    }
}
