Compare commits

..

1 commit

Author SHA1 Message Date
forgejo-actions
04d650aeea Sync to upstream Jecs 0.6.0-nightly.20250519T001113Z 2025-05-19 00:11:32 +00:00
7 changed files with 39 additions and 42 deletions

View file

@ -2,20 +2,15 @@ local jecs = require("@jecs")
type Observer = { type Observer = {
callback: (jecs.Entity) -> (), callback: (jecs.Entity) -> (),
query: jecs.Query<...any>, query: jecs.Query<...jecs.Id>,
}
type Monitor = {
callback: (jecs.Entity, jecs.Entity) -> (),
queyr: jecs.Query<any>
} }
export type PatchedWorld = jecs.World & { export type PatchedWorld = jecs.World & {
added: <T>(PatchedWorld, jecs.Id<T>, (e: jecs.Entity, id: jecs.Id, value: T) -> ()) -> () -> (), added: <T>(PatchedWorld, jecs.Id<T>, (jecs.Entity, jecs.Id, T) -> ()) -> () -> (),
removed: <T>(PatchedWorld, jecs.Id<T>, (e: jecs.Entity, id: jecs.Id) -> ()) -> () -> (), removed: <T>(PatchedWorld, jecs.Id<T>, (jecs.Entity, jecs.Id) -> ()) -> () -> (),
changed: <T>(PatchedWorld, jecs.Id<T>, (e: jecs.Entity, id: jecs.Id, value: T) -> ()) -> () -> (), changed: <T>(PatchedWorld, jecs.Id<T>, (jecs.Entity, jecs.Id, T) -> ()) -> () -> (),
observer: (PatchedWorld, Observer) -> (), observer: (PatchedWorld, Observer) -> (),
monitor: (PatchedWorld, Monitor) -> (), monitor: (PatchedWorld, Observer) -> (),
} }
local function observers_new(world, description) local function observers_new(world, description)
@ -50,6 +45,7 @@ local function observers_new(world, description)
end end
end end
local function join(world, component) local function join(world, component)
local sparse_array = {} local sparse_array = {}
local dense_array = {} local dense_array = {}
@ -167,16 +163,16 @@ local function observers_add(world: jecs.World): PatchedWorld
listener(entity, id, value) listener(entity, id, value)
end end
end end
local existing_hook = world:get(component, jecs.OnAdd) local idr = world.component_index[component]
if existing_hook then if idr then
table.insert(listeners, existing_hook) local idr_hook_existing = idr.hooks.on_add
local idr = world.component_index[component] if idr_hook_existing then
if idr then table.insert(listeners, idr_hook_existing)
idr.hooks.on_add = on_add
end end
idr.hooks.on_add = on_add :: any
else
world:set(component, jecs.OnAdd, on_add)
end end
world:set(component, jecs.OnAdd, on_add)
end end
table.insert(listeners, fn) table.insert(listeners, fn)
return function() return function()
@ -201,15 +197,16 @@ local function observers_add(world: jecs.World): PatchedWorld
listener(entity, id, value) listener(entity, id, value)
end end
end end
local existing_hook = world:get(component, jecs.OnChange) local idr = world.component_index[component]
if existing_hook then if idr then
table.insert(listeners, existing_hook) local idr_hook_existing = idr.hooks.on_change
local idr = world.component_index[component] if idr_hook_existing then
if idr then table.insert(listeners, idr_hook_existing)
idr.hooks.on_change = on_change
end end
idr.hooks.on_change = on_change :: any
else
world:set(component, jecs.OnChange, on_change)
end end
world:set(component, jecs.OnChange, on_change)
end end
table.insert(listeners, fn) table.insert(listeners, fn)
return function() return function()
@ -234,16 +231,16 @@ local function observers_add(world: jecs.World): PatchedWorld
listener(entity, id, value) listener(entity, id, value)
end end
end end
local existing_hook = world:get(component, jecs.OnRemove) local idr = world.component_index[component]
if existing_hook then if idr then
table.insert(listeners, existing_hook) local idr_hook_existing = idr.hooks.on_remove
local idr = world.component_index[component] if idr_hook_existing then
if idr then table.insert(listeners, idr_hook_existing)
idr.hooks.on_remove = on_remove
end end
idr.hooks.on_remove = on_remove :: any
else
world:set(component, jecs.OnRemove, on_remove)
end end
world:set(component, jecs.OnRemove, on_remove)
end end
table.insert(listeners, fn) table.insert(listeners, fn)
return function() return function()

View file

@ -1,2 +1,2 @@
modified = ["addons/observers.luau"] modified = ["README.md", "jecs.luau"]
version = "0.6.0-nightly.20250520T001101Z" version = "0.6.0-nightly.20250519T001113Z"

View file

@ -3,7 +3,7 @@ includes = ["init.luau", "pesde.toml", "README.md", "CHANGELOG.md", "LICENSE", "
license = "MIT" license = "MIT"
name = "marked/jecs_nightly" name = "marked/jecs_nightly"
repository = "https://git.devmarked.win/marked/jecs-nightly" repository = "https://git.devmarked.win/marked/jecs-nightly"
version = "0.6.0-nightly.20250520T001101Z" version = "0.6.0-nightly.20250519T001113Z"
[indices] [indices]
default = "https://github.com/pesde-pkg/index" default = "https://github.com/pesde-pkg/index"

View file

@ -3,7 +3,7 @@ includes = ["init.luau", "pesde.toml", "README.md", "CHANGELOG.md", "LICENSE", "
license = "MIT" license = "MIT"
name = "marked/jecs_nightly" name = "marked/jecs_nightly"
repository = "https://git.devmarked.win/marked/jecs-nightly" repository = "https://git.devmarked.win/marked/jecs-nightly"
version = "0.6.0-nightly.20250520T001101Z" version = "0.6.0-nightly.20250519T001113Z"
[indices] [indices]
default = "https://github.com/pesde-pkg/index" default = "https://github.com/pesde-pkg/index"

View file

@ -1,2 +1,2 @@
passed = true passed = true
timestamp = "20250520T001103Z" timestamp = "20250519T001115Z"

View file

@ -1,6 +1,6 @@
7.5 us  3 kB│ delete children of entity 7.3 us  3 kB│ delete children of entity
9.2 us  1 kB│ remove friends of entity 9.2 us  1 kB│ remove friends of entity
347 ns  10  B│ simple deletion of entity 348 ns  10  B│ simple deletion of entity
repro repro
NONE│  NONE│ 
@ -121,5 +121,5 @@
PASS│ #2 PASS│ #2
PASS│ #3 PASS│ #3
74/74 test cases passed in 30.716 ms. 74/74 test cases passed in 33.314 ms.
0 fails 0 fails

View file

@ -5,4 +5,4 @@ license = "MIT"
name = "mark-marks/jecs-nightly" name = "mark-marks/jecs-nightly"
realm = "shared" realm = "shared"
registry = "https://github.com/UpliftGames/wally-index" registry = "https://github.com/UpliftGames/wally-index"
version = "0.6.0-nightly.20250520T001101Z" version = "0.6.0-nightly.20250519T001113Z"