• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

excaliburjs / Excalibur / 15354777440

30 May 2025 08:03PM UTC coverage: 87.858% (-1.5%) from 89.344%
15354777440

Pull #3385

github

web-flow
Merge a00f57733 into e6ec66358
Pull Request #3385: updated Meet action to add tolerance

5002 of 6948 branches covered (71.99%)

3 of 5 new or added lines in 2 files covered. (60.0%)

872 existing lines in 83 files now uncovered.

13661 of 15549 relevant lines covered (87.86%)

25187.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.55
/src/engine/EntityComponentSystem/World.ts
1
import type { Scene } from '../Scene';
2
import { Logger } from '../Util/Log';
3
import type { Component, ComponentCtor } from './Component';
4
import { Entity } from './Entity';
5
import { EntityManager } from './EntityManager';
6
import type { Query } from './Query';
7
import { QueryManager } from './QueryManager';
8
import { System, SystemType } from './System';
9
import type { SystemCtor } from './SystemManager';
10
import { SystemManager, isSystemConstructor } from './SystemManager';
11
import type { TagQuery } from './TagQuery';
12

13
/**
14
 * The World is a self-contained entity component system for a particular context.
15
 */
16
export class World {
17
  private _logger = Logger.getInstance();
1,305✔
18
  public queryManager: QueryManager = new QueryManager(this);
1,305✔
19
  public entityManager: EntityManager = new EntityManager(this);
1,305✔
20
  public systemManager: SystemManager = new SystemManager(this);
1,305✔
21

22
  /**
23
   * The context type is passed to the system updates
24
   * @param scene
25
   */
26
  constructor(public scene: Scene) {}
1,305✔
27

28
  /**
29
   * Query the ECS world for entities that match your components
30
   * @param requiredTypes
31
   */
32
  query<TKnownComponentCtors extends ComponentCtor<Component>>(requiredTypes: TKnownComponentCtors[]): Query<TKnownComponentCtors> {
33
    return this.queryManager.createQuery(requiredTypes);
10,470✔
34
  }
35

36
  queryTags<TKnownTags extends string>(requiredTags: TKnownTags[]): TagQuery<TKnownTags> {
37
    return this.queryManager.createTagQuery(requiredTags);
3✔
38
  }
39

40
  /**
41
   * Update systems by type and time elapsed in milliseconds
42
   */
43
  update(type: SystemType, elapsed: number) {
44
    if (type === SystemType.Update) {
2,723✔
45
      this.entityManager.updateEntities(this.scene, elapsed);
1,790✔
46
    }
47
    this.systemManager.updateSystems(type, this.scene, elapsed);
2,723✔
48
    this.entityManager.findEntitiesForRemoval();
2,723✔
49
    this.entityManager.processComponentRemovals();
2,723✔
50
    this.entityManager.processEntityRemovals();
2,723✔
51
  }
52

53
  /**
54
   * Add an entity to the ECS world
55
   * @param entity
56
   */
57
  add(entity: Entity): void;
58
  /**
59
   * Add a system to the ECS world
60
   * @param system
61
   */
62
  add(system: System): void;
63
  add(system: SystemCtor<System>): void;
64
  add(entityOrSystem: Entity | System | SystemCtor<System>): void {
65
    if (entityOrSystem instanceof Entity) {
10,802✔
66
      this.entityManager.addEntity(entityOrSystem);
599✔
67
      return;
599✔
68
    }
69

70
    if (entityOrSystem instanceof System || isSystemConstructor(entityOrSystem)) {
10,203!
71
      this.systemManager.addSystem(entityOrSystem);
10,203✔
72
      return;
10,203✔
73
    }
74

UNCOV
75
    this._logger.warn(
×
76
      `Could not add entity/system ${(entityOrSystem as any).constructor.name} to Excalibur!\n\n` +
77
        `If this looks like an Excalibur type, this can be caused by 2 versions of excalibur being included on the page.\n\n` +
78
        `Check your bundler settings to make sure this is not the case! Excalibur has ESM & UMD bundles be sure one 1 is loaded.`
79
    );
80
  }
81

82
  /**
83
   * Get a system out of the ECS world
84
   */
85
  get(system: SystemCtor<System>) {
86
    return this.systemManager.get(system);
1,377✔
87
  }
88

89
  /**
90
   * Remove an entity from the ECS world
91
   * @param entity
92
   */
93
  remove(entity: Entity, deferred?: boolean): void;
94
  /**
95
   * Remove a system from the ECS world
96
   * @param system
97
   */
98
  remove(system: System): void;
99
  remove(entityOrSystem: Entity | System, deferred = true): void {
8✔
100
    if (entityOrSystem instanceof Entity) {
27✔
101
      this.entityManager.removeEntity(entityOrSystem, deferred);
26✔
102
      return;
26✔
103
    }
104

105
    if (entityOrSystem instanceof System) {
1!
106
      this.systemManager.removeSystem(entityOrSystem);
1✔
107
      return;
1✔
108
    }
109

UNCOV
110
    this._logger.warn(
×
111
      `Could not remove entity/system ${(entityOrSystem as any).constructor.name} to Excalibur!\n\n` +
112
        `If this looks like an Excalibur type, this can be caused by 2 versions of excalibur being included on the page.\n\n` +
113
        `Check your bundler settings to make sure this is not the case! Excalibur has ESM & UMD bundles be sure one 1 is loaded.`
114
    );
115
  }
116

117
  get entities() {
118
    return this.entityManager.entities;
8,940✔
119
  }
120

121
  clearEntities(): void {
122
    this.entityManager.clear();
1✔
123
  }
124

125
  clearSystems(): void {
126
    this.systemManager.clear();
13✔
127
  }
128
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc