mirror of
https://github.com/Ukendio/jecs.git
synced 2025-08-04 11:19:17 +00:00
Compare commits
1 commit
96dc0e4ac3
...
6b85195c1a
Author | SHA1 | Date | |
---|---|---|---|
|
6b85195c1a |
1 changed files with 15 additions and 29 deletions
|
@ -1,35 +1,20 @@
|
|||
--!strict
|
||||
local jecs = require("@jecs")
|
||||
|
||||
|
||||
type Description<T...> = jecs.Query<T...>
|
||||
|
||||
type ObserverArm = (<a>(
|
||||
PatchedWorld,
|
||||
{
|
||||
query: jecs.Query<a>,
|
||||
callback: ((jecs.Entity) -> ())?
|
||||
}
|
||||
) -> () -> () -> (jecs.Entity)) & (<a, b>(
|
||||
PatchedWorld,
|
||||
{
|
||||
query: jecs.Query<a, b>,
|
||||
callback: ((jecs.Entity) -> ())?
|
||||
}
|
||||
) -> () -> () -> (jecs.Entity)) & (<a, b, c>(
|
||||
PatchedWorld,
|
||||
{
|
||||
query: jecs.Query<a, b, c>,
|
||||
callback: ((jecs.Entity) -> ())?
|
||||
}
|
||||
) -> () -> () -> (jecs.Entity))
|
||||
|
||||
export type PatchedWorld = jecs.World & {
|
||||
added: <T>(PatchedWorld, jecs.Id<T>, <e>(e: jecs.Entity<e>, id: jecs.Id<T>, value: T?) -> ()) -> () -> (),
|
||||
removed: <T>(PatchedWorld, jecs.Id<T>, (e: jecs.Entity, id: jecs.Id) -> ()) -> () -> (),
|
||||
changed: <T>(PatchedWorld, jecs.Id<T>, <e>(e: jecs.Entity<e>, id: jecs.Id<T>, value: T) -> ()) -> () -> (),
|
||||
observer: ObserverArm & any,
|
||||
monitor: ObserverArm & any
|
||||
observer: <T...>(
|
||||
PatchedWorld,
|
||||
jecs.Query<T...>,
|
||||
(<a>(jecs.Entity, jecs.Id<a>, a) -> ())?
|
||||
) -> () -> (jecs.Entity),
|
||||
monitor: (
|
||||
PatchedWorld,
|
||||
any,
|
||||
(<a>(jecs.Entity, jecs.Id<a>) -> ())?
|
||||
) -> ()
|
||||
}
|
||||
|
||||
local function observers_new(
|
||||
|
@ -61,7 +46,8 @@ local function observers_new(
|
|||
id: jecs.Id<a>,
|
||||
value: a?
|
||||
)
|
||||
local r = entity_index.sparse_array[jecs.ECS_ID(entity)]
|
||||
local r = jecs.entity_index_try_get_fast(
|
||||
entity_index, entity :: any) :: jecs.Record
|
||||
|
||||
local archetype = r.archetype
|
||||
|
||||
|
@ -82,9 +68,9 @@ local function observers_new(
|
|||
return function()
|
||||
local row = i
|
||||
return function()
|
||||
if row == 0 then
|
||||
i = 0
|
||||
table.clear(entities)
|
||||
if row == 0 then
|
||||
i = 0
|
||||
table.clear(entities)
|
||||
end
|
||||
local entity = entities[row]
|
||||
row -= 1
|
||||
|
|
Loading…
Reference in a new issue