feat: implement relationship system

This commit is contained in:
2026-05-31 15:54:29 +08:00
parent 32f8f29912
commit d0bb119911
2 changed files with 403 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
// ── 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() };
}