+ entity.addComponent(new ElasticComponent());
+
+ if (engine) {
+ engine.addEntity(entity);
+ }
+
+ return entity;
+ },
+
+ /**
+ * Creates a controllable sumo entity and adds it to the engine. Can override
+ * position in the config object
+ *
+ * @function createControllableSumo
+ * @memberof SumoFactory
+ * @param {external:Serpentity} [engine] the serpentity engine to attach
+ * to. If not sent, it will not be attached.
+ * @param {object} [config] the config to override the entity, accepts
+ * the key `position` as an object with an x and y property.
+ * @return {external:Serpentity.Entity} the created entity
+ */
+ createControllableSumo(engine, config = {}) {
+
+ const entity = this.createSumo(null, config);
+
+ entity.addComponent(new ControlMapComponent({
+ map: [
+ {
+ source: {
+ type: 'keyboard',
+ index: 37 // left arrow
+ },
+ target: {
+ component: ForceComponent,
+ property: 'x',
+ value: (value) => -Number(value)
+ }
+ },
+ {
+ source: {
+ type: 'keyboard',
+ index: 39 // right arrow
+ },
+ target: {
+ component: ForceComponent,
+ property: 'x',
+ value: (value) => Number(value)
+ }
+ },
+ {
+ source: {
+ type: 'keyboard',
+ index: 38 // up arrow
+ },
+ target: {
+ component: ForceComponent,
+ property: 'y',
+ value: (value) => -Number(value)
+ }
+ },
+ {
+ source: {
+ type: 'keyboard',
+ index: 40 // down arrow
+ },
+ target: {
+ component: ForceComponent,
+ property: 'y',
+ value: (value) => Number(value)
+ }
+ },
+ {
+ source: {
+ type: 'keyboard',
+ index: 90 // Z
+ },
+ target: {
+ component: DashComponent,
+ property: 'dashing'
+ }
+ }
+ ]
+ }));
+
+ if (engine) {
+ engine.addEntity(entity);
+ }
+
+ return entity;
+ },
+
+ /**
+ * Creates a static harness entity
+ *
+ * @function createHarness
+ * @memberof SumoFactory
+ * @param {external:Serpentity} [engine] the serpentity engine to attach
+ * to. If not sent, it will not be attached.
+ * @param {object} [config] the config to override the entity, accepts
+ * the key `position` as an object with an x and y property.
+ * @return {external:Serpentity.Entity} the created entity
+ */
+ createHarness(engine, config = {}) {
+
+ const entity = new Entity();
+
+ // POSITION
+
+ entity.addComponent(new PositionComponent(config.position));
+ const position = entity.getComponent(PositionComponent);
+
+ // RENDERING
+
+ const radius = 15;
+
+ const container = config.container || {
+ container: PixiFactory.createHarness({ radius })
+ };
+ container.container.position.x = position.x;
+ container.container.position.y = position.y;
+ entity.addComponent(new PixiContainerComponent(container));
+
+ // PHYSICS
+
+ const friction = 0;
+ const frictionStatic = 0;
+ const restitution = 1;
+
+ const body = Bodies.circle(position.x / Config.meterSize, position.y / Config.meterSize, radius / Config.meterSize, {
+ isStatic: true,
+ label: 'Harness body',
+ friction,
+ restitution,
+ frictionStatic
+ });
+ entity.addComponent(new BodyComponent({ body }));
+