]> git.r.bdr.sh - rbdr/serpentity/commitdiff
Normalizes API for entities v0.1.7
authorBen Beltran <redacted>
Wed, 20 Aug 2014 14:27:23 +0000 (09:27 -0500)
committerBen Beltran <redacted>
Wed, 20 Aug 2014 14:27:23 +0000 (09:27 -0500)
README.md
bin/test
bower.json
browser_test/index.html
dist/serpentity.js
dist/serpentity.min.js
lib/serpentity/entity.js
lib/serpentity/serpentity.js
package.json

index 6703b5f0a3e221837179730a5f6bcdd4aad9e055..6724652ea0d47572cda501d06aac6e9cb14ee167 100644 (file)
--- a/README.md
+++ b/README.md
@@ -45,9 +45,9 @@ eventually be consumed by "Systems"
         }
     });
 
         }
     });
 
-You can add components to entities by using the add method:
+You can add components to entities by using the addComponent method:
 
 
-    entity.add(new PositionComponent());
+    entity.addComponent(new PositionComponent());
 
 
 Systems can refer to entities by requesting nodes.
 
 
 Systems can refer to entities by requesting nodes.
index 222a65316d32f3595010628182efb8c619d1ff4c..e5218df9dc4ff7effa5b6ba4020af66443360aa1 100755 (executable)
--- a/bin/test
+++ b/bin/test
@@ -114,7 +114,7 @@ engine.update(10);
 
 console.log("\n## Adding system to the engine and updating".bold.black)
 var entity = new Serpentity.Entity();
 
 console.log("\n## Adding system to the engine and updating".bold.black)
 var entity = new Serpentity.Entity();
-entity.add(new TestComponent());
+entity.addComponent(new TestComponent());
 engine.addEntity(entity);
 engine.update(10);
 
 engine.addEntity(entity);
 engine.update(10);
 
@@ -134,7 +134,7 @@ engine.update(10);
 
 console.log("\n## Adding a second entity".bold.black)
 var entity = new Serpentity.Entity();
 
 console.log("\n## Adding a second entity".bold.black)
 var entity = new Serpentity.Entity();
-entity.add(new TestComponent());
+entity.addComponent(new TestComponent());
 engine.addEntity(entity);
 engine.update(10);
 
 engine.addEntity(entity);
 engine.update(10);
 
index 67ade9107108b42a2c1d1f9ca0c78539e2853f4d..bf0a06a0c6d40527ffcca445efc94551ccfbd024 100644 (file)
@@ -1,6 +1,6 @@
 {
   "name": "serpentity",
 {
   "name": "serpentity",
-  "version": "0.1.6",
+  "version": "0.1.7",
   "homepage": "https://github.com/benbeltran/serpentity",
   "authors": [
     "Ben Beltran <ben@nsovocal.com>"
   "homepage": "https://github.com/benbeltran/serpentity",
   "authors": [
     "Ben Beltran <ben@nsovocal.com>"
index 82921b71c5180fe95bbea86fba7873c996aec759..1183efc45142f84fe2c1e3d965cbbce9c7862ea5 100644 (file)
 
         console.log("\n## Adding system to the engine and updating")
         var entity = new Serpentity.Entity();
 
         console.log("\n## Adding system to the engine and updating")
         var entity = new Serpentity.Entity();
-        entity.add(new TestComponent());
+        entity.addComponent(new TestComponent());
         engine.addEntity(entity);
         engine.update(10);
 
         engine.addEntity(entity);
         engine.update(10);
 
 
         console.log("\n## Adding a second entity")
         var entity = new Serpentity.Entity();
 
         console.log("\n## Adding a second entity")
         var entity = new Serpentity.Entity();
-        entity.add(new TestComponent());
+        entity.addComponent(new TestComponent());
         engine.addEntity(entity);
         engine.update(10);
 
         engine.addEntity(entity);
         engine.update(10);
 
index 3522b063a3a715436c6fe5131e2dd8bfb6c53556..1f9b250eadca63d61b7009d9c821d982a7f10fba 100644 (file)
@@ -50,7 +50,7 @@ eventually be consumed by "Systems"
 
 You can add components to entities by using the add method:
 
 
 You can add components to entities by using the add method:
 
-    entity.add(new PositionComponent());
+    entity.addComponent(new PositionComponent());
 
 
 Systems can refer to entities by requesting nodes.
 
 
 Systems can refer to entities by requesting nodes.
@@ -287,7 +287,7 @@ Class(Serpentity, "Entity")({
          *
          * returns true if added, false if already present
          */
          *
          * returns true if added, false if already present
          */
-        add : function add(component) {
+        addComponent : function addComponent(component) {
             if (this._componentKeys.indexOf(component.constructor) >= 0) {
                 return false;
             }
             if (this._componentKeys.indexOf(component.constructor) >= 0) {
                 return false;
             }
index 12aa23fd5bb58ea1933d7c98b6679e88ac97a7c0..84ef4f129855e047619dd70c6ee8af8ab261e5b2 100644 (file)
@@ -1,5 +1,5 @@
 "undefined"!=typeof require&&require("neon"),Class("Serpentity")({prototype:{systems:null,entities:null,_nodeCollections:null,_nodeCollectionKeys:null,init:function(e){var t;e=e||{},this.systems=[],this.entities=[],this._nodeCollections=[],this._nodeCollectionKeys=[];for(t in e)e.hasOwnProperty(t)&&(this[t]=e[t])},addSystem:function(e,t){var i,s;return this.systems.indexOf(e)>=0?!1:(e.priority=t,s=!1,i=0,this.systems.some(function(t,n){return i=n,t.priority>=e.priority?(s=!0,!0):void 0}),s||(i+=1),this.systems.splice(i,0,e),e.added(this),!0)},removeSystem:function(e){var t;return t=this.systems.indexOf(e),t>=0?(this.systems[t].removed(this),this.systems.splice(t,1),!0):!1},addEntity:function(e){return this.entities.indexOf(e)>=0?!1:(this.entities.push(e),this._nodeCollections.forEach(function(t){t.add(e)}),!0)},removeEntity:function(e){var t;return t=this.entities.indexOf(e),t>=0?(this._nodeCollections.forEach(function(t){t.remove(e)}),this.entities.splice(t,1),!0):!1},getNodes:function(e){var t,i;return t=this._nodeCollectionKeys.indexOf(e),t>=0?this._nodeCollections[t].nodes:(i=new Serpentity.NodeCollection({type:e}),this._nodeCollectionKeys.push(e),this._nodeCollections.push(i),this.entities.forEach(function(e){i.add(e)}),i.nodes)},update:function(e){this.systems.forEach(function(t){t.update(e)})}}}),"undefined"!=typeof require&&(require("./component.js"),require("./entity.js"),require("./node.js"),require("./node_collection.js"),require("./system.js"));
 "undefined"!=typeof require&&require("neon"),Class("Serpentity")({prototype:{systems:null,entities:null,_nodeCollections:null,_nodeCollectionKeys:null,init:function(e){var t;e=e||{},this.systems=[],this.entities=[],this._nodeCollections=[],this._nodeCollectionKeys=[];for(t in e)e.hasOwnProperty(t)&&(this[t]=e[t])},addSystem:function(e,t){var i,s;return this.systems.indexOf(e)>=0?!1:(e.priority=t,s=!1,i=0,this.systems.some(function(t,n){return i=n,t.priority>=e.priority?(s=!0,!0):void 0}),s||(i+=1),this.systems.splice(i,0,e),e.added(this),!0)},removeSystem:function(e){var t;return t=this.systems.indexOf(e),t>=0?(this.systems[t].removed(this),this.systems.splice(t,1),!0):!1},addEntity:function(e){return this.entities.indexOf(e)>=0?!1:(this.entities.push(e),this._nodeCollections.forEach(function(t){t.add(e)}),!0)},removeEntity:function(e){var t;return t=this.entities.indexOf(e),t>=0?(this._nodeCollections.forEach(function(t){t.remove(e)}),this.entities.splice(t,1),!0):!1},getNodes:function(e){var t,i;return t=this._nodeCollectionKeys.indexOf(e),t>=0?this._nodeCollections[t].nodes:(i=new Serpentity.NodeCollection({type:e}),this._nodeCollectionKeys.push(e),this._nodeCollections.push(i),this.entities.forEach(function(e){i.add(e)}),i.nodes)},update:function(e){this.systems.forEach(function(t){t.update(e)})}}}),"undefined"!=typeof require&&(require("./component.js"),require("./entity.js"),require("./node.js"),require("./node_collection.js"),require("./system.js"));
-Class(Serpentity,"Entity")({prototype:{_components:null,_componentKeys:null,init:function(n){var t;this._componentKeys=[],this._components=[];for(t in n)n.hasOwnProperty(t)&&(this[t]=n[t])},add:function(n){return this._componentKeys.indexOf(n.constructor)>=0?!1:(this._componentKeys.push(n.constructor),this._components.push(n),!0)},hasComponent:function(n){return this._componentKeys.indexOf(n)>=0?!0:!1},getComponent:function(n){var t;return t=this._componentKeys.indexOf(n),t>=0?this._components[t]:void 0}}});
+Class(Serpentity,"Entity")({prototype:{_components:null,_componentKeys:null,init:function(n){var t;this._componentKeys=[],this._components=[];for(t in n)n.hasOwnProperty(t)&&(this[t]=n[t])},addComponent:function(n){return this._componentKeys.indexOf(n.constructor)>=0?!1:(this._componentKeys.push(n.constructor),this._components.push(n),!0)},hasComponent:function(n){return this._componentKeys.indexOf(n)>=0?!0:!1},getComponent:function(n){var t;return t=this._componentKeys.indexOf(n),t>=0?this._components[t]:void 0}}});
 Class(Serpentity,"Node")({matches:function(t){var s,r,n;n=this.types;for(s in this.types)if(this.types.hasOwnProperty(s)&&(r=!1,t.hasComponent(n[s])&&(r=!0),!r))return!1;return!0},prototype:{types:null,init:function(){var t;this.types={};for(t in this.constructor)this.constructor.hasOwnProperty(t)&&(this.types[t]=this.constructor[t])}}});
 Class(Serpentity,"NodeCollection")({prototype:{type:null,nodes:null,init:function(t){var n;t=t||{},this.nodes=[];for(n in t)t.hasOwnProperty(n)&&(this[n]=t[n])},add:function(t){var n,e,i;if(this.type.matches(t)&&!this._entityExists(t)){n=new this.type({}),n.entity=t,e=this.type.types;for(i in e)e.hasOwnProperty(i)&&(n[i]=t.getComponent(e[i]));return this.nodes.push(n),!0}return!1},remove:function(t){var n;return n=-1,this.nodes.forEach(function(e,i){e.entity===t&&(n=i)}),n>=0?(this.nodes.splice(n,1),!0):!1},_entityExists:function(t){var n;return n=!1,this.nodes.forEach(function(e){e.entity===t&&(n=!0)}),n}}});
 Class(Serpentity,"Component")({prototype:{init:function(t){var n;t=t||{};for(n in t)t.hasOwnProperty(n)&&(this[n]=t[n])}}});
 Class(Serpentity,"Node")({matches:function(t){var s,r,n;n=this.types;for(s in this.types)if(this.types.hasOwnProperty(s)&&(r=!1,t.hasComponent(n[s])&&(r=!0),!r))return!1;return!0},prototype:{types:null,init:function(){var t;this.types={};for(t in this.constructor)this.constructor.hasOwnProperty(t)&&(this.types[t]=this.constructor[t])}}});
 Class(Serpentity,"NodeCollection")({prototype:{type:null,nodes:null,init:function(t){var n;t=t||{},this.nodes=[];for(n in t)t.hasOwnProperty(n)&&(this[n]=t[n])},add:function(t){var n,e,i;if(this.type.matches(t)&&!this._entityExists(t)){n=new this.type({}),n.entity=t,e=this.type.types;for(i in e)e.hasOwnProperty(i)&&(n[i]=t.getComponent(e[i]));return this.nodes.push(n),!0}return!1},remove:function(t){var n;return n=-1,this.nodes.forEach(function(e,i){e.entity===t&&(n=i)}),n>=0?(this.nodes.splice(n,1),!0):!1},_entityExists:function(t){var n;return n=!1,this.nodes.forEach(function(e){e.entity===t&&(n=!0)}),n}}});
 Class(Serpentity,"Component")({prototype:{init:function(t){var n;t=t||{};for(n in t)t.hasOwnProperty(n)&&(this[n]=t[n])}}});
index d03f16baafcbdc1223dbf17db53b5bfe73033f8d..c020f05514c0c8940a0d1079dacdb8d669fd2ee0 100644 (file)
@@ -25,7 +25,7 @@ Class(Serpentity, "Entity")({
          *
          * returns true if added, false if already present
          */
          *
          * returns true if added, false if already present
          */
-        add : function add(component) {
+        addComponent : function addComponent(component) {
             if (this._componentKeys.indexOf(component.constructor) >= 0) {
                 return false;
             }
             if (this._componentKeys.indexOf(component.constructor) >= 0) {
                 return false;
             }
index 18985c56891c27941f2ac6d64d699d9b6d9af5b7..ed1a9dffb020503e6cb5cc6636d1d4d8b0ae635e 100644 (file)
@@ -50,7 +50,7 @@ eventually be consumed by "Systems"
 
 You can add components to entities by using the add method:
 
 
 You can add components to entities by using the add method:
 
-    entity.add(new PositionComponent());
+    entity.addComponent(new PositionComponent());
 
 
 Systems can refer to entities by requesting nodes.
 
 
 Systems can refer to entities by requesting nodes.
index 642de3ec5e66907a9f723eb9bdcbffb7bb7941d0..9443ed40d08cfdea220521427dbfeebdd692d2fe 100644 (file)
@@ -1,7 +1,7 @@
 {
   "name": "serpentity",
   "description": "A simple entity framework inspired by ash",
 {
   "name": "serpentity",
   "description": "A simple entity framework inspired by ash",
-  "version": "0.1.6",
+  "version": "0.1.7",
   "contributors": [
     {
       "name": "Ben Beltran",
   "contributors": [
     {
       "name": "Ben Beltran",