mirror of
https://github.com/Ukendio/jecs.git
synced 2025-08-04 19:29:18 +00:00
Compare commits
3 commits
b0065aa2ce
...
dcd2ac8508
Author | SHA1 | Date | |
---|---|---|---|
|
dcd2ac8508 | ||
|
53f705ac2e | ||
|
ff4b0bf612 |
4 changed files with 1411 additions and 1187 deletions
|
@ -5,8 +5,7 @@ local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||||
local jecs = require(ReplicatedStorage.Lib:Clone())
|
local jecs = require(ReplicatedStorage.Lib:Clone())
|
||||||
local ecs = jecs.world()
|
local ecs = jecs.world()
|
||||||
local mirror = require(ReplicatedStorage.mirror:Clone())
|
local mirror = require(ReplicatedStorage.mirror:Clone())
|
||||||
local mcs = mirror.World.new()
|
local mcs = mirror.world()
|
||||||
|
|
||||||
|
|
||||||
local C1 = ecs:component()
|
local C1 = ecs:component()
|
||||||
local C2 = ecs:component()
|
local C2 = ecs:component()
|
||||||
|
|
|
@ -8,7 +8,7 @@ local jecs = require(ReplicatedStorage.Lib)
|
||||||
local pair = jecs.pair
|
local pair = jecs.pair
|
||||||
local ecs = jecs.world()
|
local ecs = jecs.world()
|
||||||
local mirror = require(ReplicatedStorage.mirror)
|
local mirror = require(ReplicatedStorage.mirror)
|
||||||
local mcs = mirror.World.new()
|
local mcs = mirror.world()
|
||||||
|
|
||||||
local C1 = ecs:component()
|
local C1 = ecs:component()
|
||||||
local C2 = ecs:entity()
|
local C2 = ecs:entity()
|
||||||
|
@ -32,7 +32,7 @@ return {
|
||||||
Functions = {
|
Functions = {
|
||||||
Mirror = function()
|
Mirror = function()
|
||||||
local m = mcs:entity()
|
local m = mcs:entity()
|
||||||
for i = 1, 100 do
|
for i = 1, 1000 do
|
||||||
mcs:add(m, E3)
|
mcs:add(m, E3)
|
||||||
mcs:remove(m, E3)
|
mcs:remove(m, E3)
|
||||||
end
|
end
|
||||||
|
@ -40,7 +40,7 @@ return {
|
||||||
|
|
||||||
Jecs = function()
|
Jecs = function()
|
||||||
local j = ecs:entity()
|
local j = ecs:entity()
|
||||||
for i = 1, 100 do
|
for i = 1, 1000 do
|
||||||
ecs:add(j, C3)
|
ecs:add(j, C3)
|
||||||
ecs:remove(j, C3)
|
ecs:remove(j, C3)
|
||||||
end
|
end
|
||||||
|
|
12
jecs.luau
12
jecs.luau
|
@ -755,7 +755,7 @@ local function archetype_register(world: World, archetype: Archetype)
|
||||||
local columns = archetype.columns
|
local columns = archetype.columns
|
||||||
for i, component_id in archetype.types do
|
for i, component_id in archetype.types do
|
||||||
local idr = id_record_ensure(world, component_id)
|
local idr = id_record_ensure(world, component_id)
|
||||||
local is_tag = bit32.band(idr.flags, ECS_ID_IS_TAG) ~= 0
|
local is_tag = bit32.btest(idr.flags, ECS_ID_IS_TAG)
|
||||||
local column = if is_tag then NULL_ARRAY else {}
|
local column = if is_tag then NULL_ARRAY else {}
|
||||||
columns[i] = column
|
columns[i] = column
|
||||||
|
|
||||||
|
@ -2583,7 +2583,7 @@ local function world_new()
|
||||||
|
|
||||||
if idr then
|
if idr then
|
||||||
local flags = idr.flags
|
local flags = idr.flags
|
||||||
if bit32.band(flags, ECS_ID_DELETE) ~= 0 then
|
if bit32.btest(flags, ECS_ID_DELETE) then
|
||||||
for archetype_id in idr.records do
|
for archetype_id in idr.records do
|
||||||
local idr_archetype = archetypes[archetype_id]
|
local idr_archetype = archetypes[archetype_id]
|
||||||
|
|
||||||
|
@ -2658,8 +2658,8 @@ local function world_new()
|
||||||
end
|
end
|
||||||
local id_record = component_index[id]
|
local id_record = component_index[id]
|
||||||
local flags = id_record.flags
|
local flags = id_record.flags
|
||||||
local flags_delete_mask: number = bit32.band(flags, ECS_ID_DELETE)
|
local flags_delete_mask = bit32.btest(flags, ECS_ID_DELETE)
|
||||||
if flags_delete_mask ~= 0 then
|
if flags_delete_mask then
|
||||||
for i = #entities, 1, -1 do
|
for i = #entities, 1, -1 do
|
||||||
local child = entities[i]
|
local child = entities[i]
|
||||||
inner_world_delete(world, child)
|
inner_world_delete(world, child)
|
||||||
|
@ -2701,7 +2701,7 @@ local function world_new()
|
||||||
if idr_r then
|
if idr_r then
|
||||||
local archetype_ids = idr_r.records
|
local archetype_ids = idr_r.records
|
||||||
local flags = idr_r.flags
|
local flags = idr_r.flags
|
||||||
if (bit32.band(flags, ECS_ID_DELETE) :: number) ~= 0 then
|
if bit32.btest(flags, ECS_ID_DELETE) then
|
||||||
for archetype_id in archetype_ids do
|
for archetype_id in archetype_ids do
|
||||||
local idr_r_archetype = archetypes[archetype_id]
|
local idr_r_archetype = archetypes[archetype_id]
|
||||||
local entities = idr_r_archetype.entities
|
local entities = idr_r_archetype.entities
|
||||||
|
@ -2879,7 +2879,7 @@ end
|
||||||
local function ecs_is_tag(world: World, entity: Entity): boolean
|
local function ecs_is_tag(world: World, entity: Entity): boolean
|
||||||
local idr = world.component_index[entity]
|
local idr = world.component_index[entity]
|
||||||
if idr then
|
if idr then
|
||||||
return bit32.band(idr.flags, ECS_ID_IS_TAG) ~= 0
|
return bit32.btest(idr.flags, ECS_ID_IS_TAG)
|
||||||
end
|
end
|
||||||
return not world_has_one_inline(world, entity, EcsComponent)
|
return not world_has_one_inline(world, entity, EcsComponent)
|
||||||
end
|
end
|
||||||
|
|
2575
mirror.luau
2575
mirror.luau
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue