mirror of
https://github.com/Ukendio/jecs.git
synced 2025-09-23 08:39:16 +00:00
Compare commits
4 commits
d7c31b967d
...
4bd2e47eca
Author | SHA1 | Date | |
---|---|---|---|
|
4bd2e47eca | ||
|
bd00edc8c0 | ||
|
0bc1848554 | ||
|
f912866fcb |
2 changed files with 27 additions and 5 deletions
18
jecs.d.ts
vendored
18
jecs.d.ts
vendored
|
@ -49,20 +49,28 @@ export type Column<T> = T[];
|
|||
|
||||
export type Archetype<T extends Id[]> = {
|
||||
id: number;
|
||||
types: number[];
|
||||
types: Entity[];
|
||||
type: string;
|
||||
entities: number[];
|
||||
entities: Entity[];
|
||||
columns: Column<unknown>[];
|
||||
columns_map: { [K in T[number]]: Column<InferComponent<K>> };
|
||||
};
|
||||
|
||||
type Iter<T extends Id[]> = IterableFunction<LuaTuple<[Entity, ...InferComponents<T>]>>;
|
||||
type IterFn<T extends Id[]> = IterableFunction<LuaTuple<[Entity, ...InferComponents<T>]>>;
|
||||
type Iter<T extends Id[]> = IterFn<T> & {
|
||||
/**
|
||||
* This isn't callable
|
||||
* @hidden
|
||||
* @deprecated
|
||||
*/
|
||||
(): never
|
||||
};
|
||||
|
||||
export type CachedQuery<T extends Id[]> = {
|
||||
/**
|
||||
* Returns an iterator that produces a tuple of [Entity, ...queriedComponents].
|
||||
*/
|
||||
iter(): Iter<T>;
|
||||
iter(): IterFn<T>;
|
||||
|
||||
/**
|
||||
* Returns the matched archetypes of the query
|
||||
|
@ -75,7 +83,7 @@ export type Query<T extends Id[]> = {
|
|||
/**
|
||||
* Returns an iterator that produces a tuple of [Entity, ...queriedComponents].
|
||||
*/
|
||||
iter(): Iter<T>;
|
||||
iter(): IterFn<T>;
|
||||
|
||||
/**
|
||||
* Creates and returns a cached version of this query for efficient reuse.
|
||||
|
|
14
jecs.luau
14
jecs.luau
|
@ -126,6 +126,8 @@ type world = {
|
|||
|
||||
max_component_id: number,
|
||||
max_archetype_id: number,
|
||||
start_component_id: number,
|
||||
start_tag_id: number,
|
||||
|
||||
observable: Map<i53, Map<i53, { Observer }>>,
|
||||
|
||||
|
@ -163,6 +165,8 @@ export type World = {
|
|||
|
||||
max_component_id: number,
|
||||
max_archetype_id: number,
|
||||
start_component_id: number,
|
||||
start_tag_id: number,
|
||||
|
||||
observable: Map<Id, Map<Id, { Observer }>>,
|
||||
|
||||
|
@ -760,6 +764,12 @@ local function ECS_ID_IS_WILDCARD(e: i53): boolean
|
|||
return first == EcsWildcard or second == EcsWildcard
|
||||
end
|
||||
|
||||
local function get_max_ids_difference(world: World): (number, number)
|
||||
local diff_components = world.start_component_id - ecs_max_component_id
|
||||
local diff_tags = world.start_tag_id - ecs_max_tag_id
|
||||
return diff_components, diff_tags
|
||||
end
|
||||
|
||||
local function id_record_get(world: World, id: Entity): ComponentRecord?
|
||||
local component_index = world.component_index
|
||||
local idr: ComponentRecord = component_index[id]
|
||||
|
@ -2263,6 +2273,9 @@ local function world_new()
|
|||
archetype_index = archetype_index,
|
||||
max_archetype_id = 0,
|
||||
max_component_id = ecs_max_component_id,
|
||||
|
||||
start_component_id = ecs_max_component_id,
|
||||
start_tag_id = ecs_max_tag_id,
|
||||
|
||||
observable = observable,
|
||||
signals = signals,
|
||||
|
@ -3366,6 +3379,7 @@ return {
|
|||
pair_first = ecs_pair_first :: <P, O>(world: World, pair: Pair<P, O>) -> Id<P>,
|
||||
pair_second = ecs_pair_second :: <P, O>(world: World, pair: Pair<P, O>) -> Id<O>,
|
||||
entity_index_get_alive = entity_index_get_alive,
|
||||
get_max_ids_difference = get_max_ids_difference,
|
||||
|
||||
archetype_append_to_records = archetype_append_to_records,
|
||||
id_record_ensure = id_record_ensure :: (World, Id) -> ComponentRecord,
|
||||
|
|
Loading…
Reference in a new issue