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

excaliburjs / Excalibur / 14804036802

02 May 2025 09:58PM UTC coverage: 5.927% (-83.4%) from 89.28%
14804036802

Pull #3404

github

web-flow
Merge 5c103d7f8 into 0f2ccaeb2
Pull Request #3404: feat: added Graph module to Math

234 of 8383 branches covered (2.79%)

229 of 246 new or added lines in 1 file covered. (93.09%)

13145 existing lines in 208 files now uncovered.

934 of 15759 relevant lines covered (5.93%)

4.72 hits per line

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

0.0
/src/engine/Actions/ActionQueue.ts
1
import { ActionCompleteEvent, ActionStartEvent } from '../Events';
2
import { Entity } from '../EntityComponentSystem/Entity';
3
import { Action } from './Action';
4

5
/**
6
 * Action Queues represent an ordered sequence of actions
7
 *
8
 * Action queues are part of the {@apilink ActionContext | `Action API`} and
9
 * store the list of actions to be executed for an {@apilink Actor}.
10
 *
11
 * Actors implement {@apilink Actor.actions} which can be manipulated by
12
 * advanced users to adjust the actions currently being executed in the
13
 * queue.
14
 */
15
export class ActionQueue {
16
  private _entity: Entity;
UNCOV
17
  private _actions: Action[] = [];
×
UNCOV
18
  private _currentAction: Action | null = null;
×
UNCOV
19
  private _completedActions: Action[] = [];
×
20
  constructor(entity: Entity) {
UNCOV
21
    this._entity = entity;
×
22
  }
23

24
  /**
25
   * Add an action to the sequence
26
   * @param action
27
   */
28
  public add(action: Action) {
UNCOV
29
    this._actions.push(action);
×
30
  }
31

32
  /**
33
   * Remove an action by reference from the sequence
34
   * @param action
35
   */
36
  public remove(action: Action) {
37
    const index = this._actions.indexOf(action);
×
38
    this._actions.splice(index, 1);
×
39
  }
40

41
  /**
42
   * Removes all actions from this sequence
43
   */
44
  public clearActions(): void {
UNCOV
45
    this._actions.length = 0;
×
UNCOV
46
    this._completedActions.length = 0;
×
UNCOV
47
    if (this._currentAction) {
×
UNCOV
48
      this._currentAction.stop();
×
49
    }
50
  }
51

52
  /**
53
   *
54
   * @returns The total list of actions in this sequence complete or not
55
   */
56
  public getActions(): Action[] {
UNCOV
57
    return this._actions.concat(this._completedActions);
×
58
  }
59

60
  public getIncompleteActions(): Action[] {
61
    return this._actions;
×
62
  }
63

64
  public getCurrentAction(): Action | null {
65
    return this._currentAction;
×
66
  }
67

68
  /**
69
   *
70
   * @returns `true` if there are more actions to process in the sequence
71
   */
72
  public hasNext(): boolean {
73
    return this._actions.length > 0;
×
74
  }
75

76
  /**
77
   * @returns `true` if the current sequence of actions is done
78
   */
79
  public isComplete(): boolean {
UNCOV
80
    return this._actions.length === 0;
×
81
  }
82

83
  /**
84
   * Resets the sequence of actions, this is used to restart a sequence from the beginning
85
   */
86
  public reset(): void {
UNCOV
87
    this._actions = this.getActions();
×
88

UNCOV
89
    const len = this._actions.length;
×
UNCOV
90
    for (let i = 0; i < len; i++) {
×
UNCOV
91
      this._actions[i].reset();
×
92
    }
UNCOV
93
    this._completedActions = [];
×
94
  }
95

96
  /**
97
   * Update the queue which updates actions and handles completing actions
98
   * @param elapsed
99
   */
100
  public update(elapsed: number) {
UNCOV
101
    if (this._actions.length > 0) {
×
UNCOV
102
      if (this._currentAction !== this._actions[0]) {
×
UNCOV
103
        this._currentAction = this._actions[0];
×
UNCOV
104
        this._entity.emit('actionstart', new ActionStartEvent(this._currentAction, this._entity));
×
105
      }
106

UNCOV
107
      this._currentAction.update(elapsed);
×
108

UNCOV
109
      if (this._currentAction.isComplete(this._entity)) {
×
UNCOV
110
        this._entity.emit('actioncomplete', new ActionCompleteEvent(this._currentAction, this._entity));
×
UNCOV
111
        const complete = this._actions.shift();
×
UNCOV
112
        if (complete) {
×
UNCOV
113
          this._completedActions.push(complete);
×
114
        }
115
      }
116
    }
117
  }
118
}
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