mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-25 17:40:02 +00:00
Compare commits
1 commit
275b4959c8
...
7995c15f13
Author | SHA1 | Date | |
---|---|---|---|
|
7995c15f13 |
1 changed files with 20 additions and 5 deletions
25
jecs.d.ts
vendored
25
jecs.d.ts
vendored
|
@ -4,7 +4,7 @@
|
||||||
* and cannot be used used as a component to associate any kind of data with itself.
|
* and cannot be used used as a component to associate any kind of data with itself.
|
||||||
*/
|
*/
|
||||||
export type Id = number & {
|
export type Id = number & {
|
||||||
readonly __nominal_Id: unique symbol;
|
readonly __nominal_Id: unique symbol,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -15,7 +15,7 @@ export type Id = number & {
|
||||||
* indicating that the entity is intended to only store other entities.
|
* indicating that the entity is intended to only store other entities.
|
||||||
*/
|
*/
|
||||||
export type Tag = Id & {
|
export type Tag = Id & {
|
||||||
readonly __nominal_Tag: unique symbol;
|
readonly __nominal_Tag: unique symbol,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,10 +23,25 @@ export type Tag = Id & {
|
||||||
* This identifier is associated with `TData` data when this entity is used as a component.
|
* This identifier is associated with `TData` data when this entity is used as a component.
|
||||||
*/
|
*/
|
||||||
export type Entity<TData = unknown> = Tag & {
|
export type Entity<TData = unknown> = Tag & {
|
||||||
readonly __nominal_Entity: unique symbol;
|
readonly __nominal_Entity: unique symbol,
|
||||||
readonly __type_TData: TData;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A pair of entities.
|
||||||
|
*
|
||||||
|
* `TRelationship` is the type of the predicate, `TTarget` is the type of the object, and `TData` is the type of the value (defaults to `TRelationship`)
|
||||||
|
*/
|
||||||
|
//export type Pair<TRelationship = unknown, TTarget = unknown, TData = TRelationship> = number & {
|
||||||
|
// readonly __nominal_Pair: unique symbol,
|
||||||
|
//};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Either an Entity or a Pair.
|
||||||
|
*
|
||||||
|
* An id that can be added and removed.
|
||||||
|
*/
|
||||||
|
//export type Id<TData = unknown> = Entity<TData> | Pair<unknown, unknown, TData>;
|
||||||
|
|
||||||
type InferComponent<TValue> = TValue extends Entity<infer TData> ? TData : never;
|
type InferComponent<TValue> = TValue extends Entity<infer TData> ? TData : never;
|
||||||
|
|
||||||
type FlattenTuple<TItems extends any[]> = TItems extends [infer TValue] ? TValue : LuaTuple<TItems>;
|
type FlattenTuple<TItems extends any[]> = TItems extends [infer TValue] ? TValue : LuaTuple<TItems>;
|
||||||
|
@ -134,7 +149,7 @@ export class World {
|
||||||
* @param component Target Component
|
* @param component Target Component
|
||||||
* @param value Component Value
|
* @param value Component Value
|
||||||
*/
|
*/
|
||||||
set<TData>(entity: Id, component: Entity<TData>, value: NoInfer<TData>): void;
|
set(entity: Id, component: Entity, value: InferComponent<typeof component>): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a component from the given entity
|
* Removes a component from the given entity
|
||||||
|
|
Loading…
Reference in a new issue