using System.Text.Json;
using DoomDeathmatch.Component;
using DoomDeathmatch.Component.UI;
using DoomDeathmatch.Scene.Main;
using DoomDeathmatch.Scene.Rules;
using Engine.Asset.Font;
using Engine.Asset.Font.Metadata;
using Engine.Asset.Mesh;
using Engine.Asset.Mesh.Loader;
using Engine.Graphics.Camera;
using Engine.Graphics.Pipeline;
using Engine.Graphics.Texture;
using Engine.Scene;
using Engine.Scene.Component.BuiltIn;
using Engine.Scene.Component.BuiltIn.Renderer;
using OpenTK.Mathematics;

namespace DoomDeathmatch;

public static class DoomDeathmatch
{
  public static void Initialize(Engine.Engine parEngine)
  {
    parEngine.SceneManager.TransitionTo(MainScene.Create(parEngine));
  }

  // private static Scene MainScene(Engine.Engine parEngine)
  // {
  //   var playerObject = new GameObject();
  //   playerObject.AddComponent<RigidbodyComponent>();
  //   playerObject.AddComponent(new ControllerComponent { Speed = 5f });
  //   playerObject.AddComponent(new DragComponent { Drag = 5f, Coefficient = new Vector3(1, 1, 0) });
  //   playerObject.AddComponent(new TestComponent());
  //
  //   var cameraObject = new GameObject();
  //   cameraObject.Transform.Translation.Z = 2;
  //   cameraObject.AddComponent<PerspectiveCamera>();
  //
  //   var testObject = new GameObject { Transform = { Translation = new Vector3(0, 6, 0), Rotation = Quaternion.FromAxisAngle(Vector3.UnitX, (float)Math.PI / 2) } };
  //   testObject.AddComponent(new Box2DRenderer { Color = new Vector4(1, 0, 0, 1) });
  //
  //   var mesh = parEngine.AssetResourceManager.Load<Mesh>("model/untitled.obj");
  //   var texture = parEngine.AssetResourceManager.Load<Texture>("TestImage.png");
  //   var font = parEngine.AssetResourceManager.Load<Font>("font/test");
  //
  //   var box2dRenderer = new GameObject
  //   {
  //     Transform = { Scale = new Vector3(1), Rotation = Quaternion.FromAxisAngle(Vector3.UnitX, (float)Math.PI / 2) }
  //   };
  //   // box2dRenderer.AddComponent(new MeshRenderer { Mesh = mesh, Albedo = texture });
  //   box2dRenderer.AddComponent(new TextRenderer { Font = font, Text = "A", RenderLayer = RenderLayer.HUD });
  //   // box2dRenderer.AddComponent(new BillboardComponent { Target = cameraObject.Transform });
  //
  //   var xAxis = new GameObject();
  //   xAxis.Transform.Translation.X = 5;
  //   xAxis.Transform.Scale.X = 10;
  //   xAxis.AddComponent(new Box2DRenderer { Color = new Vector4(1, 0, 0, 1) });
  //
  //   var yAxis = new GameObject();
  //   yAxis.Transform.Translation.Y = 5;
  //   yAxis.Transform.Scale.X = 10;
  //   yAxis.Transform.Rotation *= Quaternion.FromAxisAngle(Vector3.UnitZ, (float)Math.PI / 2);
  //   yAxis.AddComponent(new Box2DRenderer { Color = new Vector4(0, 1, 0, 1) });
  //
  //   var zAxis = new GameObject();
  //   zAxis.Transform.Translation.Z = 5;
  //   zAxis.Transform.Scale.Y = 10;
  //   zAxis.Transform.Scale.X = 10;
  //   zAxis.Transform.Rotation *= Quaternion.FromAxisAngle(Vector3.UnitX, (float)Math.PI / 2);
  //   zAxis.AddComponent(new Box2DRenderer
  //   {
  //     Color = new Vector4(0, 0, 1, 1), Texture = parEngine.AssetResourceManager.Load<Texture>("test.jpeg")
  //   });
  //
  //   var scene = new Scene();
  //   scene.Add(cameraObject);
  //   scene.AddChild(cameraObject, testObject);
  //   scene.Add(playerObject);
  //   scene.SetChild(playerObject, cameraObject);
  //
  //   scene.Add(box2dRenderer);
  //   // scene.AddChild(box2dRenderer, testChild);
  //
  //   scene.Add(xAxis);
  //   // scene.Add(yAxis);
  //   // scene.Add(zAxis);
  //
  //   return scene;
  // }
}