docs/FelFlame/ComponentManager.html in felflame-3.0.0 vs docs/FelFlame/ComponentManager.html in felflame-4.0.0

- old
+ new

@@ -35,11 +35,11 @@ <div id="main" tabindex="-1"> <div id="header"> <div id="menu"> <a href="../_index.html">Index (C)</a> &raquo; - <span class='title'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span> + <span class='title'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span> &raquo; <span class="title">ComponentManager</span> </div> @@ -100,11 +100,11 @@ </div> <h2>Overview</h2><div class="docstring"> <div class="discussion"> -<p>Component Managers are what is used to create individual components which can be attached to entities. When a Component is created from a Component Manager that has accessors given to it, you can set or get the values of those accessors using standard ruby message sending (e.g <tt>@component.var = 5</tt>), or by using the <span class='object_link'><a href="#attrs-instance_method" title="FelFlame::ComponentManager#attrs (method)">#attrs</a></span> and <span class='object_link'><a href="#update_attrs-instance_method" title="FelFlame::ComponentManager#update_attrs (method)">#update_attrs</a></span> methods instead.</p> +<p>Component Managers are what is used to create individual components which can be attached to entities. When a Component is created from a Component Manager that has accessors given to it, you can set or get the values of those accessors using standard ruby message sending (e.g <tt>@component.var = 5</tt>), or by using the <span class='object_link'><a href="#to_h-instance_method" title="FelFlame::ComponentManager#to_h (method)">#to_h</a></span> and <span class='object_link'><a href="#update_attrs-instance_method" title="FelFlame::ComponentManager#update_attrs (method)">#update_attrs</a></span> methods instead.</p> </div> </div> <div class="tags"> @@ -268,39 +268,10 @@ <li class="public "> <span class="summary_signature"> - <a href="#id-instance_method" title="#id (instance method)">#<strong>id</strong> &#x21d2; Integer </a> - - - - </span> - - - - - <span class="note title readonly">readonly</span> - - - - - - - - - - <span class="summary_desc"><div class='inline'> -<p>Holds the <span class='object_link'><a href="#id-instance_method" title="FelFlame::ComponentManager#id (method)">unique ID</a></span> of a component.</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; Array&lt;System&gt; </a> </span> @@ -330,77 +301,20 @@ <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="#[]-class_method" title="[] (class method)">.<strong>[]</strong>(component_id) &#x21d2; Component </a> - - - - </span> - - - - - - - - - - <span class="summary_desc"><div class='inline'> -<p>Gets a Component from the given <span class='object_link'><a href="#id-instance_method" title="FelFlame::ComponentManager#id (method)">unique ID</a></span>.</p> -</div></span> - -</li> - - - <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>Iterates over all components within the component manager.</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="#attr_changed_trigger_systems-instance_method" title="#attr_changed_trigger_systems (instance method)">#<strong>attr_changed_trigger_systems</strong>(attr) &#x21d2; Boolean </a> + <a href="#delete-instance_method" title="#delete (instance method)">#<strong>delete</strong> &#x21d2; Boolean </a> </span> @@ -411,20 +325,20 @@ <span class="summary_desc"><div class='inline'> -<p>Execute systems that have been added to execute on variable change.</p> +<p>Removes this component from the list and purges all references to this Component from other Entities, as well as its data.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> - <a href="#attrs-instance_method" title="#attrs (instance method)">#<strong>attrs</strong> &#x21d2; Hash&lt;Symbol, Value&gt; </a> + <a href="#entities-instance_method" title="#entities (instance method)">#<strong>entities</strong> &#x21d2; Array&lt;Component&gt; </a> </span> @@ -435,20 +349,20 @@ <span class="summary_desc"><div class='inline'> -<p>A hash, where all the keys are attributes linked to their respective values.</p> +<p>Entities that have this component.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> - <a href="#delete-instance_method" title="#delete (instance method)">#<strong>delete</strong> &#x21d2; Boolean </a> + <a href="#entity-instance_method" title="#entity (instance method)">#<strong>entity</strong> &#x21d2; Component </a> </span> @@ -459,43 +373,19 @@ <span class="summary_desc"><div class='inline'> -<p>Removes this component from the list and purges all references to this Component from other Entities, as well as its <span class='object_link'><a href="#id-instance_method" title="FelFlame::ComponentManager#id (method)">ID</a></span> and data.</p> +<p>A single entity.</p> </div></span> </li> <li class="public "> <span class="summary_signature"> - <a href="#entities-instance_method" title="#entities (instance method)">#<strong>entities</strong> &#x21d2; Array&lt;Integer&gt; </a> - - - - </span> - - - - - - - - - - <span class="summary_desc"><div class='inline'> -<p>A list of entity ids that are linked to the component.</p> -</div></span> - -</li> - - - <li class="public "> - <span class="summary_signature"> - <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(**attrs) &#x21d2; Component </a> </span> @@ -518,11 +408,11 @@ <li class="public "> <span class="summary_signature"> - <a href="#to_i-instance_method" title="#to_i (instance method)">#<strong>to_i</strong> &#x21d2; Integer </a> + <a href="#to_h-instance_method" title="#to_h (instance method)">#<strong>to_h</strong> &#x21d2; Hash&lt;Symbol, Value&gt; </a> </span> @@ -533,11 +423,11 @@ <span class="summary_desc"><div class='inline'> -<p>An alias for the <span class='object_link'><a href="#id-instance_method" title="FelFlame::ComponentManager#id (method)">ID Reader</a></span>.</p> +<p>A hash, where all the keys are attributes storing their respective values.</p> </div></span> </li> @@ -615,51 +505,41 @@ <tr> <td> <pre class="lines"> -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122</pre> +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 104</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 132</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 </span> <span class='comment'># (this is a function created with metaprogramming -</span> <span class='comment'># in FelFlame::Components +</span> <span class='comment'># in FelFlame::Components) </span> <span class='id identifier rubyid_set_defaults'>set_defaults</span> - <span class='comment'># Generate ID -</span> <span class='id identifier rubyid_new_id'>new_id</span> <span class='op'>=</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='period'>.</span><span class='id identifier rubyid_find_index'>find_index</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_i'>i</span><span class='op'>|</span> <span class='id identifier rubyid_i'>i</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='rbrace'>}</span> - <span class='id identifier rubyid_new_id'>new_id</span> <span class='op'>=</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='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='kw'>if</span> <span class='id identifier rubyid_new_id'>new_id</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> - <span class='ivar'>@id</span> <span class='op'>=</span> <span class='id identifier rubyid_new_id'>new_id</span> - <span class='comment'># Fill params </span> <span class='id identifier rubyid_attrs'>attrs</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> <span class='id identifier rubyid_send'>send</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span> <span class='kw'>end</span> <span class='comment'># Save Component -</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_new_id'>new_id</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='kw'>self</span> +</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_push'>push</span> <span class='kw'>self</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> @@ -708,16 +588,16 @@ <tr> <td> <pre class="lines"> -136 -137 -138</pre> +180 +181 +182</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 136</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 180</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> @@ -764,16 +644,16 @@ <tr> <td> <pre class="lines"> -152 -153 -154</pre> +196 +197 +198</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 152</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 196</span> <span class='kw'>def</span> <span class='id identifier rubyid_attr_triggers'>attr_triggers</span> <span class='ivar'>@attr_triggers</span> <span class='op'>||=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span> <span class='kw'>end</span></pre> </td> @@ -820,16 +700,16 @@ <tr> <td> <pre class="lines"> -144 -145 -146</pre> +188 +189 +190</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 144</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 188</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> @@ -881,16 +761,16 @@ <tr> <td> <pre class="lines"> -81 -82 -83</pre> +109 +110 +111</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 81</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 109</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> @@ -937,82 +817,26 @@ <tr> <td> <pre class="lines"> -97 -98 -99</pre> +125 +126 +127</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 97</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 125</span> <span class='kw'>def</span> <span class='id identifier rubyid_attr_triggers'>attr_triggers</span> <span class='ivar'>@attr_triggers</span> <span class='op'>||=</span> <span class='lbrace'>{</span><span class='rbrace'>}</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> - - - - - -</h3><div class="docstring"> - <div class="discussion"> - -<p>Holds the <span class='object_link'><a href="#id-instance_method" title="FelFlame::ComponentManager#id (method)">unique ID</a></span> of a component. The <span class='object_link'><a href="#id-instance_method" title="FelFlame::ComponentManager#id (method)">ID</a></span> is only unique within the scope of the component manager it was created from.</p> - - - </div> -</div> -<div class="tags"> - -<p class="tag_title">Returns:</p> -<ul class="return"> - - <li> - - - <span class='type'>(<tt>Integer</tt>)</span> - - - - </li> - -</ul> - -</div><table class="source_code"> - <tr> - <td> - <pre class="lines"> - - -63 -64 -65</pre> - </td> - <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 63</span> - -<span class='kw'>def</span> <span class='id identifier rubyid_id'>id</span> - <span class='ivar'>@id</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>Array&lt;System&gt;</tt> @@ -1049,16 +873,16 @@ <tr> <td> <pre class="lines"> -89 -90 -91</pre> +117 +118 +119</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 89</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 117</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> @@ -1067,170 +891,27 @@ </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="[]-class_method"> - - .<strong>[]</strong>(component_id) &#x21d2; <tt>Component</tt> - - - - - -</h3><div class="docstring"> - <div class="discussion"> - -<p>Gets a Component from the given <span class='object_link'><a href="#id-instance_method" title="FelFlame::ComponentManager#id (method)">unique ID</a></span>. Usage is simular to how an Array lookup works.</p> - - - </div> -</div> -<div class="tags"> - - <div class="examples"> - <p class="tag_title">Examples:</p> - - - <pre class="example code"><code><span class='comment'># this gets the &#39;Health&#39; Component with ID 7 -</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='lbracket'>[</span><span class='int'>7</span><span class='rbracket'>]</span></code></pre> - - </div> -<p class="tag_title">Parameters:</p> -<ul class="param"> - - <li> - - <span class='name'>component_id</span> - - - <span class='type'>(<tt>Integer</tt>)</span> - - - - </li> - -</ul> - -<p class="tag_title">Returns:</p> -<ul class="return"> - - <li> - - - <span class='type'>(<tt>Component</tt>)</span> - - - - &mdash; - <div class='inline'> -<p>Returns the Component that uses the given unique <span class='object_link'><a href="#id-instance_method" title="FelFlame::ComponentManager#id (method)">ID</a></span>, nil if there is no Component associated with the given <span class='object_link'><a href="#id-instance_method" title="FelFlame::ComponentManager#id (method)">ID</a></span></p> -</div> - - </li> - -</ul> - -</div><table class="source_code"> - <tr> - <td> - <pre class="lines"> - - -169 -170 -171</pre> - </td> - <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 169</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> -<span class='kw'>end</span></pre> - </td> - </tr> -</table> -</div> - - <div class="method_details "> - <h3 class="signature " id="each-class_method"> - - .<strong>each</strong>(&amp;block) &#x21d2; <tt>Enumerator</tt> - - - - - -</h3><div class="docstring"> - <div class="discussion"> - -<p>Iterates over all components within the component manager. Special Enumerable methods like <code>map</code> or <code>each_with_index</code> are not implemented</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"> - - -176 -177 -178</pre> - </td> - <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 176</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> -<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="attr_changed_trigger_systems-instance_method"> + <h3 class="signature first" id="delete-instance_method"> - #<strong>attr_changed_trigger_systems</strong>(attr) &#x21d2; <tt>Boolean</tt> + #<strong>delete</strong> &#x21d2; <tt>Boolean</tt> </h3><div class="docstring"> <div class="discussion"> -<p>Execute systems that have been added to execute on variable change</p> +<p>Removes this component from the list and purges all references to this Component from other Entities, as well as its data.</p> </div> </div> <div class="tags"> @@ -1245,11 +926,11 @@ &mdash; <div class='inline'> -<p><code>true</code></p> +<p><code>true</code>.</p> </div> </li> </ul> @@ -1258,50 +939,58 @@ <tr> <td> <pre class="lines"> -203 -204 -205 -206 -207 -208 -209 -210 -211</pre> +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 203</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 247</span> -<span class='kw'>def</span> <span class='id identifier rubyid_attr_changed_trigger_systems'>attr_changed_trigger_systems</span><span class='lparen'>(</span><span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span> - <span class='id identifier rubyid_systems_to_execute'>systems_to_execute</span> <span class='op'>=</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_attr_triggers'>attr_triggers</span><span class='lbracket'>[</span><span class='id identifier rubyid_attr'>attr</span><span class='rbracket'>]</span> - <span class='id identifier rubyid_systems_to_execute'>systems_to_execute</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='id identifier rubyid_systems_to_execute'>systems_to_execute</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> - - <span class='id identifier rubyid_systems_to_execute'>systems_to_execute</span> <span class='op'>|=</span> <span class='id identifier rubyid_attr_triggers'>attr_triggers</span><span class='lbracket'>[</span><span class='id identifier rubyid_attr'>attr</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_attr_triggers'>attr_triggers</span><span class='lbracket'>[</span><span class='id identifier rubyid_attr'>attr</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> - - <span class='id identifier rubyid_systems_to_execute'>systems_to_execute</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='symbol'>:call</span><span class='rparen'>)</span> +<span class='kw'>def</span> <span class='id identifier rubyid_delete'>delete</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='id identifier rubyid_entities'>entities</span><span class='period'>.</span><span class='id identifier rubyid_reverse_each'>reverse_each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_entity'>entity</span><span class='op'>|</span> + <span class='id identifier rubyid_entity'>entity</span><span class='period'>.</span><span class='id identifier rubyid_remove'>remove</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_class'>class</span><span class='period'>.</span><span class='id identifier rubyid__data'>_data</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='kw'>self</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> <span class='kw'>true</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> - <h3 class="signature " id="attrs-instance_method"> + <h3 class="signature " id="entities-instance_method"> - #<strong>attrs</strong> &#x21d2; <tt>Hash&lt;Symbol, Value&gt;</tt> + #<strong>entities</strong> &#x21d2; <tt>Array&lt;Component&gt;</tt> </h3><div class="docstring"> <div class="discussion"> -<p>Returns A hash, where all the keys are attributes linked to their respective values.</p> +<p>Entities that have this component</p> </div> </div> <div class="tags"> @@ -1310,65 +999,52 @@ <ul class="return"> <li> - <span class='type'>(<tt>Hash&lt;Symbol, Value&gt;</tt>)</span> + <span class='type'>(<tt>Array&lt;Component&gt;</tt>)</span> - &mdash; - <div class='inline'> -<p>A hash, where all the keys are attributes linked to their respective values.</p> -</div> - </li> </ul> </div><table class="source_code"> <tr> <td> <pre class="lines"> -235 -236 -237 -238 -239 -240 -241</pre> +209 +210 +211</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 235</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 209</span> -<span class='kw'>def</span> <span class='id identifier rubyid_attrs'>attrs</span> - <span class='id identifier rubyid_return_hash'>return_hash</span> <span class='op'>=</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> - <span class='id identifier rubyid_final'>final</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_delete_prefix'>delete_prefix</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>@</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_instance_variable_get'>instance_variable_get</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span> - <span class='kw'>end</span> - <span class='id identifier rubyid_return_hash'>return_hash</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:attr_triggers</span><span class='rparen'>)</span> - <span class='id identifier rubyid_return_hash'>return_hash</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> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> - <h3 class="signature " id="delete-instance_method"> + <h3 class="signature " id="entity-instance_method"> - #<strong>delete</strong> &#x21d2; <tt>Boolean</tt> + #<strong>entity</strong> &#x21d2; <tt>Component</tt> </h3><div class="docstring"> <div class="discussion"> -<p>Removes this component from the list and purges all references to this Component from other Entities, as well as its <span class='object_link'><a href="#id-instance_method" title="FelFlame::ComponentManager#id (method)">ID</a></span> and data.</p> +<p>A single entity. Use this if you expect the component to only belong to one entity and you want to access it.</p> </div> </div> <div class="tags"> @@ -1377,19 +1053,14 @@ <ul class="return"> <li> - <span class='type'>(<tt>Boolean</tt>)</span> + <span class='type'>(<tt>Component</tt>)</span> - &mdash; - <div class='inline'> -<p><code>true</code>.</p> -</div> - </li> </ul> </div><table class="source_code"> @@ -1403,61 +1074,41 @@ 217 218 219 220 221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232</pre> +222</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 215</span> -<span class='kw'>def</span> <span class='id identifier rubyid_delete'>delete</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'>def</span> <span class='id identifier rubyid_entity'>entity</span> + <span class='kw'>if</span> <span class='id identifier rubyid_entities'>entities</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> + <span class='const'>Warning</span><span class='period'>.</span><span class='id identifier rubyid_warn'>warn</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>This component belongs to NO entities but you called the method that is intended for components belonging to a single entity.\nYou may have a bug in your logic.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> + <span class='kw'>elsif</span> <span class='id identifier rubyid_entities'>entities</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>&gt;</span> <span class='int'>1</span> + <span class='const'>Warning</span><span class='period'>.</span><span class='id identifier rubyid_warn'>warn</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>This component belongs to MANY entities but you called the method that is intended for components belonging to a single entity.\nYou may have a bug in your logic.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</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'>entity</span><span class='op'>|</span> - <span class='comment'>#FelFlame::Entities[entity_id].remove self #unless FelFlame::Entities[entity_id].nil? -</span> <span class='id identifier rubyid_entity'>entity</span><span class='period'>.</span><span class='id identifier rubyid_remove'>remove</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_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='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> - <span class='kw'>true</span> + <span class='id identifier rubyid_entities'>entities</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> <div class="method_details "> - <h3 class="signature " id="entities-instance_method"> + <h3 class="signature " id="to_h-instance_method"> - #<strong>entities</strong> &#x21d2; <tt>Array&lt;Integer&gt;</tt> + #<strong>to_h</strong> &#x21d2; <tt>Hash&lt;Symbol, Value&gt;</tt> </h3><div class="docstring"> <div class="discussion"> -<p>A list of entity ids that are linked to the component</p> +<p>Returns A hash, where all the keys are attributes storing their respective values.</p> </div> </div> <div class="tags"> @@ -1466,87 +1117,46 @@ <ul class="return"> <li> - <span class='type'>(<tt>Array&lt;Integer&gt;</tt>)</span> + <span class='type'>(<tt>Hash&lt;Symbol, Value&gt;</tt>)</span> - </li> - -</ul> - -</div><table class="source_code"> - <tr> - <td> - <pre class="lines"> - - -189 -190 -191</pre> - </td> - <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 189</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> -<span class='kw'>end</span></pre> - </td> - </tr> -</table> + &mdash; + <div class='inline'> +<p>A hash, where all the keys are attributes storing their respective values.</p> </div> - - <div class="method_details "> - <h3 class="signature " id="to_i-instance_method"> - - #<strong>to_i</strong> &#x21d2; <tt>Integer</tt> - - - - - -</h3><div class="docstring"> - <div class="discussion"> - -<p>An alias for the <span class='object_link'><a href="#id-instance_method" title="FelFlame::ComponentManager#id (method)">ID Reader</a></span></p> - - - </div> -</div> -<div class="tags"> - -<p class="tag_title">Returns:</p> -<ul class="return"> - - <li> - - <span class='type'>(<tt>Integer</tt>)</span> - - - </li> </ul> </div><table class="source_code"> <tr> <td> <pre class="lines"> -183 -184 -185</pre> +262 +263 +264 +265 +266 +267 +268</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 183</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 262</span> -<span class='kw'>def</span> <span class='id identifier rubyid_to_i'>to_i</span> - <span class='id identifier rubyid_id'>id</span> +<span class='kw'>def</span> <span class='id identifier rubyid_to_h'>to_h</span> + <span class='id identifier rubyid_return_hash'>return_hash</span> <span class='op'>=</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> + <span class='id identifier rubyid_final'>final</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_delete_prefix'>delete_prefix</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>@</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_instance_variable_get'>instance_variable_get</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span> + <span class='kw'>end</span> + <span class='id identifier rubyid_return_hash'>return_hash</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:attr_triggers</span><span class='rparen'>)</span> + <span class='id identifier rubyid_return_hash'>return_hash</span> <span class='kw'>end</span></pre> </td> </tr> </table> </div> @@ -1593,18 +1203,18 @@ <tr> <td> <pre class="lines"> -195 -196 -197 -198 -199</pre> +226 +227 +228 +229 +230</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 195</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 226</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> <span class='id identifier rubyid_send'>send</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span> <span class='kw'>end</span> @@ -1617,10 +1227,10 @@ </div> </div> <div id="footer"> - Generated on Mon Jul 12 18:28:27 2021 by + Generated on Mon Jan 3 08:23:04 2022 by <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.26 (ruby-2.7.3). </div> </div> \ No newline at end of file