hammer/lib/world.luau
Mark Marks 5a043b2912 fix: Refs and cmd buffers, add unit tests, v0.1.0
- Refs and command buffers used to share data with every single world, this is now mitigated by using a separate data set for every world

- Working unit tests have been added

- jecs-utils has now been released at mark-marks/jecs-utils@v0.1.0!
2024-09-22 00:50:30 +02:00

29 lines
445 B
Text

--!strict
--!optimize 2
local jecs = require("./jecs")
local WORLD: jecs.World
local listeners: { (jecs.World) -> () } = {}
local function get(): jecs.World
return WORLD
end
local function set(world: jecs.World)
WORLD = world
for _, fn in listeners do
fn(world)
end
end
local function on_set(fn: (jecs.World) -> ())
table.insert(listeners, fn)
end
return {
get = get,
set = set,
on_set = on_set,
}