using System;
using System.Collections.Generic;
using System.Text;
using nft.contributions.terrain;
using nft.framework.plugin;
using nft.core.geometry;

namespace nft.core {
    /// <summary>
    /// Assign the most suitable graphics for given parameters, among the registerd contributions.
    /// </summary>
    public interface IApparentAssignor {
        ITerrainImageSet<T> GetTerrainTexture<T>(object hint) where T : ITerrainPolygon;
        IGroundPlateSet DefaultLandTexture { get; }
        ICliffPlateSet DefaultCliffTexture { get; }
    }

    /// <summary>
    /// System default implementation of IApparentAssignor.
    /// This class can be used as a base class of custom assignor.
    /// </summary>
    public class DefaultApparentAssignor : IApparentAssignor {
        static readonly VContributionId CID_DefGround = new VContributionId(VPluginId.System, "BareLandTexture");
        static readonly VContributionId CID_DefCliff = new VContributionId(VPluginId.System, "DefaultCliffTexture");
        static readonly VContributionId CID_UnderWater = new VContributionId(VPluginId.System, "UnderWaterTexture");
        static readonly VContributionId CID_UnderWaterCliff = new VContributionId(VPluginId.System, "UnderWaterCliffTexture");
        
        static public readonly DefaultApparentAssignor TheInstance = new DefaultApparentAssignor();
        protected IGroundPlateSet defaultGroundSet;
        protected ICliffPlateSet defaultCliffSet;

        protected DefaultApparentAssignor() {
            CtbSimpleGroundTexture ctb1;
            CtbSimpleCliffTexture ctb2;
            ctb1 = PluginManager.GetContribution(CID_DefGround) as CtbSimpleGroundTexture;
            defaultGroundSet = ctb1.TerrainPlateSet;
            ctb2 = PluginManager.GetContribution(CID_DefCliff) as CtbSimpleCliffTexture;
            defaultCliffSet = ctb2.TextureSet;
        }

        protected PluginManager PluginManager { get { return PluginManager.theInstance; } }

        #region IApparentAssignor メンバ


        public IGroundPlateSet DefaultLandTexture {
            get {
                return defaultGroundSet;
            }
        }

        public ICliffPlateSet DefaultCliffTexture {
            get {
                return defaultCliffSet;
            }
        }

        public ITerrainImageSet<T> GetTerrainTexture<T>(object hint) where T : ITerrainPolygon {
            Type type = typeof(T);
            throw new NotImplementedException();
        }

        #endregion
    }
}
