Skip to content

Commit

Permalink
Merge pull request #26 from ayebear/more-refactoring
Browse files Browse the repository at this point in the history
More refactoring
  • Loading branch information
ayebear authored Apr 7, 2018
2 parents ecc4231 + 74ab931 commit cf419be
Show file tree
Hide file tree
Showing 18 changed files with 17,763 additions and 15,541 deletions.
4,614 changes: 2,130 additions & 2,484 deletions docs/ast/source/component_index.js.json

Large diffs are not rendered by default.

9,935 changes: 5,039 additions & 4,896 deletions docs/ast/source/entity.js.json

Large diffs are not rendered by default.

938 changes: 856 additions & 82 deletions docs/ast/source/utilities.js.json

Large diffs are not rendered by default.

17,200 changes: 9,382 additions & 7,818 deletions docs/ast/source/world.js.json

Large diffs are not rendered by default.

44 changes: 28 additions & 16 deletions docs/class/src/entity.js~Entity.html
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ <h3 data-ice="anchor" id="instance-set-id">
<span class="right-info">


<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber49">source</a></span></span>
<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber51">source</a></span></span>
</span>
</h3>

Expand All @@ -770,7 +770,19 @@ <h3 data-ice="anchor" id="instance-set-id">




<div data-ice="throwWrap">
<h4>Throw:</h4>
<table>
<tbody>

<tr class="throw" data-ice="throw">
<td><p data-ice="throwName"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error">Error</a></span></p></td>
<td data-ice="throwDesc"><p>Cannot set entity id</p>
</td>
</tr>
</tbody>
</table>
</div>



Expand All @@ -796,7 +808,7 @@ <h3 data-ice="anchor" id="instance-method-access">
<span class="right-info">


<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber94">source</a></span></span>
<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber96">source</a></span></span>
</span>
</h3>

Expand Down Expand Up @@ -884,7 +896,7 @@ <h3 data-ice="anchor" id="instance-method-attach">
<span class="right-info">


<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber303">source</a></span></span>
<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber305">source</a></span></span>
</span>
</h3>

Expand Down Expand Up @@ -954,7 +966,7 @@ <h3 data-ice="anchor" id="instance-method-destroy">
<span class="right-info">


<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber215">source</a></span></span>
<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber217">source</a></span></span>
</span>
</h3>

Expand Down Expand Up @@ -1006,7 +1018,7 @@ <h3 data-ice="anchor" id="instance-method-detach">
<span class="right-info">


<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber322">source</a></span></span>
<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber324">source</a></span></span>
</span>
</h3>

Expand Down Expand Up @@ -1060,7 +1072,7 @@ <h3 data-ice="anchor" id="instance-method-fromJSON">
<span class="right-info">


<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber278">source</a></span></span>
<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber280">source</a></span></span>
</span>
</h3>

Expand Down Expand Up @@ -1142,7 +1154,7 @@ <h3 data-ice="anchor" id="instance-method-get">
<span class="right-info">


<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber79">source</a></span></span>
<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber81">source</a></span></span>
</span>
</h3>

Expand Down Expand Up @@ -1223,7 +1235,7 @@ <h3 data-ice="anchor" id="instance-method-has">
<span class="right-info">


<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber65">source</a></span></span>
<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber67">source</a></span></span>
</span>
</h3>

Expand Down Expand Up @@ -1306,7 +1318,7 @@ <h3 data-ice="anchor" id="instance-method-remove">
<span class="right-info">


<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber174">source</a></span></span>
<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber176">source</a></span></span>
</span>
</h3>

Expand Down Expand Up @@ -1389,7 +1401,7 @@ <h3 data-ice="anchor" id="instance-method-removeAll">
<span class="right-info">


<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber202">source</a></span></span>
<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber204">source</a></span></span>
</span>
</h3>

Expand Down Expand Up @@ -1453,7 +1465,7 @@ <h3 data-ice="anchor" id="instance-method-set">
<span class="right-info">


<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber120">source</a></span></span>
<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber122">source</a></span></span>
</span>
</h3>

Expand Down Expand Up @@ -1551,7 +1563,7 @@ <h3 data-ice="anchor" id="instance-method-toJSON">
<span class="right-info">


<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber263">source</a></span></span>
<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber265">source</a></span></span>
</span>
</h3>

Expand Down Expand Up @@ -1616,7 +1628,7 @@ <h3 data-ice="anchor" id="instance-method-toString">
<span class="right-info">


<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber250">source</a></span></span>
<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber252">source</a></span></span>
</span>
</h3>

