Skip to content

Commit

Permalink
chore(e2e): integration test example
Browse files Browse the repository at this point in the history
  • Loading branch information
cherrynik committed Nov 19, 2023
1 parent 1436abd commit b7240c1
Show file tree
Hide file tree
Showing 15 changed files with 202 additions and 219 deletions.
114 changes: 2 additions & 112 deletions src/Apps/GameDesktop/Game.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System.Numerics;
using Components.Data;
using Entities;
using Entities.Factories;
using Components.Data;
using Entities.Factories.Characters;
using Entities.Factories.Meta;
using Features;
using GameDesktop.CompositionRoots.Features;
using ImGuiNET;
using Implementations;
Expand All @@ -18,119 +16,11 @@
using Systems.Debugging;
using Systems.Render;
using Myra;
using Myra.Graphics2D;
using Myra.Graphics2D.TextureAtlases;
using Myra.Graphics2D.UI;
using Myra.Graphics2D.UI.Styles;
using Scellecs.Morpeh.Extended;
using Systems.Debugging.Render;
using Vector2 = System.Numerics.Vector2;

namespace GameDesktop;

public class WorldInitializer : IInitializer
{
public World World { get; set; }
private readonly WorldEntityFactory _worldEntityFactory;
private readonly PlayerEntityFactory _playerEntityFactory;
private readonly DummyEntityFactory _dummyEntityFactory;

public WorldInitializer(World world,
WorldEntityFactory worldEntityFactory,
PlayerEntityFactory playerEntityFactory,
DummyEntityFactory dummyEntityFactory)
{
World = world;
_worldEntityFactory = worldEntityFactory;
_playerEntityFactory = playerEntityFactory;
_dummyEntityFactory = dummyEntityFactory;
}

public void OnAwake()
{
_worldEntityFactory.CreateEntity(@in: World);
_playerEntityFactory.CreateEntity(@in: World);
_dummyEntityFactory.CreateEntity(@in: World);
}

public void Dispose()
{
}
}

public class RenderFeature : Feature
{
public RenderFeature(World world,
RenderCharacterMovementAnimationSystem renderCharacterMovementAnimationSystem) : base(world)
{
Add(renderCharacterMovementAnimationSystem);
}
}

public class PreRenderFeature : Feature
{
public PreRenderFeature(World world,
CharacterMovementAnimationSystem characterMovementAnimationSystem,
CameraFollowingSystem cameraFollowingSystem) : base(world)
{
Add(characterMovementAnimationSystem);
Add(cameraFollowingSystem);
}
}

public class MovementFeature : Feature
{
public MovementFeature(World world,
InputSystem inputSystem,
MovementSystem movementSystem) : base(world)
{
Add(inputSystem);
Add(movementSystem);
}
}

public class DebugFeature : Feature
{
public DebugFeature(World world,
EntitiesList entitiesList,
FrameCounter frameCounter,
RenderFramesPerSec renderFramesPerSec, PivotRenderSystem pivotRenderSystem) : base(world)
{
Add(entitiesList);
Add(frameCounter);
Add(renderFramesPerSec);
}
}

public class RootFeature : Feature
{
public RootFeature(World world,
WorldInitializer worldInitializer,
MovementFeature movementFeature,
PreRenderFeature preRenderFeature,
RenderFeature renderFeature
) : base(world)
{
Add(worldInitializer);
Add(movementFeature);
Add(preRenderFeature);
Add(renderFeature);
}

#if DEBUG
public RootFeature(World world,
WorldInitializer worldInitializer,
MovementFeature movementFeature,
PreRenderFeature preRenderFeature,
RenderFeature renderFeature,
DebugFeature debugFeature
) : this(world, worldInitializer, movementFeature, preRenderFeature, renderFeature)
{
Add(debugFeature);
}
#endif
}

public class Game : Microsoft.Xna.Framework.Game
{
private readonly ILogger _logger;
Expand Down
9 changes: 7 additions & 2 deletions src/Libs/Entities/Factories/Characters/DummyEntityFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,19 @@ public class DummyEntityFactory : EntityFactory
private readonly RectangleCollisionComponent _rectangleCollision;

public DummyEntityFactory(TransformComponent transform,
SpriteComponent sprite,
RectangleCollisionComponent rectangleCollision)
{
_transform = transform;
_sprite = sprite;
_rectangleCollision = rectangleCollision;
}

public DummyEntityFactory(TransformComponent transform,
SpriteComponent sprite,
RectangleCollisionComponent rectangleCollision) : this(transform, rectangleCollision)
{
_sprite = sprite;
}

protected override void AddTags(Entity e)
{
}
Expand Down
16 changes: 13 additions & 3 deletions src/Libs/Entities/Factories/Characters/PlayerEntityFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,25 @@ public PlayerEntityFactory(InputMovableComponent inputMovable,
MovableComponent movable,
TransformComponent transform,
CameraComponent cameraComponent,
RectangleCollisionComponent rectangleCollision,
MovementAnimationsComponent movementAnimations,
CharacterAnimatorComponent characterAnimator)
RectangleCollisionComponent rectangleCollision
)
{
_inputMovable = inputMovable;
_movable = movable;
_transform = transform;
_cameraComponent = cameraComponent;
_rectangleCollision = rectangleCollision;
}

