mirror of
https://github.com/Ukendio/jecs.git
synced 2026-02-04 15:15:21 +00:00
Revert to example
This commit is contained in:
parent
4db44476a9
commit
81792fe314
1 changed files with 109 additions and 55 deletions
|
|
@ -2,11 +2,32 @@
|
||||||
--!native
|
--!native
|
||||||
|
|
||||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||||
|
local Matter = require(ReplicatedStorage.DevPackages.Matter)
|
||||||
|
local ecr = require(ReplicatedStorage.DevPackages.ecr)
|
||||||
|
local newWorld = Matter.World.new()
|
||||||
|
|
||||||
local jecs = require(ReplicatedStorage.Lib:Clone())
|
local jecs = require(ReplicatedStorage.Lib:Clone())
|
||||||
local chrono = require(ReplicatedStorage.chronoecs:Clone())
|
local mirror = require(ReplicatedStorage.mirror:Clone())
|
||||||
|
local mcs = mirror.world()
|
||||||
local ecs = jecs.world()
|
local ecs = jecs.world()
|
||||||
local ccs = chrono.new()
|
|
||||||
|
local A1 = Matter.component()
|
||||||
|
local A2 = Matter.component()
|
||||||
|
local A3 = Matter.component()
|
||||||
|
local A4 = Matter.component()
|
||||||
|
local A5 = Matter.component()
|
||||||
|
local A6 = Matter.component()
|
||||||
|
local A7 = Matter.component()
|
||||||
|
local A8 = Matter.component()
|
||||||
|
|
||||||
|
local B1 = ecr.component()
|
||||||
|
local B2 = ecr.component()
|
||||||
|
local B3 = ecr.component()
|
||||||
|
local B4 = ecr.component()
|
||||||
|
local B5 = ecr.component()
|
||||||
|
local B6 = ecr.component()
|
||||||
|
local B7 = ecr.component()
|
||||||
|
local B8 = ecr.component()
|
||||||
|
|
||||||
local D1 = ecs:component()
|
local D1 = ecs:component()
|
||||||
local D2 = ecs:component()
|
local D2 = ecs:component()
|
||||||
|
|
@ -17,74 +38,107 @@ local D6 = ecs:component()
|
||||||
local D7 = ecs:component()
|
local D7 = ecs:component()
|
||||||
local D8 = ecs:component()
|
local D8 = ecs:component()
|
||||||
|
|
||||||
local E1 = ccs:component()
|
local E1 = mcs:component()
|
||||||
local E2 = ccs:component()
|
local E2 = mcs:component()
|
||||||
local E3 = ccs:component()
|
local E3 = mcs:component()
|
||||||
local E4 = ccs:component()
|
local E4 = mcs:component()
|
||||||
local E5 = ccs:component()
|
local E5 = mcs:component()
|
||||||
local E6 = ccs:component()
|
local E6 = mcs:component()
|
||||||
local E7 = ccs:component()
|
local E7 = mcs:component()
|
||||||
local E8 = ccs:component()
|
local E8 = mcs:component()
|
||||||
|
|
||||||
local d_components = {}
|
local registry2 = ecr.registry()
|
||||||
local e_components = {}
|
|
||||||
|
|
||||||
for i = 1, 150 do
|
|
||||||
ecs:component()
|
|
||||||
ccs:component()
|
|
||||||
end
|
|
||||||
|
|
||||||
local function flip()
|
local function flip()
|
||||||
return math.random() >= 0.5
|
return math.random() >= 0.25
|
||||||
end
|
end
|
||||||
|
|
||||||
local N = 2 ^ 16 - 2
|
local N = 2 ^ 16 - 2
|
||||||
|
local archetypes = {}
|
||||||
|
|
||||||
|
local hm = 0
|
||||||
for i = 1, N do
|
for i = 1, N do
|
||||||
|
local id = registry2.create()
|
||||||
|
local combination = ""
|
||||||
|
local n = newWorld:spawn()
|
||||||
local entity = ecs:entity()
|
local entity = ecs:entity()
|
||||||
local m = ccs:entity()
|
local m = mcs:entity()
|
||||||
|
|
||||||
if flip() then
|
if flip() then
|
||||||
ecs:set(entity, D1, true)
|
registry2:set(id, B1, { value = true })
|
||||||
ccs:add(m, E1)
|
ecs:set(entity, D1, { value = true })
|
||||||
ccs:set(m, E1, true)
|
newWorld:insert(n, A1({ value = true }))
|
||||||
|
mcs:set(m, E1, { value = 2 })
|
||||||
end
|
end
|
||||||
if flip() then
|
if flip() then
|
||||||
ecs:set(entity, D2, true)
|
combination ..= "B"
|
||||||
ccs:add(m, E2)
|
registry2:set(id, B2, { value = true })
|
||||||
ccs:set(m, E2, true)
|
ecs:set(entity, D2, { value = true })
|
||||||
|
mcs:set(m, E2, { value = 2 })
|
||||||
|
newWorld:insert(n, A2({ value = true }))
|
||||||
end
|
end
|
||||||
if flip() then
|
if flip() then
|
||||||
ecs:set(entity, D3, true)
|
combination ..= "C"
|
||||||
ccs:add(m, E3)
|
registry2:set(id, B3, { value = true })
|
||||||
ccs:set(m, E3, true)
|
ecs:set(entity, D3, { value = true })
|
||||||
|
mcs:set(m, E3, { value = 2 })
|
||||||
|
newWorld:insert(n, A3({ value = true }))
|
||||||
end
|
end
|
||||||
if flip() then
|
if flip() then
|
||||||
ecs:set(entity, D4, true)
|
combination ..= "D"
|
||||||
ccs:add(m, E4)
|
registry2:set(id, B4, { value = true })
|
||||||
ccs:set(m, E4, true)
|
ecs:set(entity, D4, { value = true })
|
||||||
|
mcs:set(m, E4, { value = 2 })
|
||||||
|
|
||||||
|
newWorld:insert(n, A4({ value = true }))
|
||||||
end
|
end
|
||||||
if flip() then
|
if flip() then
|
||||||
ecs:set(entity, D5, true)
|
combination ..= "E"
|
||||||
ccs:add(m, E4)
|
registry2:set(id, B5, { value = true })
|
||||||
ccs:set(m, E5, true)
|
ecs:set(entity, D5, { value = true })
|
||||||
|
mcs:set(m, E5, { value = 2 })
|
||||||
|
|
||||||
|
newWorld:insert(n, A5({ value = true }))
|
||||||
end
|
end
|
||||||
if flip() then
|
if flip() then
|
||||||
ecs:set(entity, D6, true)
|
combination ..= "F"
|
||||||
ccs:add(m, E6)
|
registry2:set(id, B6, { value = true })
|
||||||
ccs:set(m, E6, true)
|
ecs:set(entity, D6, { value = true })
|
||||||
|
mcs:set(m, E6, { value = 2 })
|
||||||
|
newWorld:insert(n, A6({ value = true }))
|
||||||
end
|
end
|
||||||
if flip() then
|
if flip() then
|
||||||
ecs:set(entity, D7, true)
|
combination ..= "G"
|
||||||
ccs:add(m, E7)
|
registry2:set(id, B7, { value = true })
|
||||||
ccs:set(m, E7, true)
|
ecs:set(entity, D7, { value = true })
|
||||||
|
mcs:set(m, E7, { value = 2 })
|
||||||
|
newWorld:insert(n, A7({ value = true }))
|
||||||
end
|
end
|
||||||
if flip() then
|
if flip() then
|
||||||
ccs:add(m, E8)
|
combination ..= "H"
|
||||||
ecs:set(entity, D8, true)
|
registry2:set(id, B8, { value = true })
|
||||||
ccs:set(m, E8, true)
|
newWorld:insert(n, A8({ value = true }))
|
||||||
|
ecs:set(entity, D8, { value = true })
|
||||||
|
mcs:set(m, E8, { value = 2 })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if combination:find("BCDF") then
|
||||||
|
if not archetypes[combination] then
|
||||||
|
print(combination)
|
||||||
end
|
end
|
||||||
|
hm += 1
|
||||||
|
end
|
||||||
|
archetypes[combination] = true
|
||||||
|
end
|
||||||
|
print("TEST", hm)
|
||||||
|
|
||||||
|
local count = 0
|
||||||
|
|
||||||
|
for _, archetype in ecs:query(D2, D4, D6, D8):archetypes() do
|
||||||
|
count += #archetype.entities
|
||||||
|
end
|
||||||
|
|
||||||
|
print(count)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ParameterGenerator = function()
|
ParameterGenerator = function()
|
||||||
|
|
@ -92,21 +146,21 @@ return {
|
||||||
end,
|
end,
|
||||||
|
|
||||||
Functions = {
|
Functions = {
|
||||||
-- Matter = function()
|
Matter = function()
|
||||||
-- for entityId, firstComponent in newWorld:query(A2, A4, A6, A8) do
|
for entityId, firstComponent in newWorld:query(A2, A4, A6, A8) do
|
||||||
-- end
|
|
||||||
-- end,
|
|
||||||
|
|
||||||
-- ECR = function()
|
|
||||||
-- for entityId, firstComponent in registry2:view(B2, B4, B6, B8) do
|
|
||||||
-- end
|
|
||||||
-- end,
|
|
||||||
--
|
|
||||||
chrono = function()
|
|
||||||
for entityId, firstComponent in ccs:view(E2, E4, E6, E8) do
|
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
ECR = function()
|
||||||
|
for entityId, firstComponent in registry2:view(B2, B4, B6, B8) do
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
-- Mirror = function()
|
||||||
|
-- for entityId, firstComponent in mcs:query(E2, E4, E6, E8) do
|
||||||
|
-- end
|
||||||
|
-- end,
|
||||||
|
|
||||||
Jecs = function()
|
Jecs = function()
|
||||||
for entityId, firstComponent in ecs:query(D2, D4, D6, D8) do
|
for entityId, firstComponent in ecs:query(D2, D4, D6, D8) do
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue