using UnityEngine;

namespace RedCircuit.AIAssistant
{
    /// <summary>
    /// 上下文采集器，收集当前游戏状态供 AI 参考。
    /// </summary>
    public class AIContextProvider : MonoBehaviour
    {
        /// <summary>采集当前游戏上下文</summary>
        public GameContext CollectContext()
        {
            var context = new GameContext
            {
                Mode = GetCurrentMode(),
                CanvasWidth = GetCanvasWidth(),
                CanvasHeight = GetCanvasHeight(),
                ComponentCount = GetComponentCount(),
                SelectedComponentId = GetSelectedComponentId(),
                SelectedComponentType = GetSelectedComponentType(),
                LevelId = GetCurrentLevelId(),
                LevelTitle = GetCurrentLevelTitle(),
                RedstoneCoins = GetRedstoneCoins()
            };

            return context;
        }

        private string GetCurrentMode()
        {
            // TODO: 从 GameManager 获取当前游戏模式
            return "creative"; // creative / puzzle / automation / multiplayer
        }

        private int GetCanvasWidth()
        {
            // TODO: 从 GridCanvas 获取画布宽度
            return 128;
        }

        private int GetCanvasHeight()
        {
            // TODO: 从 GridCanvas 获取画布高度
            return 128;
        }

        private int GetComponentCount()
        {
            // TODO: 从 CircuitGraph 获取当前元件数
            return 0;
        }

        private string GetSelectedComponentId()
        {
            // TODO: 从 PlacementController 获取选中元件 ID
            return null;
        }

        private string GetSelectedComponentType()
        {
            // TODO: 从 PlacementController 获取选中元件类型
            return null;
        }

        private int? GetCurrentLevelId()
        {
            // TODO: 解谜模式下获取当前关卡 ID
            return null;
        }

        private string GetCurrentLevelTitle()
        {
            // TODO: 解谜模式下获取当前关卡标题
            return null;
        }

        private long GetRedstoneCoins()
        {
            // TODO: 从 EconomyManager 获取红石币余额
            return 0;
        }
    }
}
