]>
git.r.bdr.sh - rbdr/sumo/blob - lib/systems/draw_dash.js
cb04eb59e133f8e4d93a4fab8f9a245ab523dfa6
1 import { System
} from '@serpentity/serpentity';
3 import DrawnDasherNode
from '../nodes/drawn_dasher';
6 * Shows a different graphic during the duration of lock
8 * @extends {external:Serpentity.System}
9 * @class DrawDashSystem
10 * @param {object} config a configuration object to extend.
12 export default class DrawDashSystem
extends System
{
14 constructor(config
= {}) {
19 * The node collection of dashers
21 * @property {external:Serpentity.NodeCollection} drawnDashers
23 * @memberof DrawDashSystem
25 this.drawnDashers
= null;
29 * Initializes system when added. Requests drawn dasher nodes
32 * @memberof DrawDashSystem
34 * @param {external:Serpentity.Engine} engine the serpentity engine to
35 * which we are getting added
39 this.drawnDashers
= engine
.getNodes(DrawnDasherNode
);
43 * Clears system resources when removed.
47 * @memberof DrawDashSystem
51 this.drawnDashers
= null;
55 * Runs on every update of the loop. Updates image depending on if
60 * @param {Number} currentFrameDuration the duration of the current
62 * @memberof DrawDashSystem
64 update(currentFrameDuration
) {
66 for (const drawnDasher
of this.drawnDashers
) {
68 const dash
= drawnDasher
.dash
;
69 const container
= drawnDasher
.container
.container
;
72 this._drawDashFace(container
);
76 this._removeDashFace(container
);
80 // Draws the dash face
82 _drawDashFace(container
) {
84 const blush
= container
.getChildByName('blush');
85 const smile
= container
.getChildByName('smile');
86 const frown
= container
.getChildByName('frown');
89 smile
.visible
= false;
92 // Removes the dash face
94 _removeDashFace(container
) {
96 const blush
= container
.getChildByName('blush');
97 const smile
= container
.getChildByName('smile');
98 const frown
= container
.getChildByName('frown');
99 blush
.visible
= false;
100 frown
.visible
= false;
101 smile
.visible
= true;