From 41682236a172f1ae5914b6a8d52bb08d6f831d36 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 24 Jun 2024 18:44:34 -0400 Subject: [PATCH 1/6] Return function instead of table for empty view --- lib/World.luau | 12 ++++++++---- lib/World.spec.luau | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/lib/World.luau b/lib/World.luau index 0762f0fb..a142844e 100644 --- a/lib/World.luau +++ b/lib/World.luau @@ -381,10 +381,14 @@ local noopQuery = setmetatable({ without = function(self) return self end, - view = { - get = noop, - contains = noop, - }, + view = function() + return { + get = noop, + contains = function() + return false + end, + } + end, }, { __iter = function() return noop diff --git a/lib/World.spec.luau b/lib/World.spec.luau index e1903000..c0b8fbec 100644 --- a/lib/World.spec.luau +++ b/lib/World.spec.luau @@ -224,6 +224,21 @@ return function() expect(withoutCount).to.equal(1) end) + it("should return an empty query with the same methods", function() + local world = World.new() + + local Player = component() + local Enemy = component() + + expect(world:query(Player):next()).to.equal(nil) + expect(#world:query(Player):snapshot()).to.equal(0) + + expect(world:query(Player):without(Enemy):next()).to.equal(world:query(Player):next()) + + expect(world:query(Player):view():get()).to.equal(nil) + expect(world:query(Player):view():contains()).to.equal(false) + end) + it("should allow getting single components", function() local world = World.new() From 4b568087a1c023e6886d02ddae4e28ee9a4ad536 Mon Sep 17 00:00:00 2001 From: Ukendio Date: Tue, 25 Jun 2024 02:00:42 +0200 Subject: [PATCH 2/6] Initial commit --- CHANGELOG.md | 15 +++++++++++++++ wally.toml | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e456894..8fde3f3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,21 @@ The format is based on [Keep a Changelog][kac], and this project adheres to ## [Unreleased] +## [0.8.2] - 2024-06-25 + +### Fixed +- Fixed the `:view()` arm on an empty Query to return a function rather than a handle. +- Snapshot now correctly returns an empty list rather tahn nil on an empty Query.l +- Fixed an error that would happen when calling an empty Query. + +### Changed +- Optimized `Views` performance. + - No longer allocates a table for each entity in the view, making it much cheaper for queries that match against many entities. +- Converted the lua files to luau files. +- Reverted the changes to the format of the debugger table. + +## [0.8.1] - 2024-04-23 + ### Fixed - `QueryResult:without` now correctly matches against entity archetype after cache has been invalidated from transitioning archetype. diff --git a/wally.toml b/wally.toml index 10de9408..3e3662f8 100644 --- a/wally.toml +++ b/wally.toml @@ -1,7 +1,7 @@ [package] name = "matter-ecs/matter" description = "A modern ECS library for Roblox" -version = "0.8.1" +version = "0.8.2" license = "MIT" authors = [ "Eryn L. K.", From 74c0d3988a1b1c35683fd1d3ed95767b6949bc3b Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 24 Jun 2024 20:18:49 -0400 Subject: [PATCH 3/6] Change version references in docs --- README.md | 2 +- docs/Guides/Migration.md | 2 +- docs/Installation.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9da3caf1..34ec3f79 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Matter can be installed with [Wally] by including it as a dependency in your `wally.toml` file. ```toml -Matter = "matter-ecs/matter@0.8.1" +Matter = "matter-ecs/matter@0.8.2" ``` ## Migration diff --git a/docs/Guides/Migration.md b/docs/Guides/Migration.md index 72a58573..50c448db 100644 --- a/docs/Guides/Migration.md +++ b/docs/Guides/Migration.md @@ -4,5 +4,5 @@ Migrating from `evaera/matter` to `matter-ecs/matter` is easy! The only thing yo ```toml title="wally.toml" [dependencies] - matter = "matter-ecs/matter@0.8.1" + matter = "matter-ecs/matter@0.8.2" ``` diff --git a/docs/Installation.md b/docs/Installation.md index f662b40a..ac4f52af 100644 --- a/docs/Installation.md +++ b/docs/Installation.md @@ -25,7 +25,7 @@ wally = "UpliftGames/wally@x.x.x" ```toml title="wally.toml" [dependencies] -matter = "matter-ecs/matter@0.8.1" +matter = "matter-ecs/matter@0.8.2" ``` 6. Run `wally install`. From fe927d3ed021a4299f8c04781f72fe7429a890e7 Mon Sep 17 00:00:00 2001 From: Ukendio Date: Tue, 25 Jun 2024 02:21:22 +0200 Subject: [PATCH 4/6] Fix typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fde3f3d..3b4a55d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ The format is based on [Keep a Changelog][kac], and this project adheres to ### Fixed - Fixed the `:view()` arm on an empty Query to return a function rather than a handle. -- Snapshot now correctly returns an empty list rather tahn nil on an empty Query.l +- Snapshot now correctly returns an empty list rather than nil on an empty Query. - Fixed an error that would happen when calling an empty Query. ### Changed From c02f28aef21d2c5a016e7163025e4e819eb8ce36 Mon Sep 17 00:00:00 2001 From: Marcus Date: Tue, 25 Jun 2024 03:29:00 +0200 Subject: [PATCH 5/6] Update CHANGELOG.md Co-authored-by: Michael --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b4a55d9..9b6b1a2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ The format is based on [Keep a Changelog][kac], and this project adheres to ### Fixed - Fixed the `:view()` arm on an empty Query to return a function rather than a handle. -- Snapshot now correctly returns an empty list rather than nil on an empty Query. +- Fixed `:snapshot()` on an empty query returning nil instead of an empty array. - Fixed an error that would happen when calling an empty Query. ### Changed From ec7c6576d8248c267a4b3f9c0c6001ada2221c7b Mon Sep 17 00:00:00 2001 From: Marcus Date: Tue, 25 Jun 2024 03:34:58 +0200 Subject: [PATCH 6/6] Update CHANGELOG.md Co-authored-by: Michael --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b6b1a2d..38987897 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ The format is based on [Keep a Changelog][kac], and this project adheres to ## [0.8.2] - 2024-06-25 ### Fixed -- Fixed the `:view()` arm on an empty Query to return a function rather than a handle. +- Calling `:view()` on an empty query will no longer error. - Fixed `:snapshot()` on an empty query returning nil instead of an empty array. - Fixed an error that would happen when calling an empty Query.