@codehz/ecs 0.3.7 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.mts +785 -0
- package/index.mjs +1881 -0
- package/index.mjs.map +1 -0
- package/package.json +6 -6
- package/archetype.d.ts +0 -156
- package/changeset.d.ts +0 -38
- package/command-buffer.d.ts +0 -46
- package/entity.d.ts +0 -192
- package/index.d.ts +0 -7
- package/index.js +0 -1481
- package/multi-map.d.ts +0 -19
- package/query-filter.d.ts +0 -21
- package/query.d.ts +0 -80
- package/system-scheduler.d.ts +0 -25
- package/system.d.ts +0 -13
- package/types.d.ts +0 -34
- package/utils.d.ts +0 -19
- package/world.d.ts +0 -221
package/entity.d.ts
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Unique symbol brand for associating component type information with EntityId
|
|
3
|
-
*/
|
|
4
|
-
declare const __componentTypeMarker: unique symbol;
|
|
5
|
-
/**
|
|
6
|
-
* Unique symbol brand for tagging the kind of EntityId (e.g., 'component', 'entity-relation')
|
|
7
|
-
*/
|
|
8
|
-
declare const __entityIdTypeTag: unique symbol;
|
|
9
|
-
/**
|
|
10
|
-
* Entity ID type for ECS architecture
|
|
11
|
-
* Based on 52-bit integers within safe integer range
|
|
12
|
-
* - Component IDs: 1-1023
|
|
13
|
-
* - Entity IDs: 1024+
|
|
14
|
-
* - Relation IDs: negative numbers encoding component and entity associations
|
|
15
|
-
*/
|
|
16
|
-
export type EntityId<T = void, U = unknown> = number & {
|
|
17
|
-
readonly [__componentTypeMarker]: T;
|
|
18
|
-
readonly [__entityIdTypeTag]: U;
|
|
19
|
-
};
|
|
20
|
-
export type ComponentId<T = void> = EntityId<T, "component">;
|
|
21
|
-
export type EntityRelationId<T = void> = EntityId<T, "entity-relation">;
|
|
22
|
-
export type ComponentRelationId<T = void> = EntityId<T, "component-relation">;
|
|
23
|
-
export type WildcardRelationId<T = void> = EntityId<T, "wildcard-relation">;
|
|
24
|
-
export type RelationId<T = void> = EntityRelationId<T> | ComponentRelationId<T> | WildcardRelationId<T>;
|
|
25
|
-
/**
|
|
26
|
-
* Constants for ID ranges
|
|
27
|
-
*/
|
|
28
|
-
export declare const INVALID_COMPONENT_ID = 0;
|
|
29
|
-
export declare const COMPONENT_ID_MAX = 1023;
|
|
30
|
-
export declare const ENTITY_ID_START = 1024;
|
|
31
|
-
/**
|
|
32
|
-
* Constants for relation ID encoding
|
|
33
|
-
*/
|
|
34
|
-
export declare const RELATION_SHIFT: number;
|
|
35
|
-
export declare const WILDCARD_TARGET_ID = 0;
|
|
36
|
-
/**
|
|
37
|
-
* Create a component ID
|
|
38
|
-
* @param id Component identifier (1-1023)
|
|
39
|
-
* @see component
|
|
40
|
-
*/
|
|
41
|
-
export declare function createComponentId<T = void>(id: number): ComponentId<T>;
|
|
42
|
-
/**
|
|
43
|
-
* Create an entity ID
|
|
44
|
-
* @param id Entity identifier (starting from 1024)
|
|
45
|
-
*/
|
|
46
|
-
export declare function createEntityId(id: number): EntityId;
|
|
47
|
-
/**
|
|
48
|
-
* Type for relation ID based on component and target types
|
|
49
|
-
*/
|
|
50
|
-
type RelationIdType<T, R> = R extends ComponentId<infer U> ? U extends void ? ComponentRelationId<T> : ComponentRelationId<T extends void ? U : T> : R extends EntityId<any> ? EntityRelationId<T> : never;
|
|
51
|
-
/**
|
|
52
|
-
* Create a relation ID by associating a component with another ID (entity or component)
|
|
53
|
-
* @param componentId The component ID (0-1023)
|
|
54
|
-
* @param targetId The target ID (entity, component, or '*' for wildcard)
|
|
55
|
-
*/
|
|
56
|
-
export declare function relation<T>(componentId: ComponentId<T>, targetId: "*"): WildcardRelationId<T>;
|
|
57
|
-
export declare function relation<T, R extends EntityId<any>>(componentId: ComponentId<T>, targetId: R): RelationIdType<T, R>;
|
|
58
|
-
/**
|
|
59
|
-
* Check if an ID is a component ID
|
|
60
|
-
*/
|
|
61
|
-
export declare function isComponentId<T>(id: EntityId<T>): id is ComponentId<T>;
|
|
62
|
-
/**
|
|
63
|
-
* Check if an ID is an entity ID
|
|
64
|
-
*/
|
|
65
|
-
export declare function isEntityId<T>(id: EntityId<T>): id is EntityId<T>;
|
|
66
|
-
/**
|
|
67
|
-
* Check if an ID is a relation ID
|
|
68
|
-
*/
|
|
69
|
-
export declare function isRelationId<T>(id: EntityId<T>): id is RelationId<T>;
|
|
70
|
-
/**
|
|
71
|
-
* Check if an ID is a wildcard relation id
|
|
72
|
-
*/
|
|
73
|
-
export declare function isWildcardRelationId<T>(id: EntityId<T>): id is WildcardRelationId<T>;
|
|
74
|
-
/**
|
|
75
|
-
* Decode a relation ID into component and target IDs
|
|
76
|
-
* @param relationId The relation ID (must be negative)
|
|
77
|
-
* @returns Object with componentId, targetId, and relation type
|
|
78
|
-
*/
|
|
79
|
-
export declare function decodeRelationId(relationId: RelationId<any>): {
|
|
80
|
-
componentId: ComponentId<any>;
|
|
81
|
-
targetId: EntityId<any>;
|
|
82
|
-
type: "entity" | "component" | "wildcard";
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* Get the string representation of an ID type
|
|
86
|
-
*/
|
|
87
|
-
export declare function getIdType(id: EntityId<any>): "component" | "entity" | "entity-relation" | "component-relation" | "wildcard-relation" | "invalid";
|
|
88
|
-
/**
|
|
89
|
-
* Get detailed type information for an EntityId
|
|
90
|
-
* @param id The EntityId to analyze
|
|
91
|
-
* @returns Detailed type information including relation subtypes
|
|
92
|
-
*/
|
|
93
|
-
export declare function getDetailedIdType(id: EntityId<any>): {
|
|
94
|
-
type: "component" | "entity" | "invalid";
|
|
95
|
-
componentId?: never;
|
|
96
|
-
targetId?: never;
|
|
97
|
-
} | {
|
|
98
|
-
type: "entity-relation" | "wildcard-relation";
|
|
99
|
-
componentId: ComponentId<any>;
|
|
100
|
-
targetId: EntityId<any>;
|
|
101
|
-
} | {
|
|
102
|
-
type: "component-relation";
|
|
103
|
-
componentId: ComponentId<any>;
|
|
104
|
-
targetId: ComponentId<any>;
|
|
105
|
-
};
|
|
106
|
-
/**
|
|
107
|
-
* Inspect an EntityId and return a human-readable string representation
|
|
108
|
-
* @param id The EntityId to inspect
|
|
109
|
-
* @returns A friendly string representation of the ID
|
|
110
|
-
*/
|
|
111
|
-
export declare function inspectEntityId(id: EntityId<any>): string;
|
|
112
|
-
/**
|
|
113
|
-
* Entity ID Manager for automatic allocation and freelist recycling
|
|
114
|
-
*/
|
|
115
|
-
export declare class EntityIdManager {
|
|
116
|
-
private nextId;
|
|
117
|
-
private freelist;
|
|
118
|
-
/**
|
|
119
|
-
* Allocate a new entity ID
|
|
120
|
-
* Uses freelist if available, otherwise increments counter
|
|
121
|
-
*/
|
|
122
|
-
allocate(): EntityId;
|
|
123
|
-
/**
|
|
124
|
-
* Deallocate an entity ID, adding it to the freelist for reuse
|
|
125
|
-
* @param id The entity ID to deallocate
|
|
126
|
-
*/
|
|
127
|
-
deallocate(id: EntityId<any>): void;
|
|
128
|
-
/**
|
|
129
|
-
* Get the current freelist size (for debugging/monitoring)
|
|
130
|
-
*/
|
|
131
|
-
getFreelistSize(): number;
|
|
132
|
-
/**
|
|
133
|
-
* Get the next ID that would be allocated (for debugging)
|
|
134
|
-
*/
|
|
135
|
-
getNextId(): number;
|
|
136
|
-
/**
|
|
137
|
-
* Serialize internal state for persistence.
|
|
138
|
-
* Returns a plain object representing allocator state. Values may be non-JSON-serializable.
|
|
139
|
-
*/
|
|
140
|
-
serializeState(): {
|
|
141
|
-
nextId: number;
|
|
142
|
-
freelist: number[];
|
|
143
|
-
};
|
|
144
|
-
/**
|
|
145
|
-
* Restore internal state from a previously-serialized object.
|
|
146
|
-
* Overwrites the current nextId and freelist.
|
|
147
|
-
*/
|
|
148
|
-
deserializeState(state: {
|
|
149
|
-
nextId: number;
|
|
150
|
-
freelist?: number[];
|
|
151
|
-
}): void;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Component ID Manager for automatic allocation
|
|
155
|
-
* Components are typically registered once and not recycled
|
|
156
|
-
*/
|
|
157
|
-
export declare class ComponentIdAllocator {
|
|
158
|
-
private nextId;
|
|
159
|
-
/**
|
|
160
|
-
* Allocate a new component ID
|
|
161
|
-
* Increments counter sequentially from 1
|
|
162
|
-
*/
|
|
163
|
-
allocate<T = void>(): ComponentId<T>;
|
|
164
|
-
/**
|
|
165
|
-
* Get the next ID that would be allocated (for debugging)
|
|
166
|
-
*/
|
|
167
|
-
getNextId(): number;
|
|
168
|
-
/**
|
|
169
|
-
* Check if more component IDs are available
|
|
170
|
-
*/
|
|
171
|
-
hasAvailableIds(): boolean;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Allocate a new component ID from the global allocator.
|
|
175
|
-
* Optionally register a name for the component.
|
|
176
|
-
* The name is only for serialization/debugging and does not affect base functionality.
|
|
177
|
-
* @param name Optional name for the component
|
|
178
|
-
* @returns The allocated component ID
|
|
179
|
-
*/
|
|
180
|
-
export declare function component<T = void>(name?: string): ComponentId<T>;
|
|
181
|
-
/**
|
|
182
|
-
* Get a component ID by its registered name
|
|
183
|
-
* @param name The component name
|
|
184
|
-
* @returns The component ID if found, undefined otherwise
|
|
185
|
-
*/
|
|
186
|
-
export declare function getComponentIdByName(name: string): ComponentId<any> | undefined;
|
|
187
|
-
/** Get a component name by its ID
|
|
188
|
-
* @param id The component ID
|
|
189
|
-
* @returns The component name if found, undefined otherwise
|
|
190
|
-
*/
|
|
191
|
-
export declare function getComponentNameById(id: ComponentId<any>): string | undefined;
|
|
192
|
-
export {};
|