humus-old/server/create-entity-for-connection.js

59 lines
1.2 KiB
JavaScript
Raw Normal View History

import {Entity} from '@avocado/entity';
2019-03-27 15:51:58 -05:00
// Create an entity for a new connection.
export function createEntityForConnection(socket) {
let entity = new Entity();
2019-03-27 15:51:58 -05:00
entity = entity.fromJSON({
traits: {
animated: {
params: {
animations: {
idle: {
offset: [0, -12],
uri: '/idle.animation.json',
},
moving: {
offset: [0, -12],
uri: '/moving.animation.json',
},
}
},
},
2019-04-08 15:20:43 -05:00
collider: {},
2019-03-27 15:51:58 -05:00
directional: {
params: {
directionCount: 4,
},
},
existent: {},
2019-04-05 11:59:14 -05:00
followed: {},
2019-04-14 18:42:23 -05:00
visible: {},
2019-03-27 15:51:58 -05:00
mobile: {
state: {
speed: 100,
},
},
2019-04-08 13:32:52 -05:00
physical: {},
positioned: {
state: {
x: 400,
y: 400,
2019-04-08 13:32:52 -05:00
},
},
shaped: {
2019-03-27 15:51:58 -05:00
params: {
shape: {
2019-04-13 03:19:41 -05:00
type: 'circle',
radius: 4,
2019-04-08 13:32:52 -05:00
},
2019-03-27 15:51:58 -05:00
},
},
vulnerable: {},
2019-03-27 15:51:58 -05:00
},
});
entity.addTrait('controllable');
entity.addTrait('informed');
// Embed socket.
entity.socket = socket;
return entity;
}