]> git.r.bdr.sh - rbdr/serpentity/blobdiff - lib/serpentity/node_collection.js
Adapts libraries to style guide
[rbdr/serpentity] / lib / serpentity / node_collection.js
index f5b1794a8a88f8fdf79255581a4871c9354f0d5d..7c519912364c3a7559b8f0131a27ce90db66f909 100644 (file)
@@ -28,15 +28,15 @@ let NodeCollection = class NodeCollection {
   add (entity) {
 
     if (this.type.matches(entity) && !this._entityExists(entity)) {
-      let node, types, property;
 
-      node = new this.type({});
+      let node = new this.type({});
+      let types = this.type.types;
+
       node.entity = entity;
-      types = this.type.types;
 
-      for (property in types) {
-        if (types.hasOwnProperty(property)) {
-          node[property] = entity.getComponent(types[property]);
+      for (let typeName in types) {
+        if (types.hasOwnProperty(typeName)) {
+          node[typeName] = entity.getComponent(types[typeName]);
         }
       }
 
@@ -54,9 +54,8 @@ let NodeCollection = class NodeCollection {
    * returns true if it was removed, false otherwise.
    */
   remove (entity) {
-    let found;
+    let found = -1;
 
-    found = -1;
     this.nodes.forEach(function (node, i) {
       if (node.entity === entity) {
         found = i;
@@ -75,10 +74,9 @@ let NodeCollection = class NodeCollection {
    * Checks whether we already have nodes for this entity.
    */
   _entityExists (entity) {
-    let found, node;
+    let found = false;
 
-    found = false;
-    for (node of this.nodes) {
+    for (let node of this.nodes) {
       if (node.entity === entity) {
         found = true;
       }