From 911843561c755ddf10c5079b5daf4e990ac236d9 Mon Sep 17 00:00:00 2001 From: cha0s Date: Sat, 4 May 2019 11:39:43 -0500 Subject: [PATCH] perf: inline entity from JSON --- server/create-entity-for-connection.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/create-entity-for-connection.js b/server/create-entity-for-connection.js index 094813c..bf7bc7e 100644 --- a/server/create-entity-for-connection.js +++ b/server/create-entity-for-connection.js @@ -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;