mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-25 01:20:04 +00:00
Put world back to constructor
This commit is contained in:
parent
d5de1ad425
commit
ab3023b57b
1 changed files with 7 additions and 7 deletions
|
@ -662,8 +662,7 @@ do
|
||||||
removed = changes_removed,
|
removed = changes_removed,
|
||||||
}
|
}
|
||||||
|
|
||||||
local function track(worldToTrack, fn)
|
local function track(fn)
|
||||||
world = worldToTrack
|
|
||||||
added = true
|
added = true
|
||||||
removed = true
|
removed = true
|
||||||
|
|
||||||
|
@ -690,7 +689,8 @@ do
|
||||||
|
|
||||||
local tracker = { track = track }
|
local tracker = { track = track }
|
||||||
|
|
||||||
function ChangeTracker<T>(component: Entity<T>): Tracker<T>
|
function ChangeTracker<T>(worldToTrack: World, component: Entity<T>): Tracker<T>
|
||||||
|
world = worldToTrack
|
||||||
T = component
|
T = component
|
||||||
-- We just use jecs.Rest because people will probably not use it anyways
|
-- We just use jecs.Rest because people will probably not use it anyways
|
||||||
PreviousT = jecs.pair(jecs.Rest, T)
|
PreviousT = jecs.pair(jecs.Rest, T)
|
||||||
|
@ -706,12 +706,12 @@ TEST("changetracker", function()
|
||||||
|
|
||||||
do CASE "should allow change tracking"
|
do CASE "should allow change tracking"
|
||||||
local Test = world:component() :: Entity<{ foo: number }>
|
local Test = world:component() :: Entity<{ foo: number }>
|
||||||
local TestTracker = ChangeTracker(Test)
|
local TestTracker = ChangeTracker(world, Test)
|
||||||
|
|
||||||
local e = world:entity()
|
local e = world:entity()
|
||||||
world:set(e, Test, { foo = 11 })
|
world:set(e, Test, { foo = 11 })
|
||||||
|
|
||||||
TestTracker.track(world, function(changes)
|
TestTracker.track(function(changes)
|
||||||
local added = 0
|
local added = 0
|
||||||
local changed = 0
|
local changed = 0
|
||||||
local removed = 0
|
local removed = 0
|
||||||
|
@ -733,7 +733,7 @@ TEST("changetracker", function()
|
||||||
test.foo = test.foo + 1
|
test.foo = test.foo + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
TestTracker.track(world, function(changes)
|
TestTracker.track(function(changes)
|
||||||
local added = 0
|
local added = 0
|
||||||
local changed = 0
|
local changed = 0
|
||||||
local removed = 0
|
local removed = 0
|
||||||
|
@ -755,7 +755,7 @@ TEST("changetracker", function()
|
||||||
|
|
||||||
world:remove(e, Test)
|
world:remove(e, Test)
|
||||||
|
|
||||||
TestTracker.track(world, function(changes)
|
TestTracker.track(function(changes)
|
||||||
local added = 0
|
local added = 0
|
||||||
local changed = 0
|
local changed = 0
|
||||||
local removed = 0
|
local removed = 0
|
||||||
|
|
Loading…
Reference in a new issue