perf: inline entity from JSON
This commit is contained in:
parent
86ae9ab3b1
commit
911843561c
|
@ -1,10 +1,10 @@
|
|||
import {Entity} from '@avocado/entity';
|
||||
// Create an entity for a new connection.
|
||||
export function createEntityForConnection(socket) {
|
||||
let entity = new Entity();
|
||||
// let entity = new Entity();
|
||||
const x = Math.floor(Math.random() * 284) + 50;
|
||||
const y = Math.floor(Math.random() * 284) + 50;
|
||||
entity = entity.fromJSON({
|
||||
const entity = new Entity({
|
||||
traits: {
|
||||
alive: {
|
||||
state: {
|
||||
|
@ -27,6 +27,7 @@ export function createEntityForConnection(socket) {
|
|||
},
|
||||
},
|
||||
collider: {},
|
||||
controllable: {},
|
||||
directional: {
|
||||
params: {
|
||||
directionCount: 4,
|
||||
|
@ -35,7 +36,7 @@ export function createEntityForConnection(socket) {
|
|||
emitter: {},
|
||||
existent: {},
|
||||
followed: {},
|
||||
visible: {},
|
||||
informed: {},
|
||||
mobile: {
|
||||
state: {
|
||||
speed: 100,
|
||||
|
@ -56,11 +57,10 @@ export function createEntityForConnection(socket) {
|
|||
},
|
||||
},
|
||||
},
|
||||
visible: {},
|
||||
vulnerable: {},
|
||||
},
|
||||
});
|
||||
entity.addTrait('controllable');
|
||||
entity.addTrait('informed');
|
||||
// Embed socket.
|
||||
entity.socket = socket;
|
||||
return entity;
|
||||
|
|
Loading…
Reference in New Issue
Block a user