]> git.r.bdr.sh - rbdr/serpentity/commitdiff
Components extend without having to define init v0.1.6
authorBen Beltran <redacted>
Wed, 13 Aug 2014 00:25:52 +0000 (19:25 -0500)
committerBen Beltran <redacted>
Wed, 13 Aug 2014 00:25:52 +0000 (19:25 -0500)
bower.json
dist/serpentity.js
dist/serpentity.min.js
gulpfile.js
lib/serpentity/component.js
package.json

index 5e5d89c3e3ccb7f554544e6921f89e94df8af00f..67ade9107108b42a2c1d1f9ca0c78539e2853f4d 100644 (file)
@@ -1,6 +1,6 @@
 {
   "name": "serpentity",
-  "version": "0.1.5",
+  "version": "0.1.6",
   "homepage": "https://github.com/benbeltran/serpentity",
   "authors": [
     "Ben Beltran <ben@nsovocal.com>"
index 2f91c253fa0f0bf69901b35c84762a8c7f99f40d..3522b063a3a715436c6fe5131e2dd8bfb6c53556 100644 (file)
@@ -472,7 +472,19 @@ Class(Serpentity, "NodeCollection")({
  * components can be any class whatsoever.
  */
 Class(Serpentity, "Component")({
+    prototype : {
+        init : function init(config) {
+            var property;
 
+            config = config || {};
+
+            for (property in config) {
+                if (config.hasOwnProperty(property)) {
+                    this[property] = config[property];
+                }
+            }
+        }
+    }
 });
 
 /*
index 2950427d9872c9e393effd1dcd70479f8db3beb2..12aa23fd5bb58ea1933d7c98b6679e88ac97a7c0 100644 (file)
@@ -2,5 +2,5 @@
 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,"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")({});
+Class(Serpentity,"Component")({prototype:{init:function(t){var n;t=t||{};for(n in t)t.hasOwnProperty(n)&&(this[n]=t[n])}}});
 Class(Serpentity,"System")({prototype:{added:function(){},removed:function(){},update:function(){}}});
\ No newline at end of file
index f1fb5e6ad743b7bd5146b2580231dc2f7a8705ee..dcbfdc7007fb20a5e36d819d5752d1f85b7c8fed 100644 (file)
@@ -12,6 +12,17 @@ gulp.task('build', function() {
               'lib/serpentity/system.js',
           ])
     .pipe(uglify())
+    .pipe(concat('serpentity.min.js'))
+    .pipe(gulp.dest('dist'))
+
+    gulp.src([
+              'lib/serpentity/serpentity.js',
+              'lib/serpentity/entity.js',
+              'lib/serpentity/node.js',
+              'lib/serpentity/node_collection.js',
+              'lib/serpentity/component.js',
+              'lib/serpentity/system.js',
+          ])
     .pipe(concat('serpentity.js'))
     .pipe(gulp.dest('dist'))
 });
index 0204e302c8a4f823d011f4f90b0602d8ebe866fd..0018a880413a7b8c6f02272bbb6081a0ca032971 100644 (file)
@@ -5,5 +5,17 @@
  * components can be any class whatsoever.
  */
 Class(Serpentity, "Component")({
+    prototype : {
+        init : function init(config) {
+            var property;
 
+            config = config || {};
+
+            for (property in config) {
+                if (config.hasOwnProperty(property)) {
+                    this[property] = config[property];
+                }
+            }
+        }
+    }
 });
index 06ed1b981a2117295ca5449c8fa27dc63d96eb06..642de3ec5e66907a9f723eb9bdcbffb7bb7941d0 100644 (file)
@@ -1,7 +1,7 @@
 {
   "name": "serpentity",
   "description": "A simple entity framework inspired by ash",
-  "version": "0.1.5",
+  "version": "0.1.6",
   "contributors": [
     {
       "name": "Ben Beltran",