Compare commits

..

4 commits

Author SHA1 Message Date
Ukendio
d99088ea1e Bump rc
Some checks are pending
analysis / Run Luau Analyze (push) Waiting to run
deploy-docs / build (push) Waiting to run
deploy-docs / Deploy (push) Blocked by required conditions
publish-npm / publish (push) Waiting to run
unit-testing / Run Luau Tests (push) Waiting to run
2025-07-18 00:38:39 +02:00
Ukendio
012b5e2bfa Make cleanup conditions 2025-07-18 00:37:58 +02:00
Ukendio
54b21001ab Bump versions 2025-07-17 23:45:56 +02:00
Ukendio
9c09686a69 always check OnDelete condition 2025-07-17 23:45:04 +02:00
4 changed files with 30 additions and 11 deletions

View file

@ -714,13 +714,13 @@ local function id_record_ensure(world: World, id: Entity): ComponentRecord
if world_has_one_inline(world, relation, EcsExclusive) then if world_has_one_inline(world, relation, EcsExclusive) then
is_exclusive = true is_exclusive = true
end end
else end
local cleanup_policy = world_target(world, relation, EcsOnDelete, 0) local cleanup_policy = world_target(world, relation, EcsOnDelete, 0)
if cleanup_policy == EcsDelete then if cleanup_policy == EcsDelete then
has_delete = true has_delete = true
end end
end
local on_add, on_change, on_remove = world_get(world, local on_add, on_change, on_remove = world_get(world,
relation, EcsOnAdd, EcsOnChange, EcsOnRemove) relation, EcsOnAdd, EcsOnChange, EcsOnRemove)
@ -2766,7 +2766,7 @@ local function world_new()
if idr then if idr then
local flags = idr.flags local flags = idr.flags
if bit32.btest(flags, ECS_ID_DELETE) then if (bit32.btest(flags, ECS_ID_DELETE) == true) 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]
@ -2873,7 +2873,8 @@ 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.btest(flags, ECS_ID_DELETE) then local has_delete_policy = bit32.btest(flags, ECS_ID_DELETE)
if has_delete_policy 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
@ -3003,8 +3004,10 @@ local function world_new()
inner_world_set(world, EcsWildcard, EcsName, "jecs.Wildcard") inner_world_set(world, EcsWildcard, EcsName, "jecs.Wildcard")
inner_world_set(world, EcsChildOf, EcsName, "jecs.ChildOf") inner_world_set(world, EcsChildOf, EcsName, "jecs.ChildOf")
inner_world_set(world, EcsComponent, EcsName, "jecs.Component") inner_world_set(world, EcsComponent, EcsName, "jecs.Component")
inner_world_set(world, EcsOnDelete, EcsName, "jecs.OnDelete") inner_world_set(world, EcsOnDelete, EcsName, "jecs.OnDelete")
inner_world_set(world, EcsOnDeleteTarget, EcsName, "jecs.OnDeleteTarget") inner_world_set(world, EcsOnDeleteTarget, EcsName, "jecs.OnDeleteTarget")
inner_world_set(world, EcsDelete, EcsName, "jecs.Delete") inner_world_set(world, EcsDelete, EcsName, "jecs.Delete")
inner_world_set(world, EcsRemove, EcsName, "jecs.Remove") inner_world_set(world, EcsRemove, EcsName, "jecs.Remove")
inner_world_set(world, EcsName, EcsName, "jecs.Name") inner_world_set(world, EcsName, EcsName, "jecs.Name")
@ -3013,6 +3016,9 @@ local function world_new()
inner_world_add(world, EcsChildOf, ECS_PAIR(EcsOnDeleteTarget, EcsDelete)) inner_world_add(world, EcsChildOf, ECS_PAIR(EcsOnDeleteTarget, EcsDelete))
inner_world_add(world, EcsChildOf, EcsExclusive) inner_world_add(world, EcsChildOf, EcsExclusive)
inner_world_add(world, EcsOnDelete, EcsExclusive)
inner_world_add(world, EcsOnDeleteTarget, EcsExclusive)
for i = EcsRest + 1, ecs_max_tag_id do for i = EcsRest + 1, ecs_max_tag_id do
entity_index_new_id(entity_index) entity_index_new_id(entity_index)
end end

View file

@ -1,6 +1,6 @@
{ {
"name": "@rbxts/jecs", "name": "@rbxts/jecs",
"version": "0.9.0-rc.0", "version": "0.9.0-rc.2",
"description": "Stupidly fast Entity Component System", "description": "Stupidly fast Entity Component System",
"main": "jecs.luau", "main": "jecs.luau",
"repository": { "repository": {

View file

@ -24,6 +24,19 @@ type Id<T=unknown> = jecs.Id<T>
local entity_visualiser = require("@tools/entity_visualiser") local entity_visualiser = require("@tools/entity_visualiser")
local dwi = entity_visualiser.stringify local dwi = entity_visualiser.stringify
TEST("ardi", function()
local world = jecs.world()
local r = world:entity()
world:add(r, jecs.pair(jecs.OnDelete, jecs.Delete))
local e = world:entity()
local e1 = world:entity()
world:add(e, jecs.pair(r, e1))
world:delete(r)
CHECK(not world:contains(e))
end)
TEST("dai", function() TEST("dai", function()
local world = jecs.world() local world = jecs.world()
local C = world:component() local C = world:component()
@ -621,9 +634,9 @@ TEST("world:delete()", function()
world:add(e1, ct) world:add(e1, ct)
world:add(e2, jecs.pair(ct, dummy)) world:add(e2, jecs.pair(ct, dummy))
world:delete(dummy) -- world:delete(dummy)
CHECK(world:contains(e2)) -- CHECK(world:contains(e2))
world:delete(ct) world:delete(ct)

View file

@ -1,6 +1,6 @@
[package] [package]
name = "ukendio/jecs" name = "ukendio/jecs"
version = "0.9.0-rc.0" version = "0.9.0-rc.2"
registry = "https://github.com/UpliftGames/wally-index" registry = "https://github.com/UpliftGames/wally-index"
realm = "shared" realm = "shared"
license = "MIT" license = "MIT"