Files
Christopher Whitley 3a5269cfea Reorganization (#909)
* Removed MonoGame.Extended.Animations
This project was just a shell that referenced MonoGame.Extended.csproj. It added no additional functionality.

* Rework BitmapFonts for new project organization.

* Cleanup namespaces

* Cleanup namespaces

* Move MonoGame.Extended.Collision into base project

* Moved MonoGame.Extended.Entities into base project

* Moved MonoGame.Extended.Graphics into base project

* Moved MonoGame.Extended.Graphics into base project

* Moved MonoGame.Extended.Input into base project

* Moved MonoGame.Extended.Particles into base project

* Moved MonoGame.Extended.Tiled into base project

* Moved MonoGame.Extended.Tiled into base project

* Moved MonoGame.Extended.Tweening into base project

* Removing SpriteFactory support
This will be added back in at a later date once the SpriteFactory application has been updated

* Update TexturePacker content import support

* Only needs to reference base project now

* Moved to Serialization namespace

* Moved  Json serialization to Serialization.Json namespace

* Moved TexturePacker content DTOs to the Content namespace

* Renamed to Texture2DRegion.Extensions.cs

* Cleaned up namespace

* Moved ReadTiledMapProperties into the ContentReaderExtensions

* Created an Extended content manager

* Moved Tweening tests to base test project

* Moved Tiled test to base test project

* Moved Entities Tests to base test project

* Moved Entities tests to base test project

* Moved Collisions tests to base test project

* Moved Pipeline Tiled test to Pipeline tests project

* Use `var` instead of full type name

* Add Tiled namespace

* Correct `Metadata` property name to new `Meta` property name

* Cleanup namespace

* Add effects namespace

* Add Content namespace

* Update using statements to new namespaces

* Move Pipeline Tiled tests to Pipeline test project

* Use correct namespace

* Use `var` instead of typing out nested types

* Remove unused namespaces

* Update to new namespaces

* Remove unused namespaces

* Update to new namespaces

* Remove dependency on Particles csproj

* Update included content on build

* Add embedded resources

* Merge multi csproj structure into single csproj structure

* TexturePackerPoint properties should be `double` not `int`

* Update csproj

* Use dotnet tool to rebuild effects

* Move effect compilation to targets file
This will ensure the effects are always built

* Fix workflow to build effects on linux

* Set wine path

* Export instead of using actions env section

* Revert back to manual effect compile until automation can be solved on GitHub Ubuntu runner
2024-07-06 23:46:20 -04:00

88 lines
2.8 KiB
C#

using System.Collections.Specialized;
using MonoGame.Extended.Graphics;
using Xunit;
namespace MonoGame.Extended.ECS.Tests
{
public class DummyComponent
{
}
public class AspectTests
{
private readonly ComponentManager _componentManager;
private readonly BitVector32 _entityA;
private readonly BitVector32 _entityB;
public AspectTests()
{
_componentManager = new ComponentManager();
_entityA = new BitVector32
{
[1 << _componentManager.GetComponentTypeId(typeof(Transform2))] = true,
[1 << _componentManager.GetComponentTypeId(typeof(Sprite))] = true,
[1 << _componentManager.GetComponentTypeId(typeof(DummyComponent))] = true
};
_entityB = new BitVector32
{
[1 << _componentManager.GetComponentTypeId(typeof(Transform2))] = true,
[1 << _componentManager.GetComponentTypeId(typeof(Sprite))] = true,
};
}
[Fact]
public void EmptyAspectMatchesAllComponents()
{
var componentManager = new ComponentManager();
var emptyAspect = Aspect.All()
.Build(componentManager);
Assert.True(emptyAspect.IsInterested(_entityA));
Assert.True(emptyAspect.IsInterested(_entityB));
}
[Fact]
public void IsInterestedInAllComponents()
{
var allAspect = Aspect
.All(typeof(Sprite), typeof(Transform2), typeof(DummyComponent))
.Build(_componentManager);
Assert.True(allAspect.IsInterested(_entityA));
Assert.False(allAspect.IsInterested(_entityB));
}
[Fact]
public void IsInterestedInEitherOneOfTheComponents()
{
var eitherOneAspect = Aspect
.One(typeof(Transform2), typeof(DummyComponent))
.Build(_componentManager);
Assert.True(eitherOneAspect.IsInterested(_entityA));
Assert.True(eitherOneAspect.IsInterested(_entityB));
}
[Fact]
public void IsInterestedInJustOneComponent()
{
var oneAspect = Aspect
.One(typeof(DummyComponent))
.Build(_componentManager);
Assert.True(oneAspect.IsInterested(_entityA));
Assert.False(oneAspect.IsInterested(_entityB));
}
[Fact]
public void IsInterestedInExcludingOneComponent()
{
var oneAspect = Aspect
.Exclude(typeof(DummyComponent))
.Build(_componentManager);
Assert.False(oneAspect.IsInterested(_entityA));
Assert.True(oneAspect.IsInterested(_entityB));
}
}
}