mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-25 09:30:03 +00:00
Remove Tag
This commit is contained in:
parent
699beccc1c
commit
f0f00f959e
1 changed files with 129 additions and 130 deletions
259
src/index.d.ts
vendored
259
src/index.d.ts
vendored
|
@ -16,164 +16,164 @@ type TupleForWorldGet = [Id] | [Id, Id] | [Id, Id, Id] | [Id, Id, Id, Id];
|
||||||
type Item<T extends unknown[]> = (this: Query<T>) => LuaTuple<[Entity, ...T]>;
|
type Item<T extends unknown[]> = (this: Query<T>) => LuaTuple<[Entity, ...T]>;
|
||||||
|
|
||||||
export type Query<T extends unknown[]> = {
|
export type Query<T extends unknown[]> = {
|
||||||
/**
|
/**
|
||||||
* Get the next result in the query. Drain must have been called beforehand or otherwise it will error.
|
* Get the next result in the query. Drain must have been called beforehand or otherwise it will error.
|
||||||
*/
|
*/
|
||||||
next: Item<T>;
|
next: Item<T>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the Iterator for a query.
|
* Resets the Iterator for a query.
|
||||||
*/
|
*/
|
||||||
drain: (this: Query<T>) => Query<T>;
|
drain: (this: Query<T>) => Query<T>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modifies the query to include specified components, but will not include the values.
|
* Modifies the query to include specified components, but will not include the values.
|
||||||
* @param components The components to include
|
* @param components The components to include
|
||||||
* @returns Modified Query
|
* @returns Modified Query
|
||||||
*/
|
*/
|
||||||
with: (this: Query<T>, ...components: Id[]) => Query<T>;
|
with: (this: Query<T>, ...components: Id[]) => Query<T>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modifies the Query to exclude specified components
|
* Modifies the Query to exclude specified components
|
||||||
* @param components The components to exclude
|
* @param components The components to exclude
|
||||||
* @returns Modified Query
|
* @returns Modified Query
|
||||||
*/
|
*/
|
||||||
without: (this: Query<T>, ...components: Id[]) => Query<T>;
|
without: (this: Query<T>, ...components: Id[]) => Query<T>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modifies component data with a callback function
|
* Modifies component data with a callback function
|
||||||
* @param fn The function to modify data
|
* @param fn The function to modify data
|
||||||
*/
|
*/
|
||||||
replace: (this: Query<T>, fn: (...components: T) => FlattenTuple<T>) => void;
|
replace: (this: Query<T>, fn: (...components: T) => FlattenTuple<T>) => void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the archetypes associated with this query.
|
* Returns the archetypes associated with this query.
|
||||||
*/
|
*/
|
||||||
archetypes: () => Archetype[];
|
archetypes: () => Archetype[];
|
||||||
} & IterableFunction<LuaTuple<[Entity, ...T]>>;
|
} & IterableFunction<LuaTuple<[Entity, ...T]>>;
|
||||||
|
|
||||||
export type Archetype = {
|
export type Archetype = {
|
||||||
id: number;
|
id: number;
|
||||||
edges: { [key: number]: ArchetypeEdge };
|
edges: { [key: number]: ArchetypeEdge };
|
||||||
types: number[];
|
types: number[];
|
||||||
type: string | number;
|
type: string | number;
|
||||||
entities: number[];
|
entities: number[];
|
||||||
columns: unknown[][];
|
columns: unknown[][];
|
||||||
records: { [key: number]: ArchetypeRecord };
|
records: { [key: number]: ArchetypeRecord };
|
||||||
};
|
};
|
||||||
|
|
||||||
type ArchetypeRecord = {
|
type ArchetypeRecord = {
|
||||||
count: number;
|
count: number;
|
||||||
column: number;
|
column: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ArchetypeEdge = {
|
type ArchetypeEdge = {
|
||||||
add: Archetype;
|
add: Archetype;
|
||||||
remove: Archetype;
|
remove: Archetype;
|
||||||
};
|
};
|
||||||
|
|
||||||
export class World {
|
export class World {
|
||||||
/**
|
/**
|
||||||
* Creates a new World
|
* Creates a new World
|
||||||
*/
|
*/
|
||||||
constructor();
|
constructor();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new entity
|
* Creates a new entity
|
||||||
* @returns Entity
|
* @returns Entity
|
||||||
*/
|
*/
|
||||||
entity(): Entity;
|
entity(): Entity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new entity located in the first 256 ids.
|
* Creates a new entity located in the first 256 ids.
|
||||||
* These should be used for static components for fast access.
|
* These should be used for static components for fast access.
|
||||||
* @returns Entity<T>
|
* @returns Entity<T>
|
||||||
*/
|
*/
|
||||||
component<T = unknown>(): Entity<T>;
|
component<T = unknown>(): Entity<T>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the target of a relationship. For example, when a user calls
|
* Gets the target of a relationship. For example, when a user calls
|
||||||
* `world.target(entity, ChildOf(parent))`, you will obtain the parent entity.
|
* `world.target(entity, ChildOf(parent))`, you will obtain the parent entity.
|
||||||
* @param entity Entity
|
* @param entity Entity
|
||||||
* @param relation The Relationship
|
* @param relation The Relationship
|
||||||
* @returns The Parent Entity if it exists
|
* @returns The Parent Entity if it exists
|
||||||
*/
|
*/
|
||||||
target(entity: Entity, relation: Entity, index: number): Entity | undefined;
|
target(entity: Entity, relation: Entity, index: number): Entity | undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears an entity from the world.
|
* Clears an entity from the world.
|
||||||
* @param entity Entity to be cleared
|
* @param entity Entity to be cleared
|
||||||
*/
|
*/
|
||||||
clear(entity: Entity): void;
|
clear(entity: Entity): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes an entity and all its related components and relationships.
|
* Deletes an entity and all its related components and relationships.
|
||||||
* @param entity Entity to be destroyed
|
* @param entity Entity to be destroyed
|
||||||
*/
|
*/
|
||||||
delete(entity: Entity): void;
|
delete(entity: Entity): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a component to the entity with no value
|
* Adds a component to the entity with no value
|
||||||
* @param entity Target Entity
|
* @param entity Target Entity
|
||||||
* @param component Component
|
* @param component Component
|
||||||
*/
|
*/
|
||||||
add<T>(entity: Entity, component: Id<T>): void;
|
add<T>(entity: Entity, component: Id<T>): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assigns a value to a component on the given entity
|
* Assigns a value to a component on the given entity
|
||||||
* @param entity Target Entity
|
* @param entity Target Entity
|
||||||
* @param component Target Component
|
* @param component Target Component
|
||||||
* @param data Component Data
|
* @param data Component Data
|
||||||
*/
|
*/
|
||||||
set<T>(entity: Entity, component: Id<T>, data: T): void;
|
set<T>(entity: Entity, component: Id<T>, data: T): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a component from the given entity
|
* Removes a component from the given entity
|
||||||
* @param entity Target Entity
|
* @param entity Target Entity
|
||||||
* @param component Target Component
|
* @param component Target Component
|
||||||
*/
|
*/
|
||||||
remove(entity: Entity, component: Id): void;
|
remove(entity: Entity, component: Id): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the values of specified components for an entity.
|
* Retrieves the values of specified components for an entity.
|
||||||
* Some values may not exist when called.
|
* Some values may not exist when called.
|
||||||
* A maximum of 4 components are allowed at a time.
|
* A maximum of 4 components are allowed at a time.
|
||||||
* @param id Target Entity
|
* @param id Target Entity
|
||||||
* @param components Target Components
|
* @param components Target Components
|
||||||
* @returns Data associated with target components if it exists.
|
* @returns Data associated with target components if it exists.
|
||||||
*/
|
*/
|
||||||
get<T extends TupleForWorldGet>(id: Entity, ...components: T): FlattenTuple<Nullable<InferComponents<T>>>;
|
get<T extends TupleForWorldGet>(id: Entity, ...components: T): FlattenTuple<Nullable<InferComponents<T>>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the entity has the specified components.
|
* Returns whether the entity has the specified components.
|
||||||
* A maximum of 4 components are allowed at a time.
|
* A maximum of 4 components are allowed at a time.
|
||||||
* @param entity Target Entity
|
* @param entity Target Entity
|
||||||
* @param components Target Components
|
* @param components Target Components
|
||||||
* @returns If the entity contains the components
|
* @returns If the entity contains the components
|
||||||
*/
|
*/
|
||||||
has(entity: Entity, ...components: Id[]): boolean;
|
has(entity: Entity, ...components: Id[]): boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if an entity exists in the world
|
* Checks if an entity exists in the world
|
||||||
* @param entity Entity to check
|
* @param entity Entity to check
|
||||||
* @returns Whether the entity exists in the world
|
* @returns Whether the entity exists in the world
|
||||||
*/
|
*/
|
||||||
contains(entity: Entity): boolean;
|
contains(entity: Entity): boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Searches the world for entities that match a given query
|
* Searches the world for entities that match a given query
|
||||||
* @param components Queried Components
|
* @param components Queried Components
|
||||||
* @returns Query
|
* @returns Query
|
||||||
*/
|
*/
|
||||||
query<T extends Id[]>(...components: T): Query<InferComponents<T>>;
|
query<T extends Id[]>(...components: T): Query<InferComponents<T>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get parent (target of ChildOf relationship) for entity.
|
* Get parent (target of ChildOf relationship) for entity.
|
||||||
* If there is no ChildOf relationship pair, it will return undefined.
|
* If there is no ChildOf relationship pair, it will return undefined.
|
||||||
* @param entity Target Entity
|
* @param entity Target Entity
|
||||||
* @returns Parent Entity or undefined
|
* @returns Parent Entity or undefined
|
||||||
*/
|
*/
|
||||||
parent(entity: Entity): Entity | undefined;
|
parent(entity: Entity): Entity | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -182,7 +182,7 @@ export class World {
|
||||||
* @param obj The second entity
|
* @param obj The second entity
|
||||||
* @returns The composite key
|
* @returns The composite key
|
||||||
*/
|
*/
|
||||||
export function pair<R, T>(pred: Entity<R>, obj: Entity<T>): Pair;
|
export function pair(pred: Entity, obj: Entity): Pair;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the entity is a composite key
|
* Checks if the entity is a composite key
|
||||||
|
@ -204,6 +204,5 @@ export const OnDelete: Entity;
|
||||||
export const OnDeleteTarget: Entity;
|
export const OnDeleteTarget: Entity;
|
||||||
export const Delete: Entity;
|
export const Delete: Entity;
|
||||||
export const Remove: Entity;
|
export const Remove: Entity;
|
||||||
export const Tag: Entity;
|
|
||||||
export const Name: Entity<string>;
|
export const Name: Entity<string>;
|
||||||
export const Rest: Entity;
|
export const Rest: Entity;
|
||||||
|
|
Loading…
Reference in a new issue