///unique shadow use two pass to generate a high resolution shadow
///fisrt pass is to generate a shadowmap in urp pass, this is by rendererfeature
///second pass is blend this shadow into scene by draw a box decal in the scene, which is automatically draw by scene
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Rendering;
using UnityEngine;
using X2Engine;

public class UniqueShadowProxy : MonoBehaviour
{
    public bool isMainCharacter = false;
    //public Light sun;
    UniqueShadowManager manager;

    public void SetMain(bool main)
    {
        isMainCharacter = main;
    }
    public void OnRendererPartsChanged()
    {
        manager.OnRendererPartsChanged(gameObject);
    }
    private void Awake()
    {
        manager = UniqueShadowManager.Instance;
    }
    private void Start()
    {
        manager.RegisterLight(gameObject, isMainCharacter, EnvironmentSystem.instance.m_sun);
    }

    private void OnDestroy()
    {
        manager.UnRegisterUniqueShadow(gameObject);
        manager = null;
    }

    private void OnEnable()
    {
        manager.RegisterUniqueShadow(gameObject);
    }
    private void OnDisable()
    {
        manager.UnRegisterUniqueShadow(gameObject);
    }
}
