]> git.r.bdr.sh - rbdr/serpentity/blobdiff - dist/serpentity.min.js
Merge branch 'release/2.0.0'
[rbdr/serpentity] / dist / serpentity.min.js
index 84ef4f129855e047619dd70c6ee8af8ab261e5b2..7f431a2bb3662cf8522023faecaf5823a5e16886 100644 (file)
@@ -1,6 +1 @@
-"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])},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,"System")({prototype:{added:function(){},removed:function(){},update:function(){}}});
\ No newline at end of file
+!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Serpentity=e():t.Serpentity=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=5)}([function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var o=function t(e){r(this,t),Object.assign(this,e)};t.exports=o},function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var o=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),i=function(){function t(e){r(this,t),this._componentKeys=[],this._components=[],Object.assign(this,e)}return o(t,[{key:"addComponent",value:function(t){return!(this._componentKeys.indexOf(t.constructor)>=0)&&(this._componentKeys.push(t.constructor),this._components.push(t),!0)}},{key:"hasComponent",value:function(t){return this._componentKeys.indexOf(t)>=0}},{key:"getComponent",value:function(t){var e=this._componentKeys.indexOf(t);if(e>=0)return this._components[e]}}]),t}();t.exports=i},function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var o=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),i=function(){function t(e){r(this,t),this.types={},Object.assign(this,e)}return o(t,null,[{key:"matches",value:function(t){var e=Object.keys(this.types),n=!0,r=!1,o=void 0;try{for(var i,s=e[Symbol.iterator]();!(n=(i=s.next()).done);n=!0){var u=i.value,a=this.types[u],c=!1;if(t.hasComponent(a)&&(c=!0),!c)return!1}}catch(t){r=!0,o=t}finally{try{!n&&s.return&&s.return()}finally{if(r)throw o}}return!0}}]),t}();t.exports=i},function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var o=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),i=function(){function t(e){r(this,t),this.nodes=[],this.type=null,Object.assign(this,e)}return o(t,[{key:"add",value:function(t){if(this.type.matches(t)&&!this._entityExists(t)){var e=new this.type({}),n=this.type.types,r=Object.keys(n);e.entity=t;var o=!0,i=!1,s=void 0;try{for(var u,a=r[Symbol.iterator]();!(o=(u=a.next()).done);o=!0){var c=u.value;e[c]=t.getComponent(n[c])}}catch(t){i=!0,s=t}finally{try{!o&&a.return&&a.return()}finally{if(i)throw s}}return this.nodes.push(e),!0}return!1}},{key:"remove",value:function(t){var e=-1,n=this.nodes.some(function(n,r){if(n.entity===t)return e=r,!0});return n&&this.nodes.splice(e,1),n}},{key:"_entityExists",value:function(t){var e=!1,n=!0,r=!1,o=void 0;try{for(var i,s=this.nodes[Symbol.iterator]();!(n=(i=s.next()).done);n=!0){i.value.entity===t&&(e=!0)}}catch(t){r=!0,o=t}finally{try{!n&&s.return&&s.return()}finally{if(r)throw o}}return e}}]),t}();t.exports=i},function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var o=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),i=function(){function t(){r(this,t)}return o(t,[{key:"added",value:function(){}},{key:"removed",value:function(){}},{key:"update",value:function(){}}]),t}();t.exports=i},function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var o=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),i=function(){function t(e){r(this,t),this.systems=[],this.entities=[],this._nodeCollections=[],this._nodeCollectionKeys=[],Object.assign(this,e)}return o(t,[{key:"addSystem",value:function(t,e){if(this.systems.indexOf(t)>=0)return!1;t.priority=e;var n=0;return this.systems.some(function(e,r){if(n=r,e.priority>=t.priority)return!0})||(n+=1),this.systems.splice(n,0,t),t.added(this),!0}},{key:"removeSystem",value:function(t){var e=this.systems.indexOf(t);return e>=0&&(this.systems[e].removed(this),this.systems.splice(e,1),!0)}},{key:"addEntity",value:function(t){if(this.entities.indexOf(t)>=0)return!1;this.entities.push(t);var e=!0,n=!1,r=void 0;try{for(var o,i=this._nodeCollections[Symbol.iterator]();!(e=(o=i.next()).done);e=!0){o.value.add(t)}}catch(t){n=!0,r=t}finally{try{!e&&i.return&&i.return()}finally{if(n)throw r}}return!0}},{key:"removeEntity",value:function(t){var e=this.entities.indexOf(t);if(e>=0){var n=!0,r=!1,o=void 0;try{for(var i,s=this._nodeCollections[Symbol.iterator]();!(n=(i=s.next()).done);n=!0){i.value.remove(t)}}catch(t){r=!0,o=t}finally{try{!n&&s.return&&s.return()}finally{if(r)throw o}}return this.entities.splice(e,1),!0}return!1}},{key:"getNodes",value:function(e){var n=this._nodeCollectionKeys.indexOf(e);if(n>=0)return this._nodeCollections[n].nodes;var r=new t.NodeCollection({type:e});this._nodeCollectionKeys.push(e),this._nodeCollections.push(r);var o=!0,i=!1,s=void 0;try{for(var u,a=this.entities[Symbol.iterator]();!(o=(u=a.next()).done);o=!0){var c=u.value;r.add(c)}}catch(t){i=!0,s=t}finally{try{!o&&a.return&&a.return()}finally{if(i)throw s}}return r.nodes}},{key:"update",value:function(t){var e=!0,n=!1,r=void 0;try{for(var o,i=this.systems[Symbol.iterator]();!(e=(o=i.next()).done);e=!0){o.value.update(t)}}catch(t){n=!0,r=t}finally{try{!e&&i.return&&i.return()}finally{if(n)throw r}}}}]),t}();i.Component=n(0),i.Entity=n(1),i.Node=n(2),i.NodeCollection=n(3),i.System=n(4),t.exports=i}])});
\ No newline at end of file