diff options
| author | _Tradam <[email protected]> | 2021-12-30 07:33:27 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-12-30 07:33:27 -0500 |
| commit | 3104eaf4ca0515572aeedc114cb6095a07825d90 (patch) | |
| tree | a1feb0d69557f1a24f9884567d0d939c129c6447 | |
| parent | 5ef652300e71b572ca58b061610d606840ce19a9 (diff) | |
| download | FelECS-revert-12-arry.tar.gz FelECS-revert-12-arry.zip | |
Revert "Major 4.0 update (#12)"revert-12-arry
This reverts commit 5ef652300e71b572ca58b061610d606840ce19a9.
28 files changed, 1354 insertions, 783 deletions
diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index 2c9b4ef..0000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -2.7.3 diff --git a/CHANGELOG.mdown b/CHANGELOG.mdown index 15f2392..6f34a95 100644 --- a/CHANGELOG.mdown +++ b/CHANGELOG.mdown @@ -8,23 +8,6 @@   -## [4.0.0](https://github.com/realtradam/FelFlame/releases/tag/4.0.0) - 2021-12-30 - -- Removed all ids as they were not used - - -- Component method `.attrs` was renamed to `.to_h` -- Renamed the `data` accessor to `._data` -- Various arrays are automatically compacted - - -- Classes and Modules which used a data array now have the entire set of array methods available to their respective Classes and Modules -- Convenience methods for accessing a single entity in a component(`@component.entity`) and accessing a single entity in a component(`@entity.component[@component_manager]`) - - -- Replaced all instances of `sort_by!` with `sort_by` for compatibility with DragonRuby -- Minor optimizations such as less array duplication - ## [3.0.0](https://github.com/realtradam/FelFlame/releases/tag/3.0.0) - 2021-07-12  - The Scene alias was changed from ```FelFlame::Sce``` to ```FelFlame::Scn``` as it is more intuitive. @@ -11,26 +11,6 @@ require "rubocop/rake_task" task :default => [:spec, :yard, 'coverage:format'] #task default: :rubocop -desc 'Export to single file' -task :buildfile do - result = '' - main = File.read('lib/felflame.rb') - tmp = main.lines(chomp: true).select do |line| - line.include? "require_relative " - end - tmp.each do |file| - file.delete_prefix!("require_relative ") - result += File.read("lib/#{file[1,file.length-2]}.rb") + "\n" - end - - result += main.lines.reject do |line| - line.include? "require_relative " - end.join - - `mkdir pkg` - File.write('pkg/felflame.rb', result) -end - RuboCop::RakeTask.new namespace :coverage do diff --git a/docs/FelFlame.html b/docs/FelFlame.html index 8fd0fd6..16bb6f9 100644 --- a/docs/FelFlame.html +++ b/docs/FelFlame.html @@ -4,7 +4,7 @@ <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title> - Module: FelFlame + Class: FelFlame — Documentation by YARD 0.9.26 @@ -59,13 +59,29 @@ <div class="clear"></div> </div> - <div id="content"><h1>Module: FelFlame + <div id="content"><h1>Class: FelFlame </h1> <div class="box_info"> + <dl> + <dt>Inherits:</dt> + <dd> + <span class="inheritName">Object</span> + + <ul class="fullTree"> + <li>Object</li> + + <li class="next">FelFlame</li> + + </ul> + <a href="#" class="inheritanceTree">show all</a> + + </dd> + </dl> + @@ -100,11 +116,9 @@ <p class="children"> - <strong class="modules">Modules:</strong> <span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span>, <span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span> - - <strong class="classes">Classes:</strong> <span class='object_link'><a href="FelFlame/ComponentManager.html" title="FelFlame::ComponentManager (class)">ComponentManager</a></span>, <span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span>, <span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span>, <span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span> + <strong class="classes">Classes:</strong> <span class='object_link'><a href="FelFlame/ComponentManager.html" title="FelFlame::ComponentManager (class)">ComponentManager</a></span>, <span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (class)">Components</a></span>, <span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span>, <span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span>, <span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (class)">Stage</a></span>, <span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span> </p> @@ -137,7 +151,7 @@ <div class="docstring"> <div class="discussion"> -<p>An alias for <span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></p> +<p>An alias for <span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (class)">Components</a></span></p> </div> @@ -147,7 +161,7 @@ </div> </dt> - <dd><pre class="code"><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span></pre></dd> + <dd><pre class="code"><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (class)">Components</a></span></span></pre></dd> <dt id="Sys-constant" class="">Sys = <div class="docstring"> @@ -185,7 +199,7 @@ <div class="docstring"> <div class="discussion"> -<p>An alias for <span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span></p> +<p>An alias for <span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (class)">Stage</a></span></p> </div> @@ -195,7 +209,7 @@ </div> </dt> - <dd><pre class="code"><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span></pre></dd> + <dd><pre class="code"><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (class)">Stage</a></span></span></pre></dd> </dl> @@ -281,7 +295,7 @@ <pre class="code"><span class="info file"># File 'lib/felflame.rb', line 15</span> <span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span> - <span class='const'><span class='object_link'><a href="" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_call'><span class='object_link'><a href="FelFlame/Stage.html#call-class_method" title="FelFlame::Stage.call (method)">call</a></span></span> + <span class='const'><span class='object_link'><a href="" title="FelFlame (class)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (class)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_call'><span class='object_link'><a href="FelFlame/Stage.html#call-class_method" title="FelFlame::Stage.call (method)">call</a></span></span> <span class='kw'>end</span></pre> </td> </tr> @@ -293,7 +307,7 @@ </div> <div id="footer"> - Generated on Thu Dec 30 07:28:05 2021 by + Generated on Mon Jul 12 18:28:27 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/ComponentManager.html b/docs/FelFlame/ComponentManager.html index 599b547..1da6816 100644 --- a/docs/FelFlame/ComponentManager.html +++ b/docs/FelFlame/ComponentManager.html @@ -37,7 +37,7 @@ <div id="menu"> <a href="../_index.html">Index (C)</a> » - <span class='title'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span> + <span class='title'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span> » <span class="title">ComponentManager</span> @@ -102,7 +102,7 @@ <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 #attrs 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="#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> </div> @@ -270,6 +270,35 @@ <li class="public "> <span class="summary_signature"> + <a href="#id-instance_method" title="#id (instance method)">#<strong>id</strong> ⇒ 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> ⇒ Array<System> </a> @@ -303,6 +332,63 @@ <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) ⇒ 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>(&block) ⇒ 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> @@ -336,7 +422,7 @@ <li class="public "> <span class="summary_signature"> - <a href="#delete-instance_method" title="#delete (instance method)">#<strong>delete</strong> ⇒ Boolean </a> + <a href="#attrs-instance_method" title="#attrs (instance method)">#<strong>attrs</strong> ⇒ Hash<Symbol, Value> </a> @@ -351,7 +437,7 @@ <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 data.</p> +<p>A hash, where all the keys are attributes linked to their respective values.</p> </div></span> </li> @@ -360,7 +446,7 @@ <li class="public "> <span class="summary_signature"> - <a href="#entities-instance_method" title="#entities (instance method)">#<strong>entities</strong> ⇒ Array<Component> </a> + <a href="#delete-instance_method" title="#delete (instance method)">#<strong>delete</strong> ⇒ Boolean </a> @@ -375,7 +461,7 @@ <span class="summary_desc"><div class='inline'> -<p>Entities that have this component.</p> +<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> </div></span> </li> @@ -384,7 +470,7 @@ <li class="public "> <span class="summary_signature"> - <a href="#entity-instance_method" title="#entity (instance method)">#<strong>entity</strong> ⇒ Component </a> + <a href="#entities-instance_method" title="#entities (instance method)">#<strong>entities</strong> ⇒ Array<Integer> </a> @@ -399,7 +485,7 @@ <span class="summary_desc"><div class='inline'> -<p>A single entity.</p> +<p>A list of entity ids that are linked to the component.</p> </div></span> </li> @@ -434,7 +520,7 @@ <li class="public "> <span class="summary_signature"> - <a href="#to_h-instance_method" title="#to_h (instance method)">#<strong>to_h</strong> ⇒ Hash<Symbol, Value> </a> + <a href="#to_i-instance_method" title="#to_i (instance method)">#<strong>to_i</strong> ⇒ Integer </a> @@ -449,7 +535,7 @@ <span class="summary_desc"><div class='inline'> -<p>A hash, where all the keys are attributes linked to their respective values.</p> +<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></span> </li> @@ -531,6 +617,11 @@ <pre class="lines"> +104 +105 +106 +107 +108 109 110 111 @@ -547,21 +638,26 @@ 122</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 109</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 104</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'>"</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'>"</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_push'>push</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_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 class='kw'>end</span></pre> </td> </tr> @@ -614,12 +710,12 @@ <pre class="lines"> -159 -160 -161</pre> +136 +137 +138</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 159</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 136</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> @@ -670,12 +766,12 @@ <pre class="lines"> -175 -176 -177</pre> +152 +153 +154</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 175</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 152</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> @@ -726,12 +822,12 @@ <pre class="lines"> -167 -168 -169</pre> +144 +145 +146</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 167</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 144</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> @@ -787,12 +883,12 @@ <pre class="lines"> -86 -87 -88</pre> +81 +82 +83</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 86</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 81</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> @@ -843,12 +939,12 @@ <pre class="lines"> -102 -103 -104</pre> +97 +98 +99</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 102</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 97</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> @@ -859,6 +955,62 @@ </div> + <span id="id=-instance_method"></span> + <div class="method_details "> + <h3 class="signature " id="id-instance_method"> + + #<strong>id</strong> ⇒ <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"> @@ -899,12 +1051,12 @@ <pre class="lines"> -94 -95 -96</pre> +89 +90 +91</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 94</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 89</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> @@ -917,6 +1069,149 @@ </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) ⇒ <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 'Health' 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> + + + + — + <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>(&block) ⇒ <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'>&</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'>&</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> @@ -965,18 +1260,18 @@ <pre class="lines"> -213 -214 -215 -216 -217 -218 -219 -220 -221</pre> +203 +204 +205 +206 +207 +208 +209 +210 +211</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 213</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 203</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> @@ -984,7 +1279,7 @@ <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'>&</span><span class='symbol'>:priority</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_reverse_each'>reverse_each</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:call</span><span class='rparen'>)</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'>&</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'>&</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='kw'>true</span> <span class='kw'>end</span></pre> </td> @@ -993,9 +1288,9 @@ </div> <div class="method_details "> - <h3 class="signature " id="delete-instance_method"> + <h3 class="signature " id="attrs-instance_method"> - #<strong>delete</strong> ⇒ <tt>Boolean</tt> + #<strong>attrs</strong> ⇒ <tt>Hash<Symbol, Value></tt> @@ -1004,7 +1299,7 @@ </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 data.</p> +<p>Returns A hash, where all the keys are attributes linked to their respective values.</p> </div> @@ -1017,13 +1312,13 @@ <li> - <span class='type'>(<tt>Boolean</tt>)</span> + <span class='type'>(<tt>Hash<Symbol, Value></tt>)</span> — <div class='inline'> -<p><code>true</code>.</p> +<p>A hash, where all the keys are attributes linked to their respective values.</p> </div> </li> @@ -1036,35 +1331,23 @@ <pre class="lines"> -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 235 -236</pre> +236 +237 +238 +239 +240 +241</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 224</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 235</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'>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'>'</span><span class='tstring_content'>@</span><span class='tstring_end'>'</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='kw'>true</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> @@ -1072,9 +1355,9 @@ </div> <div class="method_details "> - <h3 class="signature " id="entities-instance_method"> + <h3 class="signature " id="delete-instance_method"> - #<strong>entities</strong> ⇒ <tt>Array<Component></tt> + #<strong>delete</strong> ⇒ <tt>Boolean</tt> @@ -1083,7 +1366,7 @@ </h3><div class="docstring"> <div class="discussion"> -<p>Entities that have this component</p> +<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> </div> @@ -1096,10 +1379,15 @@ <li> - <span class='type'>(<tt>Array<Component></tt>)</span> + <span class='type'>(<tt>Boolean</tt>)</span> + — + <div class='inline'> +<p><code>true</code>.</p> +</div> + </li> </ul> @@ -1110,15 +1398,45 @@ <pre class="lines"> -188 -189 -190</pre> +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 188</span> + <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_entities'>entities</span> - <span class='ivar'>@entities</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</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='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'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'>&</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='kw'>end</span></pre> </td> </tr> @@ -1126,9 +1444,9 @@ </div> <div class="method_details "> - <h3 class="signature " id="entity-instance_method"> + <h3 class="signature " id="entities-instance_method"> - #<strong>entity</strong> ⇒ <tt>Component</tt> + #<strong>entities</strong> ⇒ <tt>Array<Integer></tt> @@ -1137,7 +1455,7 @@ </h3><div class="docstring"> <div class="discussion"> -<p>A single entity. Use this if you expect the component to only belong to one entity and you want to access it.</p> +<p>A list of entity ids that are linked to the component</p> </div> @@ -1150,7 +1468,7 @@ <li> - <span class='type'>(<tt>Component</tt>)</span> + <span class='type'>(<tt>Array<Integer></tt>)</span> @@ -1164,25 +1482,15 @@ <pre class="lines"> -194 -195 -196 -197 -198 -199 -200 -201</pre> +189 +190 +191</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 194</span> + <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_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'>"</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'>"</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'>></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'>"</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'>"</span></span><span class='rparen'>)</span> - <span class='kw'>end</span> - <span class='id identifier rubyid_entities'>entities</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</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> @@ -1190,9 +1498,9 @@ </div> <div class="method_details "> - <h3 class="signature " id="to_h-instance_method"> + <h3 class="signature " id="to_i-instance_method"> - #<strong>to_h</strong> ⇒ <tt>Hash<Symbol, Value></tt> + #<strong>to_i</strong> ⇒ <tt>Integer</tt> @@ -1201,7 +1509,7 @@ </h3><div class="docstring"> <div class="discussion"> -<p>Returns A hash, where all the keys are attributes linked to their respective values.</p> +<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> @@ -1214,14 +1522,9 @@ <li> - <span class='type'>(<tt>Hash<Symbol, Value></tt>)</span> - + <span class='type'>(<tt>Integer</tt>)</span> - — - <div class='inline'> -<p>A hash, where all the keys are attributes linked to their respective values.</p> -</div> </li> @@ -1233,23 +1536,15 @@ <pre class="lines"> -239 -240 -241 -242 -243 -244 -245</pre> +183 +184 +185</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 239</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 183</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'>'</span><span class='tstring_content'>@</span><span class='tstring_end'>'</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_to_i'>to_i</span> + <span class='id identifier rubyid_id'>id</span> <span class='kw'>end</span></pre> </td> </tr> @@ -1300,14 +1595,14 @@ <pre class="lines"> -205 -206 -207 -208 -209</pre> +195 +196 +197 +198 +199</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 205</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 195</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> @@ -1324,7 +1619,7 @@ </div> <div id="footer"> - Generated on Thu Dec 30 07:28:06 2021 by + Generated on Mon Jul 12 18:28:27 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 e3b6167..a44ec31 100644 --- a/docs/FelFlame/Components.html +++ b/docs/FelFlame/Components.html @@ -4,7 +4,7 @@ <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title> - Module: FelFlame::Components + Class: FelFlame::Components — Documentation by YARD 0.9.26 @@ -37,7 +37,7 @@ <div id="menu"> <a href="../_index.html">Index (C)</a> » - <span class='title'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span> + <span class='title'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span> » <span class="title">Components</span> @@ -59,16 +59,37 @@ <div class="clear"></div> </div> - <div id="content"><h1>Module: FelFlame::Components + <div id="content"><h1>Class: FelFlame::Components </h1> <div class="box_info"> + <dl> + <dt>Inherits:</dt> + <dd> + <span class="inheritName">Object</span> + + <ul class="fullTree"> + <li>Object</li> + + <li class="next">FelFlame::Components</li> + + </ul> + <a href="#" class="inheritanceTree">show all</a> + + </dd> + </dl> + + <dl> + <dt>Extended by:</dt> + <dd>Enumerable</dd> + </dl> + @@ -88,7 +109,7 @@ <h2>Overview</h2><div class="docstring"> <div class="discussion"> -<p>Creates component managers and allows accessing them them under the <span class='object_link'><a href="" title="FelFlame::Components (module)">Components</a></span> namespace as Constants.</p> +<p>Creates component managers and allows accessing them them under the <span class='object_link'><a href="" title="FelFlame::Components (class)">Components</a></span> namespace as Constants</p> <p>To see how component managers are used please look at the <span class='object_link'><a href="ComponentManager.html" title="FelFlame::ComponentManager (class)">ComponentManager</a></span> documentation.</p> @@ -116,6 +137,30 @@ <li class="public "> <span class="summary_signature"> + <a href="#each-class_method" title="each (class method)">.<strong>each</strong>(&block) ⇒ Enumerator </a> + + + + </span> + + + + + + + + + + <span class="summary_desc"><div class='inline'> +<p>Iterate over all existing component managers.</p> +</div></span> + +</li> + + + <li class="public "> + <span class="summary_signature"> + <a href="#new-class_method" title="new (class method)">.<strong>new</strong>(component_name, *attrs, **attrs_with_defaults) ⇒ ComponentManager </a> @@ -141,13 +186,68 @@ + <div id="class_method_details" class="method_details_list"> <h2>Class Method Details</h2> <div class="method_details first"> - <h3 class="signature first" id="new-class_method"> + <h3 class="signature first" id="each-class_method"> + + .<strong>each</strong>(&block) ⇒ <tt>Enumerator</tt> + + + + + +</h3><div class="docstring"> + <div class="discussion"> + +<p>Iterate over all existing component managers. 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"> + + +51 +52 +53</pre> + </td> + <td> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 51</span> + +<span class='kw'>def</span> <span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='op'>&</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_each'>each</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span> +<span class='kw'>end</span></pre> + </td> + </tr> +</table> +</div> + + <div class="method_details "> + <h3 class="signature " id="new-class_method"> .<strong>new</strong>(component_name, *attrs, **attrs_with_defaults) ⇒ <tt><span class='object_link'><a href="ComponentManager.html" title="FelFlame::ComponentManager (class)">ComponentManager</a></span></tt> @@ -173,7 +273,7 @@ </span><span class='comment'># while max and current are nil until set. </span><span class='comment'># When you make a new component using this component manager </span><span class='comment'># these are the values and accessors it will have. -</span><span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'>Component</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Health</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='symbol'>:max</span><span class='comma'>,</span> <span class='symbol'>:current</span><span class='comma'>,</span> <span class='label'>color:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>red</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span></code></pre> +</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'>Component</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Health</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='symbol'>:max</span><span class='comma'>,</span> <span class='symbol'>:current</span><span class='comma'>,</span> <span class='label'>color:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>red</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span></code></pre> </div> <p class="tag_title">Parameters:</p> @@ -249,7 +349,6 @@ <pre class="lines"> -18 19 20 21 @@ -277,39 +376,40 @@ 43 44 45 -46</pre> +46 +47</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 18</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 19</span> <span class='kw'>def</span> <span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_attrs'>attrs</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_attrs_with_defaults'>attrs_with_defaults</span><span class='rparen'>)</span> - <span class='kw'>if</span> <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Components (module)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_defined?'>const_defined?</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span> + <span class='kw'>if</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::Components (class)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_defined?'>const_defined?</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span> <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'>NameError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Component Manager '</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_component_name'>component_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>' is already defined</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>end</span> - <span class='id identifier rubyid_const_set'>const_set</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='comma'>,</span> <span class='const'>Class</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="ComponentManager.html" title="FelFlame::ComponentManager (class)">ComponentManager</a></span></span><span class='rparen'>)</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span> + <span class='id identifier rubyid_const_set'>const_set</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='comma'>,</span> <span class='const'>Class</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</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="ComponentManager.html" title="FelFlame::ComponentManager (class)">ComponentManager</a></span></span><span class='rparen'>)</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</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_attr'>attr</span><span class='op'>|</span> - <span class='kw'>if</span> <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Components (module)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_method_defined?'>method_defined?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attr'>attr</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='op'>||</span> <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Components (module)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_method_defined?'>method_defined?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attr'>attr</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> + <span class='kw'>if</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::Components (class)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_method_defined?'>method_defined?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attr'>attr</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</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="" title="FelFlame::Components (class)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_method_defined?'>method_defined?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attr'>attr</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='id identifier rubyid_raise'>raise</span> <span class='const'>NameError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>The attribute name \"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attr'>attr</span><span class='embexpr_end'>}</span><span class='tstring_content'>\" is already a method</span><span class='tstring_end'>"</span></span> <span class='kw'>end</span> - <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Components (module)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='id identifier rubyid_attr'>attr</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::Components (class)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='id identifier rubyid_attr'>attr</span> <span class='kw'>end</span> <span class='id identifier rubyid_attrs_with_defaults'>attrs_with_defaults</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_attr'>attr</span><span class='comma'>,</span> <span class='id identifier rubyid__default'>_default</span><span class='op'>|</span> <span class='id identifier rubyid_attrs_with_defaults'>attrs_with_defaults</span><span class='lbracket'>[</span><span class='id identifier rubyid_attr'>attr</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid__default'>_default</span><span class='period'>.</span><span class='id identifier rubyid_dup'>dup</span> - <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Components (module)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_attr_reader'>attr_reader</span> <span class='id identifier rubyid_attr'>attr</span> - <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Components (module)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_define_method'>define_method</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attr'>attr</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_value'>value</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="" title="FelFlame::Components (class)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_attr_reader'>attr_reader</span> <span class='id identifier rubyid_attr'>attr</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::Components (class)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_define_method'>define_method</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attr'>attr</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_value'>value</span><span class='op'>|</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='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_equal?'>equal?</span> <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span> <span class='id identifier rubyid_instance_variable_set'>instance_variable_set</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>@</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attr'>attr</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>end</span> <span class='kw'>end</span> - <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Components (module)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_define_method'>define_method</span><span class='lparen'>(</span><span class='symbol'>:set_defaults</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="" title="FelFlame::Components (class)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_define_method'>define_method</span><span class='lparen'>(</span><span class='symbol'>:set_defaults</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='id identifier rubyid_attrs_with_defaults'>attrs_with_defaults</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_attr'>attr</span><span class='comma'>,</span> <span class='id identifier rubyid_default'>default</span><span class='op'>|</span> <span class='id identifier rubyid_instance_variable_set'>instance_variable_set</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>@</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attr'>attr</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_default'>default</span><span class='period'>.</span><span class='id identifier rubyid_dup'>dup</span><span class='rparen'>)</span> <span class='kw'>end</span> <span class='kw'>end</span> - <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Components (module)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</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::Components (class)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span> <span class='kw'>end</span></pre> </td> </tr> @@ -321,7 +421,7 @@ </div> <div id="footer"> - Generated on Thu Dec 30 07:28:05 2021 by + Generated on Mon Jul 12 18:28:27 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 aca4cac..9d10529 100644 --- a/docs/FelFlame/Entities.html +++ b/docs/FelFlame/Entities.html @@ -37,7 +37,7 @@ <div id="menu"> <a href="../_index.html">Index (E)</a> » - <span class='title'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span> + <span class='title'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span> » <span class="title">Entities</span> @@ -85,6 +85,11 @@ + <dl> + <dt>Extended by:</dt> + <dd>Enumerable</dd> + </dl> + @@ -104,7 +109,7 @@ <h2>Overview</h2><div class="docstring"> <div class="discussion"> -<p>Creates and manages Entities. Allows iterating or accessing Entities using array methods directly on the class. Entities are just collections of Components.</p> +<p>Creates and manages Entities. Allows accessing Entities using their <span class='object_link'><a href="#id-instance_method" title="FelFlame::Entities#id (method)">ID</a></span>. Entities are just collections of Components.</p> </div> @@ -116,12 +121,46 @@ + <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="#id-instance_method" title="#id (instance method)">#<strong>id</strong> ⇒ Integer </a> + + + + </span> + + + + + <span class="note title readonly">readonly</span> + + + + + + + + + + <span class="summary_desc"><div class='inline'> +<p>Holds the unique ID of this entity.</p> +</div></span> + +</li> + + + </ul> + <h2> - Instance Method Summary + Class Method Summary <small><a href="#" class="summary_toggle">collapse</a></small> </h2> @@ -130,7 +169,7 @@ <li class="public "> <span class="summary_signature"> - <a href="#add-instance_method" title="#add (instance method)">#<strong>add</strong>(*components_to_add) ⇒ Boolean </a> + <a href="#[]-class_method" title="[] (class method)">.<strong>[]</strong>(entity_id) ⇒ Entity </a> @@ -145,16 +184,49 @@ <span class="summary_desc"><div class='inline'> -<p>Add any number components to the Entity.</p> +<p>Gets an Entity from the given <span class='object_link'><a href="#id-instance_method" title="FelFlame::Entities#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>(&block) ⇒ Enumerator </a> + + + + </span> + + + + + + + + + + <span class="summary_desc"><div class='inline'> +<p>Iterates over all entities.</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="#component-instance_method" title="#component (instance method)">#<strong>component</strong>(manager = nil) ⇒ Component </a> + <a href="#add-instance_method" title="#add (instance method)">#<strong>add</strong>(*components_to_add) ⇒ Boolean </a> @@ -169,7 +241,7 @@ <span class="summary_desc"><div class='inline'> -<p>A single component from a component manager.</p> +<p>Add any number components to the Entity.</p> </div></span> </li> @@ -193,7 +265,7 @@ <span class="summary_desc"><div class='inline'> -<p>A hash that uses component manager constant names as keys, and where the values of those keys are arrays that contain the the components attached to this entity.</p> +<p>A hash that uses component manager constant names as keys, and where the values of those keys are arrays that contain the <span class='object_link'><a href="ComponentManager.html#id-instance_method" title="FelFlame::ComponentManager#id (method)">IDs</a></span> of the components attached to this entity.</p> </div></span> </li> @@ -217,7 +289,7 @@ <span class="summary_desc"><div class='inline'> -<p>Removes this Entity from the list and purges all references to this Entity from other Components, as well as its data.</p> +<p>Removes this Entity from the list and purges all references to this Entity from other Components, as well as its <span class='object_link'><a href="#id-instance_method" title="FelFlame::Entities#id (method)">ID</a></span> and data.</p> </div></span> </li> @@ -273,10 +345,35 @@ </li> + <li class="public "> + <span class="summary_signature"> + + <a href="#to_i-instance_method" title="#to_i (instance method)">#<strong>to_i</strong> ⇒ Integer </a> + + + + </span> + + + + + + + + + + <span class="summary_desc"><div class='inline'> +<p>An alias for the <span class='object_link'><a href="#id-instance_method" title="FelFlame::Entities#id (method)">ID reader</a></span>.</p> +</div></span> + +</li> + + </ul> -<div id="constructor_details" class="method_details_list"> + + <div id="constructor_details" class="method_details_list"> <h2>Constructor Details</h2> <div class="method_details first"> @@ -305,7 +402,7 @@ <span class='name'>components</span> - <span class='type'>(<tt><span class='object_link'><a href="Components.html" title="FelFlame::Components (module)">Components</a></span></tt>)</span> + <span class='type'>(<tt><span class='object_link'><a href="Components.html" title="FelFlame::Components (class)">Components</a></span></tt>)</span> @@ -325,35 +422,31 @@ <pre class="lines"> -7 -8 -9 -10 -11 -12 -13 -14 -15 16 17 18 -19</pre> +19 +20 +21 +22 +23 +24 +25 +26</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 7</span> + <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 16</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_components'>components</span><span class='rparen'>)</span> + <span class='comment'># Assign new unique 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='lparen'>(</span><span class='op'>&</span><span class='symbol'>:nil?</span><span class='rparen'>)</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='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span> <span class='op'>=</span> <span class='id identifier rubyid_new_id'>new_id</span> + <span class='comment'># Add each component </span> <span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_components'>components</span><span class='rparen'>)</span> - <span class='comment'># Fancy method redirection for when the `component` method is called -</span> <span class='ivar'>@component_redirect</span> <span class='op'>=</span> <span class='const'>Object</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> - <span class='ivar'>@component_redirect</span><span class='period'>.</span><span class='id identifier rubyid_instance_variable_set'>instance_variable_set</span><span class='lparen'>(</span><span class='symbol'>:@entity</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span> - <span class='ivar'>@component_redirect</span><span class='period'>.</span><span class='id identifier rubyid_define_singleton_method'>define_singleton_method</span><span class='lparen'>(</span><span class='symbol'>:[]</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_component_manager'>component_manager</span><span class='op'>|</span> - <span class='id identifier rubyid_instance_variable_get'>instance_variable_get</span><span class='lparen'>(</span><span class='symbol'>:@entity</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_component'>component</span><span class='lparen'>(</span><span class='id identifier rubyid_component_manager'>component_manager</span><span class='rparen'>)</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_push'>push</span> <span class='kw'>self</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'>self</span> <span class='kw'>end</span></pre> </td> </tr> @@ -362,15 +455,76 @@ </div> + <div id="instance_attr_details" class="attr_details"> + <h2>Instance Attribute Details</h2> + + + <span id="id=-instance_method"></span> + <div class="method_details first"> + <h3 class="signature first" id="id-instance_method"> + + #<strong>id</strong> ⇒ <tt>Integer</tt> + - <div id="instance_method_details" class="method_details_list"> - <h2>Instance Method Details</h2> + + + +</h3><div class="docstring"> + <div class="discussion"> + +<p>Holds the unique ID of this entity</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"> + + +5 +6 +7</pre> + </td> + <td> + <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 5</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> + + </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="add-instance_method"> + <h3 class="signature first" id="[]-class_method"> - #<strong>add</strong>(*components_to_add) ⇒ <tt>Boolean</tt> + .<strong>[]</strong>(entity_id) ⇒ <tt>Entity</tt> @@ -379,28 +533,32 @@ </h3><div class="docstring"> <div class="discussion"> -<p>Add any number components to the Entity.</p> +<p>Gets an Entity from the given <span class='object_link'><a href="#id-instance_method" title="FelFlame::Entities#id (method)">unique ID</a></span>. Usage is simular to how an Array lookup works</p> </div> </div> <div class="tags"> - <p class="tag_title">Parameters:</p> + + <div class="examples"> + <p class="tag_title">Examples:</p> + + + <pre class="example code"><code><span class='comment'># This gets the Entity 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="" title="FelFlame::Entities (class)">Entities</a></span></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'>components_to_add</span> - + <span class='name'>entity_id</span> - <span class='type'>(<tt>Component</tt>)</span> + <span class='type'>(<tt>Integer</tt>)</span> - — - <div class='inline'> -<p>Any number of components created from any component manager</p> -</div> </li> @@ -412,13 +570,13 @@ <li> - <span class='type'>(<tt>Boolean</tt>)</span> + <span class='type'>(<tt>Entity</tt>)</span> — <div class='inline'> -<p><code>true</code></p> +<p>returns the Entity that uses the given unique ID, nil if there is no Entity associated with the given ID</p> </div> </li> @@ -431,37 +589,15 @@ <pre class="lines"> -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76</pre> +116 +117 +118</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 63</span> + <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 116</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_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='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='kw'>self</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='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='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='kw'>self</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='kw'>true</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> <span class='kw'>end</span></pre> </td> </tr> @@ -469,9 +605,9 @@ </div> <div class="method_details "> - <h3 class="signature " id="component-instance_method"> + <h3 class="signature " id="each-class_method"> - #<strong>component</strong>(manager = nil) ⇒ <tt>Component</tt> + .<strong>each</strong>(&block) ⇒ <tt>Enumerator</tt> @@ -480,38 +616,87 @@ </h3><div class="docstring"> <div class="discussion"> -<p>A single component from a component manager. Use this if you expect the component to only belong to one entity and you want to access it. Access the component using either parameter notation or array notation.</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> </div> <div class="tags"> - <div class="examples"> - <p class="tag_title">Examples:</p> - +<p class="tag_title">Returns:</p> +<ul class="return"> + + <li> + + + <span class='type'>(<tt>Enumerator</tt>)</span> - <pre class="example code"><code><span class='ivar'>@entity</span><span class='period'>.</span><span class='id identifier rubyid_component'>component</span><span class='lbracket'>[</span><span class='ivar'>@component_manager</span><span class='rbracket'>]</span> <span class='comment'># array notation -</span><span class='ivar'>@entity</span><span class='period'>.</span><span class='id identifier rubyid_component'>component</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='rparen'>)</span> <span class='comment'># method notation</span></code></pre> + + + </li> + +</ul> + +</div><table class="source_code"> + <tr> + <td> + <pre class="lines"> + + +123 +124 +125</pre> + </td> + <td> + <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 123</span> + +<span class='kw'>def</span> <span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='op'>&</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'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span> +<span class='kw'>end</span></pre> + </td> + </tr> +</table> +</div> </div> -<p class="tag_title">Parameters:</p> + + <div id="instance_method_details" class="method_details_list"> + <h2>Instance Method Details</h2> + + + <div class="method_details first"> + <h3 class="signature first" id="add-instance_method"> + + #<strong>add</strong>(*components_to_add) ⇒ <tt>Boolean</tt> + + + + + +</h3><div class="docstring"> + <div class="discussion"> + +<p>Add any number components to the Entity.</p> + + + </div> +</div> +<div class="tags"> + <p class="tag_title">Parameters:</p> <ul class="param"> <li> - <span class='name'>manager</span> - + <span class='name'>components_to_add</span> - <span class='type'>(<tt><span class='object_link'><a href="ComponentManager.html" title="FelFlame::ComponentManager (class)">ComponentManager</a></span></tt>)</span> + <span class='type'>(<tt>Component</tt>)</span> - <em class="default">(defaults to: <tt>nil</tt>)</em> — <div class='inline'> -<p>If you pass nil you can then use array notation to access the same value.</p> +<p>Any number of components created from any component manager</p> </div> </li> @@ -524,10 +709,15 @@ <li> - <span class='type'>(<tt>Component</tt>)</span> + <span class='type'>(<tt>Boolean</tt>)</span> + — + <div class='inline'> +<p><code>true</code></p> +</div> + </li> </ul> @@ -538,33 +728,37 @@ <pre class="lines"> -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44</pre> +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 33</span> - -<span class='kw'>def</span> <span class='id identifier rubyid_component'>component</span><span class='lparen'>(</span><span class='id identifier rubyid_manager'>manager</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span> - <span class='kw'>if</span> <span class='id identifier rubyid_manager'>manager</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> - <span class='ivar'>@component_redirect</span> - <span class='kw'>else</span> - <span class='kw'>if</span> <span class='id identifier rubyid_components'>components</span><span class='lbracket'>[</span><span class='id identifier rubyid_manager'>manager</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> - <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>This entity(</span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='embexpr_end'>}</span><span class='tstring_content'>) doesnt have any components of this type: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_manager'>manager</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span> - <span class='kw'>elsif</span> <span class='id identifier rubyid_components'>components</span><span class='lbracket'>[</span><span class='id identifier rubyid_manager'>manager</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>></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'>"</span><span class='tstring_content'>This entity has MANY of this component but you called the method that is intended for having a single of this component type.\nYou may have a bug in your logic.</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> + <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 57</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_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='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='kw'>self</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='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='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='kw'>self</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='id identifier rubyid_components'>components</span><span class='lbracket'>[</span><span class='id identifier rubyid_manager'>manager</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> <span class='kw'>end</span> + <span class='kw'>true</span> <span class='kw'>end</span></pre> </td> </tr> @@ -583,7 +777,7 @@ </h3><div class="docstring"> <div class="discussion"> -<p>A hash that uses component manager constant names as keys, and where the values of those keys are arrays that contain the the components attached to this entity.</p> +<p>A hash that uses component manager constant names as keys, and where the values of those keys are arrays that contain the <span class='object_link'><a href="ComponentManager.html#id-instance_method" title="FelFlame::ComponentManager#id (method)">IDs</a></span> of the components attached to this entity.</p> </div> @@ -610,12 +804,12 @@ <pre class="lines"> -23 -24 -25</pre> +30 +31 +32</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 23</span> + <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 30</span> <span class='kw'>def</span> <span class='id identifier rubyid_components'>components</span> <span class='ivar'>@components</span> <span class='op'>||=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span> @@ -637,7 +831,7 @@ </h3><div class="docstring"> <div class="discussion"> -<p>Removes this Entity from the list and purges all references to this Entity from other Components, as well as its data.</p> +<p>Removes this Entity from the list and purges all references to this Entity from other Components, as well as its <span class='object_link'><a href="#id-instance_method" title="FelFlame::Entities#id (method)">ID</a></span> and data.</p> </div> @@ -669,28 +863,30 @@ <pre class="lines"> +42 +43 +44 +45 +46 +47 +48 49 50 51 -52 -53 -54 -55 -56 -57 -58</pre> +52</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 49</span> + <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 42</span> <span class='kw'>def</span> <span class='id identifier rubyid_delete'>delete</span> <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_reverse_each'>reverse_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_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'>component</span><span class='op'>|</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='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span> <span class='kw'>end</span> <span class='kw'>end</span> - <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">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='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='kw'>self</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='kw'>true</span> <span class='kw'>end</span></pre> </td> @@ -762,29 +958,23 @@ <pre class="lines"> +87 +88 +89 +90 +91 +92 93 -94 -95 -96 -97 -98 -99 -100 -101 -102 -103</pre> +94</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 93</span> + <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 87</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_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='kw'>self</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='kw'>self</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='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_empty?'>empty?</span> - <span class='id identifier rubyid_components'>components</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_class'>class</span> - <span class='kw'>end</span> <span class='kw'>end</span> <span class='kw'>true</span> <span class='kw'>end</span></pre> @@ -793,12 +983,66 @@ </table> </div> + <div class="method_details "> + <h3 class="signature " id="to_i-instance_method"> + + #<strong>to_i</strong> ⇒ <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::Entities#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"> + + +36 +37 +38</pre> + </td> + <td> + <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 36</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'>end</span></pre> + </td> + </tr> +</table> +</div> + </div> </div> <div id="footer"> - Generated on Thu Dec 30 07:28:05 2021 by + Generated on Mon Jul 12 18:28:27 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/Scenes.html b/docs/FelFlame/Scenes.html index 2c160fe..41e369e 100644 --- a/docs/FelFlame/Scenes.html +++ b/docs/FelFlame/Scenes.html @@ -37,7 +37,7 @@ <div id="menu"> <a href="../_index.html">Index (S)</a> » - <span class='title'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span> + <span class='title'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span> » <span class="title">Scenes</span> @@ -104,7 +104,7 @@ <h2>Overview</h2><div class="docstring"> <div class="discussion"> -<p>Creates and manages Scenes. Scenes are collections of Systems, and execute all the Systems when called upon. Any scenes you create are accessable under the <span class='object_link'><a href="" title="FelFlame::Scenes (class)">Scenes</a></span> namespace as Constants.</p> +<p>Creates and manages Scenes. Scenes are collections of Systems, and execute all the Systems when called upon.</p> <p>TODO: Improve Scenes overview</p> @@ -308,7 +308,7 @@ <span class="summary_desc"><div class='inline'> -<p>Removes any number of Systems from this Scene.</p> +<p>Removes any number of SystemS from this Scene.</p> </div></span> </li> @@ -375,7 +375,7 @@ <pre class="code"><span class="info file"># File 'lib/felflame/scene_manager.rb', line 14</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='rparen'>)</span> - <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Scenes (class)">Scenes</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='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::Scenes (class)">Scenes</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='kw'>end</span></pre> </td> @@ -550,8 +550,8 @@ <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_systems_to_add'>systems_to_add</span><span class='rparen'>)</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_systems'>systems</span> <span class='op'>|=</span> <span class='id identifier rubyid_systems_to_add'>systems_to_add</span> - <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_systems'>systems</span> <span class='op'>=</span> <span class='id identifier rubyid_systems'>systems</span><span class='period'>.</span><span class='id identifier rubyid_sort_by'>sort_by</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:priority</span><span class='rparen'>)</span> - <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_update_systems_list'>update_systems_list</span> <span class='kw'>if</span> <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_scenes'><span class='object_link'><a href="Stage.html#scenes-class_method" title="FelFlame::Stage.scenes (method)">scenes</a></span></span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='kw'>self</span> + <span class='id identifier rubyid_systems'>systems</span><span class='period'>.</span><span class='id identifier rubyid_sort_by!'>sort_by!</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:priority</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="Stage.html" title="FelFlame::Stage (class)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_update_systems_list'>update_systems_list</span> <span class='kw'>if</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="Stage.html" title="FelFlame::Stage (class)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_scenes'><span class='object_link'><a href="Stage.html#scenes-class_method" title="FelFlame::Stage.scenes (method)">scenes</a></span></span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='kw'>self</span> <span class='kw'>true</span> <span class='kw'>end</span></pre> </td> @@ -675,7 +675,7 @@ <span class='kw'>def</span> <span class='id identifier rubyid_clear'>clear</span> <span class='id identifier rubyid_systems'>systems</span><span class='period'>.</span><span class='id identifier rubyid_clear'>clear</span> - <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_update_systems_list'>update_systems_list</span> <span class='kw'>if</span> <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_scenes'><span class='object_link'><a href="Stage.html#scenes-class_method" title="FelFlame::Stage.scenes (method)">scenes</a></span></span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='kw'>self</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="Stage.html" title="FelFlame::Stage (class)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_update_systems_list'>update_systems_list</span> <span class='kw'>if</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="Stage.html" title="FelFlame::Stage (class)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_scenes'><span class='object_link'><a href="Stage.html#scenes-class_method" title="FelFlame::Stage.scenes (method)">scenes</a></span></span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='kw'>self</span> <span class='kw'>true</span> <span class='kw'>end</span></pre> </td> @@ -695,7 +695,7 @@ </h3><div class="docstring"> <div class="discussion"> -<p>Removes any number of Systems from this Scene</p> +<p>Removes any number of SystemS from this Scene</p> </div> @@ -739,8 +739,8 @@ <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_systems_to_remove'>systems_to_remove</span><span class='rparen'>)</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_systems'>systems</span> <span class='op'>-=</span> <span class='id identifier rubyid_systems_to_remove'>systems_to_remove</span> - <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_systems'>systems</span> <span class='op'>=</span> <span class='id identifier rubyid_systems'>systems</span><span class='period'>.</span><span class='id identifier rubyid_sort_by'>sort_by</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:priority</span><span class='rparen'>)</span> - <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_update_systems_list'>update_systems_list</span> <span class='kw'>if</span> <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_scenes'><span class='object_link'><a href="Stage.html#scenes-class_method" title="FelFlame::Stage.scenes (method)">scenes</a></span></span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='kw'>self</span> + <span class='id identifier rubyid_systems'>systems</span><span class='period'>.</span><span class='id identifier rubyid_sort_by!'>sort_by!</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:priority</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="Stage.html" title="FelFlame::Stage (class)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_update_systems_list'>update_systems_list</span> <span class='kw'>if</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="Stage.html" title="FelFlame::Stage (class)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_scenes'><span class='object_link'><a href="Stage.html#scenes-class_method" title="FelFlame::Stage.scenes (method)">scenes</a></span></span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='kw'>self</span> <span class='kw'>true</span> <span class='kw'>end</span></pre> </td> @@ -753,7 +753,7 @@ </div> <div id="footer"> - Generated on Thu Dec 30 07:28:05 2021 by + Generated on Mon Jul 12 18:28:27 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/Stage.html b/docs/FelFlame/Stage.html index b2e961b..65fe2f4 100644 --- a/docs/FelFlame/Stage.html +++ b/docs/FelFlame/Stage.html @@ -4,7 +4,7 @@ <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title> - Module: FelFlame::Stage + Class: FelFlame::Stage — Documentation by YARD 0.9.26 @@ -37,7 +37,7 @@ <div id="menu"> <a href="../_index.html">Index (S)</a> » - <span class='title'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span> + <span class='title'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span> » <span class="title">Stage</span> @@ -59,13 +59,29 @@ <div class="clear"></div> </div> - <div id="content"><h1>Module: FelFlame::Stage + <div id="content"><h1>Class: FelFlame::Stage </h1> <div class="box_info"> + <dl> + <dt>Inherits:</dt> + <dd> + <span class="inheritName">Object</span> + + <ul class="fullTree"> + <li>Object</li> + + <li class="next">FelFlame::Stage</li> + + </ul> + <a href="#" class="inheritanceTree">show all</a> + + </dd> + </dl> + @@ -88,7 +104,7 @@ <h2>Overview</h2><div class="docstring"> <div class="discussion"> -<p>Stores Scenes you add to it which you want to execute on each frame. When called upon will execute all Systems in the Scenes in the Stage and will execute them according to their priority order.</p> +<p>Stores Scenes which you want to execute on each frame. When called upon will execute all Systems in the Scenes in the Stage and will execute them according to their priority order.</p> </div> @@ -372,7 +388,7 @@ <span class='id identifier rubyid_scenes_to_add'>scenes_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_scene'>scene</span><span class='op'>|</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_systems'>systems</span> <span class='op'>|=</span> <span class='id identifier rubyid_scene'>scene</span><span class='period'>.</span><span class='id identifier rubyid_systems'>systems</span> <span class='kw'>end</span> - <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_systems'>systems</span> <span class='op'>=</span> <span class='id identifier rubyid_systems'>systems</span><span class='period'>.</span><span class='id identifier rubyid_sort_by'>sort_by</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:priority</span><span class='rparen'>)</span> + <span class='id identifier rubyid_systems'>systems</span><span class='period'>.</span><span class='id identifier rubyid_sort_by!'>sort_by!</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:priority</span><span class='rparen'>)</span> <span class='kw'>true</span> <span class='kw'>end</span></pre> </td> @@ -572,7 +588,7 @@ </div> <div id="footer"> - Generated on Thu Dec 30 07:28:05 2021 by + Generated on Mon Jul 12 18:28:27 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 e549566..f0f8d56 100644 --- a/docs/FelFlame/Systems.html +++ b/docs/FelFlame/Systems.html @@ -37,7 +37,7 @@ <div id="menu"> <a href="../_index.html">Index (S)</a> » - <span class='title'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span> + <span class='title'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span> » <span class="title">Systems</span> @@ -109,7 +109,7 @@ <h2>Overview</h2><div class="docstring"> <div class="discussion"> -<p>Creates an manages Systems. Systems are the logic of the game and do not contain any data within them. Any systems you create are accessable under the <span class='object_link'><a href="" title="FelFlame::Systems (class)">Systems</a></span> namespace as Constants.</p> +<p>Creates an manages Systems. Systems are the logic of the game and do not contain any data within them.</p> <p>TODO: Improve Systems overview</p> @@ -515,8 +515,8 @@ <p class="tag_title">Examples:</p> - <pre class="example code"><code><span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">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'>'</span><span class='tstring_content'>PassiveHeal</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='op'>-</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 (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Components.html" title="FelFlame::Components (module)">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> + <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'>'</span><span class='tstring_content'>PassiveHeal</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='op'>-</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> @@ -597,7 +597,7 @@ <pre class="code"><span class="info file"># File 'lib/felflame/system_manager.rb', line 71</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'>&</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 (module)">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='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> @@ -998,19 +998,19 @@ <pre class="example code"><code><span class='comment'># To clear all triggers that execute this system when a component is added: -</span><span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">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='op'>::</span><span class='const'>ExampleSystem</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span> <span class='symbol'>:addition_triggers</span> +</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='op'>::</span><span class='const'>ExampleSystem</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span> <span class='symbol'>:addition_triggers</span> <span class='comment'># Same as above but for when a component is removed instead -</span><span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">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='op'>::</span><span class='const'>ExampleSystem</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span> <span class='symbol'>:removal_triggers</span> +</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='op'>::</span><span class='const'>ExampleSystem</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span> <span class='symbol'>:removal_triggers</span> <span class='comment'># Same as above but for when a component has a certain attribute changed -</span><span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">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='op'>::</span><span class='const'>ExampleSystem</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span> <span class='symbol'>:attr_triggers</span> +</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='op'>::</span><span class='const'>ExampleSystem</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span> <span class='symbol'>:attr_triggers</span> <span class='comment'># Clear a trigger from a specific component -</span><span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">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='op'>::</span><span class='const'>ExampleSystem</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span> <span class='symbol'>:addition_triggers</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'>Component</span><span class='op'>::</span><span class='const'>ExampleComponent</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> +</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='op'>::</span><span class='const'>ExampleSystem</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span> <span class='symbol'>:addition_triggers</span><span class='comma'>,</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'>Component</span><span class='op'>::</span><span class='const'>ExampleComponent</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='comment'># Clear a trigger from a specific component manager -</span><span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">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='op'>::</span><span class='const'>ExampleSystem</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span> <span class='symbol'>:addition_triggers</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'>Component</span><span class='op'>::</span><span class='const'>ExampleComponent</span> +</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='op'>::</span><span class='const'>ExampleSystem</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span> <span class='symbol'>:addition_triggers</span><span class='comma'>,</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'>Component</span><span class='op'>::</span><span class='const'>ExampleComponent</span> <span class='comment'># Clear the trigger that executes a system when the ':example_attr' is changes -</span><span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">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='op'>::</span><span class='const'>ExampleSystem</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span> <span class='symbol'>:attr_triggers</span><span class='comma'>,</span> <span class='symbol'>:example_attr</span></code></pre> +</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='op'>::</span><span class='const'>ExampleSystem</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span> <span class='symbol'>:attr_triggers</span><span class='comma'>,</span> <span class='symbol'>:example_attr</span></code></pre> </div> <p class="tag_title">Parameters:</p> @@ -1531,7 +1531,7 @@ </div> <div id="footer"> - Generated on Thu Dec 30 07:28:05 2021 by + Generated on Mon Jul 12 18:28:27 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_.html b/docs/Felflame_.html index ea9bbfc..498cc3e 100644 --- a/docs/Felflame_.html +++ b/docs/Felflame_.html @@ -133,7 +133,7 @@ </div> <div id="footer"> - Generated on Thu Dec 30 07:28:05 2021 by + Generated on Mon Jul 12 18:28:27 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 4b3f2de..70180bc 100644 --- a/docs/_index.html +++ b/docs/_index.html @@ -88,7 +88,7 @@ </li> <li> - <span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span> + <span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (class)">Components</a></span> <small>(FelFlame)</small> @@ -118,7 +118,7 @@ <ul> <li> - <span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span> + <span class='object_link'><a href="FelFlame.html" title="FelFlame (class)">FelFlame</a></span> </li> @@ -143,7 +143,7 @@ </li> <li> - <span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span> + <span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (class)">Stage</a></span> <small>(FelFlame)</small> @@ -168,7 +168,7 @@ </div> <div id="footer"> - Generated on Thu Dec 30 07:28:05 2021 by + Generated on Mon Jul 12 18:28:27 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/class_list.html b/docs/class_list.html index 126406f..8d7b4f0 100644 --- a/docs/class_list.html +++ b/docs/class_list.html @@ -43,7 +43,7 @@ <ul id="full_list" class="class"> <li id="object_" class="odd"><div class="item" style="padding-left:30px"><span class='object_link'><a href="top-level-namespace.html" title="Top Level Namespace (root)">Top Level Namespace</a></span></div></li> -<li id='object_FelFlame' class='even'><div class='item' style='padding-left:30px'><a class='toggle'></a> <span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span><small class='search_info'>Top Level Namespace</small></div><ul><li id='object_FelFlame::ComponentManager' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/ComponentManager.html" title="FelFlame::ComponentManager (class)">ComponentManager</a></span> < Object<small class='search_info'>FelFlame</small></div></li><li id='object_FelFlame::Components' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span><small class='search_info'>FelFlame</small></div></li><li id='object_FelFlame::Entities' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span> < Object<small class='search_info'>FelFlame</small></div></li><li id='object_FelFlame::Scenes' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span> < Object<small class='search_info'>FelFlame</small></div></li><li id='object_FelFlame::Stage' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span><small class='search_info'>FelFlame</small></div></li><li id='object_FelFlame::Systems' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span> < Object<small class='search_info'>FelFlame</small></div></li></ul></li><li id='object_Felflame' class='odd'><div class='item' style='padding-left:30px'><span class='object_link'><a href="Felflame_.html" title="Felflame (module)">Felflame</a></span><small class='search_info'>Top Level Namespace</small></div></li> +<li id='object_FelFlame' class='even'><div class='item' style='padding-left:30px'><a class='toggle'></a> <span class='object_link'><a href="FelFlame.html" title="FelFlame (class)">FelFlame</a></span> < Object<small class='search_info'>Top Level Namespace</small></div><ul><li id='object_FelFlame::ComponentManager' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/ComponentManager.html" title="FelFlame::ComponentManager (class)">ComponentManager</a></span> < Object<small class='search_info'>FelFlame</small></div></li><li id='object_FelFlame::Components' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (class)">Components</a></span> < Object<small class='search_info'>FelFlame</small></div></li><li id='object_FelFlame::Entities' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span> < Object<small class='search_info'>FelFlame</small></div></li><li id='object_FelFlame::Scenes' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span> < Object<small class='search_info'>FelFlame</small></div></li><li id='object_FelFlame::Stage' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (class)">Stage</a></span> < Object<small class='search_info'>FelFlame</small></div></li><li id='object_FelFlame::Systems' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span> < Object<small class='search_info'>FelFlame</small></div></li></ul></li><li id='object_Felflame' class='odd'><div class='item' style='padding-left:30px'><span class='object_link'><a href="Felflame_.html" title="Felflame (module)">Felflame</a></span><small class='search_info'>Top Level Namespace</small></div></li> </ul> </div> diff --git a/docs/file.README.html b/docs/file.README.html index 7deb23f..b856937 100644 --- a/docs/file.README.html +++ b/docs/file.README.html @@ -57,9 +57,7 @@ <div class="clear"></div> </div> - <div id="content"><div id='filecontents'><p><img src="https://raw.githubusercontent.com/realtradam/FelFlame/master/logos/felflame-logo-text.png" alt="FelFlame"></p> - -<!--  --> + <div id="content"><div id='filecontents'><p><img src="https://filestorage.catgirls.rodeo/images/felflame-logo-smaller-text.png" alt="FelFlame"></p> <p><a href="https://codeclimate.com/github/realtradam/FelFlame/maintainability"><img src="https://api.codeclimate.com/v1/badges/56d425d9078e98efb74b/maintainability" alt="Maintainability"></a> <a href="https://codeclimate.com/github/realtradam/FelFlame/test_coverage"><img src="https://api.codeclimate.com/v1/badges/56d425d9078e98efb74b/test_coverage" alt="Test Coverage"></a> @@ -145,7 +143,7 @@ <ol> <li><strong>Engine Agnostic:</strong> FelFlame has been designed to be rendering engine agnostic as long as the target rendering engine is written in Ruby. This means that this framework can be dropped into existing rendering engines such as <a href="http://www.ruby2d.com">Ruby2D</a> or <a href="https://dragonruby.org/toolkit/game">DRGTK</a> with little modifications.</li> <li><strong>Easily Extensible:</strong> FelFlame has been designed such that extensions to its capabilities can be easily added. Extensions such as rendering engine wrappers, premade systems, premade components, etcetera can be easily coded and then distributed as gems.</li> -<li><strong>Principle of (My) Least Astonishment:</strong> I want to develop games using a language and framework I love and makes sense to me, inspired by the <a href="https://en.wikipedia.org/wiki/Ruby_(programming_language)#Philosophy">Philosophy of the creator of Ruby</a>.</li> +<li><strong>Priciple of (My) Least Astonishment:</strong> I want to develop games using a language and framework I love and makes sense to me, inspired by the <a href="https://en.wikipedia.org/wiki/Ruby_(programming_language)#Philosophy">Philosophy of the creator of Ruby</a>.</li> </ol> <h1 id="what-is-ecs">What is ECS?</h1> @@ -197,15 +195,15 @@ ECS stands for Entity, Component, and System.</p> <p>Entities are essentially "objects" in the game world. To create a new Entity we do the following:</p> -<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Entities.html#initialize-instance_method" title="FelFlame::Entities#initialize (method)">new</a></span></span> +<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</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="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Entities.html#initialize-instance_method" title="FelFlame::Entities#initialize (method)">new</a></span></span> </code></pre> <p>or if we want to add (any number of)components to it:</p> -<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'>Entites</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span> - <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Health</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='comma'>,</span> +<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</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'>Entites</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</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="FelFlame/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_new'>new</span><span class='comma'>,</span> <span class='ivar'>@component</span><span class='comma'>,</span> - <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Armour</span><span class='lbracket'>[</span><span class='int'>7</span><span class='rbracket'>]</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="FelFlame/Components.html" title="FelFlame::Components (class)">Components</a></span></span><span class='op'>::</span><span class='const'>Armour</span><span class='lbracket'>[</span><span class='int'>7</span><span class='rbracket'>]</span> <span class='rparen'>)</span> </code></pre> @@ -213,7 +211,7 @@ ECS stands for Entity, Component, and System.</p> <p>Once components are created we can access them using their ID like so:</p> -<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span> +<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</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="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span> </code></pre> <h3 id="get-id">Get ID</h3> @@ -253,7 +251,7 @@ entity where a new entity will claim that ID. To get the ID of an Entity:</p> <p>Components are where all the data is stored. The data is stored in variables or accessors in each component. These accessors and their defaults are configured when a component manager is created, like so:</p> -<pre class="code ruby"><code class="ruby"><span class='ivar'>@component_manager</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Components.html#new-class_method" title="FelFlame::Components.new (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Stats</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='symbol'>:armour</span><span class='comma'>,</span> <span class='label'>hp:</span> <span class='int'>100</span><span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby"><span class='ivar'>@component_manager</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="FelFlame/Components.html" title="FelFlame::Components (class)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Components.html#new-class_method" title="FelFlame::Components.new (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Stats</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='symbol'>:armour</span><span class='comma'>,</span> <span class='label'>hp:</span> <span class='int'>100</span><span class='rparen'>)</span> </code></pre> <p>In this example we created a component manager called "Stats". @@ -267,12 +265,12 @@ When defining attributes symbols should be used.</p> <p>Now that we have a component manager we can make components from it like so:</p> -<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> +<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</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="FelFlame/Components.html" title="FelFlame::Components (class)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> </code></pre> <p>Or we can even change the defaults:</p> -<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='label'>armour:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>steel</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</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="FelFlame/Components.html" title="FelFlame::Components (class)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='label'>armour:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>steel</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> </code></pre> <h3 id="accessing-and-getting-id">Accessing and Getting ID</h3> @@ -281,7 +279,7 @@ When defining attributes symbols should be used.</p> These IDs are only unique within the scope of their respective Component Managers. Here is how we can get the ID, as well as how to access a Component from its Component Manager.</p> -<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span> +<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</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="FelFlame/Components.html" title="FelFlame::Components (class)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span> <span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span> <span class='comment'># => 2 </span></code></pre> @@ -309,7 +307,7 @@ Here are the ways to edit attrubutes, followed by the ways to read them.</p> <p>When you make Systems you will want to be able to iterate over all Components of the same Component Manager(for example iterating over all sprites to render them). Here is how we do that:</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Sprites</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> +<pre class="code ruby"><code class="ruby"><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="FelFlame/Components.html" title="FelFlame::Components (class)">Components</a></span></span><span class='op'>::</span><span class='const'>Sprites</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='comment'>#do something with components </span><span class='kw'>end</span> </code></pre> @@ -327,14 +325,14 @@ Here are the ways to edit attrubutes, followed by the ways to read them.</p> <p>We can create Systems like so:</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Systems.html#initialize-instance_method" title="FelFlame::Systems#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Render</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>2</span><span class='rparen'>)</span> <span class='kw'>do</span> +<pre class="code ruby"><code class="ruby"><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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Systems.html#initialize-instance_method" title="FelFlame::Systems#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='label'>name:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Render</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>2</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='comment'># Code and Logic </span><span class='kw'>end</span> </code></pre> <p>The name we assign is how we can access the System, like so:</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span> +<pre class="code ruby"><code class="ruby"><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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span> </code></pre> <p>Priority determines the order Systems should be executed, this is used for <code>Scenes</code> and the <code>Stage</code>. @@ -343,8 +341,8 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p> <p>Often we will want to execute some logic on each Component in a given Component Manager so our code might look like this:</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Systems.html#initialize-instance_method" title="FelFlame::Systems#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Render</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>priority:</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 (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Sprites</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> +<pre class="code ruby"><code class="ruby"><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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Systems.html#initialize-instance_method" title="FelFlame::Systems#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='label'>name:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Render</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>priority:</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="FelFlame/Components.html" title="FelFlame::Components (class)">Components</a></span></span><span class='op'>::</span><span class='const'>Sprites</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='comment'># do something with these components </span> <span class='kw'>end</span> <span class='kw'>end</span> @@ -354,7 +352,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p> <p>After we create a System, it won't do anything on its own until we tell it to. Here is how:</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span> +<pre class="code ruby"><code class="ruby"><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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span> </code></pre> <p>Sometimes you might want to manually activate a System, but the more common way to have Systems be triggered is to use Scenes and the Stage or the alternative ways of execution.</p> @@ -364,25 +362,25 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p> <p>Sometimes you want a System to automatically trigger when a special even happens. FelFlame can keep track of when a Component is added, removed, or when an attribute is changed and then execute Systems linked to these events. Here is how to create these links:</p> <pre class="code ruby"><code class="ruby"><span class='comment'># When this Component is added to an Entity, this System will be called -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_added'>trigger_when_added</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_added'>trigger_when_added</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='rparen'>)</span> <span class='comment'># When this Component is removed from an Entity, this System will be called -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_removed'>trigger_when_removed</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_removed'>trigger_when_removed</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='rparen'>)</span> <span class='comment'># When this Component's health attribute is changed, this System will be called -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_is_set'>trigger_when_is_set</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_is_set'>trigger_when_is_set</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span> </code></pre> <p>If we want these triggers to happen for all Components that belong to specific Component Manager then we can do that instead:</p> <pre class="code ruby"><code class="ruby"><span class='comment'># When a Component from this Component Manager is added to an Entity, this System will be called -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_added'>trigger_when_added</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_added'>trigger_when_added</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='rparen'>)</span> <span class='comment'># When a Component from this Component Manager is removed from an Entity, this System will be called -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_removed'>trigger_when_removed</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_removed'>trigger_when_removed</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='rparen'>)</span> <span class='comment'># When this Component's health attribute from this Component Manager is changed, this System will be called -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_is_set'>trigger_when_is_set</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_is_set'>trigger_when_is_set</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span> </code></pre> <p>We can create any number of these links between Systems, Components, and Component Manangers as we like, simply call the method again with our other Components and Component Managers</p> @@ -392,41 +390,41 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p> <p>If we wish to remove these links that we created, we can do that using the follwing function in any of the following ways:</p> <pre class="code ruby"><code class="ruby"><span class='comment'># clears ALL triggers with this system -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span> <span class='comment'># clears ALL triggers with this Component Manager -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='rparen'>)</span> <span class='comment'># clear the 'trigger_when_added' for this Component -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:added</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:added</span><span class='rparen'>)</span> <span class='comment'># clear the 'trigger_when_removed' for this Component -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:removed</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:removed</span><span class='rparen'>)</span> <span class='comment'># clear the 'trigger_when_is_set' for this Component specifically for the health attribute -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:is_set</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:is_set</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span> </code></pre> <p>Likewise we can do the same with Component Managers:</p> <pre class="code ruby"><code class="ruby"><span class='comment'># clears ALL triggers with this Component -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='rparen'>)</span> <span class='comment'># clear the 'trigger_when_added' for this Component Manager -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:added</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:added</span><span class='rparen'>)</span> <span class='comment'># clear the 'trigger_when_removed' for this Component Manager -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:removed</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:removed</span><span class='rparen'>)</span> <span class='comment'># clear the 'trigger_when_is_set' for this Component Manager specifically for the health attribute -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:is_set</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:is_set</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span> </code></pre> <h3 id="redefinition">Redefinition</h3> <p>If we wanted to change what code or logic a given System executes, we could do that with:</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_redefine'>redefine</span> <span class='kw'>do</span> +<pre class="code ruby"><code class="ruby"><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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_redefine'>redefine</span> <span class='kw'>do</span> <span class='comment'># Some new logic or code </span><span class='kw'>end</span> </code></pre> @@ -437,28 +435,28 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p> <p>Once we have all the core parts of ECS, we will want to organize our Systems. To do this we will use Scenes to group up Systems so they can quickly be enabled or disabled. Note that <a href="#alternative-execution">Alternative Executions</a> will occur even if they are not part of a Scene. Here is how we make a new Scene:</p> -<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Scenes.html#initialize-instance_method" title="FelFlame::Scenes#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ExampleScene</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</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="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Scenes.html#initialize-instance_method" title="FelFlame::Scenes#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ExampleScene</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> </code></pre> <h3 id="accessing">Accessing</h3> <p>Just like other classes in FelFlame, the name we gave the Scene is how we access it:</p> -<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span> +<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</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="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span> </code></pre> <h3 id="adding-systems">Adding Systems</h3> <p>Adding Systems is simple. We can add as many as we want. In this example we add 3 different systems:</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='comma'>,</span> <span class='ivar'>@system2</span><span class='comma'>,</span> <span class='ivar'>@system3</span><span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby"><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="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='comma'>,</span> <span class='ivar'>@system2</span><span class='comma'>,</span> <span class='ivar'>@system3</span><span class='rparen'>)</span> </code></pre> <h3 id="removing-systems">Removing Systems</h3> <p>Removing Systems works simularly:</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span><span class='period'>.</span><span class='id identifier rubyid_remove'>remove</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='comma'>,</span> <span class='ivar'>@system2</span><span class='comma'>,</span> <span class='ivar'>@system3</span><span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby"><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="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span><span class='period'>.</span><span class='id identifier rubyid_remove'>remove</span><span class='lparen'>(</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='comma'>,</span> <span class='ivar'>@system2</span><span class='comma'>,</span> <span class='ivar'>@system3</span><span class='rparen'>)</span> </code></pre> <h3 id="clearing">Clearing</h3> @@ -483,21 +481,21 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p> <p>Finally we have the Stage. There is only a single Stage and we do not have to create it as it exists by default. By adding a Scene to the Stage we are saying that the Scene is active. To add a Scene we do the following:</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_add'><span class='object_link'><a href="FelFlame/Stage.html#add-class_method" title="FelFlame::Stage.add (method)">add</a></span></span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'>Scene</span><span class='op'>::</span><span class='const'>ExampleScene</span> +<pre class="code ruby"><code class="ruby"><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="FelFlame/Stage.html" title="FelFlame::Stage (class)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_add'><span class='object_link'><a href="FelFlame/Stage.html#add-class_method" title="FelFlame::Stage.add (method)">add</a></span></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'>Scene</span><span class='op'>::</span><span class='const'>ExampleScene</span> </code></pre> <h3 id="removing-scenes">Removing Scenes</h3> <p>Likewise we can remove Scenes:</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_remove'><span class='object_link'><a href="FelFlame/Stage.html#remove-class_method" title="FelFlame::Stage.remove (method)">remove</a></span></span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'>Scene</span><span class='op'>::</span><span class='const'>ExampleScene</span> +<pre class="code ruby"><code class="ruby"><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="FelFlame/Stage.html" title="FelFlame::Stage (class)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_remove'><span class='object_link'><a href="FelFlame/Stage.html#remove-class_method" title="FelFlame::Stage.remove (method)">remove</a></span></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'>Scene</span><span class='op'>::</span><span class='const'>ExampleScene</span> </code></pre> <h3 id="executing">Executing</h3> <p>On each frame of the game we want to execute the Stage once. When the Stage is executed it is progressing your game 1 frame forward. The Stage will make sure for you that all the Systems from all Scenes added will be executed in the correct order according to their priority. Here is how we do it:</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_call'><span class='object_link'><a href="FelFlame/Stage.html#call-class_method" title="FelFlame::Stage.call (method)">call</a></span></span> +<pre class="code ruby"><code class="ruby"><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="FelFlame/Stage.html" title="FelFlame::Stage (class)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_call'><span class='object_link'><a href="FelFlame/Stage.html#call-class_method" title="FelFlame::Stage.call (method)">call</a></span></span> </code></pre> <h2 id="closing-notes">Closing Notes</h2> @@ -514,7 +512,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p> </div></div> <div id="footer"> - Generated on Thu Dec 30 07:28:05 2021 by + Generated on Mon Jul 12 18:28:27 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 a77181a..14d70c2 100644 --- a/docs/index.html +++ b/docs/index.html @@ -57,9 +57,7 @@ <div class="clear"></div> </div> - <div id="content"><div id='filecontents'><p><img src="https://raw.githubusercontent.com/realtradam/FelFlame/master/logos/felflame-logo-text.png" alt="FelFlame"></p> - -<!--  --> + <div id="content"><div id='filecontents'><p><img src="https://filestorage.catgirls.rodeo/images/felflame-logo-smaller-text.png" alt="FelFlame"></p> <p><a href="https://codeclimate.com/github/realtradam/FelFlame/maintainability"><img src="https://api.codeclimate.com/v1/badges/56d425d9078e98efb74b/maintainability" alt="Maintainability"></a> <a href="https://codeclimate.com/github/realtradam/FelFlame/test_coverage"><img src="https://api.codeclimate.com/v1/badges/56d425d9078e98efb74b/test_coverage" alt="Test Coverage"></a> @@ -145,7 +143,7 @@ <ol> <li><strong>Engine Agnostic:</strong> FelFlame has been designed to be rendering engine agnostic as long as the target rendering engine is written in Ruby. This means that this framework can be dropped into existing rendering engines such as <a href="http://www.ruby2d.com">Ruby2D</a> or <a href="https://dragonruby.org/toolkit/game">DRGTK</a> with little modifications.</li> <li><strong>Easily Extensible:</strong> FelFlame has been designed such that extensions to its capabilities can be easily added. Extensions such as rendering engine wrappers, premade systems, premade components, etcetera can be easily coded and then distributed as gems.</li> -<li><strong>Principle of (My) Least Astonishment:</strong> I want to develop games using a language and framework I love and makes sense to me, inspired by the <a href="https://en.wikipedia.org/wiki/Ruby_(programming_language)#Philosophy">Philosophy of the creator of Ruby</a>.</li> +<li><strong>Priciple of (My) Least Astonishment:</strong> I want to develop games using a language and framework I love and makes sense to me, inspired by the <a href="https://en.wikipedia.org/wiki/Ruby_(programming_language)#Philosophy">Philosophy of the creator of Ruby</a>.</li> </ol> <h1 id="what-is-ecs">What is ECS?</h1> @@ -197,15 +195,15 @@ ECS stands for Entity, Component, and System.</p> <p>Entities are essentially "objects" in the game world. To create a new Entity we do the following:</p> -<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Entities.html#initialize-instance_method" title="FelFlame::Entities#initialize (method)">new</a></span></span> +<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</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="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Entities.html#initialize-instance_method" title="FelFlame::Entities#initialize (method)">new</a></span></span> </code></pre> <p>or if we want to add (any number of)components to it:</p> -<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'>Entites</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span> - <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Health</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='comma'>,</span> +<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</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'>Entites</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</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="FelFlame/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_new'>new</span><span class='comma'>,</span> <span class='ivar'>@component</span><span class='comma'>,</span> - <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Armour</span><span class='lbracket'>[</span><span class='int'>7</span><span class='rbracket'>]</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="FelFlame/Components.html" title="FelFlame::Components (class)">Components</a></span></span><span class='op'>::</span><span class='const'>Armour</span><span class='lbracket'>[</span><span class='int'>7</span><span class='rbracket'>]</span> <span class='rparen'>)</span> </code></pre> @@ -213,7 +211,7 @@ ECS stands for Entity, Component, and System.</p> <p>Once components are created we can access them using their ID like so:</p> -<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span> +<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</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="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span> </code></pre> <h3 id="get-id">Get ID</h3> @@ -253,7 +251,7 @@ entity where a new entity will claim that ID. To get the ID of an Entity:</p> <p>Components are where all the data is stored. The data is stored in variables or accessors in each component. These accessors and their defaults are configured when a component manager is created, like so:</p> -<pre class="code ruby"><code class="ruby"><span class='ivar'>@component_manager</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Components.html#new-class_method" title="FelFlame::Components.new (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Stats</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='symbol'>:armour</span><span class='comma'>,</span> <span class='label'>hp:</span> <span class='int'>100</span><span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby"><span class='ivar'>@component_manager</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="FelFlame/Components.html" title="FelFlame::Components (class)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Components.html#new-class_method" title="FelFlame::Components.new (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Stats</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='symbol'>:armour</span><span class='comma'>,</span> <span class='label'>hp:</span> <span class='int'>100</span><span class='rparen'>)</span> </code></pre> <p>In this example we created a component manager called "Stats". @@ -267,12 +265,12 @@ When defining attributes symbols should be used.</p> <p>Now that we have a component manager we can make components from it like so:</p> -<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> +<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</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="FelFlame/Components.html" title="FelFlame::Components (class)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> </code></pre> <p>Or we can even change the defaults:</p> -<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='label'>armour:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>steel</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</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="FelFlame/Components.html" title="FelFlame::Components (class)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='label'>armour:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>steel</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> </code></pre> <h3 id="accessing-and-getting-id">Accessing and Getting ID</h3> @@ -281,7 +279,7 @@ When defining attributes symbols should be used.</p> These IDs are only unique within the scope of their respective Component Managers. Here is how we can get the ID, as well as how to access a Component from its Component Manager.</p> -<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span> +<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</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="FelFlame/Components.html" title="FelFlame::Components (class)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span> <span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span> <span class='comment'># => 2 </span></code></pre> @@ -309,7 +307,7 @@ Here are the ways to edit attrubutes, followed by the ways to read them.</p> <p>When you make Systems you will want to be able to iterate over all Components of the same Component Manager(for example iterating over all sprites to render them). Here is how we do that:</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Sprites</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> +<pre class="code ruby"><code class="ruby"><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="FelFlame/Components.html" title="FelFlame::Components (class)">Components</a></span></span><span class='op'>::</span><span class='const'>Sprites</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='comment'>#do something with components </span><span class='kw'>end</span> </code></pre> @@ -327,14 +325,14 @@ Here are the ways to edit attrubutes, followed by the ways to read them.</p> <p>We can create Systems like so:</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Systems.html#initialize-instance_method" title="FelFlame::Systems#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Render</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>2</span><span class='rparen'>)</span> <span class='kw'>do</span> +<pre class="code ruby"><code class="ruby"><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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Systems.html#initialize-instance_method" title="FelFlame::Systems#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='label'>name:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Render</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>2</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='comment'># Code and Logic </span><span class='kw'>end</span> </code></pre> <p>The name we assign is how we can access the System, like so:</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span> +<pre class="code ruby"><code class="ruby"><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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span> </code></pre> <p>Priority determines the order Systems should be executed, this is used for <code>Scenes</code> and the <code>Stage</code>. @@ -343,8 +341,8 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p> <p>Often we will want to execute some logic on each Component in a given Component Manager so our code might look like this:</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Systems.html#initialize-instance_method" title="FelFlame::Systems#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Render</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>priority:</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 (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Sprites</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> +<pre class="code ruby"><code class="ruby"><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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Systems.html#initialize-instance_method" title="FelFlame::Systems#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='label'>name:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Render</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>priority:</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="FelFlame/Components.html" title="FelFlame::Components (class)">Components</a></span></span><span class='op'>::</span><span class='const'>Sprites</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='comment'># do something with these components </span> <span class='kw'>end</span> <span class='kw'>end</span> @@ -354,7 +352,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p> <p>After we create a System, it won't do anything on its own until we tell it to. Here is how:</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span> +<pre class="code ruby"><code class="ruby"><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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span> </code></pre> <p>Sometimes you might want to manually activate a System, but the more common way to have Systems be triggered is to use Scenes and the Stage or the alternative ways of execution.</p> @@ -364,25 +362,25 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p> <p>Sometimes you want a System to automatically trigger when a special even happens. FelFlame can keep track of when a Component is added, removed, or when an attribute is changed and then execute Systems linked to these events. Here is how to create these links:</p> <pre class="code ruby"><code class="ruby"><span class='comment'># When this Component is added to an Entity, this System will be called -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_added'>trigger_when_added</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_added'>trigger_when_added</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='rparen'>)</span> <span class='comment'># When this Component is removed from an Entity, this System will be called -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_removed'>trigger_when_removed</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_removed'>trigger_when_removed</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='rparen'>)</span> <span class='comment'># When this Component's health attribute is changed, this System will be called -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_is_set'>trigger_when_is_set</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_is_set'>trigger_when_is_set</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span> </code></pre> <p>If we want these triggers to happen for all Components that belong to specific Component Manager then we can do that instead:</p> <pre class="code ruby"><code class="ruby"><span class='comment'># When a Component from this Component Manager is added to an Entity, this System will be called -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_added'>trigger_when_added</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_added'>trigger_when_added</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='rparen'>)</span> <span class='comment'># When a Component from this Component Manager is removed from an Entity, this System will be called -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_removed'>trigger_when_removed</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_removed'>trigger_when_removed</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='rparen'>)</span> <span class='comment'># When this Component's health attribute from this Component Manager is changed, this System will be called -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_is_set'>trigger_when_is_set</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_is_set'>trigger_when_is_set</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span> </code></pre> <p>We can create any number of these links between Systems, Components, and Component Manangers as we like, simply call the method again with our other Components and Component Managers</p> @@ -392,41 +390,41 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p> <p>If we wish to remove these links that we created, we can do that using the follwing function in any of the following ways:</p> <pre class="code ruby"><code class="ruby"><span class='comment'># clears ALL triggers with this system -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span> <span class='comment'># clears ALL triggers with this Component Manager -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='rparen'>)</span> <span class='comment'># clear the 'trigger_when_added' for this Component -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:added</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:added</span><span class='rparen'>)</span> <span class='comment'># clear the 'trigger_when_removed' for this Component -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:removed</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:removed</span><span class='rparen'>)</span> <span class='comment'># clear the 'trigger_when_is_set' for this Component specifically for the health attribute -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:is_set</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:is_set</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span> </code></pre> <p>Likewise we can do the same with Component Managers:</p> <pre class="code ruby"><code class="ruby"><span class='comment'># clears ALL triggers with this Component -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='rparen'>)</span> <span class='comment'># clear the 'trigger_when_added' for this Component Manager -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:added</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:added</span><span class='rparen'>)</span> <span class='comment'># clear the 'trigger_when_removed' for this Component Manager -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:removed</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:removed</span><span class='rparen'>)</span> <span class='comment'># clear the 'trigger_when_is_set' for this Component Manager specifically for the health attribute -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:is_set</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span> +</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:is_set</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span> </code></pre> <h3 id="redefinition">Redefinition</h3> <p>If we wanted to change what code or logic a given System executes, we could do that with:</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_redefine'>redefine</span> <span class='kw'>do</span> +<pre class="code ruby"><code class="ruby"><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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_redefine'>redefine</span> <span class='kw'>do</span> <span class='comment'># Some new logic or code </span><span class='kw'>end</span> </code></pre> @@ -437,28 +435,28 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p> <p>Once we have all the core parts of ECS, we will want to organize our Systems. To do this we will use Scenes to group up Systems so they can quickly be enabled or disabled. Note that <a href="#alternative-execution">Alternative Executions</a> will occur even if they are not part of a Scene. Here is how we make a new Scene:</p> -<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Scenes.html#initialize-instance_method" title="FelFlame::Scenes#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ExampleScene</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</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="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Scenes.html#initialize-instance_method" title="FelFlame::Scenes#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ExampleScene</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> </code></pre> <h3 id="accessing">Accessing</h3> <p>Just like other classes in FelFlame, the name we gave the Scene is how we access it:</p> -<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span> +<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</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="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span> </code></pre> <h3 id="adding-systems">Adding Systems</h3> <p>Adding Systems is simple. We can add as many as we want. In this example we add 3 different systems:</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='comma'>,</span> <span class='ivar'>@system2</span><span class='comma'>,</span> <span class='ivar'>@system3</span><span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby"><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="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='comma'>,</span> <span class='ivar'>@system2</span><span class='comma'>,</span> <span class='ivar'>@system3</span><span class='rparen'>)</span> </code></pre> <h3 id="removing-systems">Removing Systems</h3> <p>Removing Systems works simularly:</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span><span class='period'>.</span><span class='id identifier rubyid_remove'>remove</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='comma'>,</span> <span class='ivar'>@system2</span><span class='comma'>,</span> <span class='ivar'>@system3</span><span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby"><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="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span><span class='period'>.</span><span class='id identifier rubyid_remove'>remove</span><span class='lparen'>(</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="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='comma'>,</span> <span class='ivar'>@system2</span><span class='comma'>,</span> <span class='ivar'>@system3</span><span class='rparen'>)</span> </code></pre> <h3 id="clearing">Clearing</h3> @@ -483,21 +481,21 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p> <p>Finally we have the Stage. There is only a single Stage and we do not have to create it as it exists by default. By adding a Scene to the Stage we are saying that the Scene is active. To add a Scene we do the following:</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_add'><span class='object_link'><a href="FelFlame/Stage.html#add-class_method" title="FelFlame::Stage.add (method)">add</a></span></span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'>Scene</span><span class='op'>::</span><span class='const'>ExampleScene</span> +<pre class="code ruby"><code class="ruby"><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="FelFlame/Stage.html" title="FelFlame::Stage (class)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_add'><span class='object_link'><a href="FelFlame/Stage.html#add-class_method" title="FelFlame::Stage.add (method)">add</a></span></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'>Scene</span><span class='op'>::</span><span class='const'>ExampleScene</span> </code></pre> <h3 id="removing-scenes">Removing Scenes</h3> <p>Likewise we can remove Scenes:</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_remove'><span class='object_link'><a href="FelFlame/Stage.html#remove-class_method" title="FelFlame::Stage.remove (method)">remove</a></span></span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'>Scene</span><span class='op'>::</span><span class='const'>ExampleScene</span> +<pre class="code ruby"><code class="ruby"><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="FelFlame/Stage.html" title="FelFlame::Stage (class)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_remove'><span class='object_link'><a href="FelFlame/Stage.html#remove-class_method" title="FelFlame::Stage.remove (method)">remove</a></span></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'>Scene</span><span class='op'>::</span><span class='const'>ExampleScene</span> </code></pre> <h3 id="executing">Executing</h3> <p>On each frame of the game we want to execute the Stage once. When the Stage is executed it is progressing your game 1 frame forward. The Stage will make sure for you that all the Systems from all Scenes added will be executed in the correct order according to their priority. Here is how we do it:</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_call'><span class='object_link'><a href="FelFlame/Stage.html#call-class_method" title="FelFlame::Stage.call (method)">call</a></span></span> +<pre class="code ruby"><code class="ruby"><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="FelFlame/Stage.html" title="FelFlame::Stage (class)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_call'><span class='object_link'><a href="FelFlame/Stage.html#call-class_method" title="FelFlame::Stage.call (method)">call</a></span></span> </code></pre> <h2 id="closing-notes">Closing Notes</h2> @@ -514,7 +512,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p> </div></div> <div id="footer"> - Generated on Thu Dec 30 07:28:05 2021 by + Generated on Mon Jul 12 18:28:27 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 0efe4fe..4071d1b 100644 --- a/docs/method_list.html +++ b/docs/method_list.html @@ -46,6 +46,22 @@ <li class="odd "> <div class="item"> + <span class='object_link'><a href="FelFlame/Entities.html#[]-class_method" title="FelFlame::Entities.[] (method)">[]</a></span> + <small>FelFlame::Entities</small> + </div> + </li> + + + <li class="even "> + <div class="item"> + <span class='object_link'><a href="FelFlame/ComponentManager.html#[]-class_method" title="FelFlame::ComponentManager.[] (method)">[]</a></span> + <small>FelFlame::ComponentManager</small> + </div> + </li> + + + <li class="odd "> + <div class="item"> <span class='object_link'><a href="FelFlame/Scenes.html#add-instance_method" title="FelFlame::Scenes#add (method)">#add</a></span> <small>FelFlame::Scenes</small> </div> @@ -126,13 +142,21 @@ <li class="odd "> <div class="item"> + <span class='object_link'><a href="FelFlame/ComponentManager.html#attrs-instance_method" title="FelFlame::ComponentManager#attrs (method)">#attrs</a></span> + <small>FelFlame::ComponentManager</small> + </div> + </li> + + + <li class="even "> + <div class="item"> <span class='object_link'><a href="FelFlame.html#call-class_method" title="FelFlame.call (method)">call</a></span> <small>FelFlame</small> </div> </li> - <li class="even "> + <li class="odd "> <div class="item"> <span class='object_link'><a href="FelFlame/Scenes.html#call-instance_method" title="FelFlame::Scenes#call (method)">#call</a></span> <small>FelFlame::Scenes</small> @@ -140,7 +164,7 @@ </li> - <li class="odd "> + <li class="even "> <div class="item"> <span class='object_link'><a href="FelFlame/Stage.html#call-class_method" title="FelFlame::Stage.call (method)">call</a></span> <small>FelFlame::Stage</small> @@ -148,7 +172,7 @@ </li> - <li class="even "> + <li class="odd "> <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> @@ -156,7 +180,7 @@ </li> - <li class="odd "> + <li class="even "> <div class="item"> <span class='object_link'><a href="FelFlame/Scenes.html#clear-instance_method" title="FelFlame::Scenes#clear (method)">#clear</a></span> <small>FelFlame::Scenes</small> @@ -164,7 +188,7 @@ </li> - <li class="even "> + <li class="odd "> <div class="item"> <span class='object_link'><a href="FelFlame/Stage.html#clear-class_method" title="FelFlame::Stage.clear (method)">clear</a></span> <small>FelFlame::Stage</small> @@ -172,7 +196,7 @@ </li> - <li class="odd "> + <li class="even "> <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> @@ -180,14 +204,6 @@ </li> - <li class="even "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Entities.html#component-instance_method" title="FelFlame::Entities#component (method)">#component</a></span> - <small>FelFlame::Entities</small> - </div> - </li> - - <li class="odd "> <div class="item"> <span class='object_link'><a href="FelFlame/Entities.html#components-instance_method" title="FelFlame::Entities#components (method)">#components</a></span> @@ -230,23 +246,55 @@ <li class="even "> <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> + </div> + </li> + + + <li class="odd "> + <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="even "> + <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 "> <div class="item"> + <span class='object_link'><a href="FelFlame/ComponentManager.html#each-class_method" title="FelFlame::ComponentManager.each (method)">each</a></span> + <small>FelFlame::ComponentManager</small> + </div> + </li> + + + <li class="even "> + <div class="item"> <span class='object_link'><a href="FelFlame/ComponentManager.html#entities-instance_method" title="FelFlame::ComponentManager#entities (method)">#entities</a></span> <small>FelFlame::ComponentManager</small> </div> </li> + <li class="odd "> + <div class="item"> + <span class='object_link'><a href="FelFlame/Entities.html#id-instance_method" title="FelFlame::Entities#id (method)">#id</a></span> + <small>FelFlame::Entities</small> + </div> + </li> + + <li class="even "> <div class="item"> - <span class='object_link'><a href="FelFlame/ComponentManager.html#entity-instance_method" title="FelFlame::ComponentManager#entity (method)">#entity</a></span> + <span class='object_link'><a href="FelFlame/ComponentManager.html#id-instance_method" title="FelFlame::ComponentManager#id (method)">#id</a></span> <small>FelFlame::ComponentManager</small> </div> </li> @@ -374,21 +422,29 @@ <li class="even "> <div class="item"> - <span class='object_link'><a href="FelFlame/ComponentManager.html#to_h-instance_method" title="FelFlame::ComponentManager#to_h (method)">#to_h</a></span> - <small>FelFlame::ComponentManager</small> + <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> </div> </li> <li class="odd "> <div class="item"> + <span class='object_link'><a href="FelFlame/ComponentManager.html#to_i-instance_method" title="FelFlame::ComponentManager#to_i (method)">#to_i</a></span> + <small>FelFlame::ComponentManager</small> + </div> + </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="even "> + <li class="odd "> <div class="item"> <span class='object_link'><a href="FelFlame/Systems.html#trigger_when_is_changed-instance_method" title="FelFlame::Systems#trigger_when_is_changed (method)">#trigger_when_is_changed</a></span> <small>FelFlame::Systems</small> @@ -396,7 +452,7 @@ </li> - <li class="odd "> + <li class="even "> <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> @@ -404,7 +460,7 @@ </li> - <li class="even "> + <li class="odd "> <div class="item"> <span class='object_link'><a href="FelFlame/ComponentManager.html#update_attrs-instance_method" title="FelFlame::ComponentManager#update_attrs (method)">#update_attrs</a></span> <small>FelFlame::ComponentManager</small> diff --git a/docs/top-level-namespace.html b/docs/top-level-namespace.html index 26c3c67..38ed71e 100644 --- a/docs/top-level-namespace.html +++ b/docs/top-level-namespace.html @@ -82,10 +82,12 @@ <p class="children"> - <strong class="modules">Modules:</strong> <span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span>, <span class='object_link'><a href="Felflame_.html" title="Felflame (module)">Felflame</a></span> + <strong class="modules">Modules:</strong> <span class='object_link'><a href="Felflame_.html" title="Felflame (module)">Felflame</a></span> + <strong class="classes">Classes:</strong> <span class='object_link'><a href="FelFlame.html" title="FelFlame (class)">FelFlame</a></span> + </p> @@ -101,7 +103,7 @@ <div class="docstring"> <div class="discussion"> -<p>An alias for <span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></p> +<p>An alias for <span class='object_link'><a href="FelFlame.html" title="FelFlame (class)">FelFlame</a></span></p> </div> @@ -111,7 +113,7 @@ </div> </dt> - <dd><pre class="code"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span></pre></dd> + <dd><pre class="code"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span></pre></dd> </dl> @@ -127,7 +129,7 @@ </div> <div id="footer"> - Generated on Thu Dec 30 07:28:05 2021 by + Generated on Mon Jul 12 18:28:27 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/lib/felflame.rb b/lib/felflame.rb index 54084bf..cf58990 100644 --- a/lib/felflame.rb +++ b/lib/felflame.rb @@ -4,10 +4,10 @@ require_relative 'felflame/system_manager' require_relative 'felflame/scene_manager' require_relative 'felflame/stage_manager' -require_relative 'felflame/version' +require_relative "felflame/version" # The FelFlame namespace where all its functionality resides under. -module FelFlame +class FelFlame class <<self # :nocov: @@ -18,26 +18,26 @@ module FelFlame # :nocov: end - # Creates and manages Entities. Allows iterating or accessing Entities using array methods directly on the class. Entities are just collections of Components. + # Creates and manages Entities. Allows accessing Entities using their {FelFlame::Entities#id ID}. Entities are just collections of Components. class Entities; end - # Creates component managers and allows accessing them them under the {FelFlame::Components} namespace as Constants. + # Creates component managers and allows accessing them them under the {FelFlame::Components} namespace as Constants # # To see how component managers are used please look at the {FelFlame::ComponentManager} documentation. - module Components; end + class Components; end - # Creates an manages Systems. Systems are the logic of the game and do not contain any data within them. Any systems you create are accessable under the {FelFlame::Systems} namespace as Constants. + # Creates an manages Systems. Systems are the logic of the game and do not contain any data within them. # # TODO: Improve Systems overview class Systems; end - # Creates and manages Scenes. Scenes are collections of Systems, and execute all the Systems when called upon. Any scenes you create are accessable under the {FelFlame::Scenes} namespace as Constants. + # Creates and manages Scenes. Scenes are collections of Systems, and execute all the Systems when called upon. # # TODO: Improve Scenes overview class Scenes; end - # Stores Scenes you add to it which you want to execute on each frame. When called upon will execute all Systems in the Scenes in the Stage and will execute them according to their priority order. - module Stage; end + # Stores Scenes which you want to execute on each frame. When called upon will execute all Systems in the Scenes in the Stage and will execute them according to their priority order. + class Stage; end end # An alias for {FelFlame} diff --git a/lib/felflame/component_manager.rb b/lib/felflame/component_manager.rb index ca5be89..43932d2 100644 --- a/lib/felflame/component_manager.rb +++ b/lib/felflame/component_manager.rb @@ -1,7 +1,8 @@ -module FelFlame - module Components +class FelFlame + class Components @component_map = [] class <<self + include Enumerable # Creates a new {FelFlame::ComponentManager component manager}. # # @example @@ -45,26 +46,10 @@ module FelFlame FelFlame::Components.const_get(component_name) end - # Makes component module behave like an array of component - # managers with additional methods for managing the array - # @!visibility private - def respond_to_missing?(method, *) - if constants.respond_to? method - true - else - super - end - end - - # Makes component module behave like arrays with additional - # methods for managing the array - # @!visibility private - def method_missing(method, *args, **kwargs, &block) - if constants.respond_to? method - constants.send(method, *args, **kwargs, &block) - else - super - end + # Iterate over all existing component managers. You also call other enumerable methods instead of each, such as +each_with_index+ or +select+ + # @return [Enumerator] + def each(&block) + constants.each(&block) end end end @@ -73,6 +58,16 @@ module FelFlame # 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 [email protected] = 5+), or by using the {#attrs} and {#update_attrs} methods instead. class ComponentManager + # Holds the {id unique ID} of a component. The {id ID} is only unique within the scope of the component manager it was created from. + # @return [Integer] + attr_reader :id + + # A seperate attr_writer was made for documentation readability reasons. + # Yard will list attr_reader is readonly which is my intention. + # This value needs to be changable as it is set by other functions. + # @!visibility private + attr_writer :id + # Allows overwriting the storage of triggers, such as for clearing. # This method should generally only need to be used internally and # not by a game developer. @@ -109,43 +104,25 @@ module FelFlame def initialize(**attrs) # Prepare the object # (this is a function created with metaprogramming - # in FelFlame::Components) + # in FelFlame::Components set_defaults + # Generate ID + new_id = self.class.data.find_index { |i| i.nil? } + new_id = self.class.data.size if new_id.nil? + @id = new_id + # Fill params attrs.each do |key, value| send "#{key}=", value end # Save Component - self.class.push self + self.class.data[new_id] = self end class <<self - # Makes component managers behave like arrays with additional - # methods for managing the array - # @!visibility private - def respond_to_missing?(method, *) - if self._data.respond_to? method - true - else - super - end - end - - # Makes component managers behave like arrays with additional - # methods for managing the array - # @!visibility private - def method_missing(method, *args, **kwargs, &block) - if self._data.respond_to? method - self._data.send(method, *args, **kwargs, &block) - else - super - end - end - - # Allows overwriting the storage of triggers, such as for clearing. # This method should generally only need to be used internally and # not by a game developer. @@ -178,26 +155,39 @@ module FelFlame # @return [Array<Component>] Array of all Components that belong to a given component manager # @!visibility private - def _data + def data @data ||= [] end + + # Gets a Component from the given {id unique ID}. Usage is simular to how an Array lookup works. + # + # @example + # # this gets the 'Health' Component with ID 7 + # FelFlame::Components::Health[7] + # @param component_id [Integer] + # @return [Component] Returns the Component that uses the given unique {id ID}, nil if there is no Component associated with the given {id ID} + def [](component_id) + data[component_id] + end + + # Iterates over all components within the component manager. + # Special Enumerable methods like +map+ or +each_with_index+ are not implemented + # @return [Enumerator] + def each(&block) + data.compact.each(&block) + end end - # Entities that have this component - # @return [Array<Component>] - def entities - @entities ||= [] + # An alias for the {id ID Reader} + # @return [Integer] + def to_i + id end - # A single entity. Use this if you expect the component to only belong to one entity and you want to access it. - # @return [Component] - def entity - if entities.empty? - Warning.warn("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.") - elsif entities.length > 1 - Warning.warn("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.") - end - entities.first + # A list of entity ids that are linked to the component + # @return [Array<Integer>] + def entities + @entities ||= [] end # Update attribute values using a hash or keywords. @@ -216,19 +206,25 @@ module FelFlame systems_to_execute |= attr_triggers[attr] unless attr_triggers[attr].nil? - systems_to_execute.sort_by(&:priority).reverse_each(&:call) + systems_to_execute.sort_by(&:priority).reverse.each(&:call) true end - # Removes this component from the list and purges all references to this Component from other Entities, as well as its data. + + # 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 addition_triggers.each do |system| system.clear_triggers component_or_manager: self end - entities.reverse_each do |entity| + # 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| + #FelFlame::Entities[entity_id].remove self #unless FelFlame::Entities[entity_id].nil? entity.remove self end - self.class._data.delete self + self.class.data[id] = nil instance_variables.each do |var| instance_variable_set(var, nil) end @@ -236,7 +232,7 @@ module FelFlame end # @return [Hash<Symbol, Value>] A hash, where all the keys are attributes linked to their respective values. - def to_h + def attrs return_hash = instance_variables.each_with_object({}) do |key, final| final[key.to_s.delete_prefix('@').to_sym] = instance_variable_get(key) end diff --git a/lib/felflame/entity_manager.rb b/lib/felflame/entity_manager.rb index 9489f29..a05ef93 100644 --- a/lib/felflame/entity_manager.rb +++ b/lib/felflame/entity_manager.rb @@ -1,59 +1,53 @@ -module FelFlame +class FelFlame class Entities + # Holds the unique ID of this entity + # @return [Integer] + attr_reader :id + + # A seperate attr_writer was made for documentation readability reasons. + # Yard will list attr_reader is readonly which is my intention. + # This value needs to be changable as it is set by other functions. + # @!visibility private + attr_writer :id # Creating a new Entity # @param components [Components] Can be any number of components, identical duplicates will be automatically purged however different components from the same component manager are allowed. # @return [Entity] def initialize(*components) + # Assign new unique ID + new_id = self.class.data.find_index(&:nil?) + new_id = self.class.data.size if new_id.nil? + self.id = new_id + # Add each component add(*components) - # Fancy method redirection for when the `component` method is called - @component_redirect = Object.new - @component_redirect.instance_variable_set(:@entity, self) - @component_redirect.define_singleton_method(:[]) do |component_manager| - instance_variable_get(:@entity).component(component_manager) - end - - self.class._data.push self + self.class.data[id] = self end - # A hash that uses component manager constant names as keys, and where the values of those keys are arrays that contain the the components attached to this entity. + # A hash that uses component manager constant names as keys, and where the values of those keys are arrays that contain the {FelFlame::ComponentManager#id IDs} of the components attached to this entity. # @return [Hash<Component_Manager, Array<Integer>>] def components @components ||= {} end - # A single component from a component manager. Use this if you expect the component to only belong to one entity and you want to access it. Access the component using either parameter notation or array notation. - # @example - # @entity.component[@component_manager] # array notation - # @entity.component(@component_manager) # method notation - # @param manager [ComponentManager] If you pass nil you can then use array notation to access the same value. - # @return [Component] - def component(manager = nil) - if manager.nil? - @component_redirect - else - if components[manager].nil? - raise "This entity(#{self}) doesnt have any components of this type: #{manager}" - elsif components[manager].length > 1 - Warning.warn("This entity has MANY of this component but you called the method that is intended for having a single of this component type.\nYou may have a bug in your logic.") - end - components[manager].first - end + # An alias for the {#id ID reader} + # @return [Integer] + def to_i + id end - - # Removes this Entity from the list and purges all references to this Entity from other Components, as well as its data. + # Removes this Entity from the list and purges all references to this Entity from other Components, as well as its {id ID} and data. # @return [Boolean] +true+ def delete components.each do |component_manager, component_array| - component_array.reverse_each do |component| + component_array.each do |component| component.entities.delete(self) end end - FelFlame::Entities._data.delete self + FelFlame::Entities.data[id] = nil @components = {} + @id = nil true end @@ -95,9 +89,6 @@ module FelFlame check_systems component, :removal_triggers if component.entities.include? self component.entities.delete self components[component.class].delete component - if components[component.class].empty? - components.delete component.class - end end true end @@ -108,33 +99,29 @@ module FelFlame #def to_json() end class <<self - # Makes component managers behave like arrays with additional - # methods for managing the array + include Enumerable + # @return [Array<Entity>] Array of all Entities that exist # @!visibility private - def respond_to_missing?(method, *) - if self._data.respond_to? method - true - else - super - end + def data + @data ||= [] end - # Makes component managers behave like arrays with additional - # methods for managing the array - # @!visibility private - def method_missing(method, *args, **kwargs, &block) - if self._data.respond_to? method - self._data.send(method, *args, **kwargs, &block) - else - super - end + # Gets an Entity from the given {id unique ID}. Usage is simular to how an Array lookup works + # + # @example + # # This gets the Entity with ID 7 + # FelFlame::Entities[7] + # @param entity_id [Integer] + # @return [Entity] returns the Entity that uses the given unique ID, nil if there is no Entity associated with the given ID + def [](entity_id) + data[entity_id] end - - # @return [Array<Entity>] Array of all Entities that exist - # @!visibility private - def _data - @data ||= [] + # 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.compact.each(&block) end # Creates a new entity using the data from a JSON string diff --git a/lib/felflame/scene_manager.rb b/lib/felflame/scene_manager.rb index a9d3ac7..315dd55 100644 --- a/lib/felflame/scene_manager.rb +++ b/lib/felflame/scene_manager.rb @@ -1,4 +1,4 @@ -module FelFlame +class FelFlame class Scenes # The Constant name assigned to this Scene attr_reader :const_name @@ -33,16 +33,16 @@ module FelFlame # @return [Boolean] +true+ def add(*systems_to_add) self.systems |= systems_to_add - self.systems = systems.sort_by(&:priority) + systems.sort_by!(&:priority) FelFlame::Stage.update_systems_list if FelFlame::Stage.scenes.include? self true end - # Removes any number of Systems from this Scene + # Removes any number of SystemS from this Scene # @return [Boolean] +true+ def remove(*systems_to_remove) self.systems -= systems_to_remove - self.systems = systems.sort_by(&:priority) + systems.sort_by!(&:priority) FelFlame::Stage.update_systems_list if FelFlame::Stage.scenes.include? self true end diff --git a/lib/felflame/stage_manager.rb b/lib/felflame/stage_manager.rb index 05b5c19..87ee955 100644 --- a/lib/felflame/stage_manager.rb +++ b/lib/felflame/stage_manager.rb @@ -1,5 +1,5 @@ -module FelFlame - module Stage +class FelFlame + class Stage class <<self # Allows clearing of scenes and systems. # Used internally by FelFlame and shouldn't need to be ever used by developers @@ -13,7 +13,7 @@ module FelFlame scenes_to_add.each do |scene| self.systems |= scene.systems end - self.systems = systems.sort_by(&:priority) + systems.sort_by!(&:priority) true end @@ -34,7 +34,7 @@ module FelFlame scenes.each do |scene| self.systems |= scene.systems end - self.systems = systems.sort_by(&:priority) + systems.sort_by!(&:priority) true end diff --git a/lib/felflame/system_manager.rb b/lib/felflame/system_manager.rb index d936e8e..cab2c4d 100644 --- a/lib/felflame/system_manager.rb +++ b/lib/felflame/system_manager.rb @@ -1,4 +1,4 @@ -module FelFlame +class FelFlame class Systems # How early this System should be executed in a list of Systems attr_accessor :priority @@ -14,7 +14,7 @@ module FelFlame def priority=(priority) @priority = priority - FelFlame::Stage.systems = FelFlame::Stage.systems.sort_by(&:priority) + FelFlame::Stage.systems.sort_by!(&:priority) end # Stores references to components or their managers that trigger # this component when a component or component from that manager diff --git a/spec/component_manager_spec.rb b/spec/component_manager_spec.rb index 6fedf78..d99d744 100644 --- a/spec/component_manager_spec.rb +++ b/spec/component_manager_spec.rb @@ -1,4 +1,4 @@ -require_relative '../lib/felflame.rb' +require 'felflame' describe 'Components' do @@ -11,8 +11,6 @@ describe 'Components' do end before :each do - @orig_stderr = $stderr - $stderr = StringIO.new @ent0 = FelFlame::Entities.new @ent1 = FelFlame::Entities.new @ent2 = FelFlame::Entities.new @@ -22,61 +20,21 @@ describe 'Components' do end after :each do - $stderr = @orig_stderr - FelFlame::Entities.reverse_each(&:delete) - @component_manager.reverse_each(&:delete) - end - - it 'can get a single entity' do - @cmp0.entity - $stderr.rewind - $stderr.string.chomp.should eq("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.") - @ent0.add @cmp0 - expect(@cmp0.entity).to eq(@ent0) - @ent1.add @cmp0 - @cmp0.entity - $stderr.rewind - $stderr.string.chomp.should eq("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.") - end - - it 'responds to array methods' do - expect(@component_manager.respond_to?(:[])).to be true - expect(@component_manager.respond_to?(:each)).to be true - expect(@component_manager.respond_to?(:filter)).to be true - expect(@component_manager.respond_to?(:first)).to be true - expect(@component_manager.respond_to?(:last)).to be true - expect(@component_manager.respond_to?(:somethingwrong)).to be false - end - - it 'dont respond to missing methods' do - expect { @component_manager.somethingwrong }.to raise_error(NoMethodError) - end - - it 'Component module responds to array methods' do - expect(FelFlame::Components.respond_to?(:[])).to be true - expect(FelFlame::Components.respond_to?(:each)).to be true - expect(FelFlame::Components.respond_to?(:filter)).to be true - expect(FelFlame::Components.respond_to?(:first)).to be true - expect(FelFlame::Components.respond_to?(:last)).to be true - expect(FelFlame::Components.respond_to?(:somethingwrong)).to be false - end - - it 'Component module doesnt respond to missing methods' do - expect { FelFlame::Components.somethingwrong }.to raise_error(NoMethodError) + FelFlame::Entities.each(&:delete) + @component_manager.each(&:delete) end it 'can delete a component' do - #component_id = @cmp1.id + component_id = @cmp1.id @ent0.add @cmp1 - length = @component_manager.length + expect(@cmp1.delete).to be true - expect(@component_manager.length).to eq(length-1) - #expect(@cmp1.id).to be_nil - #expect(@component_manager[component_id]).to be_nil + expect(@cmp1.id).to be_nil + expect(@component_manager[component_id]).to be_nil expect(@cmp1.entities).to eq([]) end - it 'can iterate component managers' do + it 'can iterate over all component managers' do all_components = FelFlame::Components.constants expect(all_components.length).to be > 0 expect(FelFlame::Components.each).to be_an Enumerator @@ -88,7 +46,7 @@ describe 'Components' do it 'can change params on initialization' do @cmp3 = @component_manager.new(param1: 'ok', param2: 10) - expect(@cmp3.to_h).to eq(param1: 'ok', param2: 10) + expect(@cmp3.attrs).to eq(param1: 'ok', param2: 10, id: @cmp3.id) end @@ -101,33 +59,29 @@ describe 'Components' do expect(@cmp2.param2).to eq('def') end - it 'can read attributes' do - expect(@cmp0.to_h).to eq(param2: 'def') - expect(@cmp1.to_h).to eq(param2: 'def') - expect(@cmp2.to_h).to eq(param2: 'def') + it 'can read attrs' do + expect(@cmp0.attrs).to eq(param2: 'def', id: 0) + expect(@cmp1.attrs).to eq(param2: 'def', id: 1) + expect(@cmp2.attrs).to eq(param2: 'def', id: 2) end it 'can set attrs' do expect(@cmp0.param1 = 4).to eq(4) expect(@cmp1.update_attrs(param1: 3, param2: 'new')).to eq(param1: 3, param2: 'new') - expect(@cmp1.to_h).to eq(param1: 3, param2: 'new') + expect(@cmp1.attrs).to eq(param1: 3, param2: 'new', id: 1) end - it 'can be used as a singleton' do - expect(@component_manager.first).to eq(@cmp0) + it 'can be accessed' do + expect(@cmp0).to eq(@component_manager[0]) + expect(@cmp1).to eq(@component_manager[1]) + expect(@cmp2).to eq(@component_manager[2]) end - #it 'can be accessed' do - # expect(@cmp0).to eq(@component_manager[0]) - # expect(@cmp1).to eq(@component_manager[1]) - # expect(@cmp2).to eq(@component_manager[2]) - #end - - #it 'can get id from to_i' do - # expect(@cmp0.id).to eq(@cmp0.to_i) - # expect(@cmp1.id).to eq(@cmp1.to_i) - # expect(@cmp2.id).to eq(@cmp2.to_i) - #end + it 'can get id from to_i' do + expect(@cmp0.id).to eq(@cmp0.to_i) + expect(@cmp1.id).to eq(@cmp1.to_i) + expect(@cmp2.id).to eq(@cmp2.to_i) + end it 'cant overwrite exiting component managers' do FelFlame::Components.new('TestComponent1') @@ -135,7 +89,7 @@ describe 'Components' do end it 'can\'t create an attribute when its name is an existing method' do - #expect { FelFlame::Components.new('TestComponent2', :id) }.to raise_error(NameError) + expect { FelFlame::Components.new('TestComponent2', :id) }.to raise_error(NameError) expect { FelFlame::Components.new('TestComponent2', :addition_triggers) }.to raise_error(NameError) expect { FelFlame::Components.new('TestComponent2', :removal_triggers) }.to raise_error(NameError) expect { FelFlame::Components.new('TestComponent2', :attr_triggers) }.to raise_error(NameError) diff --git a/spec/entity_manager_spec.rb b/spec/entity_manager_spec.rb index 424b162..ef638c0 100644 --- a/spec/entity_manager_spec.rb +++ b/spec/entity_manager_spec.rb @@ -1,4 +1,4 @@ -require_relative '../lib/felflame.rb' +require 'felflame' #class EntitiesTest < Minitest::Test @@ -9,14 +9,11 @@ describe 'Entities' do #end before :all do - $VERBOSE = nil @component_manager ||= FelFlame::Components.new('TestEntity', :param1, param2: 'def') end before :each do - @orig_stderr = $stderr - $stderr = StringIO.new @ent0 = FelFlame::Entities.new @ent1 = FelFlame::Entities.new @ent2 = FelFlame::Entities.new @@ -26,60 +23,26 @@ describe 'Entities' do end after :each do - $stderr = @orig_stderr - FelFlame::Entities.reverse_each(&:delete) - @component_manager.reverse_each(&:delete) + FelFlame::Entities.each(&:delete) + @component_manager.each(&:delete) end - it 'can get a single component' do - expect { @ent0.component[@component_manager] }.to raise_error(RuntimeError) - #$stderr.rewind - #$stderr.string.chomp.should eq("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.") - @ent0.add @cmp0 - expect(@ent0.component[@component_manager]).to eq(@cmp0) - expect(@ent0.component[@component_manager]).to eq(@ent0.component(@component_manager)) - @ent0.add @cmp1 - @ent0.component[@component_manager] - $stderr.rewind - $stderr.string.chomp.should eq("This entity has MANY of this component but you called the method that is intended for having a single of this component type.\nYou may have a bug in your logic.") - @ent0.components[@component_manager].reverse_each do |component| - @ent0.remove component - end - expect { @ent0.component[@component_manager] }.to raise_error(RuntimeError) - end - - - - it 'responds to array methods' do - expect(FelFlame::Entities.respond_to?(:[])).to be true - expect(FelFlame::Entities.respond_to?(:each)).to be true - expect(FelFlame::Entities.respond_to?(:filter)).to be true - expect(FelFlame::Entities.respond_to?(:first)).to be true - expect(FelFlame::Entities.respond_to?(:last)).to be true - expect(FelFlame::Entities.respond_to?(:somethingwrong)).to be false - end - - it 'dont respond to missing methods' do - expect { FelFlame::Entities.somethingwrong }.to raise_error(NoMethodError) - end - - it 'won\'t add duplicate entities' do @ent0.add @cmp0, @cmp0, @cmp1, @cmp1 expect(@ent0.components[@component_manager].count).to eq(2) end - #it 'has correct ID\'s' do - # expect(@ent0.id).to eq(0) - # expect(@ent1.id).to eq(1) - # expect(@ent2.id).to eq(2) - #end + it 'has correct ID\'s' do + expect(@ent0.id).to eq(0) + expect(@ent1.id).to eq(1) + expect(@ent2.id).to eq(2) + end - #it 'can be accessed' do - # expect(@ent0).to eq(FelFlame::Entities[0]) - # expect(@ent1).to eq(FelFlame::Entities[1]) - # expect(@ent2).to eq(FelFlame::Entities[2]) - #end + it 'can be accessed' do + expect(@ent0).to eq(FelFlame::Entities[0]) + expect(@ent1).to eq(FelFlame::Entities[1]) + expect(@ent2).to eq(FelFlame::Entities[2]) + end it 'can have components attached' do @ent0.add @cmp0 @@ -91,20 +54,17 @@ describe 'Entities' do expect(@ent1.components[@component_manager].include?(@cmp2)).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 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].nil?).to be true - @ent0.add @cmp0 - @cmp0.delete - expect(@ent0.components[@component_manager].nil?).to be true + expect(@ent0.components[@component_manager].empty?).to be true end it 'can have many components added then removed' do @@ -121,12 +81,11 @@ describe 'Entities' do expect(@cmp2.entities).to eq([@ent0,@ent2]) @cmp1.delete expect(@ent0.components).to eq({@component_manager => [@cmp0,@cmp2]}) - @component_manager.reverse_each(&:delete) - expect(@component_manager.length).to eq(0) - expect(@component_manager.empty?).to be true - expect(@ent0.components).to eq({}) - expect(@ent2.components).to eq({}) - FelFlame::Entities.reverse_each(&:delete) - expect(FelFlame::Entities.empty?).to be true + @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/scene_manager_spec.rb b/spec/scene_manager_spec.rb index 65666c7..f2aee01 100644 --- a/spec/scene_manager_spec.rb +++ b/spec/scene_manager_spec.rb @@ -1,4 +1,4 @@ -require_relative '../lib/felflame.rb' +require 'felflame' #class EntitiesTest < Minitest::Test diff --git a/spec/stage_manager_spec.rb b/spec/stage_manager_spec.rb index 0aa8690..ed1125c 100644 --- a/spec/stage_manager_spec.rb +++ b/spec/stage_manager_spec.rb @@ -1,4 +1,4 @@ -require_relative '../lib/felflame.rb' +require 'felflame' #class EntitiesTest < Minitest::Test diff --git a/spec/system_manager_spec.rb b/spec/system_manager_spec.rb index 3d2e3dc..f9df439 100644 --- a/spec/system_manager_spec.rb +++ b/spec/system_manager_spec.rb @@ -1,4 +1,4 @@ -require_relative '../lib/felflame.rb' +require 'felflame' describe 'Components' do @@ -73,16 +73,6 @@ describe 'Components' do expect(second.health).to eq(init2 - (multiple * 10)) end - it 'can clear triggers from components and systems' do - @cmp0 = @component_manager.new - @system.trigger_when_added @cmp0 - expect(@cmp0.addition_triggers.length).to eq(1) - expect(@system.addition_triggers.length).to eq(1) - expect(@cmp0.delete).to be true - expect(@cmp0.addition_triggers.length).to eq(0) - expect(@system.addition_triggers.length).to eq(0) - end - it 'can trigger when a single Component is added' do @cmp0 = @component_manager.new @cmp1 = @component_manager.new health: 20 @@ -336,7 +326,7 @@ describe 'Components' do expect(@cmp0.health).to eq(10) expect(@cmp1.health).to eq(20) end - + it 'can clear addition_trigger, with component' do @cmp0 = @component_manager.new health: 10 @cmp1 = @component_manager.new health: 20 @@ -379,7 +369,7 @@ describe 'Components' do expect(@cmp0.health).to eq(10) expect(@cmp1.health).to eq(20) end - + it 'can clear removal_trigger, with component' do @cmp0 = @component_manager.new health: 10 @cmp1 = @component_manager.new health: 20 |
