felflame 1.0.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.mdown +32 -1
- data/Gemfile.lock +4 -4
- data/README.mdown +18 -0
- data/docs/_index.html +1 -80
- data/docs/class_list.html +1 -1
- data/docs/file.README.html +64 -40
- data/docs/index.html +64 -40
- data/docs/method_list.html +0 -424
- data/docs/top-level-namespace.html +1 -38
- data/lib/felflame/component_manager.rb +3 -2
- data/lib/felflame/entity_manager.rb +10 -11
- data/lib/felflame/version.rb +1 -1
- metadata +2 -3
- data/.yardopts +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfa6e4dcd216470a760e24fdff4ead4f355bd553682aa5d1c9acb0ac1f247ffd
|
4
|
+
data.tar.gz: 0c1690196c0147de8eb6f8e59916e201f56edbdfb307ba2836badadddd43e44d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 466ea6522c0c29072626e92f24a7825a9e3d443d83de51f60e2d2fd3c60d1b435627b0f37680f56f8084f8e0be6d380b5c27d038ccb97be605e9daf69ad23595
|
7
|
+
data.tar.gz: '098b2ead6ca3ff0050cee1101cdb4360f5cb28908d0f345db3584aff02bdf0360bfe7d171f22a0ce39637955055ebf4ab914aa59673a7d2e6eedde25d575fe44'
|
data/CHANGELOG.mdown
CHANGED
@@ -8,11 +8,42 @@
|
|
8
8
|
![Deprecated](https://img.shields.io/badge/-Deprecated-orange)
|
9
9
|
![Removed](https://img.shields.io/badge/-Removed-red)
|
10
10
|
|
11
|
+
## [2.0.0](https://github.com/realtradam/FelFlame/releases/tag/2.0.0) - 2021-07-10
|
12
|
+
![Changed](https://img.shields.io/badge/-Changed-yellow)
|
13
|
+
- Entities and Components now reference each other using the objects themselves rather then their id's
|
14
|
+
```ruby
|
15
|
+
# before:
|
16
|
+
@entity.components[@component_manager].each do |component_id|
|
17
|
+
# iterate over id's, usually would need to do a lookup to get the component itself
|
18
|
+
end
|
19
|
+
|
20
|
+
# after:
|
21
|
+
@entity.components[@component_manager].each do |component|
|
22
|
+
# iterate over the components themselves! No need for lookup anymore
|
23
|
+
end
|
24
|
+
```
|
25
|
+
```ruby
|
26
|
+
# same for components referencing entities
|
27
|
+
# before:
|
28
|
+
@component.entities.each do |entity_id|
|
29
|
+
#iterate over id's
|
30
|
+
end
|
31
|
+
|
32
|
+
# after:
|
33
|
+
@component.entities.each do |entity|
|
34
|
+
# directly iterate over entities themselves!
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
|
39
|
+
## [1.0.2](https://github.com/realtradam/FelFlame/releases/tag/1.0.2) - 2021-07-09
|
40
|
+
![Fixed](https://img.shields.io/badge/-Fixed-blue)
|
41
|
+
- Stripped superflous files shrinking gem size significantly
|
42
|
+
|
11
43
|
## [1.0.1](https://github.com/realtradam/FelFlame/releases/tag/1.0.1) - 2021-07-09
|
12
44
|
![Fixed](https://img.shields.io/badge/-Fixed-blue)
|
13
45
|
- Defining attributes in components are no longer allowed to overwrite methods
|
14
46
|
|
15
47
|
## [1.0.0](https://github.com/realtradam/FelFlame/releases/tag/1.0.0) - 2021-07-09
|
16
|
-
|
17
48
|
![Added](https://img.shields.io/badge/-Added-brightgreen)
|
18
49
|
- Initial release
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
felflame (
|
4
|
+
felflame (2.0.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -18,10 +18,10 @@ GEM
|
|
18
18
|
minitest (>= 5.0)
|
19
19
|
ruby-progressbar
|
20
20
|
parallel (1.20.1)
|
21
|
-
parser (3.0.
|
21
|
+
parser (3.0.2.0)
|
22
22
|
ast (~> 2.4.1)
|
23
23
|
rainbow (3.0.0)
|
24
|
-
rake (13.0.
|
24
|
+
rake (13.0.6)
|
25
25
|
redcarpet (3.5.1)
|
26
26
|
regexp_parser (2.1.1)
|
27
27
|
rexml (3.2.5)
|
@@ -38,7 +38,7 @@ GEM
|
|
38
38
|
diff-lcs (>= 1.2.0, < 2.0)
|
39
39
|
rspec-support (~> 3.10.0)
|
40
40
|
rspec-support (3.10.2)
|
41
|
-
rubocop (1.
|
41
|
+
rubocop (1.18.3)
|
42
42
|
parallel (~> 1.10)
|
43
43
|
parser (>= 3.0.0.0)
|
44
44
|
rainbow (>= 2.2.2, < 4.0)
|
data/README.mdown
CHANGED
@@ -26,6 +26,7 @@
|
|
26
26
|
- [Accessing](#accessing)
|
27
27
|
- [Get ID](#get-id)
|
28
28
|
- [Adding and Removing Components](#adding-and-removing-components)
|
29
|
+
- [Accessing Entities' Attached Components](#accessing-entities-attached-components)
|
29
30
|
- [Deletion](#deletion)
|
30
31
|
* [Components](#components-1)
|
31
32
|
- [Creating a Component Manager](#creating-a-component-manager)
|
@@ -34,6 +35,7 @@
|
|
34
35
|
- [Accessing Attributes and Changing Them](#accessing-attributes-and-changing-them)
|
35
36
|
- [Deleting Components](#deleting-components)
|
36
37
|
- [Iterating over Components](#iterating-over-components)
|
38
|
+
- [Accessing Components' attached Entities](#accessing-components-attached-entities)
|
37
39
|
* [Systems](#systems-1)
|
38
40
|
- [Creation](#creation-1)
|
39
41
|
- [Execution](#execution)
|
@@ -142,6 +144,13 @@ We can still add or remove Components from an Entity after it has been created.
|
|
142
144
|
@entity.remove @component
|
143
145
|
```
|
144
146
|
|
147
|
+
### Accessing Entities' Attached Components
|
148
|
+
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:
|
149
|
+
|
150
|
+
```ruby
|
151
|
+
@entity.components[@component_manager] # => [@component1, @component2, component3]
|
152
|
+
```
|
153
|
+
|
145
154
|
### Deletion
|
146
155
|
To have all Components from an Entity removed and the Entity deleted we do the following:
|
147
156
|
|
@@ -210,12 +219,21 @@ Deleting a Component is the same format as deleting an Entity. When a Component
|
|
210
219
|
|
211
220
|
### Iterating over Components
|
212
221
|
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:
|
222
|
+
|
213
223
|
```ruby
|
214
224
|
FelFlame::Components::Sprites.each do |component|
|
215
225
|
#do something with components
|
216
226
|
end
|
217
227
|
```
|
218
228
|
|
229
|
+
### Accessing Components' attached Entities
|
230
|
+
Components also keep track of what Entities are using it. To access this list we do the following:
|
231
|
+
|
232
|
+
```ruby
|
233
|
+
@component.entities # => [@entity1, @entity2, @entity3]
|
234
|
+
```
|
235
|
+
|
236
|
+
|
219
237
|
## Systems
|
220
238
|
|
221
239
|
### Creation
|
data/docs/_index.html
CHANGED
@@ -75,85 +75,6 @@
|
|
75
75
|
<tr>
|
76
76
|
<td valign='top' width="33%">
|
77
77
|
|
78
|
-
|
79
|
-
<ul id="alpha_C" class="alpha">
|
80
|
-
<li class="letter">C</li>
|
81
|
-
<ul>
|
82
|
-
|
83
|
-
<li>
|
84
|
-
<span class='object_link'><a href="FelFlame/ComponentManager.html" title="FelFlame::ComponentManager (class)">ComponentManager</a></span>
|
85
|
-
|
86
|
-
<small>(FelFlame)</small>
|
87
|
-
|
88
|
-
</li>
|
89
|
-
|
90
|
-
<li>
|
91
|
-
<span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (class)">Components</a></span>
|
92
|
-
|
93
|
-
<small>(FelFlame)</small>
|
94
|
-
|
95
|
-
</li>
|
96
|
-
|
97
|
-
</ul>
|
98
|
-
</ul>
|
99
|
-
|
100
|
-
|
101
|
-
<ul id="alpha_E" class="alpha">
|
102
|
-
<li class="letter">E</li>
|
103
|
-
<ul>
|
104
|
-
|
105
|
-
<li>
|
106
|
-
<span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span>
|
107
|
-
|
108
|
-
<small>(FelFlame)</small>
|
109
|
-
|
110
|
-
</li>
|
111
|
-
|
112
|
-
</ul>
|
113
|
-
</ul>
|
114
|
-
|
115
|
-
|
116
|
-
<ul id="alpha_F" class="alpha">
|
117
|
-
<li class="letter">F</li>
|
118
|
-
<ul>
|
119
|
-
|
120
|
-
<li>
|
121
|
-
<span class='object_link'><a href="FelFlame.html" title="FelFlame (class)">FelFlame</a></span>
|
122
|
-
|
123
|
-
</li>
|
124
|
-
|
125
|
-
</ul>
|
126
|
-
</ul>
|
127
|
-
|
128
|
-
|
129
|
-
<ul id="alpha_S" class="alpha">
|
130
|
-
<li class="letter">S</li>
|
131
|
-
<ul>
|
132
|
-
|
133
|
-
<li>
|
134
|
-
<span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span>
|
135
|
-
|
136
|
-
<small>(FelFlame)</small>
|
137
|
-
|
138
|
-
</li>
|
139
|
-
|
140
|
-
<li>
|
141
|
-
<span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (class)">Stage</a></span>
|
142
|
-
|
143
|
-
<small>(FelFlame)</small>
|
144
|
-
|
145
|
-
</li>
|
146
|
-
|
147
|
-
<li>
|
148
|
-
<span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span>
|
149
|
-
|
150
|
-
<small>(FelFlame)</small>
|
151
|
-
|
152
|
-
</li>
|
153
|
-
|
154
|
-
</ul>
|
155
|
-
</ul>
|
156
|
-
|
157
78
|
</td>
|
158
79
|
</tr>
|
159
80
|
</table>
|
@@ -163,7 +84,7 @@
|
|
163
84
|
</div>
|
164
85
|
|
165
86
|
<div id="footer">
|
166
|
-
Generated on
|
87
|
+
Generated on Sat Jul 10 03:06:03 2021 by
|
167
88
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
168
89
|
0.9.26 (ruby-2.7.3).
|
169
90
|
</div>
|
data/docs/class_list.html
CHANGED
@@ -43,7 +43,7 @@
|
|
43
43
|
|
44
44
|
<ul id="full_list" class="class">
|
45
45
|
<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>
|
46
|
-
|
46
|
+
|
47
47
|
|
48
48
|
</ul>
|
49
49
|
</div>
|
data/docs/file.README.html
CHANGED
@@ -65,6 +65,10 @@
|
|
65
65
|
<a href="https://github.com/realtradam/FelFlame/blob/master/LICENSE"><img src="https://img.shields.io/github/license/realtradam/FelFlame?label=license&style=flat" alt="MIT License"></a>
|
66
66
|
<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>
|
67
67
|
|
68
|
+
<p><strong><a href="https://felflame.tradam.fyi/">Check out the comprehensive documentation here!</a></strong></p>
|
69
|
+
|
70
|
+
<hr>
|
71
|
+
|
68
72
|
<!-- vim-markdown-toc GFM -->
|
69
73
|
|
70
74
|
<ul>
|
@@ -85,6 +89,7 @@
|
|
85
89
|
<li><a href="#accessing">Accessing</a></li>
|
86
90
|
<li><a href="#get-id">Get ID</a></li>
|
87
91
|
<li><a href="#adding-and-removing-components">Adding and Removing Components</a></li>
|
92
|
+
<li><a href="#accessing-entities-attached-components">Accessing Entities' Attached Components</a></li>
|
88
93
|
<li><a href="#deletion">Deletion</a></li>
|
89
94
|
</ul></li>
|
90
95
|
<li><a href="#components-1">Components</a>
|
@@ -96,6 +101,7 @@
|
|
96
101
|
<li><a href="#accessing-attributes-and-changing-them">Accessing Attributes and Changing Them</a></li>
|
97
102
|
<li><a href="#deleting-components">Deleting Components</a></li>
|
98
103
|
<li><a href="#iterating-over-components">Iterating over Components</a></li>
|
104
|
+
<li><a href="#accessing-components-attached-entities">Accessing Components' attached Entities</a></li>
|
99
105
|
</ul></li>
|
100
106
|
<li><a href="#systems-1">Systems</a>
|
101
107
|
|
@@ -181,27 +187,31 @@ ECS stands for Entity, Component, and System.</p>
|
|
181
187
|
|
182
188
|
<h1 id="usage">Usage</h1>
|
183
189
|
|
190
|
+
<p>To use FelFlame simply install the gem using <code>gem install felflame</code> or using bundler <code>bundle add felflame</code> and then require it in your project like so: <code>require 'felflame'</code>. Working outside of the gem for rendering engines that do not support the usage of gems is a planned feature in the works.</p>
|
191
|
+
|
184
192
|
<h2 id="entities">Entities</h2>
|
185
193
|
|
186
194
|
<h3 id="creation">Creation</h3>
|
187
195
|
|
188
196
|
<p>Entities are essentially "objects" in the game world. To create a new Entity we do the following:</p>
|
189
197
|
|
190
|
-
<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'
|
198
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Entities</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
191
199
|
</code></pre>
|
192
200
|
|
193
201
|
<p>or if we want to add (any number of)components to it:</p>
|
194
202
|
|
195
|
-
<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'
|
196
|
-
|
197
|
-
|
203
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'>FelFlame</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>
|
204
|
+
<span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Components</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>
|
205
|
+
<span class='ivar'>@component</span><span class='comma'>,</span>
|
206
|
+
<span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Components</span><span class='op'>::</span><span class='const'>Armour</span><span class='lbracket'>[</span><span class='int'>7</span><span class='rbracket'>]</span>
|
207
|
+
<span class='rparen'>)</span>
|
198
208
|
</code></pre>
|
199
209
|
|
200
210
|
<h3 id="accessing">Accessing</h3>
|
201
211
|
|
202
212
|
<p>Once components are created we can access them using their ID like so:</p>
|
203
213
|
|
204
|
-
<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'
|
214
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Entities</span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span>
|
205
215
|
</code></pre>
|
206
216
|
|
207
217
|
<h3 id="get-id">Get ID</h3>
|
@@ -220,6 +230,13 @@ entity where a new entity will claim that ID. To get the ID of an Entity:</p>
|
|
220
230
|
<span class='ivar'>@entity</span><span class='period'>.</span><span class='id identifier rubyid_remove'>remove</span> <span class='ivar'>@component</span>
|
221
231
|
</code></pre>
|
222
232
|
|
233
|
+
<h3 id="accessing-entities-attached-components">Accessing Entities' Attached Components</h3>
|
234
|
+
|
235
|
+
<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>
|
236
|
+
|
237
|
+
<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'># => [@component1, @component2, component3]
|
238
|
+
</span></code></pre>
|
239
|
+
|
223
240
|
<h3 id="deletion">Deletion</h3>
|
224
241
|
|
225
242
|
<p>To have all Components from an Entity removed and the Entity deleted we do the following:</p>
|
@@ -234,7 +251,7 @@ entity where a new entity will claim that ID. To get the ID of an Entity:</p>
|
|
234
251
|
<p>Components are where all the data is stored. The data is stored in variables or accessors in each component.
|
235
252
|
These accessors and their defaults are configured when a component manager is created, like so:</p>
|
236
253
|
|
237
|
-
<pre class="code ruby"><code class="ruby"><span class='ivar'>@component_manager</span> <span class='op'>=</span> <span class='const'
|
254
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@component_manager</span> <span class='op'>=</span> <span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Components</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'>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>
|
238
255
|
</code></pre>
|
239
256
|
|
240
257
|
<p>In this example we created a component manager called "Stats".
|
@@ -248,12 +265,12 @@ When defining attributes symbols should be used.</p>
|
|
248
265
|
|
249
266
|
<p>Now that we have a component manager we can make components from it like so:</p>
|
250
267
|
|
251
|
-
<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'
|
268
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Components</span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
252
269
|
</code></pre>
|
253
270
|
|
254
271
|
<p>Or we can even change the defaults:</p>
|
255
272
|
|
256
|
-
<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'
|
273
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Components</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>
|
257
274
|
</code></pre>
|
258
275
|
|
259
276
|
<h3 id="accessing-and-getting-id">Accessing and Getting ID</h3>
|
@@ -262,7 +279,7 @@ When defining attributes symbols should be used.</p>
|
|
262
279
|
These IDs are only unique within the scope of their respective Component Managers.
|
263
280
|
Here is how we can get the ID, as well as how to access a Component from its Component Manager.</p>
|
264
281
|
|
265
|
-
<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'
|
282
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Components</span><span class='op'>::</span><span class='const'>Stats</span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span>
|
266
283
|
<span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span> <span class='comment'># => 2
|
267
284
|
</span></code></pre>
|
268
285
|
|
@@ -290,25 +307,32 @@ Here are the ways to edit attrubutes, followed by the ways to read them.</p>
|
|
290
307
|
|
291
308
|
<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>
|
292
309
|
|
293
|
-
<pre class="code ruby"><code class="ruby"><span class='const'
|
310
|
+
<pre class="code ruby"><code class="ruby"><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Components</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>
|
294
311
|
<span class='comment'>#do something with components
|
295
312
|
</span><span class='kw'>end</span>
|
296
313
|
</code></pre>
|
297
314
|
|
315
|
+
<h3 id="accessing-components-attached-entities">Accessing Components' attached Entities</h3>
|
316
|
+
|
317
|
+
<p>Components also keep track of what Entities are using it. To access this list we do the following:</p>
|
318
|
+
|
319
|
+
<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'># => [@entity1, @entity2, @entity3]
|
320
|
+
</span></code></pre>
|
321
|
+
|
298
322
|
<h2 id="systems">Systems</h2>
|
299
323
|
|
300
324
|
<h3 id="creation">Creation</h3>
|
301
325
|
|
302
326
|
<p>We can create Systems like so:</p>
|
303
327
|
|
304
|
-
<pre class="code ruby"><code class="ruby"><span class='const'
|
328
|
+
<pre class="code ruby"><code class="ruby"><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Systems</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='label'>name:</span> <span class='tstring'><span class='tstring_beg'>'</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>
|
305
329
|
<span class='comment'># Code and Logic
|
306
330
|
</span><span class='kw'>end</span>
|
307
331
|
</code></pre>
|
308
332
|
|
309
333
|
<p>The name we assign is how we can access the System, like so:</p>
|
310
334
|
|
311
|
-
<pre class="code ruby"><code class="ruby"><span class='const'
|
335
|
+
<pre class="code ruby"><code class="ruby"><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Systems</span><span class='op'>::</span><span class='const'>Render</span>
|
312
336
|
</code></pre>
|
313
337
|
|
314
338
|
<p>Priority determines the order Systems should be executed, this is used for <code>Scenes</code> and the <code>Stage</code>.
|
@@ -317,8 +341,8 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p>
|
|
317
341
|
|
318
342
|
<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>
|
319
343
|
|
320
|
-
<pre class="code ruby"><code class="ruby"><span class='const'
|
321
|
-
<span class='const'
|
344
|
+
<pre class="code ruby"><code class="ruby"><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Systems</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='label'>name:</span> <span class='tstring'><span class='tstring_beg'>'</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>
|
345
|
+
<span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Components</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>
|
322
346
|
<span class='comment'># do something with these components
|
323
347
|
</span> <span class='kw'>end</span>
|
324
348
|
<span class='kw'>end</span>
|
@@ -328,7 +352,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p>
|
|
328
352
|
|
329
353
|
<p>After we create a System, it won't do anything on its own until we tell it to. Here is how:</p>
|
330
354
|
|
331
|
-
<pre class="code ruby"><code class="ruby"><span class='const'
|
355
|
+
<pre class="code ruby"><code class="ruby"><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Systems</span><span class='op'>::</span><span class='const'>Render</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span>
|
332
356
|
</code></pre>
|
333
357
|
|
334
358
|
<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>
|
@@ -338,25 +362,25 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p>
|
|
338
362
|
<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>
|
339
363
|
|
340
364
|
<pre class="code ruby"><code class="ruby"><span class='comment'># When this Component is added to an Entity, this System will be called
|
341
|
-
</span><span class='const'
|
365
|
+
</span><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Systems</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>
|
342
366
|
|
343
367
|
<span class='comment'># When this Component is removed from an Entity, this System will be called
|
344
|
-
</span><span class='const'
|
368
|
+
</span><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Systems</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>
|
345
369
|
|
346
370
|
<span class='comment'># When this Component's health attribute is changed, this System will be called
|
347
|
-
</span><span class='const'
|
371
|
+
</span><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Systems</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>
|
348
372
|
</code></pre>
|
349
373
|
|
350
374
|
<p>If we want these triggers to happen for all Components that belong to specific Component Manager then we can do that instead:</p>
|
351
375
|
|
352
376
|
<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
|
353
|
-
</span><span class='const'
|
377
|
+
</span><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Systems</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>
|
354
378
|
|
355
379
|
<span class='comment'># When a Component from this Component Manager is removed from an Entity, this System will be called
|
356
|
-
</span><span class='const'
|
380
|
+
</span><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Systems</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>
|
357
381
|
|
358
382
|
<span class='comment'># When this Component's health attribute from this Component Manager is changed, this System will be called
|
359
|
-
</span><span class='const'
|
383
|
+
</span><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Systems</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>
|
360
384
|
</code></pre>
|
361
385
|
|
362
386
|
<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>
|
@@ -366,41 +390,41 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p>
|
|
366
390
|
<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>
|
367
391
|
|
368
392
|
<pre class="code ruby"><code class="ruby"><span class='comment'># clears ALL triggers with this system
|
369
|
-
</span><span class='const'
|
393
|
+
</span><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Systems</span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span>
|
370
394
|
|
371
395
|
<span class='comment'># clears ALL triggers with this Component Manager
|
372
|
-
</span><span class='const'
|
396
|
+
</span><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Systems</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>
|
373
397
|
|
374
398
|
<span class='comment'># clear the 'trigger_when_added' for this Component
|
375
|
-
</span><span class='const'
|
399
|
+
</span><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Systems</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>
|
376
400
|
|
377
401
|
<span class='comment'># clear the 'trigger_when_removed' for this Component
|
378
|
-
</span><span class='const'
|
402
|
+
</span><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Systems</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>
|
379
403
|
|
380
404
|
<span class='comment'># clear the 'trigger_when_is_set' for this Component specifically for the health attribute
|
381
|
-
</span><span class='const'
|
405
|
+
</span><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Systems</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>
|
382
406
|
</code></pre>
|
383
407
|
|
384
408
|
<p>Likewise we can do the same with Component Managers:</p>
|
385
409
|
|
386
410
|
<pre class="code ruby"><code class="ruby"><span class='comment'># clears ALL triggers with this Component
|
387
|
-
</span><span class='const'
|
411
|
+
</span><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Systems</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>
|
388
412
|
|
389
413
|
<span class='comment'># clear the 'trigger_when_added' for this Component Manager
|
390
|
-
</span><span class='const'
|
414
|
+
</span><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Systems</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>
|
391
415
|
|
392
416
|
<span class='comment'># clear the 'trigger_when_removed' for this Component Manager
|
393
|
-
</span><span class='const'
|
417
|
+
</span><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Systems</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>
|
394
418
|
|
395
419
|
<span class='comment'># clear the 'trigger_when_is_set' for this Component Manager specifically for the health attribute
|
396
|
-
</span><span class='const'
|
420
|
+
</span><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Systems</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>
|
397
421
|
</code></pre>
|
398
422
|
|
399
423
|
<h3 id="redefinition">Redefinition</h3>
|
400
424
|
|
401
425
|
<p>If we wanted to change what code or logic a given System executes, we could do that with:</p>
|
402
426
|
|
403
|
-
<pre class="code ruby"><code class="ruby"><span class='const'
|
427
|
+
<pre class="code ruby"><code class="ruby"><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Systems</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>
|
404
428
|
<span class='comment'># Some new logic or code
|
405
429
|
</span><span class='kw'>end</span>
|
406
430
|
</code></pre>
|
@@ -411,28 +435,28 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p>
|
|
411
435
|
|
412
436
|
<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>
|
413
437
|
|
414
|
-
<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</span> <span class='op'>=</span> <span class='const'
|
438
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</span> <span class='op'>=</span> <span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Scenes</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'>ExampleScene</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
415
439
|
</code></pre>
|
416
440
|
|
417
441
|
<h3 id="accessing">Accessing</h3>
|
418
442
|
|
419
443
|
<p>Just like other classes in FelFlame, the name we gave the Scene is how we access it:</p>
|
420
444
|
|
421
|
-
<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</span> <span class='op'>=</span> <span class='const'
|
445
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</span> <span class='op'>=</span> <span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Scenes</span><span class='op'>::</span><span class='const'>ExampleScene</span>
|
422
446
|
</code></pre>
|
423
447
|
|
424
448
|
<h3 id="adding-systems">Adding Systems</h3>
|
425
449
|
|
426
450
|
<p>Adding Systems is simple. We can add as many as we want. In this example we add 3 different systems:</p>
|
427
451
|
|
428
|
-
<pre class="code ruby"><code class="ruby"><span class='const'
|
452
|
+
<pre class="code ruby"><code class="ruby"><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Scenes</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'>FelFlame</span><span class='op'>::</span><span class='const'>Systems</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>
|
429
453
|
</code></pre>
|
430
454
|
|
431
455
|
<h3 id="removing-systems">Removing Systems</h3>
|
432
456
|
|
433
457
|
<p>Removing Systems works simularly:</p>
|
434
458
|
|
435
|
-
<pre class="code ruby"><code class="ruby"><span class='const'
|
459
|
+
<pre class="code ruby"><code class="ruby"><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Scenes</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'>FelFlame</span><span class='op'>::</span><span class='const'>Systems</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>
|
436
460
|
</code></pre>
|
437
461
|
|
438
462
|
<h3 id="clearing">Clearing</h3>
|
@@ -457,26 +481,26 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p>
|
|
457
481
|
|
458
482
|
<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>
|
459
483
|
|
460
|
-
<pre class="code ruby"><code class="ruby"><span class='const'
|
484
|
+
<pre class="code ruby"><code class="ruby"><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Stage</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span> <span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Scene</span><span class='op'>::</span><span class='const'>ExampleScene</span>
|
461
485
|
</code></pre>
|
462
486
|
|
463
487
|
<h3 id="removing-scenes">Removing Scenes</h3>
|
464
488
|
|
465
489
|
<p>Likewise we can remove Scenes:</p>
|
466
490
|
|
467
|
-
<pre class="code ruby"><code class="ruby"><span class='const'
|
491
|
+
<pre class="code ruby"><code class="ruby"><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Stage</span><span class='period'>.</span><span class='id identifier rubyid_remove'>remove</span> <span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Scene</span><span class='op'>::</span><span class='const'>ExampleScene</span>
|
468
492
|
</code></pre>
|
469
493
|
|
470
494
|
<h3 id="executing">Executing</h3>
|
471
495
|
|
472
496
|
<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>
|
473
497
|
|
474
|
-
<pre class="code ruby"><code class="ruby"><span class='const'
|
498
|
+
<pre class="code ruby"><code class="ruby"><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'>Stage</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span>
|
475
499
|
</code></pre>
|
476
500
|
|
477
501
|
<h2 id="closing-notes">Closing Notes</h2>
|
478
502
|
|
479
|
-
<p>There are some methods I haven't gone over in the overview. If you want to see everything and read in more detail check out the <a href="https://
|
503
|
+
<p>There are some methods I haven'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>
|
480
504
|
|
481
505
|
<h1 id="contribution">Contribution</h1>
|
482
506
|
|
@@ -488,7 +512,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p>
|
|
488
512
|
</div></div>
|
489
513
|
|
490
514
|
<div id="footer">
|
491
|
-
Generated on
|
515
|
+
Generated on Sat Jul 10 03:06:03 2021 by
|
492
516
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
493
517
|
0.9.26 (ruby-2.7.3).
|
494
518
|
</div>
|