using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;

namespace X2Engine
{
    public class RainOcclusionReceiver
    {
        static RainOcclusionReceiver s_instance = null;
        public static RainOcclusionReceiver Instance
        {
            get
            {
                if(s_instance == null)
                {
                    s_instance = new RainOcclusionReceiver();
                }
                return s_instance;
            }
        }
        public struct OccRendererInfo
        {
            public OccRendererInfo(Renderer renderer, int subMesh)
            {
                this.renderer = renderer;
                this.subMesh = subMesh;
            }
            public Renderer renderer;
            public int subMesh;
        }

        //List<Renderer> m_rainOccRenderers = new List<Renderer>();
        Dictionary<int, OccRendererInfo> m_rainOccRenderers = new Dictionary<int, OccRendererInfo>(10);

        public Dictionary<int, OccRendererInfo> RainOccRenders
        {
            get { return m_rainOccRenderers; }
        }

        public void Register(Renderer renderer, int subMesh)
        {
            var rendererID = renderer.GetInstanceID();
            if (!m_rainOccRenderers.ContainsKey(rendererID))
            {
                m_rainOccRenderers.Add(rendererID, new OccRendererInfo(renderer, subMesh));
            }
        }

        public void UnRegister(Renderer renderer)
        {
            var rendererID = renderer.GetInstanceID();
            if (m_rainOccRenderers.ContainsKey(rendererID))
            {
                m_rainOccRenderers.Remove(rendererID);
            }
        }
    }
}
