mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-24 17:10:03 +00:00
Rollback types
Some checks are pending
Some checks are pending
This commit is contained in:
parent
59e7fd1f41
commit
045408af37
2 changed files with 14 additions and 12 deletions
|
@ -2374,9 +2374,10 @@ end
|
||||||
|
|
||||||
World.new = world_new
|
World.new = world_new
|
||||||
|
|
||||||
export type Entity<T = unknown> = { __nominal_entity: "Tag", __phantom_data: T }
|
export type Entity<T = nil> = { __T: T }
|
||||||
export type Id<T = unknown> = { __phantom_data: T }
|
export type Id<T = unknown> = { __T: T }
|
||||||
export type Pair<P, O> = { __phantom_data: P }
|
export type Pair<P, O> = Id<P>
|
||||||
|
type ecs_id_t<T=unknown> = Id<T> | Pair<T, "Tag"> | Pair<"Tag", T>
|
||||||
export type Item<T...> = (self: Query<T...>) -> (Entity, T...)
|
export type Item<T...> = (self: Query<T...>) -> (Entity, T...)
|
||||||
export type Iter<T...> = (query: Query<T...>) -> () -> (Entity, T...)
|
export type Iter<T...> = (query: Query<T...>) -> () -> (Entity, T...)
|
||||||
|
|
||||||
|
@ -2500,7 +2501,7 @@ return {
|
||||||
Name = EcsName :: Entity<string>,
|
Name = EcsName :: Entity<string>,
|
||||||
Rest = EcsRest :: Entity,
|
Rest = EcsRest :: Entity,
|
||||||
|
|
||||||
pair = (ECS_PAIR :: any) :: <P, O>(first: P, second: O) -> Pair<P, O>,
|
pair = (ECS_PAIR :: any) :: <P, O>(first: Id<P>, second: Id<O>) -> Pair<P, O>,
|
||||||
|
|
||||||
-- Inwards facing API for testing
|
-- Inwards facing API for testing
|
||||||
ECS_ID = ECS_ENTITY_T_LO,
|
ECS_ID = ECS_ENTITY_T_LO,
|
||||||
|
|
|
@ -242,9 +242,9 @@ 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() :: jecs.Id<boolean>
|
||||||
local B = world:component()
|
local B = world:component() :: jecs.Id<boolean>
|
||||||
local C = world:component()
|
local C = world:component() :: jecs.Id<boolean>
|
||||||
|
|
||||||
local e1 = world:entity()
|
local e1 = world:entity()
|
||||||
local e2 = world:entity()
|
local e2 = world:entity()
|
||||||
|
@ -355,7 +355,7 @@ TEST("world:entity()", function()
|
||||||
|
|
||||||
do CASE "Recycling max generation"
|
do CASE "Recycling max generation"
|
||||||
local world = world_new()
|
local world = world_new()
|
||||||
local pin = jecs.Rest::number + 1
|
local pin = (jecs.Rest :: any) :: number + 1
|
||||||
for i = 1, 2^16-1 do
|
for i = 1, 2^16-1 do
|
||||||
local e = world:entity()
|
local e = world:entity()
|
||||||
world:delete(e)
|
world:delete(e)
|
||||||
|
@ -569,21 +569,22 @@ TEST("world:query()", function()
|
||||||
do CASE "pairs"
|
do CASE "pairs"
|
||||||
local world = jecs.World.new()
|
local world = jecs.World.new()
|
||||||
|
|
||||||
local C1 = world:component()
|
local C1 = world:component() :: jecs.Id<boolean>
|
||||||
local C2 = world:component()
|
local C2 = world:component() :: jecs.Id<boolean>
|
||||||
local T1 = world:entity()
|
local T1 = world:entity()
|
||||||
local T2 = world:entity()
|
local T2 = world:entity()
|
||||||
|
|
||||||
local e = world:entity()
|
local e = world:entity()
|
||||||
|
|
||||||
world:set(e, pair(C1, C2), true)
|
local C1_C2 = pair(C1, C2)
|
||||||
|
world:set(e, C1_C2, true)
|
||||||
world:set(e, pair(C1, T1), true)
|
world:set(e, pair(C1, T1), true)
|
||||||
world:set(e, pair(T1, C1), true)
|
world:set(e, pair(T1, C1), true)
|
||||||
CHECK_EXPECT_ERR(function()
|
CHECK_EXPECT_ERR(function()
|
||||||
world:set(e, pair(T1, T2), true :: any)
|
world:set(e, pair(T1, T2), true :: any)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
for id, a, b, c, d in world:query(pair(C1, C2), pair(C1, T1), pair(T1, C1), pair(T1, T2)) :: any do
|
for id, a, b, c, d in world:query(pair(C1, C2), pair(C1, T1), pair(T1, C1), pair(T1, T2)):iter() do
|
||||||
CHECK(a == true)
|
CHECK(a == true)
|
||||||
CHECK(b == true)
|
CHECK(b == true)
|
||||||
CHECK(c == true)
|
CHECK(c == true)
|
||||||
|
|
Loading…
Reference in a new issue