@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
55 lines (47 loc) • 1.18 kB
JavaScript
/**
*
* @deprecated use {@link AttributeGroupSpec} instead
*/
export class ParticleSpecification {
/**
*
* @constructor
*/
constructor() {
/**
*
* @type {Array.<ParticleAttribute>}
*/
this.attributes = [];
}
/**
*
* @param {string} name
* @return {undefined|ParticleAttribute}
*/
getByName(name) {
const attributes = this.attributes;
const n = attributes.length;
for (let i = 0; i < n; i++) {
const attribute = attributes[i];
if (attribute.name === name) {
return attribute;
}
}
return undefined;
}
/**
*
* @param {ParticleAttribute} attribute
* @returns {ParticleSpecification}
*/
add(attribute) {
//check uniqueness of name
if (this.getByName(attribute.name) !== undefined) {
throw new Error(`Attribute named '${attribute.name}' already exists`);
}
this.attributes.push(attribute);
//for chaining, return self
return this;
}
}