public PlayerEntityFactory(InputMovableComponent inputMovable,
MovableComponent movable,
TransformComponent transform,
CameraComponent cameraComponent,
RectangleCollisionComponent rectangleCollision,
MovementAnimationsComponent movementAnimations,
CharacterAnimatorComponent characterAnimator) : this(inputMovable, movable, transform, cameraComponent,
rectangleCollision)
{
_movementAnimations = movementAnimations;
_characterAnimator = characterAnimator;
}
Expand Down
19 changes: 19 additions & 0 deletions src/Libs/Features.Debugging/DebugFeature.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Scellecs.Morpeh;
using Scellecs.Morpeh.Extended;
using Systems.Debugging;
using Systems.Debugging.Render;

namespace GameDesktop;

public class DebugFeature : Feature
{
public DebugFeature(World world,
EntitiesList entitiesList,
FrameCounter frameCounter,
RenderFramesPerSec renderFramesPerSec, PivotRenderSystem pivotRenderSystem) : base(world)
{
Add(entitiesList);
Add(frameCounter);
Add(renderFramesPerSec);
}
}
11 changes: 0 additions & 11 deletions src/Libs/Features.Debugging/DebugRootFeature.cs

This file was deleted.

11 changes: 0 additions & 11 deletions src/Libs/Features/CameraFeature.cs

This file was deleted.

11 changes: 0 additions & 11 deletions src/Libs/Features/InputFeature.cs

This file was deleted.

32 changes: 16 additions & 16 deletions src/Libs/Features/MovementFeature.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// using Systems;
//
// namespace Features;
//
// public sealed class MovementFeature : Entitas.Extended.Feature
// {
// public MovementFeature(
// CollisionSystem collisionSystem,
// MovementSystem movementSystem,
// AnimatedMovementSystem animatedMovementSystem)
// {
// Add(collisionSystem);
// Add(movementSystem);
// Add(animatedMovementSystem);
// }
// }
using Scellecs.Morpeh;
using Scellecs.Morpeh.Extended;
using Systems;

namespace Features;

public class MovementFeature : Feature
{
public MovementFeature(World world,
InputSystem inputSystem,
MovementSystem movementSystem) : base(world)
{
Add(inputSystem);
Add(movementSystem);
}
}
16 changes: 16 additions & 0 deletions src/Libs/Features/PreRenderFeature.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Scellecs.Morpeh;
using Scellecs.Morpeh.Extended;
using Systems.Render;

namespace Features;

public class PreRenderFeature : Feature
{
public PreRenderFeature(World world,
CharacterMovementAnimationSystem characterMovementAnimationSystem,
CameraFollowingSystem cameraFollowingSystem) : base(world)
{
Add(characterMovementAnimationSystem);
Add(cameraFollowingSystem);
}
}
14 changes: 14 additions & 0 deletions src/Libs/Features/RenderFeature.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Scellecs.Morpeh;
using Scellecs.Morpeh.Extended;
using Systems.Render;

namespace Features;

public class RenderFeature : Feature
{
public RenderFeature(World world,
RenderCharacterMovementAnimationSystem renderCharacterMovementAnimationSystem) : base(world)
{
Add(renderCharacterMovementAnimationSystem);
}
}
67 changes: 41 additions & 26 deletions src/Libs/Features/RootFeature.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
// using Features.Debugging;
//
// namespace Features;
//
// public sealed class RootFeature : Entitas.Extended.Feature
// {
// public RootFeature(WorldInitializeFeature worldInitializeFeature,
// InputFeature inputFeature,
// MovementFeature movementFeature,
// CameraFeature cameraFeature)
// {
// Add(worldInitializeFeature);
// Add(inputFeature);
// Add(movementFeature);
// Add(cameraFeature);
// }
//
// public RootFeature(DebugRootFeature debugRootFeature,
// WorldInitializeFeature worldInitializeFeature,
// InputFeature inputFeature,
// MovementFeature movementFeature,
// CameraFeature cameraFeature) : this(worldInitializeFeature, inputFeature, movementFeature, cameraFeature)
// {
// Add(debugRootFeature);
// }
// }
using GameDesktop;
using Scellecs.Morpeh;
using Scellecs.Morpeh.Extended;

namespace Features;

public class RootFeature : Feature
{
public RootFeature(World world,
WorldInitializer worldInitializer,
MovementFeature movementFeature
) : base(world)
{
Add(worldInitializer);
Add(movementFeature);
}

public RootFeature(World world,
WorldInitializer worldInitializer,
MovementFeature movementFeature,
PreRenderFeature preRenderFeature,
RenderFeature renderFeature
) : this(world, worldInitializer, movementFeature)
{
Add(preRenderFeature);
Add(renderFeature);
}

#if DEBUG
public RootFeature(World world,
WorldInitializer worldInitializer,
MovementFeature movementFeature,
PreRenderFeature preRenderFeature,
RenderFeature renderFeature,
DebugFeature debugFeature
) : this(world, worldInitializer, movementFeature, preRenderFeature, renderFeature)
{
Add(debugFeature);
}
#endif
}
23 changes: 0 additions & 23 deletions src/Libs/Features/WorldInitializeFeature.cs

This file was deleted.

Loading

0 comments on commit b7240c1

Please sign in to comment.