ecs-observable/src/relationship.ts

23 lines
618 B
TypeScript
Raw Normal View History

2026-05-31 15:54:29 +08:00
// ── Relationship ─────────────────────────────────────
/**
* A relationship definition like a component, but represents a directed
* link between two entities.
*
* @example
* ```ts
* const ChildOf = defineRelationship();
* world.relate(child, ChildOf, parent);
* ```
*/
export interface RelationshipDef {
/** Unique symbol used as the storage key. */
readonly _key: symbol;
}
/**
* Define a named relationship between entities.
*/
export function defineRelationship(): RelationshipDef {
return { _key: Symbol() };
}