Expand Down Expand Up @@ -1680,7 +1692,7 @@ <h3 data-ice="anchor" id="instance-method-update">
<span class="right-info">


<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber151">source</a></span></span>
<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber153">source</a></span></span>
</span>
</h3>

Expand Down Expand Up @@ -1768,7 +1780,7 @@ <h3 data-ice="anchor" id="instance-method-valid">
<span class="right-info">


<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber236">source</a></span></span>
<span data-ice="source"><span><a href="file/src/entity.js.html#lineNumber238">source</a></span></span>
</span>
</h3>

Expand Down
71 changes: 37 additions & 34 deletions docs/class/src/world.js~World.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@



<span data-ice="source">| <span><a href="file/src/world.js.html#lineNumber24">source</a></span></span>
<span data-ice="source">| <span><a href="file/src/world.js.html#lineNumber15">source</a></span></span>
</div>

<div class="self-detail detail">
Expand Down Expand Up @@ -365,7 +365,7 @@ <h1 data-ice="name">World</h1>



<span class="code" data-ice="name"><span><a href="class/src/world.js~World.html#instance-method-system">system</a></span></span><span class="code" data-ice="signature">(components: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a></span>, systemClass: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></span>, args: ...<span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span></span>
<span class="code" data-ice="name"><span><a href="class/src/world.js~World.html#instance-method-system">system</a></span></span><span class="code" data-ice="signature">(args: ...<span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span></span>
</p>
</div>
<div>
Expand Down Expand Up @@ -402,7 +402,7 @@ <h3 data-ice="anchor" id="instance-constructor-constructor">
<span class="right-info">


<span data-ice="source"><span><a href="file/src/world.js.html#lineNumber28">source</a></span></span>
<span data-ice="source"><span><a href="file/src/world.js.html#lineNumber19">source</a></span></span>
</span>
</h3>

Expand Down Expand Up @@ -450,7 +450,7 @@ <h3 data-ice="anchor" id="instance-method-clear">
<span class="right-info">


<span data-ice="source"><span><a href="file/src/world.js.html#lineNumber55">source</a></span></span>
<span data-ice="source"><span><a href="file/src/world.js.html#lineNumber52">source</a></span></span>
</span>
</h3>

Expand Down Expand Up @@ -502,7 +502,7 @@ <h3 data-ice="anchor" id="instance-method-component">
<span class="right-info">


<span data-ice="source"><span><a href="file/src/world.js.html#lineNumber95">source</a></span></span>
<span data-ice="source"><span><a href="file/src/world.js.html#lineNumber89">source</a></span></span>
</span>
</h3>

Expand Down Expand Up @@ -601,7 +601,7 @@ <h3 data-ice="anchor" id="instance-method-entity">
<span class="right-info">


<span data-ice="source"><span><a href="file/src/world.js.html#lineNumber116">source</a></span></span>
<span data-ice="source"><span><a href="file/src/world.js.html#lineNumber110">source</a></span></span>
</span>
</h3>

Expand Down Expand Up @@ -686,7 +686,7 @@ <h3 data-ice="anchor" id="instance-method-every">
<span class="right-info">


<span data-ice="source"><span><a href="file/src/world.js.html#lineNumber236">source</a></span></span>
<span data-ice="source"><span><a href="file/src/world.js.html#lineNumber259">source</a></span></span>
</span>
</h3>

Expand Down Expand Up @@ -789,7 +789,7 @@ <h3 data-ice="anchor" id="instance-method-get">
<span class="right-info">


<span data-ice="source"><span><a href="file/src/world.js.html#lineNumber273">source</a></span></span>
<span data-ice="source"><span><a href="file/src/world.js.html#lineNumber296">source</a></span></span>
</span>
</h3>

Expand Down Expand Up @@ -871,7 +871,7 @@ <h3 data-ice="anchor" id="instance-method-initialize">
<span class="right-info">


<span data-ice="source"><span><a href="file/src/world.js.html#lineNumber177">source</a></span></span>
<span data-ice="source"><span><a href="file/src/world.js.html#lineNumber200">source</a></span></span>
</span>
</h3>

Expand Down Expand Up @@ -939,7 +939,7 @@ <h3 data-ice="anchor" id="instance-method-prototype">
<span class="right-info">


<span data-ice="source"><span><a href="file/src/world.js.html#lineNumber293">source</a></span></span>
<span data-ice="source"><span><a href="file/src/world.js.html#lineNumber316">source</a></span></span>
</span>
</h3>

Expand Down Expand Up @@ -1026,7 +1026,7 @@ <h3 data-ice="anchor" id="instance-method-run">
<span class="right-info">


<span data-ice="source"><span><a href="file/src/world.js.html#lineNumber204">source</a></span></span>
<span data-ice="source"><span><a href="file/src/world.js.html#lineNumber227">source</a></span></span>
</span>
</h3>

Expand Down Expand Up @@ -1079,8 +1079,8 @@ <h4>Example:</h4>

<pre class="prettyprint source-code"><code data-ice="exampleCode">// Example flow of method call order:
// Setup systems:
world.system([], systemA)
world.system([], systemB)
world.system(systemA)
world.system(systemB)
// During world.run():
// systemA.pre()
// systemA.every() * number of entities
Expand All @@ -1104,11 +1104,11 @@ <h3 data-ice="anchor" id="instance-method-system">



<span class="code" data-ice="name">system</span><span class="code" data-ice="signature">(components: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a></span>, systemClass: <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></span>, args: ...<span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span></span>
<span class="code" data-ice="name">system</span><span class="code" data-ice="signature">(args: ...<span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></span>): <span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span></span>
<span class="right-info">


<span data-ice="source"><span><a href="file/src/world.js.html#lineNumber156">source</a></span></span>
<span data-ice="source"><span><a href="file/src/world.js.html#lineNumber167">source</a></span></span>
</span>
</h3>

Expand All @@ -1130,26 +1130,13 @@ <h4 data-ice="title">Params:</h4>
<tbody>

<tr data-ice="property" data-depth="0">
<td data-ice="name" class="code" data-depth="0">components</td>
<td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a></span></td>
<td data-ice="appendix"></td>
<td data-ice="description"><p>The list of components the system will process in every(). This follows the same logic as entity.has() and world.every().</p>
</td>
</tr>
<tr data-ice="property" data-depth="0">
<td data-ice="name" class="code" data-depth="0">systemClass</td>
<td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></span></td>
<td data-ice="appendix"></td>
<td data-ice="description"><p>The system class to instantiate. Can contain the following methods: constructor, initialize,
pre, every, post. Pre() and post() get called before and after every(), for each of the independent systems. See world.run()
for an example of the call order.</p>
</td>
</tr>
<tr data-ice="property" data-depth="0">
<td data-ice="name" class="code" data-depth="0">args</td>
<td data-ice="type" class="code">...<span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></span></td>
<td data-ice="appendix"><ul><li>optional</li></ul></td>
<td data-ice="description"><p>The arguments to forward to the system&apos;s constructors</p>
<td data-ice="appendix"></td>
<td data-ice="description"><p>Both signatures are accepted: (components, systemClass, ...args) or (systemClass, ...args).</p>
<p><strong>[components]</strong>: The list of components the system will process in every(). This follows the same logic as entity.has() and world.every().</p>
<p><strong>{systemClass}</strong>: The system class to instantiate. Can contain the following methods: constructor, initialize, pre, every, post. Pre() and post() get called before and after every(), for each of the independent systems. See world.run() for an example of the call order.</p>
<p><strong>[...args]</strong>: The arguments to forward to the system&apos;s constructors.</p>
</td>
</tr>
</tbody>
Expand Down Expand Up @@ -1187,11 +1174,27 @@ <h4>Example:</h4>

<pre class="prettyprint source-code"><code data-ice="exampleCode">// Movement system
world.system([&apos;position&apos;, &apos;velocity&apos;], class {
constructor(context) {
// This is showing how you can optionally pass parameters to the system&apos;s constructor
this.context = context
}
every(position, velocity, entity) {
position.x += velocity.x
position.y += velocity.y
}
})</code></pre>
}, context)</code></pre>
</div>
<div class="example-doc" data-ice="exampleDoc">

<pre class="prettyprint source-code"><code data-ice="exampleCode">// System that doesn&apos;t use every()
world.system(class {
constructor(context) {
this.context = context
}
pre() {
// Handle events or something
}
}, context)</code></pre>
</div>
</div>

Expand Down
18 changes: 9 additions & 9 deletions docs/coverage.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
14,
25,
31,
51,
68,
75,
82,
87
49,
66,
73,
80,
85
]
},
"src/entity.js": {
Expand All @@ -27,13 +27,13 @@
"undocumentLines": []
},
"src/utilities.js": {
"expectCount": 1,
"actualCount": 1,
"expectCount": 2,
"actualCount": 2,
"undocumentLines": []
},
"src/world.js": {
"expectCount": 21,
"actualCount": 21,
"expectCount": 20,
"actualCount": 20,
"undocumentLines": []
}
}
Expand Down
Loading

0 comments on commit cf419be

Please sign in to comment.