]>
git.r.bdr.sh - rbdr/sumo/blob - lib/systems/draw_dash.js
118ce1cc1fdf2fb271989021eb6802163bdc0fce
1 import { System
} from '@serpentity/serpentity';
3 import DrawnDasherNode
from '../nodes/drawn_dasher';
10 * Shows a different graphic during the duration of lock
12 * @extends {external:Serpentity.System}
13 * @class DrawDashSystem
14 * @param {object} config a configuration object to extend.
16 export default class DrawDashSystem
extends System
{
18 constructor(config
= {}) {
23 * The node collection of dashers
25 * @property {external:Serpentity.NodeCollection} drawnDashers
27 * @memberof DrawDashSystem
29 this.drawnDashers
= null;
33 * Initializes system when added. Requests drawn dasher nodes
36 * @memberof DrawDashSystem
38 * @param {external:Serpentity.Engine} engine the serpentity engine to
39 * which we are getting added
43 this.drawnDashers
= engine
.getNodes(DrawnDasherNode
);
47 * Clears system resources when removed.
51 * @memberof DrawDashSystem
55 this.drawnDashers
= null;
59 * Runs on every update of the loop. Updates image depending on if
64 * @param {Number} currentFrameDuration the duration of the current
66 * @memberof DrawDashSystem
68 update(currentFrameDuration
) {
70 for (const drawnDasher
of this.drawnDashers
) {
72 const dash
= drawnDasher
.dash
;
73 const container
= drawnDasher
.container
.container
;
76 this._drawDashFace(container
);
80 this._removeDashFace(container
);
84 // Draws the dash face
86 _drawDashFace(container
) {
88 const blush
= container
.getChildByName('blush');
89 const smile
= container
.getChildByName('smile');
90 const frown
= container
.getChildByName('frown');
93 smile
.visible
= false;
96 // Removes the dash face
98 _removeDashFace(container
) {
100 const blush
= container
.getChildByName('blush');
101 const smile
= container
.getChildByName('smile');
102 const frown
= container
.getChildByName('frown');
103 blush
.visible
= false;
104 frown
.visible
= false;
105 smile
.visible
= true;