]>
git.r.bdr.sh - rbdr/sumo/blob - lib/systems/draw_grab.js
2808783dd9eb1062d97863122cebb7482268e564
1 import { System
} from '@serpentity/serpentity';
3 import DrawnGrabberNode
from '../nodes/drawn_grabber';
6 * Shows a different graphic during the duration of lock
8 * @extends {external:Serpentity.System}
9 * @class DrawGrabSystem
10 * @param {object} config a configuration object to extend.
12 export default class DrawGrabSystem
extends System
{
14 constructor(config
= {}) {
19 * The node collection of grabbers
21 * @property {external:Serpentity.NodeCollection} drawnGrabbers
23 * @memberof DrawGrabSystem
25 this.drawnGrabbers
= null;
29 * Initializes system when added. Requests drawn grabber nodes
32 * @memberof DrawGrabSystem
34 * @param {external:Serpentity.Engine} engine the serpentity engine to
35 * which we are getting added
39 this.drawnGrabbers
= engine
.getNodes(DrawnGrabberNode
);
43 * Clears system resources when removed.
47 * @memberof DrawGrabSystem
51 this.drawnGrabbers
= null;
55 * Runs on every update of the loop. Updates image depending on if
56 * grab is locked and active
60 * @param {Number} currentFrameDuration the duration of the current
62 * @memberof DrawGrabSystem
64 update(currentFrameDuration
) {
66 for (const drawnGrabber
of this.drawnGrabbers
) {
68 const grab
= drawnGrabber
.grab
;
69 const container
= drawnGrabber
.container
.container
;
71 if (grab
.locked
&& grab
.constraint
) {
72 this._drawGrabFace(container
);
77 this._drawGrabCooldownFace(container
);
81 this._removeGrabFace(container
);
85 // Draws the grab face
87 _drawGrabFace(container
) {
89 const effort
= container
.getChildByName('effort');
90 const shadow
= container
.getChildByName('shadow');
91 effort
.visible
= true;
92 shadow
.visible
= false;
95 // Draws the grab cooldown face
97 _drawGrabCooldownFace(container
) {
99 const effort
= container
.getChildByName('effort');
100 const shadow
= container
.getChildByName('shadow');
101 effort
.visible
= false;
102 shadow
.visible
= true;
105 // Removes the dash face
107 _removeGrabFace(container
) {
109 const effort
= container
.getChildByName('effort');
110 const shadow
= container
.getChildByName('shadow');
111 effort
.visible
= false;
112 shadow
.visible
= false;