Comparing version 1.1.0 to 1.1.1
@@ -51,2 +51,3 @@ "use strict"; | ||
this._components[component.name] = component.state; | ||
this._manager._addToComponentList(component.name, this.hash()); | ||
} | ||
@@ -95,2 +96,4 @@ | ||
delete this._components[name]; | ||
this._manager._removeHashFromComponentList(name, this.hash()); | ||
} | ||
@@ -97,0 +100,0 @@ }]); |
@@ -73,3 +73,3 @@ 'use strict'; | ||
if (!action.components) { | ||
throw "'" + action.actionType + "' must specify components to add to the entity!"; | ||
throw "'" + action.type + "' must specify components to add to the entity!"; | ||
} | ||
@@ -112,3 +112,3 @@ var entity = new Entity(manager); | ||
if (action.hash === undefined) { | ||
throw "'" + action.actionType + "' must specify hash to remove!"; | ||
throw "'" + action.type + "' must specify hash to remove!"; | ||
} | ||
@@ -253,3 +253,3 @@ | ||
} | ||
this._entitiesByComponent[componentName] = this._entitiesByComponent[componentName].add(entity.hash()); | ||
this._entitiesByComponent[componentName].add(entity.hash()); | ||
} | ||
@@ -302,2 +302,37 @@ | ||
/** | ||
* @description - In the case that a component was removed from an entity, | ||
* the entity would call this method of the ECS to ensure that it wasn't | ||
* on the list for that component anymore | ||
* @param {String} componentName - the name of the component that was | ||
* removed from the entity | ||
* @param {String} hash - the hash value of the entity that is to be | ||
* removed | ||
*/ | ||
}, { | ||
key: '_removeHashFromComponentList', | ||
value: function _removeHashFromComponentList(componentName, hash) { | ||
if (!(componentName in this._entitiesByComponent)) throw new TypeError("'" + componentName.toString() + "' doesn't have" + " any entities listed!"); | ||
this._entitiesByComponent[componentName].delete(hash); | ||
if (this._entitiesByComponent[componentName].size <= 0) { | ||
delete this._entitiesByComponent[componentName]; | ||
} | ||
} | ||
/** | ||
* @description - Adds an entity to a component list | ||
* @param {String} componentName - the name of the component | ||
* @param {String} hash - the hash to add to the component set | ||
*/ | ||
}, { | ||
key: '_addToComponentList', | ||
value: function _addToComponentList(componentName, hash) { | ||
if (!(componentName in this._entitiesByComponent)) this._entitiesByComponent[componentName] = new Set(); | ||
this._entitiesByComponent[componentName].add(hash); | ||
} | ||
/** | ||
* @description - Returns a list of reducer functions by action type | ||
@@ -304,0 +339,0 @@ * @param {String} actionType - type of action the reducer is triggered by |
{ | ||
"name": "sam-ecs", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "A specialized entity component system", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
32454
788
0