using UnityEngine;
using UnityEditor;

namespace Genesis.POISystem.Editor
{
    [CustomEditor(typeof(POIManager), true)]
    public class POIManagerEditor : UnityEditor.Editor
    {
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            DrawPropertiesExcluding(serializedObject, "onStartPointingPOIEvent", "onStopPointingPOIEvent", "onSelectPOIEvent", "onDeselectPOIEvent", "interactablePOILayerMask");

            GUILayout.Space(20);

            DrawPOIManagerEventsBoxGroup();
            DrawPOIManagerOptionsBoxGroup();

            serializedObject.ApplyModifiedProperties();
        }

        void DrawPOIManagerEventsBoxGroup()
        {
            EditorUtilities.DrawTitleBox("POI Manager Events", Color.black, new Color(1.0f, 0.812f, 0.314f));

            GUIStyle boxStyle = new GUIStyle(GUI.skin.box);
            boxStyle.padding = new RectOffset(10, 10, 10, 10);

            EditorGUILayout.BeginVertical(boxStyle);

            EditorGUILayout.PropertyField(serializedObject.FindProperty("onStartPointingPOIEvent"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("onStopPointingPOIEvent"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("onSelectPOIEvent"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("onDeselectPOIEvent"));

            EditorGUILayout.EndVertical();
        }

        void DrawPOIManagerOptionsBoxGroup()
        {
            EditorUtilities.DrawTitleBox("POI Manager Options", Color.black, new Color(1.0f, 0.812f, 0.314f));

            GUIStyle boxStyle = new GUIStyle(GUI.skin.box);
            boxStyle.padding = new RectOffset(10, 10, 10, 10);

            EditorGUILayout.BeginVertical(boxStyle);

            EditorGUILayout.PropertyField(serializedObject.FindProperty("interactablePOILayerMask"));

            EditorGUILayout.EndVertical();
        }
    }
}