mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-25 01:20:04 +00:00
guarantee monomorphic objects (laymans term: alphabetize)
This commit is contained in:
parent
4d1e62cc4e
commit
19819bfcad
1 changed files with 15 additions and 15 deletions
30
lib/init.lua
30
lib/init.lua
|
@ -157,13 +157,13 @@ local function archetypeOf(world: World, types: {i24}, prev: Archetype?): Archet
|
|||
end
|
||||
|
||||
local archetype = {
|
||||
id = id;
|
||||
types = types;
|
||||
type = ty;
|
||||
columns = columns;
|
||||
entities = {};
|
||||
edges = {};
|
||||
entities = {};
|
||||
id = id;
|
||||
records = {};
|
||||
type = ty;
|
||||
types = types;
|
||||
}
|
||||
world.archetypeIndex[ty] = archetype
|
||||
world.archetypes[id] = archetype
|
||||
|
@ -178,17 +178,17 @@ local World = {}
|
|||
World.__index = World
|
||||
function World.new()
|
||||
local self = setmetatable({
|
||||
entityIndex = {};
|
||||
componentIndex = {};
|
||||
archetypes = {};
|
||||
archetypeIndex = {};
|
||||
ROOT_ARCHETYPE = (nil :: any) :: Archetype;
|
||||
nextEntityId = 0;
|
||||
nextComponentId = 0;
|
||||
nextArchetypeId = 0;
|
||||
archetypes = {};
|
||||
componentIndex = {};
|
||||
entityIndex = {};
|
||||
hooks = {
|
||||
[ON_ADD] = {};
|
||||
};
|
||||
nextArchetypeId = 0;
|
||||
nextComponentId = 0;
|
||||
nextEntityId = 0;
|
||||
ROOT_ARCHETYPE = (nil :: any) :: Archetype;
|
||||
}, World)
|
||||
return self
|
||||
end
|
||||
|
@ -197,21 +197,21 @@ local function emit(world, eventDescription)
|
|||
local event = eventDescription.event
|
||||
|
||||
table.insert(world.hooks[event], {
|
||||
ids = eventDescription.ids;
|
||||
archetype = eventDescription.archetype;
|
||||
otherArchetype = eventDescription.otherArchetype;
|
||||
ids = eventDescription.ids;
|
||||
offset = eventDescription.offset;
|
||||
otherArchetype = eventDescription.otherArchetype;
|
||||
})
|
||||
end
|
||||
|
||||
local function onNotifyAdd(world, archetype, otherArchetype, row: number, added: Ty)
|
||||
if #added > 0 then
|
||||
emit(world, {
|
||||
archetype = archetype;
|
||||
event = ON_ADD;
|
||||
ids = added;
|
||||
archetype = archetype;
|
||||
otherArchetype = otherArchetype;
|
||||
offset = row;
|
||||
otherArchetype = otherArchetype;
|
||||
})
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue