mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-26 01:50:01 +00:00
should be good
This commit is contained in:
parent
f1dc668214
commit
1e53fdc955
2 changed files with 32 additions and 27 deletions
|
@ -2,41 +2,37 @@
|
||||||
--!native
|
--!native
|
||||||
|
|
||||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||||
local rgb = require(ReplicatedStorage.rgb)
|
|
||||||
local Matter = require(ReplicatedStorage.DevPackages.Matter)
|
local Matter = require(ReplicatedStorage.DevPackages.Matter)
|
||||||
local jecs = require(ReplicatedStorage.Lib)
|
|
||||||
local ecr = require(ReplicatedStorage.DevPackages.ecr)
|
local ecr = require(ReplicatedStorage.DevPackages.ecr)
|
||||||
|
local jecs = require(ReplicatedStorage.Lib)
|
||||||
|
local rgb = require(ReplicatedStorage.rgb)
|
||||||
local newWorld = Matter.World.new()
|
local newWorld = Matter.World.new()
|
||||||
local ecs = jecs.World.new()
|
local ecs = jecs.World.new()
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ParameterGenerator = function()
|
ParameterGenerator = function()
|
||||||
local registry2 = ecr.registry()
|
local registry2 = ecr.registry()
|
||||||
|
|
||||||
return registry2
|
return registry2
|
||||||
end,
|
end;
|
||||||
|
|
||||||
Functions = {
|
Functions = {
|
||||||
Matter = function()
|
Matter = function()
|
||||||
for i = 1, 1000 do
|
for i = 1, 1000 do
|
||||||
newWorld:spawn()
|
newWorld:spawn()
|
||||||
end
|
end
|
||||||
end,
|
end;
|
||||||
|
|
||||||
|
|
||||||
ECR = function(_, registry2)
|
ECR = function(_, registry2)
|
||||||
for i = 1, 1000 do
|
for i = 1, 1000 do
|
||||||
registry2.create()
|
registry2.create()
|
||||||
end
|
end
|
||||||
end,
|
end;
|
||||||
|
|
||||||
|
|
||||||
Jecs = function()
|
Jecs = function()
|
||||||
for i = 1, 1000 do
|
for i = 1, 1000 do
|
||||||
ecs:entity()
|
ecs:entity()
|
||||||
end
|
end
|
||||||
end
|
end;
|
||||||
|
};
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
15
lib/init.lua
15
lib/init.lua
|
@ -470,9 +470,10 @@ function World.query(world: World, ...: i53): Query
|
||||||
local withoutComponents = {...}
|
local withoutComponents = {...}
|
||||||
for index = #compatibleArchetypes, 1, -1 do
|
for index = #compatibleArchetypes, 1, -1 do
|
||||||
local archetype = compatibleArchetypes[index][1]
|
local archetype = compatibleArchetypes[index][1]
|
||||||
|
local records = archetype.records
|
||||||
local shouldRemove = false
|
local shouldRemove = false
|
||||||
for _, componentId in withoutComponents do
|
for _, componentId in withoutComponents do
|
||||||
if archetype.records[componentId] then
|
if records[componentId] then
|
||||||
shouldRemove = true
|
shouldRemove = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
@ -634,15 +635,23 @@ function World.observer(world: World, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
local queryOutput = {}
|
local queryOutput = {}
|
||||||
|
local length = 0
|
||||||
|
|
||||||
local row = change.offset
|
local row = change.offset
|
||||||
local archetype = change.archetype
|
local archetype = change.archetype
|
||||||
local columns = archetype.columns
|
local columns = archetype.columns
|
||||||
local archetypeRecords = archetype.records
|
local archetypeRecords = archetype.records
|
||||||
for _, id in componentIds do
|
for _, id in componentIds do
|
||||||
table.insert(queryOutput, columns[archetypeRecords[id]][row])
|
local value = columns[archetypeRecords[id]][row]
|
||||||
|
if value == nil then
|
||||||
|
continue
|
||||||
end
|
end
|
||||||
|
|
||||||
return archetype.entities[row], unpack(queryOutput, 1, #queryOutput)
|
length += 1
|
||||||
|
queryOutput[length] = value
|
||||||
|
end
|
||||||
|
|
||||||
|
return archetype.entities[row], unpack(queryOutput, 1, length)
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue