complex-engine
Version:
JS Component Entity Framework for Gamedevelopment
2,528 lines (577 loc) • 24.3 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: Entity</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">Class: Entity</h1>
<section>
<header>
<h2><span class="attribs"><span class="type-signature"></span></span>Entity<span class="signature">(name)</span><span class="type-signature"></span></h2>
<div class="class-description">An entity is a object that holds many components. Those components define the behaviour of an entity.</div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<h4 class="name" id="Entity"><span class="type-signature"></span>new Entity<span class="signature">(name)</span><span class="type-signature"></span></h4>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>name</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="default">
Entity
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Entity.js.html">Entity.js</a>, <a href="Entity.js.html#line12">line 12</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id="alive"><span class="type-signature"></span>alive<span class="type-signature"> :boolean</span></h4>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">boolean</span>
</li>
</ul>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Entity.js.html">Entity.js</a>, <a href="Entity.js.html#line20">line 20</a>
</li></ul></dd>
</dl>
<h4 class="name" id="components"><span class="type-signature"></span>components<span class="type-signature"> :Array.<<a href="Component.html">Component</a>></span></h4>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Array.<<a href="Component.html">Component</a>></span>
</li>
</ul>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Entity.js.html">Entity.js</a>, <a href="Entity.js.html#line17">line 17</a>
</li></ul></dd>
</dl>
<h4 class="name" id="index"><span class="type-signature"></span>index<span class="type-signature"> :number|null</span></h4>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">number</span>
|
<span class="param-type">null</span>
</li>
</ul>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Entity.js.html">Entity.js</a>, <a href="Entity.js.html#line26">line 26</a>
</li></ul></dd>
</dl>
<h4 class="name" id="name"><span class="type-signature"></span>name<span class="type-signature"> :string</span></h4>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">string</span>
</li>
</ul>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Entity.js.html">Entity.js</a>, <a href="Entity.js.html#line14">line 14</a>
</li></ul></dd>
</dl>
<h4 class="name" id="remove"><span class="type-signature"></span>remove<span class="type-signature"> :boolean</span></h4>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">boolean</span>
</li>
</ul>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Entity.js.html">Entity.js</a>, <a href="Entity.js.html#line23">line 23</a>
</li></ul></dd>
</dl>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="addComponent"><span class="type-signature"></span>addComponent<span class="signature">(component)</span><span class="type-signature"> → {<a href="Entity.html">Entity</a>}</span></h4>
<div class="description">
Add a Component to the entity
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>component</code></td>
<td class="type">
<span class="param-type"><a href="Component.html">Component</a></span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Entity.js.html">Entity.js</a>, <a href="Entity.js.html#line36">line 36</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Entity.html">Entity</a></span>
</dd>
</dl>
<h4 class="name" id="addListener"><span class="type-signature"></span>addListener<span class="signature">(event, callback)</span><span class="type-signature"> → {<a href="Entity.html">Entity</a>}</span></h4>
<div class="description">
Add eventlistener to entity
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>event</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>callback</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Entity.js.html">Entity.js</a>, <a href="Entity.js.html#line53">line 53</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Entity.html">Entity</a></span>
</dd>
</dl>
<h4 class="name" id="destroy"><span class="type-signature"></span>destroy<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Kills the entity
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Entity.js.html">Entity.js</a>, <a href="Entity.js.html#line193">line 193</a>
</li></ul></dd>
</dl>
<h4 class="name" id="emit"><span class="type-signature"></span>emit<span class="signature">(event, data)</span><span class="type-signature"> → {<a href="Entity.html">Entity</a>}</span></h4>
<div class="description">
Emit event with data
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>event</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Entity.js.html">Entity.js</a>, <a href="Entity.js.html#line86">line 86</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Entity.html">Entity</a></span>
</dd>
</dl>
<h4 class="name" id="getAllComponents"><span class="type-signature"></span>getAllComponents<span class="signature">()</span><span class="type-signature"> → {Array.<<a href="Component.html">Component</a>>}</span></h4>
<div class="description">
Get all components from the entity
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Entity.js.html">Entity.js</a>, <a href="Entity.js.html#line171">line 171</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.<<a href="Component.html">Component</a>></span>
</dd>
</dl>
<h4 class="name" id="getComponent"><span class="type-signature"></span>getComponent<span class="signature">(component)</span><span class="type-signature"> → {<a href="Component.html">Component</a>}</span></h4>
<div class="description">
Get a Component from the entity
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>component</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">component constructor</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Entity.js.html">Entity.js</a>, <a href="Entity.js.html#line121">line 121</a>
</li></ul></dd>
</dl>
<h5>Throws:</h5>
<div class="param-desc">
Error
</div>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Component.html">Component</a></span>
</dd>
</dl>
<h4 class="name" id="getComponents"><span class="type-signature"></span>getComponents<span class="signature">(component)</span><span class="type-signature"> → {Array.<<a href="Component.html">Component</a>>}</span></h4>
<div class="description">
Get all mathing components
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>component</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">component constructor</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Entity.js.html">Entity.js</a>, <a href="Entity.js.html#line104">line 104</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.<<a href="Component.html">Component</a>></span>
</dd>
</dl>
<h4 class="name" id="getIndex"><span class="type-signature"></span>getIndex<span class="signature">()</span><span class="type-signature"> → {number|null}</span></h4>
<div class="description">
Get index of entity
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Entity.js.html">Entity.js</a>, <a href="Entity.js.html#line210">line 210</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">number</span>
|
<span class="param-type">null</span>
</dd>
</dl>
<h4 class="name" id="hasComponent"><span class="type-signature"></span>hasComponent<span class="signature">(component)</span><span class="type-signature"> → {boolean}</span></h4>
<div class="description">
Get a Component from the entity by its tag name
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>component</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Entity.js.html">Entity.js</a>, <a href="Entity.js.html#line136">line 136</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id="isAlive"><span class="type-signature"></span>isAlive<span class="signature">()</span><span class="type-signature"> → {boolean}</span></h4>
<div class="description">
Check if entity is alive
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Entity.js.html">Entity.js</a>, <a href="Entity.js.html#line218">line 218</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id="isRemove"><span class="type-signature"></span>isRemove<span class="signature">()</span><span class="type-signature"> → {boolean}</span></h4>
<div class="description">
Check if entity should be removed in next cycle
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Entity.js.html">Entity.js</a>, <a href="Entity.js.html#line226">line 226</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id="removeComponent"><span class="type-signature"></span>removeComponent<span class="signature">(component)</span><span class="type-signature"> → {<a href="Entity.html">Entity</a>}</span></h4>
<div class="description">
remove a Component from the entity
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>component</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Entity.js.html">Entity.js</a>, <a href="Entity.js.html#line151">line 151</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Entity.html">Entity</a></span>
</dd>
</dl>
<h4 class="name" id="removeListener"><span class="type-signature"></span>removeListener<span class="signature">(event)</span><span class="type-signature"> → {<a href="Entity.html">Entity</a>}</span></h4>
<div class="description">
Remove event listener
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>event</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Entity.js.html">Entity.js</a>, <a href="Entity.js.html#line64">line 64</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Entity.html">Entity</a></span>
</dd>
</dl>
<h4 class="name" id="setIndex"><span class="type-signature"></span>setIndex<span class="signature">(index)</span><span class="type-signature"></span></h4>
<div class="description">
Set index value of entity
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>index</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Entity.js.html">Entity.js</a>, <a href="Entity.js.html#line202">line 202</a>
</li></ul></dd>
</dl>
</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>