mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-25 01:20:04 +00:00
parent
1e633d4563
commit
c80bb0e2fd
2 changed files with 123 additions and 79 deletions
|
@ -26,7 +26,7 @@ type GraphEdges = Map<i53, GraphEdge>
|
||||||
type GraphNode = {
|
type GraphNode = {
|
||||||
add: GraphEdges,
|
add: GraphEdges,
|
||||||
remove: GraphEdges,
|
remove: GraphEdges,
|
||||||
refs: GraphEdge
|
refs: GraphEdge,
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Archetype = {
|
export type Archetype = {
|
||||||
|
@ -893,7 +893,6 @@ local function archetype_clear_edges(archetype: Archetype)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function archetype_destroy(world: World, archetype: Archetype)
|
local function archetype_destroy(world: World, archetype: Archetype)
|
||||||
|
|
||||||
if archetype == world.ROOT_ARCHETYPE then
|
if archetype == world.ROOT_ARCHETYPE then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -1053,7 +1052,6 @@ do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
archetype_destroy(world, idr_t_archetype)
|
archetype_destroy(world, idr_t_archetype)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1800,4 +1798,20 @@ return {
|
||||||
pair_first = ecs_pair_first,
|
pair_first = ecs_pair_first,
|
||||||
pair_second = ecs_pair_second,
|
pair_second = ecs_pair_second,
|
||||||
entity_index_get_alive = entity_index_get_alive,
|
entity_index_get_alive = entity_index_get_alive,
|
||||||
|
|
||||||
|
archetype_append_to_records = archetype_append_to_records,
|
||||||
|
id_record_ensure = id_record_ensure,
|
||||||
|
archetype_create = archetype_create,
|
||||||
|
archetype_ensure = archetype_ensure,
|
||||||
|
find_insert = find_insert,
|
||||||
|
find_archetype_with = find_archetype_with,
|
||||||
|
find_archetype_without = find_archetype_without,
|
||||||
|
archetype_init_edge = archetype_init_edge,
|
||||||
|
archetype_ensure_edge = archetype_ensure_edge,
|
||||||
|
init_edge_for_add = init_edge_for_add,
|
||||||
|
init_edge_for_remove = init_edge_for_remove,
|
||||||
|
create_edge_for_add = create_edge_for_add,
|
||||||
|
create_edge_for_remove = create_edge_for_remove,
|
||||||
|
archetype_traverse_add = archetype_traverse_add,
|
||||||
|
archetype_traverse_remove = archetype_traverse_remove,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
local jecs = require("@jecs")
|
local jecs: typeof(require("../jecs/src")) = require("@jecs");
|
||||||
|
|
||||||
local testkit = require("@testkit")
|
local testkit = require("@testkit")
|
||||||
local BENCH, START = testkit.benchmark()
|
local BENCH, START = testkit.benchmark()
|
||||||
local __ = jecs.Wildcard
|
local __ = jecs.Wildcard
|
||||||
|
@ -71,6 +72,35 @@ local function name(world, e)
|
||||||
return world:get(e, jecs.Name)
|
return world:get(e, jecs.Name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
TEST("archetype", function()
|
||||||
|
local archetype_append_to_records = jecs.archetype_append_to_records
|
||||||
|
local id_record_ensure = jecs.id_record_ensure
|
||||||
|
local archetype_create = jecs.archetype_create
|
||||||
|
local archetype_ensure = jecs.archetype_ensure
|
||||||
|
local find_insert = jecs.find_insert
|
||||||
|
local find_archetype_with = jecs.find_archetype_with
|
||||||
|
local find_archetype_without = jecs.find_archetype_without
|
||||||
|
local archetype_init_edge = jecs.archetype_init_edge
|
||||||
|
local archetype_ensure_edge = jecs.archetype_ensure_edge
|
||||||
|
local init_edge_for_add = jecs.init_edge_for_add
|
||||||
|
local init_edge_for_remove = jecs.init_edge_for_remove
|
||||||
|
local create_edge_for_add = jecs.create_edge_for_add
|
||||||
|
local create_edge_for_remove = jecs.create_edge_for_remove
|
||||||
|
local archetype_traverse_add = jecs.archetype_traverse_add
|
||||||
|
local archetype_traverse_remove = jecs.archetype_traverse_remove
|
||||||
|
|
||||||
|
local world = world_new()
|
||||||
|
local root = world.ROOT_ARCHETYPE
|
||||||
|
local c1 = world:component()
|
||||||
|
local c2 = world:component()
|
||||||
|
local c3 = world:component()
|
||||||
|
|
||||||
|
local a1 = archetype_traverse_add(world, c1, nil)
|
||||||
|
local a2 = archetype_traverse_remove(world, c1, a1)
|
||||||
|
CHECK(root.node.add[c1].to == a1)
|
||||||
|
CHECK(root == a2)
|
||||||
|
end)
|
||||||
|
|
||||||
TEST("world:cleanup()", function()
|
TEST("world:cleanup()", function()
|
||||||
local world = world_new()
|
local world = world_new()
|
||||||
local A = world:component()
|
local A = world:component()
|
||||||
|
|
Loading…
Reference in a new issue