-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
123 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,9 @@ | ||
// namespace Entitas.Components.Data | ||
// { | ||
// using Microsoft.Xna.Framework; | ||
// | ||
// public class RectangleCollisionComponent : IComponent | ||
// { | ||
// public Rectangle Size; | ||
// } | ||
// } | ||
using Microsoft.Xna.Framework; | ||
using Scellecs.Morpeh; | ||
|
||
namespace Components.Data | ||
{ | ||
using Scellecs.Morpeh; | ||
using System.Drawing; | ||
namespace Components.Data; | ||
|
||
public struct RectangleCollisionComponent : IComponent | ||
{ | ||
public Rectangle Rectangle; | ||
} | ||
public struct RectangleCollisionComponent : IComponent | ||
{ | ||
public Rectangle Size; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,16 @@ | ||
// namespace Entitas.Components.Data | ||
// { | ||
// using Microsoft.Xna.Framework; | ||
// | ||
// public class TransformComponent : IComponent | ||
// { | ||
// public Vector2 Position; | ||
// public Vector2 Velocity; | ||
// } | ||
// } | ||
using Microsoft.Xna.Framework; | ||
using Scellecs.Morpeh; | ||
|
||
namespace Components.Data | ||
{ | ||
using Scellecs.Morpeh; | ||
using System.Numerics; | ||
namespace Components.Data; | ||
|
||
public struct TransformComponent : IComponent | ||
{ | ||
public Vector2 Position; | ||
public Vector2 Velocity; | ||
} | ||
public struct TransformComponent : IComponent | ||
{ | ||
public Vector2 Position; | ||
public Vector2 Velocity; | ||
} | ||
|
||
// Input Scan System -> Write Velocity | ||
|
||
// Movement System -> Write Velocity | ||
// Collision System -> Reset Velocity if there's collider in the velocity direction | ||
// Position System -> Apply Velocity by changing Position |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,7 @@ | ||
// namespace Entitas.Components.Tags | ||
// { | ||
// public class MovableComponent : IComponent | ||
// { | ||
// } | ||
// } | ||
using Scellecs.Morpeh; | ||
|
||
namespace Components.Tags | ||
{ | ||
using Scellecs.Morpeh; | ||
namespace Components.Tags; | ||
|
||
public struct MovableComponent : IComponent | ||
{ | ||
} | ||
public struct MovableComponent : IComponent | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,7 @@ | ||
// namespace Entitas.Components.Tags | ||
// { | ||
// public class PlayerComponent : IComponent | ||
// { | ||
// } | ||
// } | ||
using Scellecs.Morpeh; | ||
|
||
namespace Components.Tags | ||
{ | ||
using Scellecs.Morpeh; | ||
namespace Components.Tags; | ||
|
||
public struct PlayerComponent : IComponent | ||
{ | ||
} | ||
public struct PlayerComponent : IComponent | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
global using NUnit.Framework; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using Components.Data; | ||
using Components.Render.Animation; | ||
using Components.Tags; | ||
using Entities; | ||
using Scellecs.Morpeh; | ||
|
||
namespace UnitTests.Entities; | ||
|
||
public class Tests | ||
{ | ||
// TODO: Systems test | ||
private World _world; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
_world = World.Create(); | ||
} | ||
|
||
[TearDown] | ||
public void TearDown() | ||
{ | ||
_world.Dispose(); | ||
} | ||
|
||
[Test] | ||
public void PlayerEntity_IsCreatedInTheWorld() | ||
{ | ||
// TODO: Use mocks for deps | ||
Entity playerEntity = new PlayerEntity(new PlayerComponent(), | ||
new MovableComponent(), | ||
new TransformComponent(), | ||
new RectangleCollisionComponent(), | ||
new MovementAnimationsComponent(), | ||
new CharacterAnimatorComponent()) | ||
.Create(@in: _world); | ||
|
||
{ | ||
_world.TryGetEntity(playerEntity.ID, out Entity result); | ||
|
||
Assert.That(playerEntity.ID, Is.EqualTo(result.ID)); | ||
} | ||
} | ||
|
||
[Test] | ||
public void PlayerEntity_HasComponents() | ||
{ | ||
Entity playerEntity = new PlayerEntity(new PlayerComponent(), | ||
new MovableComponent(), | ||
new TransformComponent(), | ||
new RectangleCollisionComponent(), | ||
new MovementAnimationsComponent(), | ||
new CharacterAnimatorComponent()) | ||
.Create(@in: _world); | ||
|
||
{ | ||
_world.TryGetEntity(playerEntity.ID, out Entity result); | ||
|
||
Assert.That(result.Has<PlayerComponent>(), Is.True); | ||
Assert.That(result.Has<MovableComponent>(), Is.True); | ||
// ... | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/UnitTests/UnitTests.Entities/UnitTests.Entities.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.1"/> | ||
<PackageReference Include="NUnit" Version="3.13.3"/> | ||
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2"/> | ||
<PackageReference Include="NUnit.Analyzers" Version="3.6.1"/> | ||
<PackageReference Include="coverlet.collector" Version="3.2.0"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\Libs\Entities\Entities.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |