Skip to content

0.29.0-alpha.868+8f4d990

@eonarheim eonarheim tagged this 23 Jan 01:31
This PR includes the new ECS simplification to remove the "stringly" typed components/systems. 

- New simplified way to query entities `ex.World.query([MyComponentA, MyComponentB])`;
- New way to query for tags on entities `ex.World.queryTags(['A', 'B'])`
- Systems can be added as a constructor to a world, if they are the world will construct and pass a world instance to them
  ```typescript
  world.add(MySystem);
  ...

  class MySystem extends System {
    query: Query;
    constructor(world: World) {
      super()
      this.query = world.query([MyComponent]);
    }

    update(elapsed) {
      for (const entity of this.query.entities) {
        // do stuff
      }
    }
  }
  
  ```

- ECS implementation has been updated to remove the "stringly" typed nature of components & systems
  * For average users of Excalibur folks shouldn't notice any difference
  * For folks leveraging the ECS, Systems/Components no longer have type parameters based on strings. The type itself is used to track changes.
  * `class MySystem extends System<'ex.component'>` becomes `class MySystem extends System`
  * `class MyComponent extends Component<'ex.component'>` becomes `class MyComponent extends Component`
  * `ex.System.update(elapsedMs: number)` is only passed an elapsed time
Assets 2
Loading