UNPKG

complex-engine

Version:

JS Component Entity Framework for Gamedevelopment

102 lines (76 loc) 2.56 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Source: Manager/GroupManager.js</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Source: Manager/GroupManager.js</h1> <section> <article> <pre class="prettyprint source linenums"><code>import Manager from '../Manager'; /** * */ class GroupManager extends Manager { constructor() { super(); this.groups = {}; } /** * Add entity to group * @param {Entity} entity * @param {string} groupName */ addToGroup(entity, groupName) { if (!this.groups[groupName]) { this.groups[groupName] = []; } this.groups[groupName].push(entity); } /** * * @param {Entity} entity * @param {string} groupName */ removeFromGroup(entity, groupName) { if (!this.groups[groupName]) { return; } this.groups[groupName] = this.groups[groupName].filter((entry) => { return entry.index !== entity.index; }) } /** * Get a group * @param {string} name * @return {Entity[]} */ getGroup(name) { return this.groups[name] || []; } } export default GroupManager; </code></pre> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Component.html">Component</a></li><li><a href="Engine.html">Engine</a></li><li><a href="Entity.html">Entity</a></li><li><a href="EntitySystem.html">EntitySystem</a></li><li><a href="GroupManager.html">GroupManager</a></li><li><a href="Manager.html">Manager</a></li><li><a href="Scene.html">Scene</a></li><li><a href="System.html">System</a></li><li><a href="VoidSystem.html">VoidSystem</a></li><li><a href="World.html">World</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Sun Sep 08 2019 20:40:30 GMT+0200 (Central European Summer Time) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>