summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--codeclimate/export-coverage.rb2
-rw-r--r--component_manager.rb36
-rw-r--r--docs/FelFlame.html4
-rw-r--r--docs/FelFlame/Components.html2
-rw-r--r--docs/FelFlame/Entities.html82
-rw-r--r--docs/FelFlame/Helper.html2
-rw-r--r--docs/FelFlame/Helper/ComponentManager.html378
-rw-r--r--docs/FelFlame/Systems.html1174
-rw-r--r--docs/_index.html2
-rw-r--r--docs/file.README.html37
-rw-r--r--docs/index.html37
-rw-r--r--docs/method_list.html152
-rw-r--r--docs/top-level-namespace.html2
-rw-r--r--entity_manager.rb37
-rw-r--r--spec/entity_manager_spec.rb31
-rw-r--r--spec/system_manager_spec.rb185
-rw-r--r--system_manager.rb110
17 files changed, 2107 insertions, 166 deletions
diff --git a/codeclimate/export-coverage.rb b/codeclimate/export-coverage.rb
index a7a2c12..7a63acd 100644
--- a/codeclimate/export-coverage.rb
+++ b/codeclimate/export-coverage.rb
@@ -4,6 +4,8 @@ require_relative 'env'
class ReportCoverage
class <<self
def format
+ puts
+ puts 'Formatting Coverage...'
puts `./codeclimate/test-reporter-latest-linux-amd64 format-coverage -t simplecov`
end
diff --git a/component_manager.rb b/component_manager.rb
index f4402b3..a29aac8 100644
--- a/component_manager.rb
+++ b/component_manager.rb
@@ -56,6 +56,18 @@ class FelFlame
# @return [Integer]
attr_accessor :id
+ attr_writer :addition_triggers
+
+ def addition_triggers
+ @addition_triggers ||= []
+ end
+
+ attr_writer :removal_triggers
+
+ def removal_triggers
+ @removal_triggers ||= []
+ end
+
# Creates a new component and sets the values of the attributes given to it. If an attritbute is not passed then it will remain as the default.
# @param attrs [Keyword: Value] You can pass any number of Keyword-Value pairs
# @return [Component]
@@ -80,6 +92,18 @@ class FelFlame
end
class <<self
+ attr_writer :addition_triggers
+
+ def addition_triggers
+ @addition_triggers ||= []
+ end
+
+ attr_writer :removal_triggers
+
+ def removal_triggers
+ @removal_triggers ||= []
+ end
+
# @return [Array<Component>] Array of all Components that belong to a given component manager
# @!visibility private
def data
@@ -128,11 +152,17 @@ class FelFlame
# Removes this component from the list and purges all references to this Component from other Entities, as well as its {id ID} and data.
# @return [Boolean] true.
def delete
- entities.each do |entity_id|
- FelFlame::Entities[entity_id].remove self
+ addition_triggers.each do |system|
+ system.clear_triggers component_or_manager: self
+ end
+ # This needs to be cloned because indices get deleted as
+ # the remove command is called, breaking the loop if it
+ # wasn't referencing a clone(will get Nil errors)
+ iter = entities.map(&:clone)
+ iter.each do |entity_id|
+ FelFlame::Entities[entity_id].remove self #unless FelFlame::Entities[entity_id].nil?
end
self.class.data[id] = nil
- @entities = nil
instance_variables.each do |var|
instance_variable_set(var, nil)
end
diff --git a/docs/FelFlame.html b/docs/FelFlame.html
index 1dba2dc..13eb3f1 100644
--- a/docs/FelFlame.html
+++ b/docs/FelFlame.html
@@ -95,7 +95,7 @@
<dl>
<dt>Defined in:</dt>
<dd>component_manager.rb<span class="defines">,<br />
- entity_manager.rb,<br /> felflame.rb</span>
+ system_manager.rb,<br /> entity_manager.rb,<br /> felflame.rb</span>
</dd>
</dl>
@@ -193,7 +193,7 @@
</div>
<div id="footer">
- Generated on Sat Jun 12 03:12:49 2021 by
+ Generated on Wed Jun 16 07:08:52 2021 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.26 (ruby-2.7.3).
</div>
diff --git a/docs/FelFlame/Components.html b/docs/FelFlame/Components.html
index 54946ae..3472ea0 100644
--- a/docs/FelFlame/Components.html
+++ b/docs/FelFlame/Components.html
@@ -403,7 +403,7 @@
</div>
<div id="footer">
- Generated on Sat Jun 12 03:12:49 2021 by
+ Generated on Wed Jun 16 07:08:52 2021 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.26 (ruby-2.7.3).
</div>
diff --git a/docs/FelFlame/Entities.html b/docs/FelFlame/Entities.html
index 7669d53..e91c2c0 100644
--- a/docs/FelFlame/Entities.html
+++ b/docs/FelFlame/Entities.html
@@ -643,12 +643,12 @@
<pre class="lines">
-104
-105
-106</pre>
+113
+114
+115</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'entity_manager.rb', line 104</span>
+ <pre class="code"><span class="info file"># File 'entity_manager.rb', line 113</span>
<span class='kw'>def</span> <span class='op'>[]</span><span class='lparen'>(</span><span class='id identifier rubyid_entity_id'>entity_id</span><span class='rparen'>)</span>
<span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_entity_id'>entity_id</span><span class='rbracket'>]</span>
@@ -670,7 +670,7 @@
</h3><div class="docstring">
<div class="discussion">
-<p>Iterates over all entities. In general when using ECS the use of this method should never be neccassary unless you are doing something very wrong, however I will not stop you. You also call other enumerable methods instead of each, such as <code>each_with_index</code> or <code>select</code></p>
+<p>Iterates over all entities. The data is compacted so that means index does not correlate to ID. You also call other enumerable methods instead of each, such as <code>each_with_index</code> or <code>select</code></p>
</div>
@@ -697,15 +697,15 @@
<pre class="lines">
-111
-112
-113</pre>
+120
+121
+122</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'entity_manager.rb', line 111</span>
+ <pre class="code"><span class="info file"># File 'entity_manager.rb', line 120</span>
<span class='kw'>def</span> <span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
- <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
+ <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
@@ -774,10 +774,10 @@
<pre class="lines">
-119</pre>
+128</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'entity_manager.rb', line 119</span>
+ <pre class="code"><span class="info file"># File 'entity_manager.rb', line 128</span>
<span class='kw'>def</span> <span class='id identifier rubyid_from_json'>from_json</span><span class='lparen'>(</span><span class='id identifier rubyid_json_string'>json_string</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_opts'>opts</span><span class='rparen'>)</span> <span class='kw'>end</span></pre>
</td>
@@ -814,7 +814,7 @@
<li>
- <span class='name'>component</span>
+ <span class='name'>components_to_add</span>
<span class='type'>(<tt>Component</tt>)</span>
@@ -855,7 +855,6 @@
<pre class="lines">
-54
55
56
57
@@ -868,26 +867,23 @@
64
65
66
-67
-68</pre>
+67</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'entity_manager.rb', line 54</span>
+ <pre class="code"><span class="info file"># File 'entity_manager.rb', line 55</span>
<span class='kw'>def</span> <span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_components_to_add'>components_to_add</span><span class='rparen'>)</span>
- <span class='id identifier rubyid_added'>added</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='id identifier rubyid_components_to_add'>components_to_add</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_component'>component</span><span class='op'>|</span>
<span class='kw'>if</span> <span class='id identifier rubyid_components'>components</span><span class='lbracket'>[</span><span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
<span class='id identifier rubyid_components'>components</span><span class='lbracket'>[</span><span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span><span class='rbracket'>]</span>
<span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_entities'>entities</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span> <span class='id identifier rubyid_id'>id</span>
- <span class='id identifier rubyid_added'>added</span> <span class='op'>=</span><span class='kw'>true</span>
+ <span class='id identifier rubyid_check_systems'>check_systems</span> <span class='id identifier rubyid_component'>component</span><span class='comma'>,</span> <span class='symbol'>:addition_triggers</span>
<span class='kw'>elsif</span> <span class='op'>!</span><span class='id identifier rubyid_components'>components</span><span class='lbracket'>[</span><span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span>
<span class='id identifier rubyid_components'>components</span><span class='lbracket'>[</span><span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span> <span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span>
<span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_entities'>entities</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span> <span class='id identifier rubyid_id'>id</span>
- <span class='id identifier rubyid_added'>added</span> <span class='op'>=</span> <span class='kw'>true</span>
+ <span class='id identifier rubyid_check_systems'>check_systems</span> <span class='id identifier rubyid_component'>component</span><span class='comma'>,</span> <span class='symbol'>:addition_triggers</span>
<span class='kw'>end</span>
<span class='kw'>end</span>
- <span class='id identifier rubyid_added'>added</span>
<span class='kw'>end</span></pre>
</td>
</tr>
@@ -1002,7 +998,8 @@
46
47
48
-49</pre>
+49
+50</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'entity_manager.rb', line 39</span>
@@ -1011,11 +1008,12 @@
<span class='id identifier rubyid_components'>components</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_component_manager'>component_manager</span><span class='comma'>,</span> <span class='id identifier rubyid_component_array'>component_array</span><span class='op'>|</span>
<span class='id identifier rubyid_component_array'>component_array</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_component_id'>component_id</span><span class='op'>|</span>
<span class='id identifier rubyid_component_manager'>component_manager</span><span class='lbracket'>[</span><span class='id identifier rubyid_component_id'>component_id</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_entities'>entities</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_id'>id</span><span class='rparen'>)</span>
- <span class='kw'>end</span>
+ <span class='comment'>#self.remove FelFlame::Components.const_get(component_manager.name)[component_id]
+</span> <span class='kw'>end</span>
<span class='kw'>end</span>
<span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Entities (class)">Entities</a></span></span><span class='period'>.</span><span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_id'>id</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='kw'>nil</span>
+ <span class='ivar'>@components</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
<span class='ivar'>@id</span> <span class='op'>=</span> <span class='kw'>nil</span>
- <span class='ivar'>@components</span> <span class='op'>=</span> <span class='kw'>nil</span>
<span class='kw'>true</span>
<span class='kw'>end</span></pre>
</td>
@@ -1046,7 +1044,7 @@
<li>
- <span class='name'>component_to_remove</span>
+ <span class='name'>components_to_remove</span>
<span class='type'>(<tt>Component</tt>)</span>
@@ -1087,29 +1085,25 @@
<pre class="lines">
-73
-74
-75
-76
-77
-78
-79
-80
-81
-82</pre>
+84
+85
+86
+87
+88
+89
+90
+91</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'entity_manager.rb', line 73</span>
+ <pre class="code"><span class="info file"># File 'entity_manager.rb', line 84</span>
<span class='kw'>def</span> <span class='id identifier rubyid_remove'>remove</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_components_to_remove'>components_to_remove</span><span class='rparen'>)</span>
- <span class='id identifier rubyid_removed'>removed</span> <span class='op'>=</span> <span class='kw'>false</span>
<span class='id identifier rubyid_components_to_remove'>components_to_remove</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_component'>component</span><span class='op'>|</span>
+ <span class='id identifier rubyid_check_systems'>check_systems</span> <span class='id identifier rubyid_component'>component</span><span class='comma'>,</span> <span class='symbol'>:removal_triggers</span> <span class='kw'>if</span> <span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_entities'>entities</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='id identifier rubyid_id'>id</span>
+ <span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_entities'>entities</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='id identifier rubyid_id'>id</span>
<span class='id identifier rubyid_components'>components</span><span class='lbracket'>[</span><span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span>
- <span class='kw'>if</span> <span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_entities'>entities</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='id identifier rubyid_id'>id</span>
- <span class='id identifier rubyid_removed'>removed</span> <span class='op'>=</span> <span class='kw'>true</span>
- <span class='kw'>end</span>
<span class='kw'>end</span>
- <span class='id identifier rubyid_removed'>removed</span>
+ <span class='kw'>true</span>
<span class='kw'>end</span></pre>
</td>
</tr>
@@ -1214,10 +1208,10 @@
<pre class="lines">
-87</pre>
+96</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'entity_manager.rb', line 87</span>
+ <pre class="code"><span class="info file"># File 'entity_manager.rb', line 96</span>
<span class='kw'>def</span> <span class='id identifier rubyid_to_json'>to_json</span><span class='lparen'>(</span><span class='rparen'>)</span> <span class='kw'>end</span></pre>
</td>
@@ -1230,7 +1224,7 @@
</div>
<div id="footer">
- Generated on Sat Jun 12 03:12:49 2021 by
+ Generated on Wed Jun 16 07:08:52 2021 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.26 (ruby-2.7.3).
</div>
diff --git a/docs/FelFlame/Helper.html b/docs/FelFlame/Helper.html
index 497de3a..19f40b6 100644
--- a/docs/FelFlame/Helper.html
+++ b/docs/FelFlame/Helper.html
@@ -132,7 +132,7 @@
</div>
<div id="footer">
- Generated on Sat Jun 12 03:12:49 2021 by
+ Generated on Wed Jun 16 07:08:52 2021 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.26 (ruby-2.7.3).
</div>
diff --git a/docs/FelFlame/Helper/ComponentManager.html b/docs/FelFlame/Helper/ComponentManager.html
index 7f6e857..425d91b 100644
--- a/docs/FelFlame/Helper/ComponentManager.html
+++ b/docs/FelFlame/Helper/ComponentManager.html
@@ -114,12 +114,92 @@
+ <h2>Class Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
+ <ul class="summary">
+
+ <li class="public ">
+ <span class="summary_signature">
+
+ <a href="#addition_triggers-class_method" title="addition_triggers (class method)">.<strong>addition_triggers</strong> &#x21d2; Object </a>
+
+
+
+ </span>
+
+
+
+
+
+
+
+
+
+
+
+
+ <span class="summary_desc"><div class='inline'></div></span>
+
+</li>
+
+
+ <li class="public ">
+ <span class="summary_signature">
+
+ <a href="#removal_triggers-class_method" title="removal_triggers (class method)">.<strong>removal_triggers</strong> &#x21d2; Object </a>
+
+
+
+ </span>
+
+
+
+
+
+
+
+
+
+
+
+
+ <span class="summary_desc"><div class='inline'></div></span>
+
+</li>
+
+
+ </ul>
+
<h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
+ <a href="#addition_triggers-instance_method" title="#addition_triggers (instance method)">#<strong>addition_triggers</strong> &#x21d2; Object </a>
+
+
+
+ </span>
+
+
+
+
+
+
+
+
+
+
+
+
+ <span class="summary_desc"><div class='inline'></div></span>
+
+</li>
+
+
+ <li class="public ">
+ <span class="summary_signature">
+
<a href="#id-instance_method" title="#id (instance method)">#<strong>id</strong> &#x21d2; Integer </a>
@@ -144,6 +224,31 @@
</li>
+ <li class="public ">
+ <span class="summary_signature">
+
+ <a href="#removal_triggers-instance_method" title="#removal_triggers (instance method)">#<strong>removal_triggers</strong> &#x21d2; Object </a>
+
+
+
+ </span>
+
+
+
+
+
+
+
+
+
+
+
+
+ <span class="summary_desc"><div class='inline'></div></span>
+
+</li>
+
+
</ul>
@@ -436,28 +541,28 @@
<pre class="lines">
-62
-63
-64
-65
-66
-67
-68
-69
-70
-71
-72
-73
74
75
76
77
78
79
-80</pre>
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'component_manager.rb', line 62</span>
+ <pre class="code"><span class="info file"># File 'component_manager.rb', line 74</span>
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_attrs'>attrs</span><span class='rparen'>)</span>
<span class='comment'># Prepare the object
@@ -485,13 +590,114 @@
</div>
+ <div id="class_attr_details" class="attr_details">
+ <h2>Class Attribute Details</h2>
+
+
+ <span id="addition_triggers=-class_method"></span>
+ <div class="method_details first">
+ <h3 class="signature first" id="addition_triggers-class_method">
+
+ .<strong>addition_triggers</strong> &#x21d2; <tt>Object</tt>
+
+
+
+
+
+</h3><table class="source_code">
+ <tr>
+ <td>
+ <pre class="lines">
+
+
+97
+98
+99</pre>
+ </td>
+ <td>
+ <pre class="code"><span class="info file"># File 'component_manager.rb', line 97</span>
+
+<span class='kw'>def</span> <span class='id identifier rubyid_addition_triggers'>addition_triggers</span>
+ <span class='ivar'>@addition_triggers</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
+<span class='kw'>end</span></pre>
+ </td>
+ </tr>
+</table>
+</div>
+
+
+ <span id="removal_triggers=-class_method"></span>
+ <div class="method_details ">
+ <h3 class="signature " id="removal_triggers-class_method">
+
+ .<strong>removal_triggers</strong> &#x21d2; <tt>Object</tt>
+
+
+
+
+
+</h3><table class="source_code">
+ <tr>
+ <td>
+ <pre class="lines">
+
+
+103
+104
+105</pre>
+ </td>
+ <td>
+ <pre class="code"><span class="info file"># File 'component_manager.rb', line 103</span>
+
+<span class='kw'>def</span> <span class='id identifier rubyid_removal_triggers'>removal_triggers</span>
+ <span class='ivar'>@removal_triggers</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
+<span class='kw'>end</span></pre>
+ </td>
+ </tr>
+</table>
+</div>
+
+ </div>
+
<div id="instance_attr_details" class="attr_details">
<h2>Instance Attribute Details</h2>
- <span id="id=-instance_method"></span>
+ <span id="addition_triggers=-instance_method"></span>
<div class="method_details first">
- <h3 class="signature first" id="id-instance_method">
+ <h3 class="signature first" id="addition_triggers-instance_method">
+
+ #<strong>addition_triggers</strong> &#x21d2; <tt>Object</tt>
+
+
+
+
+
+</h3><table class="source_code">
+ <tr>
+ <td>
+ <pre class="lines">
+
+
+61
+62
+63</pre>
+ </td>
+ <td>
+ <pre class="code"><span class="info file"># File 'component_manager.rb', line 61</span>
+
+<span class='kw'>def</span> <span class='id identifier rubyid_addition_triggers'>addition_triggers</span>
+ <span class='ivar'>@addition_triggers</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
+<span class='kw'>end</span></pre>
+ </td>
+ </tr>
+</table>
+</div>
+
+
+ <span id="id=-instance_method"></span>
+ <div class="method_details ">
+ <h3 class="signature " id="id-instance_method">
#<strong>id</strong> &#x21d2; <tt>Integer</tt>
@@ -544,6 +750,38 @@
</table>
</div>
+
+ <span id="removal_triggers=-instance_method"></span>
+ <div class="method_details ">
+ <h3 class="signature " id="removal_triggers-instance_method">
+
+ #<strong>removal_triggers</strong> &#x21d2; <tt>Object</tt>
+
+
+
+
+
+</h3><table class="source_code">
+ <tr>
+ <td>
+ <pre class="lines">
+
+
+67
+68
+69</pre>
+ </td>
+ <td>
+ <pre class="code"><span class="info file"># File 'component_manager.rb', line 67</span>
+
+<span class='kw'>def</span> <span class='id identifier rubyid_removal_triggers'>removal_triggers</span>
+ <span class='ivar'>@removal_triggers</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
+<span class='kw'>end</span></pre>
+ </td>
+ </tr>
+</table>
+</div>
+
</div>
@@ -619,12 +857,12 @@
<pre class="lines">
-96
-97
-98</pre>
+120
+121
+122</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'component_manager.rb', line 96</span>
+ <pre class="code"><span class="info file"># File 'component_manager.rb', line 120</span>
<span class='kw'>def</span> <span class='op'>[]</span><span class='lparen'>(</span><span class='id identifier rubyid_component_id'>component_id</span><span class='rparen'>)</span>
<span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_component_id'>component_id</span><span class='rbracket'>]</span>
@@ -673,12 +911,12 @@
<pre class="lines">
-103
-104
-105</pre>
+127
+128
+129</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'component_manager.rb', line 103</span>
+ <pre class="code"><span class="info file"># File 'component_manager.rb', line 127</span>
<span class='kw'>def</span> <span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
<span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
@@ -738,14 +976,14 @@
<pre class="lines">
-143
-144
-145
-146
-147</pre>
+173
+174
+175
+176
+177</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'component_manager.rb', line 143</span>
+ <pre class="code"><span class="info file"># File 'component_manager.rb', line 173</span>
<span class='kw'>def</span> <span class='id identifier rubyid_attrs'>attrs</span>
<span class='id identifier rubyid_instance_variables'>instance_variables</span><span class='period'>.</span><span class='id identifier rubyid_each_with_object'>each_with_object</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_final'>final</span><span class='op'>|</span>
@@ -801,27 +1039,39 @@
<pre class="lines">
-130
-131
-132
-133
-134
-135
-136
-137
-138
-139
-140</pre>
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'component_manager.rb', line 130</span>
+ <pre class="code"><span class="info file"># File 'component_manager.rb', line 154</span>
<span class='kw'>def</span> <span class='id identifier rubyid_delete'>delete</span>
- <span class='id identifier rubyid_entities'>entities</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_entity_id'>entity_id</span><span class='op'>|</span>
- <span class='const'><span class='object_link'><a href="../../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='lbracket'>[</span><span class='id identifier rubyid_entity_id'>entity_id</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_remove'>remove</span> <span class='kw'>self</span>
+ <span class='id identifier rubyid_addition_triggers'>addition_triggers</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_system'>system</span><span class='op'>|</span>
+ <span class='id identifier rubyid_system'>system</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span> <span class='label'>component_or_manager:</span> <span class='kw'>self</span>
<span class='kw'>end</span>
+ <span class='comment'># This needs to be cloned because indices get deleted as
+</span> <span class='comment'># the remove command is called, breaking the loop if it
+</span> <span class='comment'># wasn&#39;t referencing a clone(will get Nil errors)
+</span> <span class='id identifier rubyid_iter'>iter</span> <span class='op'>=</span> <span class='id identifier rubyid_entities'>entities</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:clone</span><span class='rparen'>)</span>
+ <span class='id identifier rubyid_iter'>iter</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_entity_id'>entity_id</span><span class='op'>|</span>
+ <span class='const'><span class='object_link'><a href="../../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='lbracket'>[</span><span class='id identifier rubyid_entity_id'>entity_id</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_remove'>remove</span> <span class='kw'>self</span> <span class='comment'>#unless FelFlame::Entities[entity_id].nil?
+</span> <span class='kw'>end</span>
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_id'>id</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='kw'>nil</span>
- <span class='ivar'>@entities</span> <span class='op'>=</span> <span class='kw'>nil</span>
<span class='id identifier rubyid_instance_variables'>instance_variables</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_var'>var</span><span class='op'>|</span>
<span class='id identifier rubyid_instance_variable_set'>instance_variable_set</span><span class='lparen'>(</span><span class='id identifier rubyid_var'>var</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='rparen'>)</span>
<span class='kw'>end</span>
@@ -871,12 +1121,12 @@
<pre class="lines">
-116
-117
-118</pre>
+140
+141
+142</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'component_manager.rb', line 116</span>
+ <pre class="code"><span class="info file"># File 'component_manager.rb', line 140</span>
<span class='kw'>def</span> <span class='id identifier rubyid_entities'>entities</span>
<span class='ivar'>@entities</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
@@ -925,12 +1175,12 @@
<pre class="lines">
-110
-111
-112</pre>
+134
+135
+136</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'component_manager.rb', line 110</span>
+ <pre class="code"><span class="info file"># File 'component_manager.rb', line 134</span>
<span class='kw'>def</span> <span class='id identifier rubyid_to_i'>to_i</span>
<span class='id identifier rubyid_id'>id</span>
@@ -984,12 +1234,12 @@
<pre class="lines">
-152
-153
-154</pre>
+182
+183
+184</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'component_manager.rb', line 152</span>
+ <pre class="code"><span class="info file"># File 'component_manager.rb', line 182</span>
<span class='kw'>def</span> <span class='id identifier rubyid_to_json'>to_json</span>
<span class='comment'># should return a json or hash of all data in this component
@@ -1043,14 +1293,14 @@
<pre class="lines">
-122
-123
-124
-125
-126</pre>
+146
+147
+148
+149
+150</pre>
</td>
<td>
- <pre class="code"><span class="info file"># File 'component_manager.rb', line 122</span>
+ <pre class="code"><span class="info file"># File 'component_manager.rb', line 146</span>
<span class='kw'>def</span> <span class='id identifier rubyid_update_attrs'>update_attrs</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_opts'>opts</span><span class='rparen'>)</span>
<span class='id identifier rubyid_opts'>opts</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
@@ -1067,7 +1317,7 @@
</div>
<div id="footer">
- Generated on Sat Jun 12 03:12:49 2021 by
+ Generated on Wed Jun 16 07:08:52 2021 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.26 (ruby-2.7.3).
</div>
diff --git a/docs/FelFlame/Systems.html b/docs/FelFlame/Systems.html
index cfb3a95..65d463b 100644
--- a/docs/FelFlame/Systems.html
+++ b/docs/FelFlame/Systems.html
@@ -85,6 +85,11 @@
+ <dl>
+ <dt>Extended by:</dt>
+ <dd>Enumerable</dd>
+ </dl>
+
@@ -94,7 +99,9 @@
<dl>
<dt>Defined in:</dt>
- <dd>felflame.rb</dd>
+ <dd>felflame.rb<span class="defines">,<br />
+ system_manager.rb</span>
+</dd>
</dl>
</div>
@@ -116,15 +123,1178 @@
+ <h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
+ <ul class="summary">
+
+ <li class="public ">
+ <span class="summary_signature">
+
+ <a href="#addition_triggers-instance_method" title="#addition_triggers (instance method)">#<strong>addition_triggers</strong> &#x21d2; Object </a>
+
+
+
+ </span>
+
+
+
+
+
+
+
+
+
+
+
+
+ <span class="summary_desc"><div class='inline'></div></span>
+
+</li>
+
+
+ <li class="public ">
+ <span class="summary_signature">
+
+ <a href="#const_name-instance_method" title="#const_name (instance method)">#<strong>const_name</strong> &#x21d2; Object </a>
+
+
+
+ </span>
+
+
+
+
+
+
+
+
+
+
+
+
+ <span class="summary_desc"><div class='inline'>
+<p>The Constant name assigned to this System.</p>
+</div></span>
+
+</li>
+
+
+ <li class="public ">
+ <span class="summary_signature">
+
+ <a href="#frame-instance_method" title="#frame (instance method)">#<strong>frame</strong> &#x21d2; Object </a>
+
+
+
+ </span>
+
+
+
+
+
+
+
+
+
+
+
+
+ <span class="summary_desc"><div class='inline'>
+<p>How many frames need to pass before this System is executed when controlled by Stage.</p>
+</div></span>
+
+</li>
+
+
+ <li class="public ">
+ <span class="summary_signature">
+
+ <a href="#priority-instance_method" title="#priority (instance method)">#<strong>priority</strong> &#x21d2; Object </a>
+
+
+
+ </span>
+
+
+
+
+
+
+
+
+
+
+
+
+ <span class="summary_desc"><div class='inline'>
+<p>How early this System should be executed in a list of Systems.</p>
+</div></span>
+
+</li>
+
+
+ <li class="public ">
+ <span class="summary_signature">
+
+ <a href="#removal_triggers-instance_method" title="#removal_triggers (instance method)">#<strong>removal_triggers</strong> &#x21d2; Object </a>
+
+
+
+ </span>
+
+
+
+
+
+
+
+
+
+
+
+
+ <span class="summary_desc"><div class='inline'></div></span>
+
+</li>
+
+
+ </ul>
+
+
+
+
+
+ <h2>
+ Class Method Summary
+ <small><a href="#" class="summary_toggle">collapse</a></small>
+ </h2>
+
+ <ul class="summary">
+
+ <li class="public ">
+ <span class="summary_signature">
+
+ <a href="#each-class_method" title="each (class method)">.<strong>each</strong>(&amp;block) &#x21d2; Enumerator </a>
+
+
+
+ </span>
+
+
+
+
+
+
+
+
+
+ <span class="summary_desc"><div class='inline'>
+<p>Iterate over all Systems, sorted by their priority.</p>
+</div></span>
+
+</li>
+
+
+ </ul>
+
+ <h2>
+ Instance Method Summary
+ <small><a href="#" class="summary_toggle">collapse</a></small>
+ </h2>
+
+ <ul class="summary">
+
+ <li class="public ">
+ <span class="summary_signature">
+
+ <a href="#call-instance_method" title="#call (instance method)">#<strong>call</strong> &#x21d2; Object </a>
+
+
+
+ </span>
+
+
+
+
+
+
+
+
+
+ <span class="summary_desc"><div class='inline'>
+<p>Manually execute the system a single time.</p>
+</div></span>
+
+</li>
+
+
+ <li class="public ">
+ <span class="summary_signature">
+
+ <a href="#clear_triggers-instance_method" title="#clear_triggers (instance method)">#<strong>clear_triggers</strong>(*trigger_types, component_or_manager: nil) &#x21d2; Boolean </a>
+
+
+
+ </span>
+
+
+
+
+
+
+
+
+
+ <span class="summary_desc"><div class='inline'>
+<p>Removes triggers from this system.</p>
+</div></span>
+
+</li>
+
+
+ <li class="public ">
+ <span class="summary_signature">
+
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(name, priority: 0, &amp;block) &#x21d2; Systems </a>
+
+
+
+ </span>
+
+
+ <span class="note title constructor">constructor</span>
+
+
+
+
+
+
+
+
+ <span class="summary_desc"><div class='inline'>
+<p>Creates a new System which can be accessed as a constant under the namespace <span class='object_link'><a href="" title="FelFlame::Systems (class)">Systems</a></span>.</p>
+</div></span>
+
+</li>
+
+
+ <li class="public ">
+ <span class="summary_signature">
+
+ <a href="#redefine-instance_method" title="#redefine (instance method)">#<strong>redefine</strong>(&amp;block) &#x21d2; Object </a>
+
+
+
+ </span>
+
+
+
+
+
+
+
+
+
+ <span class="summary_desc"><div class='inline'>
+<p>Redefine what code is executed by this System when it is called upon.</p>
+</div></span>
+
+</li>
+
+
+ <li class="public ">
+ <span class="summary_signature">
+
+ <a href="#step-instance_method" title="#step (instance method)">#<strong>step</strong> &#x21d2; Boolean </a>
+
+
+
+ </span>
+
+
+
+
+
+
+
+
+
+ <span class="summary_desc"><div class='inline'>
+<p>Attempt to execute the system following the frame parameter set on this system.</p>
+</div></span>
+
+</li>
+
+
+ <li class="public ">
+ <span class="summary_signature">
+
+ <a href="#trigger_when_added-instance_method" title="#trigger_when_added (instance method)">#<strong>trigger_when_added</strong>(component_or_manager) &#x21d2; Boolean </a>
+
+
+
+ </span>
+
+
+
+
+
+
+
+
+
+ <span class="summary_desc"><div class='inline'>
+<p>Add a component or component manager so that it triggers this system when the component or a component from the component manager is added to an entity.</p>
+</div></span>
+
+</li>
+
+
+ <li class="public ">
+ <span class="summary_signature">
+
+ <a href="#trigger_when_removed-instance_method" title="#trigger_when_removed (instance method)">#<strong>trigger_when_removed</strong>(component_or_manager) &#x21d2; Boolean </a>
+
+
+
+ </span>
+
+
+
+
+
+
+
+
+
+ <span class="summary_desc"><div class='inline'>
+<p>Add a component or component manager so that it triggers this system when the component or a component from the component manager is removed from an entity.</p>
+</div></span>
+
+</li>
+
+
+ </ul>
+
+
+
+ <div id="constructor_details" class="method_details_list">
+ <h2>Constructor Details</h2>
+
+ <div class="method_details first">
+ <h3 class="signature first" id="initialize-instance_method">
+
+ #<strong>initialize</strong>(name, priority: 0, &amp;block) &#x21d2; <tt><span class='object_link'><a href="" title="FelFlame::Systems (class)">Systems</a></span></tt>
+
+
+
+
+
+</h3><div class="docstring">
+ <div class="discussion">
+
+<p>Creates a new System which can be accessed as a constant under the namespace <span class='object_link'><a href="" title="FelFlame::Systems (class)">FelFlame::Systems</a></span>. The name given is what constant the system is assigned to</p>
+
+
+ </div>
+</div>
+<div class="tags">
+
+ <div class="examples">
+ <p class="tag_title">Examples:</p>
+
+
+ <pre class="example code"><code><span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Systems (class)">Systems</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>PassiveHeal</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='op'>-</span><span class='int'>2</span><span class='comma'>,</span> <span class='label'>frame:</span> <span class='int'>2</span><span class='rparen'>)</span> <span class='kw'>do</span>
+ <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Components.html" title="FelFlame::Components (class)">Components</a></span></span><span class='op'>::</span><span class='const'>Health</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_component'>component</span><span class='op'>|</span>
+ <span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_hp'>hp</span> <span class='op'>+=</span> <span class='int'>5</span>
+ <span class='kw'>end</span>
+<span class='kw'>end</span>
+<span class='comment'># Only heal all characters with health every other frame.
+</span><span class='comment'># Give it a low priority so other systems such as a
+</span><span class='comment'># Poison system would kill the player first</span></code></pre>
+
+ </div>
+<p class="tag_title">Parameters:</p>
+<ul class="param">
+
+ <li>
+
+ <span class='name'>name</span>
+
+
+ <span class='type'>(<tt>String</tt>)</span>
+
+
+
+ &mdash;
+ <div class='inline'>
+<p>The name this system will use. Needs to to be in the Ruby Constant format.</p>
+</div>
+
+ </li>
+
+ <li>
+
+ <span class='name'>priority</span>
+
+
+ <span class='type'>(<tt>Integer</tt>)</span>
+
+
+ <em class="default">(defaults to: <tt>0</tt>)</em>
+
+
+ &mdash;
+ <div class='inline'>
+<p>Which priority order this system should be executed in relative to other systems. Higher means executed earlier.</p>
+</div>
+
+ </li>
+
+ <li>
+
+ <span class='name'>block</span>
+
+
+ <span class='type'>(<tt>Proc</tt>)</span>
+
+
+
+ &mdash;
+ <div class='inline'>
+<p>The code you wish to be executed when the system is triggered. Can be defined by using a <tt>do end</tt> block or using <tt>{ }</tt> braces.</p>
+</div>
+
+ </li>
+
+</ul>
+
+
+</div><table class="source_code">
+ <tr>
+ <td>
+ <pre class="lines">
+
+
+50
+51
+52
+53
+54
+55</pre>
+ </td>
+ <td>
+ <pre class="code"><span class="info file"># File 'system_manager.rb', line 50</span>
+
+<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>0</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
+ <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Systems (class)">Systems</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_set'>const_set</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
+ <span class='ivar'>@const_name</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span>
+ <span class='ivar'>@priority</span> <span class='op'>=</span> <span class='id identifier rubyid_priority'>priority</span>
+ <span class='ivar'>@block</span> <span class='op'>=</span> <span class='id identifier rubyid_block'>block</span>
+<span class='kw'>end</span></pre>
+ </td>
+ </tr>
+</table>
+</div>
+
+</div>
+
+ <div id="instance_attr_details" class="attr_details">
+ <h2>Instance Attribute Details</h2>
+
+
+ <span id="addition_triggers=-instance_method"></span>
+ <div class="method_details first">
+ <h3 class="signature first" id="addition_triggers-instance_method">
+
+ #<strong>addition_triggers</strong> &#x21d2; <tt>Object</tt>
+
+
+
+
+
+</h3><table class="source_code">
+ <tr>
+ <td>
+ <pre class="lines">
+
+
+14
+15
+16</pre>
+ </td>
+ <td>
+ <pre class="code"><span class="info file"># File 'system_manager.rb', line 14</span>
+
+<span class='kw'>def</span> <span class='id identifier rubyid_addition_triggers'>addition_triggers</span>
+ <span class='ivar'>@addition_triggers</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
+<span class='kw'>end</span></pre>
+ </td>
+ </tr>
+</table>
+</div>
+
+
+ <span id="const_name=-instance_method"></span>
+ <div class="method_details ">
+ <h3 class="signature " id="const_name-instance_method">
+
+ #<strong>const_name</strong> &#x21d2; <tt>Object</tt>
+
+
+
+
+
+</h3><div class="docstring">
+ <div class="discussion">
+
+<p>The Constant name assigned to this System</p>
+
+
+ </div>
+</div>
+<div class="tags">
+
+
+</div><table class="source_code">
+ <tr>
+ <td>
+ <pre class="lines">
+
+
+7
+8
+9</pre>
+ </td>
+ <td>
+ <pre class="code"><span class="info file"># File 'system_manager.rb', line 7</span>
+
+<span class='kw'>def</span> <span class='id identifier rubyid_const_name'>const_name</span>
+ <span class='ivar'>@const_name</span>
+<span class='kw'>end</span></pre>
+ </td>
+ </tr>
+</table>
+</div>
+
+
+ <span id="frame=-instance_method"></span>
+ <div class="method_details ">
+ <h3 class="signature " id="frame-instance_method">
+
+ #<strong>frame</strong> &#x21d2; <tt>Object</tt>
+
+
+
+
+
+</h3><div class="docstring">
+ <div class="discussion">
+
+<p>How many frames need to pass before this System is executed when controlled by FelFlame::Stage</p>
+
+
+ </div>
+</div>
+<div class="tags">
+
+
+</div><table class="source_code">
+ <tr>
+ <td>
+ <pre class="lines">
+
+
+10
+11
+12</pre>
+ </td>
+ <td>
+ <pre class="code"><span class="info file"># File 'system_manager.rb', line 10</span>
+
+<span class='kw'>def</span> <span class='id identifier rubyid_frame'>frame</span>
+ <span class='ivar'>@frame</span>
+<span class='kw'>end</span></pre>
+ </td>
+ </tr>
+</table>
+</div>
+
+
+ <span id="priority=-instance_method"></span>
+ <div class="method_details ">
+ <h3 class="signature " id="priority-instance_method">
+
+ #<strong>priority</strong> &#x21d2; <tt>Object</tt>
+
+
+
+
+
+</h3><div class="docstring">
+ <div class="discussion">
+
+<p>How early this System should be executed in a list of Systems</p>
+
+
+ </div>
+</div>
+<div class="tags">
+
+
+</div><table class="source_code">
+ <tr>
+ <td>
+ <pre class="lines">
+
+
+4
+5
+6</pre>
+ </td>
+ <td>
+ <pre class="code"><span class="info file"># File 'system_manager.rb', line 4</span>
+
+<span class='kw'>def</span> <span class='id identifier rubyid_priority'>priority</span>
+ <span class='ivar'>@priority</span>
+<span class='kw'>end</span></pre>
+ </td>
+ </tr>
+</table>
+</div>
+
+
+ <span id="removal_triggers=-instance_method"></span>
+ <div class="method_details ">
+ <h3 class="signature " id="removal_triggers-instance_method">
+
+ #<strong>removal_triggers</strong> &#x21d2; <tt>Object</tt>
+
+
+
+
+
+</h3><table class="source_code">
+ <tr>
+ <td>
+ <pre class="lines">
+
+
+20
+21
+22</pre>
+ </td>
+ <td>
+ <pre class="code"><span class="info file"># File 'system_manager.rb', line 20</span>
+
+<span class='kw'>def</span> <span class='id identifier rubyid_removal_triggers'>removal_triggers</span>
+ <span class='ivar'>@removal_triggers</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
+<span class='kw'>end</span></pre>
+ </td>
+ </tr>
+</table>
+</div>
+
+ </div>
+
+
+ <div id="class_method_details" class="method_details_list">
+ <h2>Class Method Details</h2>
+
+
+ <div class="method_details first">
+ <h3 class="signature first" id="each-class_method">
+
+ .<strong>each</strong>(&amp;block) &#x21d2; <tt>Enumerator</tt>
+
+
+
+
+
+</h3><div class="docstring">
+ <div class="discussion">
+
+<p>Iterate over all Systems, sorted by their priority. You also call other enumerable methods instead of each, such as <code>each_with_index</code> or <code>select</code></p>
+
+
+ </div>
+</div>
+<div class="tags">
+
+<p class="tag_title">Returns:</p>
+<ul class="return">
+
+ <li>
+
+
+ <span class='type'>(<tt>Enumerator</tt>)</span>
+
+
+
+ </li>
+
+</ul>
+
+</div><table class="source_code">
+ <tr>
+ <td>
+ <pre class="lines">
+
+
+29
+30
+31</pre>
+ </td>
+ <td>
+ <pre class="code"><span class="info file"># File 'system_manager.rb', line 29</span>
+
+<span class='kw'>def</span> <span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
+ <span class='id identifier rubyid_constants'>constants</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_sym'>sym</span><span class='op'>|</span> <span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_sym'>sym</span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_sort_by'>sort_by</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:priority</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_reverse'>reverse</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
+<span class='kw'>end</span></pre>
+ </td>
+ </tr>
+</table>
+</div>
+
+ </div>
+
+ <div id="instance_method_details" class="method_details_list">
+ <h2>Instance Method Details</h2>
+
+
+ <div class="method_details first">
+ <h3 class="signature first" id="call-instance_method">
+
+ #<strong>call</strong> &#x21d2; <tt>Object</tt>
+
+
+
+
+
+</h3><div class="docstring">
+ <div class="discussion">
+
+<p>Manually execute the system a single time</p>
+
+
+ </div>
+</div>
+<div class="tags">
+
+
+</div><table class="source_code">
+ <tr>
+ <td>
+ <pre class="lines">
+
+
+58
+59
+60</pre>
+ </td>
+ <td>
+ <pre class="code"><span class="info file"># File 'system_manager.rb', line 58</span>
+
+<span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span>
+ <span class='ivar'>@block</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span>
+<span class='kw'>end</span></pre>
+ </td>
+ </tr>
+</table>
+</div>
+
+ <div class="method_details ">
+ <h3 class="signature " id="clear_triggers-instance_method">
+
+ #<strong>clear_triggers</strong>(*trigger_types, component_or_manager: nil) &#x21d2; <tt>Boolean</tt>
+
+
+
+
+
+</h3><div class="docstring">
+ <div class="discussion">
+
+<p>Removes triggers from this system</p>
+
+
+ </div>
+</div>
+<div class="tags">
+ <p class="tag_title">Parameters:</p>
+<ul class="param">
+
+ <li>
+
+ <span class='name'>component_or_manager</span>
+
+
+ <span class='type'>(<tt>Component or ComponentManager</tt>)</span>
+
+
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
+
+
+ &mdash;
+ <div class='inline'>
+<p>The object to clear triggers from. Use Nil to clear triggers from all components associated with this system.</p>
+</div>
+
+ </li>
+
+</ul>
+
+<p class="tag_title">Returns:</p>
+<ul class="return">
+
+ <li>
+
+
+ <span class='type'>(<tt>Boolean</tt>)</span>
+
+
+
+ &mdash;
+ <div class='inline'>
+<p>true</p>
+</div>
+
+ </li>
+
+</ul>
+
+</div><table class="source_code">
+ <tr>
+ <td>
+ <pre class="lines">
+
+
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91</pre>
+ </td>
+ <td>
+ <pre class="code"><span class="info file"># File 'system_manager.rb', line 77</span>
+
+<span class='kw'>def</span> <span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_trigger_types'>trigger_types</span><span class='comma'>,</span> <span class='label'>component_or_manager:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
+ <span class='id identifier rubyid_trigger_types'>trigger_types</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='symbol'>:addition_triggers</span><span class='comma'>,</span> <span class='symbol'>:removal_triggers</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='id identifier rubyid_trigger_types'>trigger_types</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
+ <span class='id identifier rubyid_trigger_types'>trigger_types</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_trigger_type'>trigger_type</span><span class='op'>|</span>
+ <span class='kw'>if</span> <span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
+ <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_trigger_type'>trigger_type</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_trigger'>trigger</span><span class='op'>|</span>
+ <span class='id identifier rubyid_trigger'>trigger</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_trigger_type'>trigger_type</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='kw'>self</span>
+ <span class='kw'>end</span>
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_addition_triggers'>addition_triggers</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
+ <span class='kw'>else</span>
+ <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_trigger_type'>trigger_type</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='id identifier rubyid_component_or_manager'>component_or_manager</span>
+ <span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_trigger_type'>trigger_type</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='kw'>self</span>
+ <span class='kw'>end</span>
+ <span class='kw'>end</span>
+ <span class='kw'>true</span>
+<span class='kw'>end</span></pre>
+ </td>
+ </tr>
+</table>
+</div>
+
+ <div class="method_details ">
+ <h3 class="signature " id="redefine-instance_method">
+
+ #<strong>redefine</strong>(&amp;block) &#x21d2; <tt>Object</tt>
+
+
+
+
+
+</h3><div class="docstring">
+ <div class="discussion">
+
+<p>Redefine what code is executed by this System when it is called upon.</p>
+
+
+ </div>
+</div>
+<div class="tags">
+ <p class="tag_title">Parameters:</p>
+<ul class="param">
+
+ <li>
+
+ <span class='name'>block</span>
+
+
+ <span class='type'>(<tt>Proc</tt>)</span>
+
+
+
+ &mdash;
+ <div class='inline'>
+<p>The code you wish to be executed when the system is triggered. Can be defined by using a <tt>do end</tt> block or using <tt>{ }</tt> braces.</p>
+</div>
+
+ </li>
+
+</ul>
+
+
+</div><table class="source_code">
+ <tr>
+ <td>
+ <pre class="lines">
+
+
+70
+71
+72</pre>
+ </td>
+ <td>
+ <pre class="code"><span class="info file"># File 'system_manager.rb', line 70</span>
+
+<span class='kw'>def</span> <span class='id identifier rubyid_redefine'>redefine</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
+ <span class='ivar'>@block</span> <span class='op'>=</span> <span class='id identifier rubyid_block'>block</span>
+<span class='kw'>end</span></pre>
+ </td>
+ </tr>
+</table>
+</div>
+
+ <div class="method_details ">
+ <h3 class="signature " id="step-instance_method">
+
+ #<strong>step</strong> &#x21d2; <tt>Boolean</tt>
+
+
+
+
+
+</h3><div class="docstring">
+ <div class="discussion">
+
+<p>Attempt to execute the system following the frame parameter set on this system. For example if a System has its frame set to 3, it will only execute once every third frame that is called in FelFlame::Stage</p>
+
+
+ </div>
+</div>
+<div class="tags">
+
+<p class="tag_title">Returns:</p>
+<ul class="return">
+
+ <li>
+
+
+ <span class='type'>(<tt>Boolean</tt>)</span>
+
+
+
+ &mdash;
+ <div class='inline'>
+<p><code>true</code> if the frame of the FelFlame::Stage is a multiple of this System&#39;s frame setting and this system has executed, <code>false</code> otherwise where the system has not executed.</p>
+</div>
+
+ </li>
+
+</ul>
+
+</div><table class="source_code">
+ <tr>
+ <td>
+ <pre class="lines">
+
+
+66</pre>
+ </td>
+ <td>
+ <pre class="code"><span class="info file"># File 'system_manager.rb', line 66</span>
+
+<span class='kw'>def</span> <span class='id identifier rubyid_step'>step</span><span class='semicolon'>;</span> <span class='kw'>end</span></pre>
+ </td>
+ </tr>
+</table>
+</div>
+
+ <div class="method_details ">
+ <h3 class="signature " id="trigger_when_added-instance_method">
+
+ #<strong>trigger_when_added</strong>(component_or_manager) &#x21d2; <tt>Boolean</tt>
+
+
+
+
+
+</h3><div class="docstring">
+ <div class="discussion">
+
+<p>Add a component or component manager so that it triggers this system when the component or a component from the component manager is added to an entity</p>
+
+
+ </div>
+</div>
+<div class="tags">
+ <p class="tag_title">Parameters:</p>
+<ul class="param">
+
+ <li>
+
+ <span class='name'>component_or_manager</span>
+
+
+ <span class='type'>(<tt>Component or ComponentManager</tt>)</span>
+
+
+
+ &mdash;
+ <div class='inline'>
+<p>The component or component manager to trigger this system when added</p>
+</div>
+
+ </li>
+
+</ul>
+
+<p class="tag_title">Returns:</p>
+<ul class="return">
+
+ <li>
+
+
+ <span class='type'>(<tt>Boolean</tt>)</span>
+
+
+
+ &mdash;
+ <div class='inline'>
+<p>true</p>
+</div>
+
+ </li>
+
+</ul>
+
+</div><table class="source_code">
+ <tr>
+ <td>
+ <pre class="lines">
+
+
+96
+97
+98
+99
+100</pre>
+ </td>
+ <td>
+ <pre class="code"><span class="info file"># File 'system_manager.rb', line 96</span>
+<span class='kw'>def</span> <span class='id identifier rubyid_trigger_when_added'>trigger_when_added</span><span class='lparen'>(</span><span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='rparen'>)</span>
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_addition_triggers'>addition_triggers</span> <span class='op'>|=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='rbracket'>]</span>
+ <span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='period'>.</span><span class='id identifier rubyid_addition_triggers'>addition_triggers</span> <span class='op'>|=</span> <span class='lbracket'>[</span><span class='kw'>self</span><span class='rbracket'>]</span>
+ <span class='kw'>true</span>
+<span class='kw'>end</span></pre>
+ </td>
+ </tr>
+</table>
+</div>
+
+ <div class="method_details ">
+ <h3 class="signature " id="trigger_when_removed-instance_method">
+
+ #<strong>trigger_when_removed</strong>(component_or_manager) &#x21d2; <tt>Boolean</tt>
+
+
+
+
+
+</h3><div class="docstring">
+ <div class="discussion">
+
+<p>Add a component or component manager so that it triggers this system when the component or a component from the component manager is removed from an entity</p>
+
+
+ </div>
+</div>
+<div class="tags">
+ <p class="tag_title">Parameters:</p>
+<ul class="param">
+
+ <li>
+
+ <span class='name'>component_or_manager</span>
+
+
+ <span class='type'>(<tt>Component or ComponentManager</tt>)</span>
+
+
+
+ &mdash;
+ <div class='inline'>
+<p>The component or component manager to trigger this system when removed</p>
+</div>
+
+ </li>
+
+</ul>
+<p class="tag_title">Returns:</p>
+<ul class="return">
+
+ <li>
+
+
+ <span class='type'>(<tt>Boolean</tt>)</span>
+
+
+
+ &mdash;
+ <div class='inline'>
+<p>true</p>
+</div>
+
+ </li>
+
+</ul>
+
+</div><table class="source_code">
+ <tr>
+ <td>
+ <pre class="lines">
+105
+106
+107
+108
+109</pre>
+ </td>
+ <td>
+ <pre class="code"><span class="info file"># File 'system_manager.rb', line 105</span>
+
+<span class='kw'>def</span> <span class='id identifier rubyid_trigger_when_removed'>trigger_when_removed</span><span class='lparen'>(</span><span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='rparen'>)</span>
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_removal_triggers'>removal_triggers</span> <span class='op'>|=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='rbracket'>]</span>
+ <span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='period'>.</span><span class='id identifier rubyid_removal_triggers'>removal_triggers</span> <span class='op'>|=</span> <span class='lbracket'>[</span><span class='kw'>self</span><span class='rbracket'>]</span>
+ <span class='kw'>true</span>
+<span class='kw'>end</span></pre>
+ </td>
+ </tr>
+</table>
+</div>
+
+ </div>
</div>
<div id="footer">
- Generated on Sat Jun 12 03:12:49 2021 by
+ Generated on Wed Jun 16 07:08:52 2021 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.26 (ruby-2.7.3).
</div>
diff --git a/docs/_index.html b/docs/_index.html
index 2c11d39..cc26e86 100644
--- a/docs/_index.html
+++ b/docs/_index.html
@@ -164,7 +164,7 @@
</div>
<div id="footer">
- Generated on Sat Jun 12 03:12:49 2021 by
+ Generated on Wed Jun 16 07:08:51 2021 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.26 (ruby-2.7.3).
</div>
diff --git a/docs/file.README.html b/docs/file.README.html
index 98047e1..2de097c 100644
--- a/docs/file.README.html
+++ b/docs/file.README.html
@@ -98,6 +98,8 @@ I plan to eventually add functionality outside of just ECS such as loading tiles
<h3 id="ff-entities">FF::Entities</h3>
+<p><code>WARNING: POTENTIALLY OUT OF DATE</code></p>
+
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="top-level-namespace.html#FF-constant" title="FF (constant)">FF</a></span></span><span class='op'>::</span><span class='const'>Ent</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='ivar'>@component1</span><span class='comma'>,</span> <span class='ivar'>@component2</span><span class='rparen'>)</span>
<span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="top-level-namespace.html#FF-constant" title="FF (constant)">FF</a></span></span><span class='op'>::</span><span class='const'>Ent</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='id identifier rubyid_entity_id'>entity_id</span><span class='rparen'>)</span>
<span class='const'><span class='object_link'><a href="top-level-namespace.html#FF-constant" title="FF (constant)">FF</a></span></span><span class='op'>::</span><span class='const'>Ent</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_entity_id'>entity_id</span><span class='rparen'>)</span>
@@ -111,6 +113,8 @@ I plan to eventually add functionality outside of just ECS such as loading tiles
<h3 id="ff-components">FF::Components</h3>
+<p><code>WARNING: POTENTIALLY OUT OF DATE</code></p>
+
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="top-level-namespace.html#FF-constant" title="FF (constant)">FF</a></span></span><span class='op'>::</span><span class='const'>Cmp</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Name</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>param1</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>param2:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>default</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='const'><span class='object_link'><a href="top-level-namespace.html#FF-constant" title="FF (constant)">FF</a></span></span><span class='op'>::</span><span class='const'>Cmp</span><span class='op'>::</span><span class='const'>Name</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='label'>param1:</span> <span class='id identifier rubyid_value1'>value1</span><span class='rparen'>)</span>
<span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="top-level-namespace.html#FF-constant" title="FF (constant)">FF</a></span></span><span class='op'>::</span><span class='const'>Cmp</span><span class='op'>::</span><span class='const'>Name</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_id'>component_id</span><span class='rparen'>)</span>
@@ -130,14 +134,29 @@ I plan to eventually add functionality outside of just ECS such as loading tiles
<h3 id="ff-systems">FF::Systems</h3>
-<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="top-level-namespace.html#FF-constant" title="FF (constant)">FF</a></span></span><span class='op'>::</span><span class='const'>Sys</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='label'>name:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Render</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>position:</span> <span class='int'>5</span><span class='comma'>,</span> <span class='label'>frame:</span> <span class='int'>1</span><span class='rparen'>)</span> <span class='kw'>do</span>
- <span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span>
- <span class='comment'># functionality
-</span> <span class='kw'>end</span>
-<span class='kw'>end</span>
-<span class='const'><span class='object_link'><a href="top-level-namespace.html#FF-constant" title="FF (constant)">FF</a></span></span><span class='op'>::</span><span class='const'>Sys</span><span class='op'>::</span><span class='const'>Render</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when'>trigger_when</span> <span class='const'><span class='object_link'><a href="top-level-namespace.html#FF-constant" title="FF (constant)">FF</a></span></span><span class='op'>::</span><span class='const'>Cmp</span><span class='op'>::</span><span class='const'>Health</span><span class='period'>.</span><span class='id identifier rubyid_added'>added</span>
-<span class='const'><span class='object_link'><a href="top-level-namespace.html#FF-constant" title="FF (constant)">FF</a></span></span><span class='op'>::</span><span class='const'>Sys</span><span class='op'>::</span><span class='const'>Render</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when'>trigger_when</span> <span class='const'><span class='object_link'><a href="top-level-namespace.html#FF-constant" title="FF (constant)">FF</a></span></span><span class='op'>::</span><span class='const'>Cmp</span><span class='op'>::</span><span class='const'>Health</span><span class='period'>.</span><span class='id identifier rubyid_removed'>removed</span>
-<span class='const'><span class='object_link'><a href="top-level-namespace.html#FF-constant" title="FF (constant)">FF</a></span></span><span class='op'>::</span><span class='const'>Sys</span><span class='op'>::</span><span class='const'>Render</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when'>trigger_when</span> <span class='const'><span class='object_link'><a href="top-level-namespace.html#FF-constant" title="FF (constant)">FF</a></span></span><span class='op'>::</span><span class='const'>Cmp</span><span class='op'>::</span><span class='const'>Health</span><span class='period'>.</span><span class='id identifier rubyid_is_set'>is_set</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>var</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
+<pre class="code ruby"><code class="ruby">FF::Sys.new(name: &#39;Render&#39;, position: 5, frame: 1) do
+ @component.each do
+ # functionality
+ end
+end
+
+# for all components belonging to a certain component manager
+FF::Sys::Render.trigger_when_added FF::Cmp::Health
+FF::Sys::Render.trigger_when_removed FF::Cmp::Health
+FF::Sys::Render.trigger_when_is_set(FF::Cmp::Health, &#39;var&#39;)
+FF::Sys::Render.clear_triggers FF::Cmp::Health # clears all triggers
+FF::Sys::Render.clear_triggers (FF::Cmp::Health, :added)
+FF::Sys::Render.clear_triggers (FF::Cmp::Health, :removed)
+FF::Sys::Render.clear_triggers (FF::Cmp::Health, :is_set, &#39;var&#39;)
+
+# for specific components
+FF::Sys::Render.trigger_when_added FF::Cmp::Health[3]
+FF::Sys::Render.trigger_when_removed FF::Cmp::Health[3]
+FF::Sys::Render.trigger_when_is_set(FF::Cmp::Health[3], &#39;var&#39;)
+FF::Sys::Render.clear_triggers FF::Cmp::Health[3] # clears all triggers
+FF::Sys::Render.clear_triggers (FF::Cmp::Health[3], :added)
+FF::Sys::Render.clear_triggers (FF::Cmp::Health[3], :removed)
+FF::Sys::Render.clear_triggers (FF::Cmp::Health[3], :is_set, &#39;var&#39;)
</code></pre>
<h3 id="ff-scenes">FF::Scenes</h3>
@@ -354,7 +373,7 @@ complete I will use a more verbose explanation as below to help users of the fra
</div></div>
<div id="footer">
- Generated on Sat Jun 12 03:12:49 2021 by
+ Generated on Wed Jun 16 07:08:51 2021 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.26 (ruby-2.7.3).
</div>
diff --git a/docs/index.html b/docs/index.html
index 44132ea..ce3390b 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -98,6 +98,8 @@ I plan to eventually add functionality outside of just ECS such as loading tiles
<h3 id="ff-entities">FF::Entities</h3>
+<p><code>WARNING: POTENTIALLY OUT OF DATE</code></p>
+
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="top-level-namespace.html#FF-constant" title="FF (constant)">FF</a></span></span><span class='op'>::</span><span class='const'>Ent</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='ivar'>@component1</span><span class='comma'>,</span> <span class='ivar'>@component2</span><span class='rparen'>)</span>
<span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="top-level-namespace.html#FF-constant" title="FF (constant)">FF</a></span></span><span class='op'>::</span><span class='const'>Ent</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='id identifier rubyid_entity_id'>entity_id</span><span class='rparen'>)</span>
<span class='const'><span class='object_link'><a href="top-level-namespace.html#FF-constant" title="FF (constant)">FF</a></span></span><span class='op'>::</span><span class='const'>Ent</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_entity_id'>entity_id</span><span class='rparen'>)</span>
@@ -111,6 +113,8 @@ I plan to eventually add functionality outside of just ECS such as loading tiles
<h3 id="ff-components">FF::Components</h3>
+<p><code>WARNING: POTENTIALLY OUT OF DATE</code></p>
+
<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="top-level-namespace.html#FF-constant" title="FF (constant)">FF</a></span></span><span class='op'>::</span><span class='const'>Cmp</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Name</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>param1</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>param2:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>default</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
<span class='const'><span class='object_link'><a href="top-level-namespace.html#FF-constant" title="FF (constant)">FF</a></span></span><span class='op'>::</span><span class='const'>Cmp</span><span class='op'>::</span><span class='const'>Name</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='label'>param1:</span> <span class='id identifier rubyid_value1'>value1</span><span class='rparen'>)</span>
<span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="top-level-namespace.html#FF-constant" title="FF (constant)">FF</a></span></span><span class='op'>::</span><span class='const'>Cmp</span><span class='op'>::</span><span class='const'>Name</span><span class='period'>.</span><span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_id'>component_id</span><span class='rparen'>)</span>
@@ -130,14 +134,29 @@ I plan to eventually add functionality outside of just ECS such as loading tiles
<h3 id="ff-systems">FF::Systems</h3>
-<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="top-level-namespace.html#FF-constant" title="FF (constant)">FF</a></span></span><span class='op'>::</span><span class='const'>Sys</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='label'>name:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Render</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>position:</span> <span class='int'>5</span><span class='comma'>,</span> <span class='label'>frame:</span> <span class='int'>1</span><span class='rparen'>)</span> <span class='kw'>do</span>
- <span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span>
- <span class='comment'># functionality
-</span> <span class='kw'>end</span>
-<span class='kw'>end</span>
-<span class='const'><span class='object_link'><a href="top-level-namespace.html#FF-constant" title="FF (constant)">FF</a></span></span><span class='op'>::</span><span class='const'>Sys</span><span class='op'>::</span><span class='const'>Render</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when'>trigger_when</span> <span class='const'><span class='object_link'><a href="top-level-namespace.html#FF-constant" title="FF (constant)">FF</a></span></span><span class='op'>::</span><span class='const'>Cmp</span><span class='op'>::</span><span class='const'>Health</span><span class='period'>.</span><span class='id identifier rubyid_added'>added</span>
-<span class='const'><span class='object_link'><a href="top-level-namespace.html#FF-constant" title="FF (constant)">FF</a></span></span><span class='op'>::</span><span class='const'>Sys</span><span class='op'>::</span><span class='const'>Render</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when'>trigger_when</span> <span class='const'><span class='object_link'><a href="top-level-namespace.html#FF-constant" title="FF (constant)">FF</a></span></span><span class='op'>::</span><span class='const'>Cmp</span><span class='op'>::</span><span class='const'>Health</span><span class='period'>.</span><span class='id identifier rubyid_removed'>removed</span>
-<span class='const'><span class='object_link'><a href="top-level-namespace.html#FF-constant" title="FF (constant)">FF</a></span></span><span class='op'>::</span><span class='const'>Sys</span><span class='op'>::</span><span class='const'>Render</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when'>trigger_when</span> <span class='const'><span class='object_link'><a href="top-level-namespace.html#FF-constant" title="FF (constant)">FF</a></span></span><span class='op'>::</span><span class='const'>Cmp</span><span class='op'>::</span><span class='const'>Health</span><span class='period'>.</span><span class='id identifier rubyid_is_set'>is_set</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>var</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
+<pre class="code ruby"><code class="ruby">FF::Sys.new(name: &#39;Render&#39;, position: 5, frame: 1) do
+ @component.each do
+ # functionality
+ end
+end
+
+# for all components belonging to a certain component manager
+FF::Sys::Render.trigger_when_added FF::Cmp::Health
+FF::Sys::Render.trigger_when_removed FF::Cmp::Health
+FF::Sys::Render.trigger_when_is_set(FF::Cmp::Health, &#39;var&#39;)
+FF::Sys::Render.clear_triggers FF::Cmp::Health # clears all triggers
+FF::Sys::Render.clear_triggers (FF::Cmp::Health, :added)
+FF::Sys::Render.clear_triggers (FF::Cmp::Health, :removed)
+FF::Sys::Render.clear_triggers (FF::Cmp::Health, :is_set, &#39;var&#39;)
+
+# for specific components
+FF::Sys::Render.trigger_when_added FF::Cmp::Health[3]
+FF::Sys::Render.trigger_when_removed FF::Cmp::Health[3]
+FF::Sys::Render.trigger_when_is_set(FF::Cmp::Health[3], &#39;var&#39;)
+FF::Sys::Render.clear_triggers FF::Cmp::Health[3] # clears all triggers
+FF::Sys::Render.clear_triggers (FF::Cmp::Health[3], :added)
+FF::Sys::Render.clear_triggers (FF::Cmp::Health[3], :removed)
+FF::Sys::Render.clear_triggers (FF::Cmp::Health[3], :is_set, &#39;var&#39;)
</code></pre>
<h3 id="ff-scenes">FF::Scenes</h3>
@@ -354,7 +373,7 @@ complete I will use a more verbose explanation as below to help users of the fra
</div></div>
<div id="footer">
- Generated on Sat Jun 12 03:12:49 2021 by
+ Generated on Wed Jun 16 07:08:51 2021 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.26 (ruby-2.7.3).
</div>
diff --git a/docs/method_list.html b/docs/method_list.html
index cdf6aae..6d634b1 100644
--- a/docs/method_list.html
+++ b/docs/method_list.html
@@ -70,20 +70,68 @@
<li class="even ">
<div class="item">
+ <span class='object_link'><a href="FelFlame/Systems.html#addition_triggers-instance_method" title="FelFlame::Systems#addition_triggers (method)">#addition_triggers</a></span>
+ <small>FelFlame::Systems</small>
+ </div>
+ </li>
+
+
+ <li class="odd ">
+ <div class="item">
+ <span class='object_link'><a href="FelFlame/Helper/ComponentManager.html#addition_triggers-instance_method" title="FelFlame::Helper::ComponentManager#addition_triggers (method)">#addition_triggers</a></span>
+ <small>FelFlame::Helper::ComponentManager</small>
+ </div>
+ </li>
+
+
+ <li class="even ">
+ <div class="item">
+ <span class='object_link'><a href="FelFlame/Helper/ComponentManager.html#addition_triggers-class_method" title="FelFlame::Helper::ComponentManager.addition_triggers (method)">addition_triggers</a></span>
+ <small>FelFlame::Helper::ComponentManager</small>
+ </div>
+ </li>
+
+
+ <li class="odd ">
+ <div class="item">
<span class='object_link'><a href="FelFlame/Helper/ComponentManager.html#attrs-instance_method" title="FelFlame::Helper::ComponentManager#attrs (method)">#attrs</a></span>
<small>FelFlame::Helper::ComponentManager</small>
</div>
</li>
+ <li class="even ">
+ <div class="item">
+ <span class='object_link'><a href="FelFlame/Systems.html#call-instance_method" title="FelFlame::Systems#call (method)">#call</a></span>
+ <small>FelFlame::Systems</small>
+ </div>
+ </li>
+
+
<li class="odd ">
<div class="item">
+ <span class='object_link'><a href="FelFlame/Systems.html#clear_triggers-instance_method" title="FelFlame::Systems#clear_triggers (method)">#clear_triggers</a></span>
+ <small>FelFlame::Systems</small>
+ </div>
+ </li>
+
+
+ <li class="even ">
+ <div class="item">
<span class='object_link'><a href="FelFlame/Entities.html#components-instance_method" title="FelFlame::Entities#components (method)">#components</a></span>
<small>FelFlame::Entities</small>
</div>
</li>
+ <li class="odd ">
+ <div class="item">
+ <span class='object_link'><a href="FelFlame/Systems.html#const_name-instance_method" title="FelFlame::Systems#const_name (method)">#const_name</a></span>
+ <small>FelFlame::Systems</small>
+ </div>
+ </li>
+
+
<li class="even ">
<div class="item">
<span class='object_link'><a href="FelFlame/Helper/ComponentManager.html#delete-instance_method" title="FelFlame::Helper::ComponentManager#delete (method)">#delete</a></span>
@@ -102,13 +150,21 @@
<li class="even ">
<div class="item">
+ <span class='object_link'><a href="FelFlame/Systems.html#each-class_method" title="FelFlame::Systems.each (method)">each</a></span>
+ <small>FelFlame::Systems</small>
+ </div>
+ </li>
+
+
+ <li class="odd ">
+ <div class="item">
<span class='object_link'><a href="FelFlame/Components.html#each-class_method" title="FelFlame::Components.each (method)">each</a></span>
<small>FelFlame::Components</small>
</div>
</li>
- <li class="odd ">
+ <li class="even ">
<div class="item">
<span class='object_link'><a href="FelFlame/Helper/ComponentManager.html#each-class_method" title="FelFlame::Helper::ComponentManager.each (method)">each</a></span>
<small>FelFlame::Helper::ComponentManager</small>
@@ -116,7 +172,7 @@
</li>
- <li class="even ">
+ <li class="odd ">
<div class="item">
<span class='object_link'><a href="FelFlame/Entities.html#each-class_method" title="FelFlame::Entities.each (method)">each</a></span>
<small>FelFlame::Entities</small>
@@ -124,7 +180,7 @@
</li>
- <li class="odd ">
+ <li class="even ">
<div class="item">
<span class='object_link'><a href="FelFlame/Helper/ComponentManager.html#entities-instance_method" title="FelFlame::Helper::ComponentManager#entities (method)">#entities</a></span>
<small>FelFlame::Helper::ComponentManager</small>
@@ -132,6 +188,14 @@
</li>
+ <li class="odd ">
+ <div class="item">
+ <span class='object_link'><a href="FelFlame/Systems.html#frame-instance_method" title="FelFlame::Systems#frame (method)">#frame</a></span>
+ <small>FelFlame::Systems</small>
+ </div>
+ </li>
+
+
<li class="even ">
<div class="item">
<span class='object_link'><a href="FelFlame/Entities.html#from_json-class_method" title="FelFlame::Entities.from_json (method)">from_json</a></span>
@@ -158,13 +222,21 @@
<li class="odd ">
<div class="item">
+ <span class='object_link'><a href="FelFlame/Systems.html#initialize-instance_method" title="FelFlame::Systems#initialize (method)">#initialize</a></span>
+ <small>FelFlame::Systems</small>
+ </div>
+ </li>
+
+
+ <li class="even ">
+ <div class="item">
<span class='object_link'><a href="FelFlame/Helper/ComponentManager.html#initialize-instance_method" title="FelFlame::Helper::ComponentManager#initialize (method)">#initialize</a></span>
<small>FelFlame::Helper::ComponentManager</small>
</div>
</li>
- <li class="even ">
+ <li class="odd ">
<div class="item">
<span class='object_link'><a href="FelFlame/Entities.html#initialize-instance_method" title="FelFlame::Entities#initialize (method)">#initialize</a></span>
<small>FelFlame::Entities</small>
@@ -172,7 +244,7 @@
</li>
- <li class="odd ">
+ <li class="even ">
<div class="item">
<span class='object_link'><a href="FelFlame/Components.html#new-class_method" title="FelFlame::Components.new (method)">new</a></span>
<small>FelFlame::Components</small>
@@ -180,6 +252,46 @@
</li>
+ <li class="odd ">
+ <div class="item">
+ <span class='object_link'><a href="FelFlame/Systems.html#priority-instance_method" title="FelFlame::Systems#priority (method)">#priority</a></span>
+ <small>FelFlame::Systems</small>
+ </div>
+ </li>
+
+
+ <li class="even ">
+ <div class="item">
+ <span class='object_link'><a href="FelFlame/Systems.html#redefine-instance_method" title="FelFlame::Systems#redefine (method)">#redefine</a></span>
+ <small>FelFlame::Systems</small>
+ </div>
+ </li>
+
+
+ <li class="odd ">
+ <div class="item">
+ <span class='object_link'><a href="FelFlame/Systems.html#removal_triggers-instance_method" title="FelFlame::Systems#removal_triggers (method)">#removal_triggers</a></span>
+ <small>FelFlame::Systems</small>
+ </div>
+ </li>
+
+
+ <li class="even ">
+ <div class="item">
+ <span class='object_link'><a href="FelFlame/Helper/ComponentManager.html#removal_triggers-instance_method" title="FelFlame::Helper::ComponentManager#removal_triggers (method)">#removal_triggers</a></span>
+ <small>FelFlame::Helper::ComponentManager</small>
+ </div>
+ </li>
+
+
+ <li class="odd ">
+ <div class="item">
+ <span class='object_link'><a href="FelFlame/Helper/ComponentManager.html#removal_triggers-class_method" title="FelFlame::Helper::ComponentManager.removal_triggers (method)">removal_triggers</a></span>
+ <small>FelFlame::Helper::ComponentManager</small>
+ </div>
+ </li>
+
+
<li class="even ">
<div class="item">
<span class='object_link'><a href="FelFlame/Entities.html#remove-instance_method" title="FelFlame::Entities#remove (method)">#remove</a></span>
@@ -190,13 +302,21 @@
<li class="odd ">
<div class="item">
+ <span class='object_link'><a href="FelFlame/Systems.html#step-instance_method" title="FelFlame::Systems#step (method)">#step</a></span>
+ <small>FelFlame::Systems</small>
+ </div>
+ </li>
+
+
+ <li class="even ">
+ <div class="item">
<span class='object_link'><a href="FelFlame/Helper/ComponentManager.html#to_i-instance_method" title="FelFlame::Helper::ComponentManager#to_i (method)">#to_i</a></span>
<small>FelFlame::Helper::ComponentManager</small>
</div>
</li>
- <li class="even ">
+ <li class="odd ">
<div class="item">
<span class='object_link'><a href="FelFlame/Entities.html#to_i-instance_method" title="FelFlame::Entities#to_i (method)">#to_i</a></span>
<small>FelFlame::Entities</small>
@@ -204,7 +324,7 @@
</li>
- <li class="odd ">
+ <li class="even ">
<div class="item">
<span class='object_link'><a href="FelFlame/Helper/ComponentManager.html#to_json-instance_method" title="FelFlame::Helper::ComponentManager#to_json (method)">#to_json</a></span>
<small>FelFlame::Helper::ComponentManager</small>
@@ -212,7 +332,7 @@
</li>
- <li class="even ">
+ <li class="odd ">
<div class="item">
<span class='object_link'><a href="FelFlame/Entities.html#to_json-instance_method" title="FelFlame::Entities#to_json (method)">#to_json</a></span>
<small>FelFlame::Entities</small>
@@ -220,8 +340,24 @@
</li>
+ <li class="even ">
+ <div class="item">
+ <span class='object_link'><a href="FelFlame/Systems.html#trigger_when_added-instance_method" title="FelFlame::Systems#trigger_when_added (method)">#trigger_when_added</a></span>
+ <small>FelFlame::Systems</small>
+ </div>
+ </li>
+
+
<li class="odd ">
<div class="item">
+ <span class='object_link'><a href="FelFlame/Systems.html#trigger_when_removed-instance_method" title="FelFlame::Systems#trigger_when_removed (method)">#trigger_when_removed</a></span>
+ <small>FelFlame::Systems</small>
+ </div>
+ </li>
+
+
+ <li class="even ">
+ <div class="item">
<span class='object_link'><a href="FelFlame/Helper/ComponentManager.html#update_attrs-instance_method" title="FelFlame::Helper::ComponentManager#update_attrs (method)">#update_attrs</a></span>
<small>FelFlame::Helper::ComponentManager</small>
</div>
diff --git a/docs/top-level-namespace.html b/docs/top-level-namespace.html
index 804d156..d08d816 100644
--- a/docs/top-level-namespace.html
+++ b/docs/top-level-namespace.html
@@ -127,7 +127,7 @@
</div>
<div id="footer">
- Generated on Sat Jun 12 03:12:49 2021 by
+ Generated on Wed Jun 16 07:08:52 2021 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.26 (ruby-2.7.3).
</div>
diff --git a/entity_manager.rb b/entity_manager.rb
index abbf1d0..2e1b845 100644
--- a/entity_manager.rb
+++ b/entity_manager.rb
@@ -40,45 +40,54 @@ class FelFlame
components.each do |component_manager, component_array|
component_array.each do |component_id|
component_manager[component_id].entities.delete(id)
+ #self.remove FelFlame::Components.const_get(component_manager.name)[component_id]
end
end
FelFlame::Entities.data[id] = nil
+ @components = {}
@id = nil
- @components = nil
true
end
# Add any number components to the Entity.
- # @param component [Component] Any number of components created from any component manager
+ # @param components_to_add [Component] Any number of components created from any component manager
# @return [Boolean] true if component is added, false if it already is attached or no components given
def add(*components_to_add)
- added = false
components_to_add.each do |component|
if components[component.class].nil?
components[component.class] = [component.id]
component.entities.push id
- added =true
+ check_systems component, :addition_triggers
elsif !components[component.class].include? component.id
components[component.class].push component.id
component.entities.push id
- added = true
+ check_systems component, :addition_triggers
end
end
- added
+ end
+
+ # triggers every system associated with this component's trigger
+ # @return [Boolean] true
+ # @!visibility private
+ def check_systems(component, trigger_type)
+ component_calls = component.class.send(trigger_type)
+ component.send(trigger_type).each do |system|
+ component_calls |= [system]
+ end
+ component_calls.sort_by(&:priority).reverse.each(&:call)
+ true
end
# Remove a component from the Entity
- # @param component_to_remove [Component] A component created from any component manager
+ # @param components_to_remove [Component] A component created from any component manager
# @return [Boolean] true if at least one component is removed, false if none of them were attached to the component
def remove(*components_to_remove)
- removed = false
components_to_remove.each do |component|
+ check_systems component, :removal_triggers if component.entities.include? id
+ component.entities.delete id
components[component.class].delete component.id
- if component.entities.delete id
- removed = true
- end
end
- removed
+ true
end
# Export all data into a JSON String which can then be saved into a file
@@ -105,11 +114,11 @@ class FelFlame
data[entity_id]
end
- # Iterates over all entities. In general when using ECS the use of this method should never be neccassary unless you are doing something very wrong, however I will not stop you.
+ # Iterates over all entities. The data is compacted so that means index does not correlate to ID.
# You also call other enumerable methods instead of each, such as +each_with_index+ or +select+
# @return [Enumerator]
def each(&block)
- data.each(&block)
+ data.compact.each(&block)
end
# Creates a new entity using the data from a JSON string
diff --git a/spec/entity_manager_spec.rb b/spec/entity_manager_spec.rb
index 532e583..2db4787 100644
--- a/spec/entity_manager_spec.rb
+++ b/spec/entity_manager_spec.rb
@@ -54,15 +54,38 @@ describe 'Entities' do
expect(@ent1.components[@component_manager].include?(@cmp2.id)).to be true
end
+ it 'can get id from to_i' do
+ expect(@ent0.id).to eq(@ent0.to_i)
+ expect(@ent1.id).to eq(@ent1.to_i)
+ expect(@ent2.id).to eq(@ent2.to_i)
+ end
+
it 'can have components removed' do
@ent0.add @cmp0
expect(@ent0.remove @cmp0).to be true
+ expect(@cmp0.entities.empty?).to be true
expect(@ent0.components[@component_manager].empty?).to be true
end
- it 'can get id from to_i' do
- expect(@ent0.id).to eq(@ent0.to_i)
- expect(@ent1.id).to eq(@ent1.to_i)
- expect(@ent2.id).to eq(@ent2.to_i)
+ it 'can have many components added then removed' do
+ @ent0.add @cmp0, @cmp1, @cmp2
+ @ent1.add @cmp0, @cmp1
+ @ent2.add @cmp1, @cmp2
+ expect(@ent0.components).to eq({@component_manager => [0,1,2]})
+ expect(@cmp0.entities).to eq([0,1])
+ expect(@cmp1.entities).to eq([0,1,2])
+ expect(@cmp2.entities).to eq([0,2])
+ @ent1.delete
+ expect(@cmp0.entities).to eq([0])
+ expect(@cmp1.entities).to eq([0,2])
+ expect(@cmp2.entities).to eq([0,2])
+ @cmp1.delete
+ expect(@ent0.components).to eq({@component_manager => [0,2]})
+ @component_manager.each(&:delete)
+ expect(@component_manager.each.to_a).to eq([])
+ expect(@ent0.components).to eq({@component_manager => []})
+ expect(@ent2.components).to eq({@component_manager => []})
+ FelFlame::Entities.each(&:delete)
+ expect(FelFlame::Entities.each.to_a).to eq([])
end
end
diff --git a/spec/system_manager_spec.rb b/spec/system_manager_spec.rb
new file mode 100644
index 0000000..c2b8cf6
--- /dev/null
+++ b/spec/system_manager_spec.rb
@@ -0,0 +1,185 @@
+require_relative '../felflame.rb'
+
+describe 'Components' do
+
+ before :all do
+ @component_manager ||= FelFlame::Components.new('TestSystems', health: 10, name: 'imp')
+ end
+
+ before :each do
+ end
+
+ after :each do
+ #TODO: order breaks it
+ @component_manager.each(&:delete)
+ FelFlame::Entities.each(&:delete)
+ FelFlame::Systems.each(&:clear_triggers)
+ end
+
+ it 'can create a system' do
+ FelFlame::Systems.new('Test100') do
+ 'Works'
+ end
+ expect(FelFlame::Systems::Test100.call).to eq('Works')
+ end
+
+ it 'can be redefined' do
+ FelFlame::Systems.new('Test101') do
+ 'neat'
+ end
+ FelFlame::Systems::Test101.redefine do
+ 'very neat'
+ end
+ expect(FelFlame::Systems::Test101.call).to eq('very neat')
+ end
+
+ it 'can iterate over the sorted systems by priority' do
+ FelFlame::Systems.new('Test102', priority: 1) {}
+ FelFlame::Systems.new('Test103', priority: 50) {}
+ FelFlame::Systems.new('Test104', priority: 7) {}
+ answer_key = ['Test103', 'Test104', 'Test102']
+ test = FelFlame::Systems.each.to_a
+ # converts the system name to the constant, compares their positions making sure they are sorted
+ # higher priority should be placed first
+ expect(test.map(&:const_name).find_index(answer_key[0])).to be <= test.map(&:const_name).find_index(answer_key[1])
+ expect(test.map(&:const_name).find_index(answer_key[0])).to be <= test.map(&:const_name).find_index(answer_key[2])
+ expect(test.map(&:const_name).find_index(answer_key[1])).to be >= test.map(&:const_name).find_index(answer_key[0])
+ expect(test.map(&:const_name).find_index(answer_key[1])).to be <= test.map(&:const_name).find_index(answer_key[2])
+ expect(test.map(&:const_name).find_index(answer_key[2])).to be >= test.map(&:const_name).find_index(answer_key[0])
+ expect(test.map(&:const_name).find_index(answer_key[2])).to be >= test.map(&:const_name).find_index(answer_key[1])
+ end
+
+ it 'can manipulate components' do
+ init1 = 27
+ init2 = 130
+ multiple = 3
+ first = @component_manager.new(health: init1)
+ second = @component_manager.new(health: init2)
+ FelFlame::Systems.new('Test105') do
+ @component_manager.each do |component|
+ component.health -= multiple
+ end
+ end
+ FelFlame::Systems::Test105.call
+ expect(first.health).to eq(init1 -= multiple)
+ expect(second.health).to eq(init2 -= multiple)
+ 10.times do
+ FelFlame::Systems::Test105.call
+ end
+ expect(first.health).to eq(init1 - (multiple * 10))
+ expect(second.health).to eq(init2 - (multiple * 10))
+ end
+ it 'can trigger when a single Component is added' do
+ FelFlame::Systems.new 'Test107' do
+ @component_manager.each do |component|
+ component.health += 5
+ end
+ end
+ @cmp0 = @component_manager.new
+ @cmp1 = @component_manager.new health: 20
+ FelFlame::Systems::Test107.trigger_when_added @cmp0
+ expect(@cmp0.health).to eq(10)
+ expect(@cmp1.health).to eq(20)
+ @entity0 = FelFlame::Entities.new
+ @entity1 = FelFlame::Entities.new @cmp0
+ expect(@cmp0.health).to eq(15)
+ expect(@cmp1.health).to eq(25)
+ @entity0.add @cmp0
+ expect(@cmp0.health).to eq(20)
+ expect(@cmp1.health).to eq(30)
+ end
+
+ it 'can trigger when a Component from a manager is added' do
+ FelFlame::Systems.new 'Test106' do
+ @component_manager.each do |component|
+ component.health += 5
+ end
+ end
+ @cmp1 = @component_manager.new
+ @cmp2 = @component_manager.new health: 20
+ FelFlame::Systems::Test106.trigger_when_added @component_manager
+ expect(@cmp1.health).to eq(10)
+ expect(@cmp2.health).to eq(20)
+ @entity1 = FelFlame::Entities.new
+ @entity2 = FelFlame::Entities.new @cmp2
+ expect(@cmp1.health).to eq(15)
+ expect(@cmp2.health).to eq(25)
+ FelFlame::Systems::Test106.trigger_when_added @cmp1
+ @entity1.add @cmp1
+ expect(@cmp1.health).to eq(20)
+ expect(@cmp2.health).to eq(30)
+ end
+
+ it 'can trigger when a single Component is removed' do
+ FelFlame::Systems.new 'Test108' do
+ @component_manager.each do |component|
+ component.health += 5
+ end
+ end
+ @cmp0 = @component_manager.new
+ @cmp1 = @component_manager.new health: 20
+ FelFlame::Systems::Test108.trigger_when_removed @cmp0
+ expect(@cmp0.health).to eq(10)
+ expect(@cmp1.health).to eq(20)
+ @entity0 = FelFlame::Entities.new
+ @entity1 = FelFlame::Entities.new @cmp0
+ expect(@cmp0.health).to eq(10)
+ expect(@cmp1.health).to eq(20)
+ @entity1.remove @cmp0
+ expect(@cmp0.health).to eq(15)
+ expect(@cmp1.health).to eq(25)
+ @entity0.add @cmp1, @cmp0
+ @entity0.remove @cmp1
+ expect(@cmp0.health).to eq(15)
+ expect(@cmp1.health).to eq(25)
+ end
+
+ it 'can trigger when a Component from a manager is removed' do
+ FelFlame::Systems.new 'Test109' do
+ @component_manager.each do |component|
+ component.health += 5
+ end
+ end
+ @cmp0 = @component_manager.new
+ @cmp1 = @component_manager.new health: 20
+ FelFlame::Systems::Test109.trigger_when_removed @component_manager
+ expect(@cmp0.health).to eq(10)
+ expect(@cmp1.health).to eq(20)
+ @entity0 = FelFlame::Entities.new
+ @entity1 = FelFlame::Entities.new @cmp0
+ expect(@cmp0.health).to eq(10)
+ expect(@cmp1.health).to eq(20)
+ @entity1.remove @cmp0
+ expect(@cmp0.health).to eq(15)
+ expect(@cmp1.health).to eq(25)
+ FelFlame::Systems::Test109.trigger_when_removed @cmp1
+ @entity0.add @cmp1, @cmp0
+ @entity0.remove @cmp1
+ expect(@cmp0.health).to eq(20)
+ expect(@cmp1.health).to eq(30)
+ end
+=begin
+ it 'can trigger when a single Component is added' do
+ FelFlame::Systems.new 'Test110' do
+ @component_manager.each do |component|
+ component.health += 5
+ end
+ end
+ @cmp0 = @component_manager.new
+ @cmp1 = @component_manager.new health: 20
+ FelFlame::Systems::Test110.trigger_when_is_changed @cmp0, :name
+ expect(@cmp0.health).to eq(10)
+ expect(@cmp1.health).to eq(20)
+ @entity0 = FelFlame::Entities.new
+ @entity1 = FelFlame::Entities.new @cmp0
+ expect(@cmp0.health).to eq(10)
+ expect(@cmp1.health).to eq(20)
+ @cmp0.name = 'different'
+ expect(@cmp0.health).to eq(15)
+ expect(@cmp1.health).to eq(25)
+ @cmp1.name = 'different'
+ expect(@cmp0.health).to eq(15)
+ expect(@cmp1.health).to eq(25)
+ end
+=end
+end
diff --git a/system_manager.rb b/system_manager.rb
index 14f37d4..4bd37b2 100644
--- a/system_manager.rb
+++ b/system_manager.rb
@@ -1,7 +1,111 @@
-#require 'app/ECS/systems/00_movement.rb'
-#require 'app/ECS/systems/01_flying.rb'
-
class FelFlame
class Systems
+ # How early this System should be executed in a list of Systems
+ attr_accessor :priority
+
+ # The Constant name assigned to this System
+ attr_accessor :const_name
+
+ # How many frames need to pass before this System is executed when controlled by {FelFlame::Stage}
+ attr_accessor :frame
+
+ attr_writer :addition_triggers
+
+ def addition_triggers
+ @addition_triggers ||= []
+ end
+
+ attr_writer :removal_triggers
+
+ def removal_triggers
+ @removal_triggers ||= []
+ end
+
+ class <<self
+ include Enumerable
+
+ # Iterate over all Systems, sorted by their priority. You also call other enumerable methods instead of each, such as +each_with_index+ or +select+
+ # @return [Enumerator]
+ def each(&block)
+ constants.map { |sym| const_get(sym) }.sort_by(&:priority).reverse.each(&block)
+ end
+ end
+
+ # Creates a new System which can be accessed as a constant under the namespace {FelFlame::Systems}.
+ # The name given is what constant the system is assigned to
+ #
+ # @example
+ # FelFlame::Systems.new('PassiveHeal', priority: -2, frame: 2) do
+ # FelFlame::Components::Health.each do |component|
+ # component.hp += 5
+ # end
+ # end
+ # # Only heal all characters with health every other frame.
+ # # Give it a low priority so other systems such as a
+ # # Poison system would kill the player first
+ #
+ # @param name [String] The name this system will use. Needs to to be in the Ruby Constant format.
+ # @param priority [Integer] Which priority order this system should be executed in relative to other systems. Higher means executed earlier.
+ # @param block [Proc] The code you wish to be executed when the system is triggered. Can be defined by using a +do end+ block or using +{ }+ braces.
+ def initialize(name, priority: 0, &block)
+ FelFlame::Systems.const_set(name, self)
+ @const_name = name
+ @priority = priority
+ @block = block
+ end
+
+ # Manually execute the system a single time
+ def call
+ @block.call
+ end
+
+ # Attempt to execute the system following the frame parameter set on this system.
+ # @return [Boolean] +true+ if the frame of the {FelFlame::Stage} is a multiple of this System's frame setting and this system has executed, +false+ otherwise where the system has not executed.
+ # For example if a System has its frame set to 3, it will only execute once every third frame that is called in FelFlame::Stage
+ #
+ def step; end
+
+ # Redefine what code is executed by this System when it is called upon.
+ # @param block [Proc] The code you wish to be executed when the system is triggered. Can be defined by using a +do end+ block or using +{ }+ braces.
+ def redefine(&block)
+ @block = block
+ end
+
+ # Removes triggers from this system
+ # @param component_or_manager [Component or ComponentManager] The object to clear triggers from. Use Nil to clear triggers from all components associated with this system.
+ # @return [Boolean] true
+ def clear_triggers(*trigger_types, component_or_manager: nil)
+ trigger_types = [:addition_triggers, :removal_triggers] if trigger_types.empty?
+ trigger_types.each do |trigger_type|
+ if component_or_manager.nil?
+ send(trigger_type).each do |trigger|
+ trigger.send(trigger_type).delete self
+ end
+ self.addition_triggers = []
+ else
+ send(trigger_type).delete component_or_manager
+ component_or_manager.send(trigger_type).delete self
+ end
+ end
+ true
+ end
+
+ # Add a component or component manager so that it triggers this system when the component or a component from the component manager is added to an entity
+ # @param component_or_manager [Component or ComponentManager] The component or component manager to trigger this system when added
+ # @return [Boolean] true
+ def trigger_when_added(component_or_manager)
+ self.addition_triggers |= [component_or_manager]
+ component_or_manager.addition_triggers |= [self]
+ true
+ end
+
+ # Add a component or component manager so that it triggers this system when the component or a component from the component manager is removed from an entity
+ # @param component_or_manager [Component or ComponentManager] The component or component manager to trigger this system when removed
+ # @return [Boolean] true
+ def trigger_when_removed(component_or_manager)
+ self.removal_triggers |= [component_or_manager]
+ component_or_manager.removal_triggers |= [self]
+ true
+ end
end
end