diff --git a/src/Apps/GameDesktop/CompositionRoots/Features/RootFeatureCompositionRoot.cs b/src/Apps/GameDesktop/CompositionRoots/Features/RootFeatureCompositionRoot.cs index 9a16d21..69c36a4 100644 --- a/src/Apps/GameDesktop/CompositionRoots/Features/RootFeatureCompositionRoot.cs +++ b/src/Apps/GameDesktop/CompositionRoots/Features/RootFeatureCompositionRoot.cs @@ -1,6 +1,19 @@ -using LightInject; +using Components.Data; +using Entities.Factories.Characters; +using Entities.Factories.Meta; +using Features; +using LightInject; using GameDesktop.CompositionRoots.Components; using GameDesktop.CompositionRoots.Entities; +using Implementations; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Scellecs.Morpeh; +using Services.Movement; +using Systems; +using Systems.Debugging; +using Systems.Debugging.Render; +using Systems.Render; #if DEBUG using GameDesktop.CompositionRoots.DebugFeatures; #endif @@ -29,7 +42,7 @@ public void Compose(IServiceRegistry serviceRegistry) serviceRegistry.RegisterFrom(); #endif - // RegisterEntryPoint(serviceRegistry); + RegisterEntryPoint(serviceRegistry); } private static void RegisterFundamental(IServiceRegistry serviceRegistry) => @@ -52,6 +65,37 @@ private static void RegisterFeatures(IServiceRegistry serviceRegistry) // serviceRegistry.RegisterFrom(); } - // private static void RegisterEntryPoint(IServiceRegistry serviceRegistry) => + private static void RegisterEntryPoint(IServiceRegistry serviceRegistry) + { + serviceRegistry.RegisterSingleton(_ => World.Create()); + + serviceRegistry.RegisterSingleton(factory => + { + Texture2D pixel = new(factory.GetInstance().GraphicsDevice, 1, 1); + pixel.SetData(new[] { Color.Gold }); + + return new RootFeature(factory.GetInstance(), + new WorldInitializer(factory.GetInstance(), new WorldEntityFactory(new WorldComponent()), + factory.GetInstance(), + factory.GetInstance()), + new MovementFeature(factory.GetInstance(), + new InputSystem(factory.GetInstance(), new KeyboardInput()), + new MovementSystem(factory.GetInstance(), new SimpleMovement())), + new PreRenderFeature(factory.GetInstance(), + new CharacterMovementAnimationSystem(factory.GetInstance()), + new CameraFollowingSystem(factory.GetInstance())), + new RenderFeature(factory.GetInstance(), + new RenderCharacterMovementAnimationSystem(factory.GetInstance(), + factory.GetInstance())) +#if DEBUG + , + new DebugFeature(factory.GetInstance(), new EntitiesList(factory.GetInstance()), + new FrameCounter(factory.GetInstance()), + new RenderFramesPerSec(factory.GetInstance()), + new PivotRenderSystem(factory.GetInstance(), factory.GetInstance(), pixel)) +#endif + ); + }); + } // serviceRegistry.RegisterSingleton(); } diff --git a/src/Apps/GameDesktop/Game.cs b/src/Apps/GameDesktop/Game.cs index b94db8a..6b1289d 100644 --- a/src/Apps/GameDesktop/Game.cs +++ b/src/Apps/GameDesktop/Game.cs @@ -132,26 +132,7 @@ protected override void LoadContent() // _desktop.Root = grid; // ------ - World world = World.Create(); - - _rootFeature = new RootFeature(world, - new WorldInitializer(world, new WorldEntityFactory(new WorldComponent()), - _container.GetInstance(), - _container.GetInstance()), - new MovementFeature(world, - new InputSystem(world, new KeyboardInput()), - new MovementSystem(world, new SimpleMovement())), - new PreRenderFeature(world, - new CharacterMovementAnimationSystem(world), - new CameraFollowingSystem(world)), - new RenderFeature(world, - new RenderCharacterMovementAnimationSystem(world, _spriteBatch)) -#if DEBUG - , - new DebugFeature(world, new EntitiesList(world), new FrameCounter(world), new RenderFramesPerSec(world), - new PivotRenderSystem(world, _spriteBatch, pixel)) -#endif - ); + _rootFeature = _container.GetInstance(); _rootFeature.OnAwake(); diff --git a/src/UnitTests/UnitTests.Entities/PlayerEntity.cs b/src/UnitTests/UnitTests.Entities/PlayerEntity.cs index f0bef47..73e1b1f 100644 --- a/src/UnitTests/UnitTests.Entities/PlayerEntity.cs +++ b/src/UnitTests/UnitTests.Entities/PlayerEntity.cs @@ -95,7 +95,7 @@ public void WorldSystemAndEntityWorkTogether() Assert.That(transform.Velocity.X, Is.EqualTo(0)); Assert.That(transform.Position.Y, Is.EqualTo(0)); - rootFeature.OnUpdate(16.6f); + rootFeature.OnUpdate(.0f); Assert.That(transform.Velocity.X, Is.EqualTo(1)); // Assert.That(transform.Position.Y, Is.EqualTo(0));