@ue-too/ecs / index / System
介面: System
定義於: index.ts:1154
System interface for processing entities with specific component combinations.
備註
A System maintains a set of entities that match its component signature. The ECS automatically updates this set when entities are created, destroyed, or have their components modified.
Systems contain only the logic for processing entities - the entities set is automatically managed by the SystemManager.
範例
typescript
const Position = createComponentName('Position');
const Velocity = createComponentName('Velocity');
const movementSystem: System = {
entities: new Set()
};
// System logic (called in game loop)
function updateMovement(deltaTime: number) {
movementSystem.entities.forEach(entity => {
const pos = ecs.getComponentFromEntity<Position>(Position, entity);
const vel = ecs.getComponentFromEntity<Velocity>(Velocity, entity);
if (pos && vel) {
pos.x += vel.x * deltaTime;
pos.y += vel.y * deltaTime;
}
});
}屬性
entities
entities:
Set<number>
定義於: index.ts:1155