felecs 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +7 -0
  2. data/.byebug_history +20 -0
  3. data/.gitignore +17 -0
  4. data/.inch.yml +11 -0
  5. data/.rspec +1 -0
  6. data/.rubocop.yml +13 -0
  7. data/.ruby-version +1 -0
  8. data/CHANGELOG.mdown +80 -0
  9. data/Gemfile +10 -0
  10. data/Gemfile.lock +87 -0
  11. data/LICENSE +21 -0
  12. data/README.mdown +465 -0
  13. data/Rakefile +66 -0
  14. data/bin/console +15 -0
  15. data/bin/setup +8 -0
  16. data/docs/CNAME +1 -0
  17. data/docs/FelECS/ComponentManager.html +1239 -0
  18. data/docs/FelECS/Components.html +337 -0
  19. data/docs/FelECS/Entities.html +792 -0
  20. data/docs/FelECS/Order.html +251 -0
  21. data/docs/FelECS/Scenes.html +765 -0
  22. data/docs/FelECS/Stage.html +572 -0
  23. data/docs/FelECS/Systems.html +1505 -0
  24. data/docs/FelECS.html +335 -0
  25. data/docs/FelFlame/ComponentManager.html +1239 -0
  26. data/docs/FelFlame/Components.html +333 -0
  27. data/docs/FelFlame/Entities.html +792 -0
  28. data/docs/FelFlame/Helper/ComponentManager.html +1627 -0
  29. data/docs/FelFlame/Helper.html +142 -0
  30. data/docs/FelFlame/Order.html +251 -0
  31. data/docs/FelFlame/Scenes.html +765 -0
  32. data/docs/FelFlame/Stage.html +572 -0
  33. data/docs/FelFlame/Systems.html +1505 -0
  34. data/docs/FelFlame.html +319 -0
  35. data/docs/Felflame_.html +143 -0
  36. data/docs/_index.html +188 -0
  37. data/docs/class_list.html +51 -0
  38. data/docs/css/common.css +1 -0
  39. data/docs/css/full_list.css +58 -0
  40. data/docs/css/style.css +497 -0
  41. data/docs/file.README.html +560 -0
  42. data/docs/file.version.html +74 -0
  43. data/docs/file_list.html +56 -0
  44. data/docs/frames.html +17 -0
  45. data/docs/index.html +560 -0
  46. data/docs/js/app.js +314 -0
  47. data/docs/js/full_list.js +216 -0
  48. data/docs/js/jquery.js +4 -0
  49. data/docs/method_list.html +419 -0
  50. data/docs/top-level-namespace.html +137 -0
  51. data/felecs.gemspec +45 -0
  52. data/lib/felecs/component_manager.rb +279 -0
  53. data/lib/felecs/entity_manager.rb +160 -0
  54. data/lib/felecs/order.rb +24 -0
  55. data/lib/felecs/scene_manager.rb +69 -0
  56. data/lib/felecs/stage_manager.rb +47 -0
  57. data/lib/felecs/system_manager.rb +258 -0
  58. data/lib/felecs/version.rb +9 -0
  59. data/lib/felecs.rb +67 -0
  60. data/mrbgem/mrbgem.rake +4 -0
  61. data/mrbgem/mrblib/felecs.rb +913 -0
  62. metadata +229 -0
