]> git.r.bdr.sh - rbdr/serpentity/blobdiff - lib/serpentity/entity.js
Feature/code update (#1)
[rbdr/serpentity] / lib / serpentity / entity.js
index add823e422fdf1a831ff40759e5dcaa686f6b14d..2a4b03fbc6d323677d6855025aff78ce159080ea 100644 (file)
@@ -1,18 +1,17 @@
 'use strict';
 
-/* global Serpentity */
-
 /*
  * The entity gives the entity framework its name. It exists only
  * to hold components.
  */
 
-let Entity = class Entity {
-  constructor (config) {
+const Entity = class Entity {
+  constructor(config) {
+
     this._componentKeys = [];
     this._components = [];
 
-    Object.assign(this, config || {});
+    Object.assign(this, config);
   }
 
   /*
@@ -20,7 +19,8 @@ let Entity = class Entity {
    *
    * returns true if added, false if already present
    */
-  addComponent (component) {
+  addComponent(component) {
+
     if (this._componentKeys.indexOf(component.constructor) >= 0) {
       return false;
     }
@@ -32,7 +32,8 @@ let Entity = class Entity {
   /*
    * returns true if component is included, false otherwise
    */
-  hasComponent (componentClass) {
+  hasComponent(componentClass) {
+
     if (this._componentKeys.indexOf(componentClass) >= 0) {
       return true;
     }
@@ -42,16 +43,13 @@ let Entity = class Entity {
   /*
    * returns the component associated with that key
    */
-  getComponent (componentClass) {
-    let position = this._componentKeys.indexOf(componentClass);
+  getComponent(componentClass) {
+
+    const position = this._componentKeys.indexOf(componentClass);
     if (position >= 0) {
       return this._components[position];
     }
   }
 };
 
-if (typeof module !== 'undefined' && this.module !== module) {
-  module.exports = Entity;
-} else {
-  Serpentity.Entity = Entity;
-}
+module.exports = Entity;