Nerfed/Nerfed.Editor/Program.cs

79 lines
2.1 KiB
C#
Raw Normal View History

using MoonTools.ECS;
using Nerfed.Editor.Systems;
using Nerfed.Runtime;
using Nerfed.Runtime.Components;
using Nerfed.Runtime.Systems;
using Nerfed.Runtime.Util;
using System.Numerics;
namespace Nerfed.Editor;
2024-07-05 12:56:37 +02:00
internal class Program
2024-07-05 12:21:17 +02:00
{
private static readonly World world = new World();
private static List<MoonTools.ECS.System> systems = new List<MoonTools.ECS.System>();
public static List<MoonTools.ECS.System> editorSystems = new List<MoonTools.ECS.System>();
private static void Main(string[] args)
2024-07-05 12:21:17 +02:00
{
Engine.OnInitialize += HandleOnInitialize;
Engine.OnUpdate += HandleOnUpdate;
Engine.OnRender += HandleOnRender;
Engine.OnQuit += HandleOnQuit;
Engine.Run(args);
2024-07-05 12:21:17 +02:00
}
private static void HandleOnInitialize()
{
//systems.Add(new ParentSystem(world));
systems.Add(new LocalToWorldSystem(world));
editorSystems.Add(new EditorHierarchyWindow(world));
Entity ent1 = world.CreateEntity("parent");
world.Set(ent1, new LocalTransform(new Vector3(1, 0, 0), Quaternion.Identity, Vector3.One));
Entity ent2 = world.CreateEntity("child");
world.Set(ent2, new LocalTransform(new Vector3(0, 1, 0), Quaternion.Identity, Vector3.One));
Transform.SetParent(world, ent2, ent1);
Entity ent3 = world.CreateEntity("entity3");
world.Set(ent3, new Root());
Transform.SetParent(world, ent3, ent2);
Entity ent4 = world.CreateEntity("entity4");
world.Set(ent4, new Root());
Entity ent5 = world.CreateBaseEntity("entity5");
// Open project.
// Setip EditorGui.
EditorGui.Initialize();
}
private static void HandleOnUpdate()
{
foreach (MoonTools.ECS.System system in systems)
{
system.Update(Engine.Timestep);
}
// Editor Update.
EditorGui.Update();
// Try Catch UserCode Update.
world.FinishUpdate();
}
private static void HandleOnRender()
{
EditorGui.Render();
}
private static void HandleOnQuit()
{
EditorGui.Quit();
}
}