data/docs/index.html ADDED
@@ -0,0 +1,560 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ File: README
8
+
9
+ &mdash; Documentation by YARD 0.9.26
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "README";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+ <span class="title">File: README</span>
41
+
42
+ </div>
43
+
44
+ <div id="search">
45
+
46
+ <a class="full_list_link" id="class_list_link"
47
+ href="class_list.html">
48
+
49
+ <svg width="24" height="24">
50
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
+ </svg>
54
+ </a>
55
+
56
+ </div>
57
+ <div class="clear"></div>
58
+ </div>
59
+
60
+ <div id="content"><div id='filecontents'><p><img src="https://raw.githubusercontent.com/realtradam/FelECS/master/logos/felecs-logo-text.png" alt="FelECS"></p>
61
+
62
+ <!-- ![FelFlame](https://filestorage.catgirls.rodeo/images/felecs-logo-smaller-text.png) -->
63
+
64
+ <p><a href="https://codeclimate.com/github/realtradam/FelFlame/maintainability"><img src="https://api.codeclimate.com/v1/badges/56d425d9078e98efb74b/maintainability" alt="Maintainability"></a>
65
+ <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>
66
+ <a href="http://inch-ci.org/github/realtradam/FelECS"><img src="http://inch-ci.org/github/realtradam/FelECS.svg?branch=master" alt="Inline docs"></a>
67
+ <a href="https://github.com/realtradam/FelFlame/blob/master/LICENSE"><img src="https://img.shields.io/github/license/realtradam/FelECS" alt="MIT License"></a>
68
+ <a href="https://ko-fi.com/tradam"><img src="https://img.shields.io/static/v1?message=Buy%20me%20a%20coffee&logo=kofi&labelColor=ff5e5b&color=434B57&logoColor=white&label=%20" alt="Ko-Fi"></a></p>
69
+
70
+ <p><strong><a href="https://felflame.tradam.fyi/">Check out the comprehensive documentation here!</a></strong></p>
71
+
72
+ <hr>
73
+
74
+ <!-- vim-markdown-toc GFM -->
75
+
76
+ <ul>
77
+ <li><a href="#what-is-felecs">What is FelECS?</a></li>
78
+ <li><a href="#what-is-ecs">What is ECS?</a>
79
+ * <a href="#components">Components</a>
80
+ * <a href="#entities">Entities</a>
81
+ * <a href="#systems">Systems</a>
82
+ * <a href="#scenes">Scenes</a>
83
+ * <a href="#stage">Stage</a>
84
+ * <a href="#order">Order</a></li>
85
+ <li><a href="#usage">Usage</a>
86
+
87
+ <ul>
88
+ <li><a href="#entities-1">Entities</a>
89
+
90
+ <ul>
91
+ <li><a href="#creation">Creation</a></li>
92
+ <li><a href="#accessing">Accessing</a></li>
93
+ <li><a href="#adding-and-removing-components">Adding and Removing Components</a></li>
94
+ <li><a href="#accessing-entities-attached-components">Accessing Entities&#39; Attached Components</a></li>
95
+ <li><a href="#deletion">Deletion</a></li>
96
+ </ul></li>
97
+ <li><a href="#components-1">Components</a>
98
+
99
+ <ul>
100
+ <li><a href="#creating-a-component-manager">Creating a Component Manager</a></li>
101
+ <li><a href="#creating-a-component-from-a-component-manager">Creating a Component from a Component Manager</a></li>
102
+ <li><a href="#accessing-1">Accessing</a></li>
103
+ <li><a href="#accessing-attributes-and-changing-them">Accessing Attributes and Changing Them</a></li>
104
+ <li><a href="#deleting-components">Deleting Components</a></li>
105
+ <li><a href="#accessing-components-attached-entities">Accessing Components&#39; attached Entities</a></li>
106
+ </ul></li>
107
+ <li><a href="#systems-1">Systems</a>
108
+
109
+ <ul>
110
+ <li><a href="#creation-1">Creation</a></li>
111
+ <li><a href="#execution">Execution</a></li>
112
+ <li><a href="#alternative-execution">Alternative Execution</a></li>
113
+ <li><a href="#clearing-alternative-executions">Clearing Alternative Executions</a></li>
114
+ <li><a href="#redefinition">Redefinition</a></li>
115
+ </ul></li>
116
+ <li><a href="#scenes-1">Scenes</a>
117
+
118
+ <ul>
119
+ <li><a href="#creation-2">Creation</a></li>
120
+ <li><a href="#accessing-2">Accessing</a></li>
121
+ <li><a href="#adding-systems">Adding Systems</a></li>
122
+ <li><a href="#removing-systems">Removing Systems</a></li>
123
+ <li><a href="#clearing">Clearing</a></li>
124
+ <li><a href="#execution-1">Execution</a></li>
125
+ </ul></li>
126
+ <li><a href="#stage-1">Stage</a>
127
+
128
+ <ul>
129
+ <li><a href="#adding-scenes">Adding Scenes</a></li>
130
+ <li><a href="#removing-scenes">Removing Scenes</a></li>
131
+ <li><a href="#executing">Executing</a></li>
132
+ </ul></li>
133
+ <li><a href="#order-1">Order</a>
134
+
135
+ <ul>
136
+ <li><a href="#setting-the-order">Setting the order</a></li>
137
+ </ul></li>
138
+ <li><a href="#closing-notes">Closing Notes</a></li>
139
+ </ul></li>
140
+ <li><a href="#contribution">Contribution</a></li>
141
+ </ul>
142
+
143
+ <!-- vim-markdown-toc -->
144
+
145
+ <h1 id="what-is-felecs">What is FelECS?</h1>
146
+
147
+ <p>FelECS is an ECS framework for developing games in the Ruby language. FelECS has been designed from the ground up with these three ideas in mind:</p>
148
+
149
+ <ol>
150
+ <li><strong>Engine Agnostic:</strong> FelECS 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>
151
+ <li><strong>Easily Extensible:</strong> FelECS 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>
152
+ <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>
153
+ </ol>
154
+
155
+ <h1 id="what-is-ecs">What is ECS?</h1>
156
+
157
+ <p>ECS is a software architectural pattern that is used in video game development. Traditionally games were programmed using an object oriented method, while ECS instead attempts to program games using a data oriented method instead.<br>
158
+ ECS stands for Entity, Component, and System.</p>
159
+
160
+ <hr>
161
+
162
+ <h3 id="components">Components</h3>
163
+
164
+ <p>This is where the data or information of a given &quot;object&quot; is stored. There is no logic or code here. </p>
165
+
166
+ <h3 id="entities">Entities</h3>
167
+
168
+ <p>Entities will contain one or more Components, but contains no logic or data otherwise</p>
169
+
170
+ <h3 id="systems">Systems</h3>
171
+
172
+ <p>Systems are where all the logic or code is kept. There is no data stored in here.</p>
173
+
174
+ <hr>
175
+
176
+ <p>By using this pattern it allows programmers to easily control what an &quot;object&quot; or entity can do and how much data it needs to have. It avoids the issue of inhertance as no inhertance is ever required in this system. If you need a certain entity to have a certain functionality you just add the relevant component to it, and the systems that automatically go over specific components will give your entitiy the desired functionality. </p>
177
+
178
+ <p><strong>&quot;But your framework also has <code>Scenes</code>, <code>Stage</code>, and <code>Order</code>, what is that about?&quot;</strong> </p>
179
+
180
+ <hr>
181
+
182
+ <h3 id="scenes">Scenes</h3>
183
+
184
+ <p>Scenes are simply a collection or subset of Systems. This allows for an easy way to activate and deactivate Systems.</p>
185
+
186
+ <h3 id="stage">Stage</h3>
187
+
188
+ <p>The Stage is Scenes which are activated. This means any Scenes on the Stage are executed each frame, while the rest of the Systems are not.</p>
189
+
190
+ <h3 id="order">Order</h3>
191
+
192
+ <p>Order is a helper class which can set the priority of Scenes and Systems.</p>
193
+
194
+ <hr>
195
+
196
+ <h1 id="usage">Usage</h1>
197
+
198
+ <p>There are 2 ways of using FelECS. You can either <code>include</code> it as a gem in your project if your game engine supports this. The other option is to download the single file export of FelECS and then <code>require_relative</code> this file in your project. The single file export takes all the ruby code in the various files and concatenates them into a single file so it is more portable and easy to add.</p>
199
+
200
+ <p>To use the gem method you can do the following: install the gem using <code>gem install felecs</code> or using bundler <code>bundle add felecs</code> and then require it in your project like so: <code>require &#39;felecs&#39;</code>.</p>
201
+
202
+ <p>To use the single file export method you simply download the felecs.rb file from the <a href="https://github.com/realtradam/FelECS/releases">releases page on Github</a> and add it to your source folder and add a <code>require relative &#39;felecs.rb&#39;</code> line or wherever you have placed the file to use it.</p>
203
+
204
+ <h2 id="entities">Entities</h2>
205
+
206
+ <h3 id="creation">Creation</h3>
207
+
208
+ <p>Entities are essentially &quot;objects&quot; in the game world. To create a new Entity we do the following:</p>
209
+
210
+ <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="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Entities.html" title="FelECS::Entities (class)">Entities</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelECS/Entities.html#initialize-instance_method" title="FelECS::Entities#initialize (method)">new</a></span></span>
211
+ </code></pre>
212
+
213
+ <p>or if we want to add (any number of)components to it when creating it:</p>
214
+
215
+ <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="FelECS.html" title="FelECS (module)">FelECS</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>
216
+ <span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Components.html" title="FelECS::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>
217
+ <span class='ivar'>@component</span><span class='comma'>,</span>
218
+ <span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Components.html" title="FelECS::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>EnemyTeam</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
219
+ <span class='rparen'>)</span>
220
+ </code></pre>
221
+
222
+ <h3 id="accessing">Accessing</h3>
223
+
224
+ <p>Oftentimes you will not be accessing an Entity this way. Later we will shows you a more common way of accessing entities.
225
+ If you need to you can access Entities using the <code>Entities</code> module:</p>
226
+
227
+ <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="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Entities.html" title="FelECS::Entities (class)">Entities</a></span></span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span>
228
+ <span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Entities.html" title="FelECS::Entities (class)">Entities</a></span></span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
229
+ <span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Entities.html" title="FelECS::Entities (class)">Entities</a></span></span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='comment'># you can iterate over all entities this way. Any valid array method can be used
230
+ </span></code></pre>
231
+
232
+ <h3 id="adding-and-removing-components">Adding and Removing Components</h3>
233
+
234
+ <p>We can still add or remove Components from an Entity after it has been created. Here is how:</p>
235
+
236
+ <pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='ivar'>@component</span>
237
+ <span class='ivar'>@entity</span><span class='period'>.</span><span class='id identifier rubyid_remove'>remove</span> <span class='ivar'>@component</span>
238
+ </code></pre>
239
+
240
+ <h3 id="accessing-entities-attached-components">Accessing Entities&#39; Attached Components</h3>
241
+
242
+ <p>This is the most common way of accessing an Entity</p>
243
+
244
+ <p>When Components are added to Entities, they can be accessed from the Entity. By using a Component Manager as a key we can access an array of all components created from that Component Manager that are attached to an entity:</p>
245
+
246
+ <pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span><span class='period'>.</span><span class='id identifier rubyid_components'>components</span><span class='lbracket'>[</span><span class='ivar'>@component_manager</span><span class='rbracket'>]</span> <span class='comment'># =&gt; [@component1, @component2, @component3]
247
+ </span></code></pre>
248
+
249
+ <h3 id="deletion">Deletion</h3>
250
+
251
+ <p>To have all Components from an Entity <strong>removed</strong> and the Entity deleted we do the following:</p>
252
+
253
+ <p>NOTE: The components will <strong>not be deleted</strong>. They are simply <strong>removed</strong> from the entity and then the entity is destroyed. You must handle component deletion yourself as for example singleton components need to removed instead of deleted.</p>
254
+
255
+ <pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span>
256
+ </code></pre>
257
+
258
+ <h2 id="components">Components</h2>
259
+
260
+ <h3 id="creating-a-component-manager">Creating a Component Manager</h3>
261
+
262
+ <p>Components are where all the data is stored. The data is stored in variables or accessors in each component.
263
+ These accessors and their defaults are configured when a component manager is created, like so:</p>
264
+
265
+ <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="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Components.html" title="FelECS::Components (module)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelECS/Components.html#new-class_method" title="FelECS::Components.new (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Stats</span><span class='tstring_end'>&#39;</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>
266
+ </code></pre>
267
+
268
+ <p>In this example we created a component manager called &quot;Stats&quot;.
269
+ The name given to component managers must follow the same rules for naming constants in ruby for a reason you will shortly see.
270
+ The parameters following are all creating the attributes we can set.
271
+ We can set any number of parameters we wish, in this example we define two.
272
+ The <code>:armour</code> parameter is being created without a default, it will equal to <code>nil</code> when a new component is created, while <code>hp</code> will be equal to 100 when a component is created.
273
+ When defining attributes symbols should be used.</p>
274
+
275
+ <h3 id="creating-a-component-from-a-component-manager">Creating a Component from a Component Manager</h3>
276
+
277
+ <p>Now that we have a component manager we can make components from it like so:</p>
278
+
279
+ <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="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Components.html" title="FelECS::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>
280
+ </code></pre>
281
+
282
+ <p>Or we can even override the defaults when creating the component:</p>
283
+
284
+ <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="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Components.html" title="FelECS::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'>&#39;</span><span class='tstring_content'>steel</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
285
+ </code></pre>
286
+
287
+ <h3 id="accessing">Accessing</h3>
288
+
289
+ <p>You can access components using any array method.</p>
290
+
291
+ <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="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Components.html" title="FelECS::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>
292
+ <span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Components.html" title="FelECS::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
293
+ <span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Components.html" title="FelECS::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='comment'># you can use iterators this way
294
+ </span></code></pre>
295
+
296
+ <h3 id="accessing-attributes-and-changing-them">Accessing Attributes and Changing Them</h3>
297
+
298
+ <p>There are a few different ways we can read or change the attributes of a component depending on what our needs are.
299
+ Here are the ways to edit attrubutes, followed by the ways to read them.</p>
300
+
301
+ <pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_armour'>armour</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Mythril</span><span class='tstring_end'>&#39;</span></span>
302
+ <span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_update_attrs'>update_attrs</span><span class='lparen'>(</span><span class='label'>armour:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Leather</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>hp:</span> <span class='int'>95</span><span class='rparen'>)</span>
303
+ </code></pre>
304
+
305
+ <pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_hp'>hp</span> <span class='comment'># =&gt; 95
306
+ </span><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_to_h'>to_h</span> <span class='comment'># =&gt; {armour: &#39;Leather&#39;, hp: 95}
307
+ </span></code></pre>
308
+
309
+ <h3 id="deleting-components">Deleting Components</h3>
310
+
311
+ <p>Deleting a Component is the same convention as deleting an Entity. When a Component is deleted referenced to it such as to entities are automatically cleared.</p>
312
+
313
+ <pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span>
314
+ </code></pre>
315
+
316
+ <h3 id="accessing-components-attached-entities">Accessing Components&#39; attached Entities</h3>
317
+
318
+ <p>Components also keep track of what Entities are using it. To access this list we do the following:</p>
319
+
320
+ <pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_entities'>entities</span> <span class='comment'># =&gt; [@entity1, @entity2, @entity3]
321
+ </span>
322
+ <span class='comment'># get the first entity attached.
323
+ </span><span class='comment'># this will throw a warning if there is more or less then
324
+ </span><span class='comment'># exactly one entity
325
+ </span><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_entity'>entity</span> <span class='comment'># =&gt; @entity
326
+ </span></code></pre>
327
+
328
+ <h2 id="systems">Systems</h2>
329
+
330
+ <h3 id="creation">Creation</h3>
331
+
332
+ <p>We can create Systems like so:</p>
333
+
334
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Systems.html" title="FelECS::Systems (class)">Systems</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelECS/Systems.html#initialize-instance_method" title="FelECS::Systems#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Render</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>2</span><span class='rparen'>)</span> <span class='kw'>do</span>
335
+ <span class='comment'># Code and Logic
336
+ </span><span class='kw'>end</span>
337
+ </code></pre>
338
+
339
+ <p>The name we assign is how we can access the System, like so:</p>
340
+
341
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Systems.html" title="FelECS::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span>
342
+ </code></pre>
343
+
344
+ <p>Priority determines the order Systems should be executed, this is used for <code>Scenes</code> and the <code>Stage</code>.
345
+ The lower the number, the earlier a given System will be executed.
346
+ E.g priority 1 will go first, priority 2 will go second, etcetera. </p>
347
+
348
+ <p>Both Scenes and Systems have a priority. System priority will decide the order it will be called inside of a Scene, which the Scene priority will decide the order it will be called inside of the Stage.</p>
349
+
350
+ <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>
351
+
352
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Systems.html" title="FelECS::Systems (class)">Systems</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelECS/Systems.html#initialize-instance_method" title="FelECS::Systems#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Render</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>2</span><span class='rparen'>)</span> <span class='kw'>do</span>
353
+ <span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Components.html" title="FelECS::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>
354
+ <span class='comment'># do something with these components
355
+ </span> <span class='kw'>end</span>
356
+ <span class='kw'>end</span>
357
+ </code></pre>
358
+
359
+ <h3 id="execution">Execution</h3>
360
+
361
+ <p>After we create a System, it won&#39;t do anything on its own until we tell it to. Here is how:</p>
362
+
363
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Systems.html" title="FelECS::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>
364
+ </code></pre>
365
+
366
+ <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>
367
+
368
+ <h3 id="alternative-execution">Alternative Execution</h3>
369
+
370
+ <p>Sometimes you want a System to automatically trigger when a special even happens. FelECS 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>
371
+
372
+ <pre class="code ruby"><code class="ruby"><span class='comment'># When this Component is added to an Entity, this System will be called
373
+ </span><span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Systems.html" title="FelECS::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>
374
+
375
+ <span class='comment'># When this Component is removed from an Entity, this System will be called
376
+ </span><span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Systems.html" title="FelECS::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>
377
+
378
+ <span class='comment'># When this Component&#39;s health attribute is changed, this System will be called
379
+ </span><span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Systems.html" title="FelECS::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_changed'>trigger_when_is_changed</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span>
380
+ </code></pre>
381
+
382
+ <p>If we want these triggers to happen for all Components that belong to specific Component Manager then we can do that instead:</p>
383
+
384
+ <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
385
+ </span><span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Systems.html" title="FelECS::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>
386
+
387
+ <span class='comment'># When a Component from this Component Manager is removed from an Entity, this System will be called
388
+ </span><span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Systems.html" title="FelECS::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>
389
+
390
+ <span class='comment'># When this Component&#39;s health attribute from this Component Manager is changed, this System will be called
391
+ </span><span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Systems.html" title="FelECS::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_changed'>trigger_when_is_changed</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span>
392
+ </code></pre>
393
+
394
+ <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>
395
+
396
+ <h3 id="clearing-alternative-executions">Clearing Alternative Executions</h3>
397
+
398
+ <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>
399
+
400
+ <pre class="code ruby"><code class="ruby"><span class='comment'># clears ALL triggers with this system
401
+ </span><span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Systems.html" title="FelECS::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>
402
+
403
+ <span class='comment'># clears ALL triggers with this Component Manager
404
+ </span><span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Systems.html" title="FelECS::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>
405
+
406
+ <span class='comment'># clear the &#39;trigger_when_added&#39; for this Component
407
+ </span><span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Systems.html" title="FelECS::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>
408
+
409
+ <span class='comment'># clear the &#39;trigger_when_removed&#39; for this Component
410
+ </span><span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Systems.html" title="FelECS::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>
411
+
412
+ <span class='comment'># clear the &#39;trigger_when_is_changed&#39; for this Component specifically for the health attribute
413
+ </span><span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Systems.html" title="FelECS::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>
414
+ </code></pre>
415
+
416
+ <p>Likewise we can do the same with Component Managers:</p>
417
+
418
+ <pre class="code ruby"><code class="ruby"><span class='comment'># clears ALL triggers with this Component
419
+ </span><span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Systems.html" title="FelECS::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>
420
+
421
+ <span class='comment'># clear the &#39;trigger_when_added&#39; for this Component Manager
422
+ </span><span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Systems.html" title="FelECS::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>
423
+
424
+ <span class='comment'># clear the &#39;trigger_when_removed&#39; for this Component Manager
425
+ </span><span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Systems.html" title="FelECS::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>
426
+
427
+ <span class='comment'># clear the &#39;trigger_when_is_changed&#39; for this Component Manager specifically for the health attribute
428
+ </span><span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Systems.html" title="FelECS::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>
429
+ </code></pre>
430
+
431
+ <h3 id="redefinition">Redefinition</h3>
432
+
433
+ <p>If we wanted to change what code or logic a given System executes, we could do that with:</p>
434
+
435
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Systems.html" title="FelECS::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>
436
+ <span class='comment'># Some new logic or code
437
+ </span><span class='kw'>end</span>
438
+ </code></pre>
439
+
440
+ <h2 id="scenes">Scenes</h2>
441
+
442
+ <h3 id="creation">Creation</h3>
443
+
444
+ <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>
445
+
446
+ <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="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Scenes.html" title="FelECS::Scenes (class)">Scenes</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelECS/Scenes.html#initialize-instance_method" title="FelECS::Scenes#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>ExampleScene</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>5</span><span class='rparen'>)</span>
447
+ </code></pre>
448
+
449
+ <h3 id="accessing">Accessing</h3>
450
+
451
+ <p>Just like other classes in FelECS, the name we gave the Scene is how we access it:</p>
452
+
453
+ <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="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Scenes.html" title="FelECS::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span>
454
+ </code></pre>
455
+
456
+ <h3 id="adding-systems">Adding Systems</h3>
457
+
458
+ <p>Adding Systems is simple. We can add as many as we want. In this example we add 3 different systems:</p>
459
+
460
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Scenes.html" title="FelECS::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>
461
+ <span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Systems.html" title="FelECS::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='comma'>,</span>
462
+ <span class='ivar'>@system2</span><span class='comma'>,</span>
463
+ <span class='ivar'>@system3</span>
464
+ <span class='rparen'>)</span>
465
+ </code></pre>
466
+
467
+ <h3 id="removing-systems">Removing Systems</h3>
468
+
469
+ <p>Removing Systems works similarly:</p>
470
+
471
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Scenes.html" title="FelECS::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>
472
+ <span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Systems.html" title="FelECS::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='comma'>,</span>
473
+ <span class='ivar'>@system2</span><span class='comma'>,</span>
474
+ <span class='ivar'>@system3</span>
475
+ <span class='rparen'>)</span>
476
+ </code></pre>
477
+
478
+ <h3 id="clearing">Clearing</h3>
479
+
480
+ <p>If you want to remove all Systems from a Scene here is how we do it:</p>
481
+
482
+ <pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</span><span class='period'>.</span><span class='id identifier rubyid_clear'>clear</span>
483
+ </code></pre>
484
+
485
+ <h3 id="execution">Execution</h3>
486
+
487
+ <p>To execute all Systems within a scene once we can just do:</p>
488
+
489
+ <pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span>
490
+ </code></pre>
491
+
492
+ <p>The Scene will make sure that the systems are executed in the correct order based on their given priorities</p>
493
+
494
+ <h2 id="stage">Stage</h2>
495
+
496
+ <h3 id="adding-scenes">Adding Scenes</h3>
497
+
498
+ <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 &#39;active&#39;. To add a Scene we do the following:</p>
499
+
500
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Stage.html" title="FelECS::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_add'><span class='object_link'><a href="FelECS/Stage.html#add-class_method" title="FelECS::Stage.add (method)">add</a></span></span> <span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'>Scene</span><span class='op'>::</span><span class='const'>ExampleScene</span>
501
+ </code></pre>
502
+
503
+ <h3 id="removing-scenes">Removing Scenes</h3>
504
+
505
+ <p>Likewise we can remove Scenes:</p>
506
+
507
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Stage.html" title="FelECS::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_remove'><span class='object_link'><a href="FelECS/Stage.html#remove-class_method" title="FelECS::Stage.remove (method)">remove</a></span></span> <span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'>Scene</span><span class='op'>::</span><span class='const'>ExampleScene</span>
508
+ </code></pre>
509
+
510
+ <h3 id="executing">Executing</h3>
511
+
512
+ <p>On each frame of the game generally we will want to execute the Stage once. When the Stage is executed it is progressing your game 1 frame forward. The Stage will call all Scenes you added to it in the order of their priority. Here is how we do it:</p>
513
+
514
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Stage.html" title="FelECS::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_call'><span class='object_link'><a href="FelECS/Stage.html#call-class_method" title="FelECS::Stage.call (method)">call</a></span></span>
515
+ </code></pre>
516
+
517
+ <h2 id="order">Order</h2>
518
+
519
+ <h3 id="setting-the-order">Setting the order</h3>
520
+
521
+ <p>To set the order you just need to call <code>FelECS::Order.sort</code> and pass Scenes or Systems in the parameters in the order you wish for them to execute</p>
522
+
523
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Order.html" title="FelECS::Order (module)">Order</a></span></span><span class='period'>.</span><span class='id identifier rubyid_sort'><span class='object_link'><a href="FelECS/Order.html#sort-class_method" title="FelECS::Order.sort (method)">sort</a></span></span><span class='lparen'>(</span>
524
+ <span class='ivar'>@system1</span><span class='comma'>,</span>
525
+ <span class='ivar'>@system2</span><span class='comma'>,</span>
526
+ <span class='ivar'>@system3</span>
527
+ <span class='rparen'>)</span>
528
+ </code></pre>
529
+
530
+ <p>If you want some Scenes or Systems to have the same priority then just pass them as an array:</p>
531
+
532
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelECS.html" title="FelECS (module)">FelECS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelECS/Order.html" title="FelECS::Order (module)">Order</a></span></span><span class='period'>.</span><span class='id identifier rubyid_sort'><span class='object_link'><a href="FelECS/Order.html#sort-class_method" title="FelECS::Order.sort (method)">sort</a></span></span><span class='lparen'>(</span>
533
+ <span class='ivar'>@scene1</span><span class='comma'>,</span>
534
+ <span class='lbracket'>[</span><span class='ivar'>@scene2_1</span><span class='comma'>,</span> <span class='ivar'>@scene2_2</span><span class='rbracket'>]</span><span class='comma'>,</span>
535
+ <span class='ivar'>@scene3</span>
536
+ <span class='rparen'>)</span>
537
+ </code></pre>
538
+
539
+ <h2 id="closing-notes">Closing Notes</h2>
540
+
541
+ <p>There are some methods I haven&#39;t gone over in the overview. If you want to see everything and read in more detail check out the <a href="https://felflame.tradam.fyi">Documentation</a>!</p>
542
+
543
+ <h1 id="contribution">Contribution</h1>
544
+
545
+ <p>Contributors are welcome! I am always looking to impove the capabilities of game development in Ruby. Feel free to open an issue to discuss a proposed changed or fix. To code a change or fix first fork the project. Next write your changes or fixes. Make sure all your changes and fixes are properly documented using Yard(I will not merge if it is not 100% documented) and make sure everything has tests written for it with Rspec(I will also not merge if it does not have 100% test coverage). Once you have your changes made then simply make a pull request. </p>
546
+
547
+ <p>If you need help writing documentation or tests feel free to ask! </p>
548
+
549
+ <p>If you want to contribute to development with a thanks you can always <a href="https://ko-fi.com/tradam">buy me a coffee ;^)</a></p>
550
+ </div></div>
551
+
552
+ <div id="footer">
553
+ Generated on Wed Feb 2 03:29:07 2022 by
554
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
555
+ 0.9.26 (ruby-2.7.3).
556
+ </div>
557
+
558
+ </div>
559
+ </body>
560
+ </html>