2019-03-27 15:51:58 -05:00
|
|
|
import {create as createEntity} from '@avocado/entity';
|
|
|
|
// Create an entity for a new connection.
|
|
|
|
export function createEntityForConnection(socket) {
|
|
|
|
let entity = createEntity();
|
|
|
|
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: {
|
2019-04-10 20:22:09 -05:00
|
|
|
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
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
entity.addTrait('controllable');
|
|
|
|
entity.addTrait('informed');
|
|
|
|
// Embed socket.
|
|
|
|
entity.socket = socket;
|
|
|
|
return entity;
|
|
|
|
}
|