+ container.container.position.x = position.x;
+ container.container.position.y = position.y;
+ container.container.rotation = angle.angle;
+ entity.addComponent(new PixiContainerComponent(container));
+
+ // PHYSICS
+
+ const frictionAir = 0.02;
+ const friction = 0.01;
+ const frictionStatic = 0.01;
+ const restitution = 1;
+ const density = 1.5;
+
+ const body = Bodies.circle(position.x / Config.meterSize, position.y / Config.meterSize, radius / Config.meterSize, {
+ label: 'Sumo body',
+ angle: angle.angle,
+ density,
+ frictionAir,
+ frictionStatic,
+ friction,
+ restitution
+ });
+ entity.addComponent(new BodyComponent({ body }));
+
+ // GRAB
+
+ const areaSizeFactor = 2; // Multiplier vs the radius
+ const area = Bodies.circle(position.x / Config.meterSize, position.y / Config.meterSize, (radius * areaSizeFactor) / Config.meterSize, {
+ label: 'Sumo Grab Area',
+ isSensor: true
+ });
+
+ entity.addComponent(new GrabAreaComponent({ area }));
+ entity.addComponent(new GrabComponent({ body }));
+ entity.addComponent(new GrabbableComponent({ body }));
+
+ if (engine) {
+ engine.addEntity(entity);
+ }
+
+ return entity;
+ },
+
+ /**
+ * Creates a rubber band entity and adds it to the engine.
+ *
+ * @function createRubberBand
+ * @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, it
+ * must include entityA and entityB which will be tied by it. If they
+ * are not sent or don't have a physics body, this will throw.
+ * @return {external:Serpentity.Entity} the created entity
+ */
+ createRubberBand(engine, config = {}) {
+
+ const entity = new Entity();
+
+ if (!config.entityA || !config.entityB) {
+ throw new Error(internals.kNoEntityError);
+ }
+
+ if (!config.entityA.hasComponent(BodyComponent) || !config.entityB.hasComponent(BodyComponent)) {
+ throw new Error(internals.kEntityHasNoBodyError);
+ }
+
+ // RENDERING
+
+ const container = config.container || {
+ container: PixiFactory.createEmptyGraphic()
+ };
+ entity.addComponent(new PixiContainerComponent(container));
+
+ // PHYSICS
+
+ const bodyA = config.entityA.getComponent(BodyComponent).body;
+ const bodyB = config.entityB.getComponent(BodyComponent).body;
+ const damping = 0;
+ const length = 100 / Config.meterSize;
+ const stiffness = 0.001;
+
+ const body = Constraint.create({
+ bodyA,
+ bodyB,
+ damping,
+ length,
+ stiffness
+ });
+ entity.addComponent(new BodyComponent({ body }));
+
+ entity.addComponent(new CoupledEntitiesComponent({
+ coupledEntities: [config.entityA, config.entityB]
+ }));
+
+ 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'
+ }
+ },
+ {
+ source: {
+ type: 'keyboard',
+ index: 88 // X
+ },
+ target: {
+ component: GrabComponent,
+ property: 'grabbing'
+ }
+ }
+ ]
+ }));
+
+ 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();