1 import { System
} from '@serpentity/serpentity';
3 import RenderableWithAttributesNode
from '../nodes/renderable_with_attributes';
6 * Updates the renderables based on their attribuets
8 * @extends {external:Serpentity.System}
9 * @class AttributesToRenderableSystem
10 * @param {object} config a configuration object to extend.
12 export default class AttributesToRenderableSystem
extends System
{
14 constructor(config
= {}) {
19 * The node collection of renderable entities
21 * @property {external:Serpentity.NodeCollection} renderables
23 * @memberof AttributesToRenderableSystem
25 this.renderables
= null;
29 * Initializes system when added. Requests renderable nodes and
30 * attaches to event listeners to add / remove them to pixi stage
33 * @memberof AttributesToRenderableSystem
35 * @param {external:Serpentity.Engine} engine the serpentity engine to
36 * which we are getting added
40 this.renderables
= engine
.getNodes(RenderableWithAttributesNode
);
44 * Clears system resources when removed.
48 * @memberof AttributesToRenderableSystem
52 this.renderables
= null;
56 * Runs on every update of the loop. Updates the graphics so they're
61 * @param {Number} currentFrameDuration the duration of the current
63 * @memberof AttributesToRenderableSystem
65 update(currentFrameDuration
) {
67 for (const renderable
of this.renderables
) {
68 renderable
.container
.container
.position
.x
= renderable
.position
.x
;
69 renderable
.container
.container
.position
.y
= renderable
.position
.y
;
70 renderable
.container
.container
.rotation
= renderable
.angle
.angle
;