using System;

namespace Editor.GON.StageEditor
{
    public sealed class StageEditorState
    {
        public StageLogicalLayer activeLayer = StageLogicalLayer.Structural;
        public StagePaletteEntry activePaletteEntry;
        public StageObjectDefinition selectedObject;
        public bool showWorldSyncUnderlay = true;

        public event Action Changed;

        public void ClearListeners()
        {
            Changed = null;
        }

        public void SetActiveLayer(StageLogicalLayer layer)
        {
            activeLayer = layer;
            NotifyChanged();
        }

        public void SetPaletteEntry(StagePaletteEntry entry)
        {
            activePaletteEntry = entry;
            if (entry != null)
            {
                activeLayer = entry.layer;
            }
            NotifyChanged();
        }

        public void SelectObject(StageObjectDefinition obj)
        {
            selectedObject = obj;
            NotifyChanged();
        }

        public void SetWorldSyncUnderlayVisible(bool visible)
        {
            showWorldSyncUnderlay = visible;
            NotifyChanged();
        }

        public void NotifyChanged()
        {
            Changed?.Invoke();
        }
    }
}
