diff --git a/.editorconfig b/.editorconfig index d8478e1..5ca11b4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -65,13 +65,13 @@ dotnet_naming_symbols.private_constants_symbols.applicable_kinds = field dotnet_naming_symbols.private_constants_symbols.required_modifiers = const dotnet_naming_symbols.private_instance_fields_symbols.applicable_accessibilities = private dotnet_naming_symbols.private_instance_fields_symbols.applicable_kinds = field -dotnet_naming_symbols.private_static_fields_override_symbols.applicable_accessibilities = local,private +dotnet_naming_symbols.private_static_fields_override_symbols.applicable_accessibilities = local, private dotnet_naming_symbols.private_static_fields_override_symbols.applicable_kinds = field -dotnet_naming_symbols.private_static_fields_override_symbols.required_modifiers = const,static +dotnet_naming_symbols.private_static_fields_override_symbols.required_modifiers = const, static dotnet_naming_symbols.private_static_fields_symbols.applicable_accessibilities = private dotnet_naming_symbols.private_static_fields_symbols.applicable_kinds = field dotnet_naming_symbols.private_static_fields_symbols.required_modifiers = static -dotnet_naming_symbols.private_static_fields_symbols_1.applicable_accessibilities = local,private +dotnet_naming_symbols.private_static_fields_symbols_1.applicable_accessibilities = local, private dotnet_naming_symbols.private_static_fields_symbols_1.applicable_kinds = field dotnet_naming_symbols.private_static_fields_symbols_1.required_modifiers = static dotnet_naming_symbols.private_static_fields_symbols_1.resharper_applicable_kinds = field diff --git a/.prettierignore b/.prettierignore index f1a0e24..d08d49a 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,8 +1,9 @@ *~ flake.* +*.cs node_modules/ .direnv/ .config/ obj/ -bin/ +bin/ \ No newline at end of file diff --git a/README.md b/README.md index 32532cc..2c05bd2 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # Gallium CIL -A small Entity-Component-System (ECS) that is built around LINQ calls and `IEnumerable` objects. \ No newline at end of file +A small Entity-Component-System (ECS) that is built around LINQ calls and `IEnumerable` objects. diff --git a/lefthook.yml b/lefthook.yml index bf398e4..e9dc928 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -7,10 +7,7 @@ pre-push: pre-commit: parallel: true commands: - dotnet-format-style: - glob: "*.cs" - run: dotnet format prettier: run: prettier . --write --loglevel warn nixfmt: - run: nixfmt flake.nix + run: nixfmt flake.nix \ No newline at end of file diff --git a/src/Gallium/WhereEntityHasExtensions.cs b/src/Gallium/WhereEntityHasExtensions.cs index e769486..70b2154 100644 --- a/src/Gallium/WhereEntityHasExtensions.cs +++ b/src/Gallium/WhereEntityHasExtensions.cs @@ -5,26 +5,22 @@ namespace Gallium { public static class WhereEntityHasExtensions { - public static IEnumerable WhereEntityHas( - this IEnumerable entities) + public static IEnumerable WhereEntityHas(this IEnumerable entities) { return entities.Where(x => x.Has()); } - public static IEnumerable WhereEntityHasAll( - this IEnumerable entities) + public static IEnumerable WhereEntityHasAll(this IEnumerable entities) { return entities.Where(x => x.HasAll()); } - public static IEnumerable WhereEntityHasAll( - this IEnumerable entities) + public static IEnumerable WhereEntityHasAll(this IEnumerable entities) { return entities.Where(x => x.HasAll()); } - public static IEnumerable WhereEntityHasAll( - this IEnumerable entities) + public static IEnumerable WhereEntityHasAll(this IEnumerable entities) { return entities.Where(x => x.HasAll()); } diff --git a/tests/Gallium.Tests/EntityTests.cs b/tests/Gallium.Tests/EntityTests.cs index a497750..2decd21 100644 --- a/tests/Gallium.Tests/EntityTests.cs +++ b/tests/Gallium.Tests/EntityTests.cs @@ -39,6 +39,7 @@ namespace Gallium.Tests public void AddingTwiceThrowsException() { var component1 = new TestComponent1(); + Exception exception = Assert.Throws( () => new Entity() .Add(component1) @@ -153,6 +154,7 @@ namespace Gallium.Tests { var component1 = new TestComponent3a(); var component2 = new TestComponent3b(); + Entity entity1 = new Entity() .Set(component1) .Set(component1) diff --git a/tests/Gallium.Tests/EnumerableEntityTests.cs b/tests/Gallium.Tests/EnumerableEntityTests.cs index 28e9823..7200101 100644 --- a/tests/Gallium.Tests/EnumerableEntityTests.cs +++ b/tests/Gallium.Tests/EnumerableEntityTests.cs @@ -11,14 +11,20 @@ namespace Gallium.Tests { Entity[] entities = { - new Entity().Add("1").Add(new TestComponent1()), - new Entity().Add("2").Add(new TestComponent2()), - new Entity().Add("3").Add(new TestComponent1()), + new Entity().Add("1") + .Add(new TestComponent1()), + new Entity().Add("2") + .Add(new TestComponent2()), + new Entity().Add("3") + .Add(new TestComponent1()), }; Assert.Equal( new[] { "1!", "2", "3!" }, - entities.SelectEntity((e, _) => e.Set(e.Get() + "!")) + entities.SelectEntity( + ( + e, + _) => e.Set(e.Get() + "!")) .Select(x => x.Get()) .ToArray()); } @@ -28,14 +34,22 @@ namespace Gallium.Tests { Entity[] entities = { - new Entity().Add("1").Add(new TestComponent1()), - new Entity().Add("2").Add(new TestComponent2()), - new Entity().Add("3").Add(new TestComponent1()).Add(new TestComponent2()), + new Entity().Add("1") + .Add(new TestComponent1()), + new Entity().Add("2") + .Add(new TestComponent2()), + new Entity().Add("3") + .Add(new TestComponent1()) + .Add(new TestComponent2()), }; Assert.Equal( new[] { "1", "2", "3!" }, - entities.SelectEntity((e, _, _) => e.Set(e.Get() + "!")) + entities.SelectEntity( + ( + e, + _, + _) => e.Set(e.Get() + "!")) .Select(x => x.Get()) .ToArray()); } @@ -45,8 +59,11 @@ namespace Gallium.Tests { Entity[] entities = { - new Entity().Add("1").Add(new TestComponent1()), - new Entity().Add("2").Add(new TestComponent2()).Add(new TestComponent3b()), + new Entity().Add("1") + .Add(new TestComponent1()), + new Entity().Add("2") + .Add(new TestComponent2()) + .Add(new TestComponent3b()), new Entity().Add("3") .Add(new TestComponent3a()) .Add(new TestComponent1()) @@ -56,7 +73,15 @@ namespace Gallium.Tests Assert.Equal( new[] { "1", "2", "3-TestComponent3a" }, entities.SelectEntity( - (e, _, _, t) => e.Set(e.Get() + "-" + t.GetType().Name)) + ( + e, + _, + _, + t) => e.Set( + e.Get() + + "-" + + t.GetType() + .Name)) .Select(x => x.Get()) .ToArray()); } @@ -66,14 +91,19 @@ namespace Gallium.Tests { Entity[] entities = { - new Entity().Add("1").Add(new TestComponent1()), - new Entity().Add("2").Add(new TestComponent2()), - new Entity().Add("3").Add(new TestComponent1()), + new Entity().Add("1") + .Add(new TestComponent1()), + new Entity().Add("2") + .Add(new TestComponent2()), + new Entity().Add("3") + .Add(new TestComponent1()), }; Assert.Equal( new[] { "1", "3" }, - entities.WhereEntityHas().Select(x => x.Get()).ToArray()); + entities.WhereEntityHas() + .Select(x => x.Get()) + .ToArray()); } [Fact] @@ -81,14 +111,20 @@ namespace Gallium.Tests { Entity[] entities = { - new Entity().Add("1").Add(new TestComponent1()), - new Entity().Add("2").Add(new TestComponent2()).Add(new TestComponent1()), - new Entity().Add("3").Add(new TestComponent1()), + new Entity().Add("1") + .Add(new TestComponent1()), + new Entity().Add("2") + .Add(new TestComponent2()) + .Add(new TestComponent1()), + new Entity().Add("3") + .Add(new TestComponent1()), }; Assert.Equal( new[] { "2" }, - entities.WhereEntityHasAll().Select(x => x.Get()).ToArray()); + entities.WhereEntityHasAll() + .Select(x => x.Get()) + .ToArray()); } [Fact] @@ -100,8 +136,11 @@ namespace Gallium.Tests .Add(new TestComponent1()) .Add(new TestComponent3b()) .Add(new TestComponent2()), - new Entity().Add("2").Add(new TestComponent2()).Add(new TestComponent1()), - new Entity().Add("3").Add(new TestComponent3a()), + new Entity().Add("2") + .Add(new TestComponent2()) + .Add(new TestComponent1()), + new Entity().Add("3") + .Add(new TestComponent3a()), }; Assert.Equal( @@ -116,14 +155,19 @@ namespace Gallium.Tests { Entity[] entities = { - new Entity().Add("1").Add(new TestComponent1()), - new Entity().Add("2").Add(new TestComponent2()), - new Entity().Add("3").Add(new TestComponent1()), + new Entity().Add("1") + .Add(new TestComponent1()), + new Entity().Add("2") + .Add(new TestComponent2()), + new Entity().Add("3") + .Add(new TestComponent1()), }; Assert.Equal( new[] { "2" }, - entities.WhereEntityNotHas().Select(x => x.Get()).ToArray()); + entities.WhereEntityNotHas() + .Select(x => x.Get()) + .ToArray()); } [Fact] @@ -131,8 +175,11 @@ namespace Gallium.Tests { Entity[] entities = { - new Entity().Add("1").Add(new TestComponent1()), - new Entity().Add("2").Add(new TestComponent2()).Add(new TestComponent1()), + new Entity().Add("1") + .Add(new TestComponent1()), + new Entity().Add("2") + .Add(new TestComponent2()) + .Add(new TestComponent1()), new Entity().Add("3"), }; @@ -148,12 +195,14 @@ namespace Gallium.Tests { Entity[] entities = { - new Entity().Add("1").Add(new TestComponent1()), + new Entity().Add("1") + .Add(new TestComponent1()), new Entity().Add("2") .Add(new TestComponent1()) .Add(new TestComponent2()) .Add(new TestComponent3b()), - new Entity().Add("3").Add(new TestComponent3a()), + new Entity().Add("3") + .Add(new TestComponent3a()), }; Assert.Equal( diff --git a/tests/Gallium.Tests/Gallium.Tests.csproj b/tests/Gallium.Tests/Gallium.Tests.csproj index a148142..c343015 100644 --- a/tests/Gallium.Tests/Gallium.Tests.csproj +++ b/tests/Gallium.Tests/Gallium.Tests.csproj @@ -10,10 +10,10 @@ 1.1.0 - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -24,6 +24,6 @@ - + \ No newline at end of file