using System.Reflection;
using RaylibCogwheel;
using Raylib_cs;
using rlImGui_cs;
using Cogwheel;

public class Game
{
    
    private RaylibCogwheelConsole _console = new();
    private CommandsManager _commandsManager = new();
    
    public void Init()
    {
        _commandsManager.AddAssembly(Assembly.GetAssembly(typeof(CommandsManager)));
        _commandsManager.AddAssembly(Assembly.GetCallingAssembly());
        
        COGWHEEL.Initialize(_commandsManager, _console);
        
        Raylib.InitWindow(1280, 720, "RaylibCogwheel");
        Raylib.SetTargetFPS(60);

        rlImGui.Setup();
        
        while (!Raylib.WindowShouldClose())
        {
            Update();
            
            Raylib.BeginDrawing();
            Raylib.ClearBackground(new Color(0, 50, 80));
            rlImGui.Begin();    
            
            Draw();
            DrawImGui();
            
            rlImGui.End();
            Raylib.EndDrawing();
        }
        
        rlImGui.Shutdown();
        Raylib.CloseWindow();
    }
    
    private void Update()
    {
        _console.Update();
    }
    
    private void Draw()
    {
        // All drawing code goes here
    }
    
    private void DrawImGui()
    {
        _console.Draw();
    }
}