diff options
| author | realtradam <[email protected]> | 2022-01-20 22:41:04 -0500 |
|---|---|---|
| committer | realtradam <[email protected]> | 2022-01-20 22:41:04 -0500 |
| commit | 9ae334ecc6aaef009f14c0bb8b57afcb721f709b (patch) | |
| tree | d1d41747a0a4fcde281919933ce59757a4b5e7ce | |
| parent | f003a1acc5dac70b267685701a3b130773310e0b (diff) | |
| download | FelECS-9ae334ecc6aaef009f14c0bb8b57afcb721f709b.tar.gz FelECS-9ae334ecc6aaef009f14c0bb8b57afcb721f709b.zip | |
rename to FelECS
| -rw-r--r-- | Gemfile.lock | 4 | ||||
| -rw-r--r-- | README.mdown | 487 | ||||
| -rw-r--r-- | docs/_index.html | 101 | ||||
| -rw-r--r-- | docs/class_list.html | 2 | ||||
| -rw-r--r-- | docs/file.README.html | 540 | ||||
| -rw-r--r-- | docs/index.html | 540 | ||||
| -rw-r--r-- | docs/method_list.html | 368 | ||||
| -rw-r--r-- | docs/top-level-namespace.html | 39 | ||||
| -rw-r--r-- | felecs.gemspec (renamed from felflame.gemspec) | 6 | ||||
| -rw-r--r-- | lib/felecs.rb (renamed from lib/felflame.rb) | 58 | ||||
| -rw-r--r-- | lib/felecs/component_manager.rb (renamed from lib/felflame/component_manager.rb) | 42 | ||||
| -rw-r--r-- | lib/felecs/entity_manager.rb (renamed from lib/felflame/entity_manager.rb) | 12 | ||||
| -rw-r--r-- | lib/felecs/order.rb (renamed from lib/felflame/order.rb) | 2 | ||||
| -rw-r--r-- | lib/felecs/scene_manager.rb (renamed from lib/felflame/scene_manager.rb) | 8 | ||||
| -rw-r--r-- | lib/felecs/stage_manager.rb (renamed from lib/felflame/stage_manager.rb) | 4 | ||||
| -rw-r--r-- | lib/felecs/system_manager.rb (renamed from lib/felflame/system_manager.rb) | 74 | ||||
| -rw-r--r-- | lib/felecs/version.rb (renamed from lib/felflame/version.rb) | 4 | ||||
| -rw-r--r-- | logos/felecs-logo-text.png (renamed from logos/felecs-logo-text.png.png) | bin | 44520 -> 44520 bytes | |||
| -rw-r--r-- | spec/component_manager_spec.rb | 52 | ||||
| -rw-r--r-- | spec/entity_manager_spec.rb | 38 | ||||
| -rw-r--r-- | spec/order_spec.rb | 18 | ||||
| -rw-r--r-- | spec/scene_manager_spec.rb | 14 | ||||
| -rw-r--r-- | spec/stage_manager_spec.rb | 40 | ||||
| -rw-r--r-- | spec/system_manager_spec.rb | 74 |
24 files changed, 1156 insertions, 1371 deletions
diff --git a/Gemfile.lock b/Gemfile.lock index 7b5b5fe..5ce0ad2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - felflame (4.0.0) + felecs (5.0.0) GEM remote: https://rubygems.org/ @@ -69,7 +69,7 @@ PLATFORMS ruby DEPENDENCIES - felflame! + felecs! minitest-reporters (~> 1.4, >= 1.4.3) rake (~> 13.0) redcarpet (~> 3.5, >= 3.5.1) diff --git a/README.mdown b/README.mdown index acae578..8cc18d9 100644 --- a/README.mdown +++ b/README.mdown @@ -1,10 +1,10 @@ - -<!--  --> + +<!--  --> -[](https://codeclimate.com/github/realtradam/FelFlame/maintainability) -[](https://codeclimate.com/github/realtradam/FelFlame/test_coverage) -[](http://inch-ci.org/github/realtradam/FelFlame) -[](https://github.com/realtradam/FelFlame/blob/master/LICENSE) +[](https://codeclimate.com/github/realtradam/FelECS/maintainability) +[](https://codeclimate.com/github/realtradam/FelECS/test_coverage) +[](http://inch-ci.org/github/realtradam/FelECS) +[](https://github.com/realtradam/FelECS/blob/master/LICENSE) [](https://ko-fi.com/tradam) **[Check out the comprehensive documentation here!](https://felflame.tradam.fyi/)** @@ -13,7 +13,7 @@ <!-- vim-markdown-toc GFM --> -* [What is FelFlame?](#what-is-felflame) +* [What is FelECS?](#what-is-felecs) * [What is ECS?](#what-is-ecs) * [Components](#components) * [Entities](#entities) @@ -35,12 +35,33 @@ * [Accessing Attributes and Changing Them](#accessing-attributes-and-changing-them) * [Deleting Components](#deleting-components) * [Accessing Components' attached Entities](#accessing-components-attached-entities) +* [get the first entity attached.](#get-the-first-entity-attached) +* [this will throw a warning if there is more or less then](#this-will-throw-a-warning-if-there-is-more-or-less-then) +* [exactly one entity](#exactly-one-entity) * [Systems](#systems-1) * [Creation](#creation-1) +* [Code and Logic](#code-and-logic) +* [do something with these components](#do-something-with-these-components) * [Execution](#execution) * [Alternative Execution](#alternative-execution) +* [When this Component is added to an Entity, this System will be called](#when-this-component-is-added-to-an-entity-this-system-will-be-called) +* [When this Component is removed from an Entity, this System will be called](#when-this-component-is-removed-from-an-entity-this-system-will-be-called) +* [When this Component's health attribute is changed, this System will be called](#when-this-components-health-attribute-is-changed-this-system-will-be-called) +* [When a Component from this Component Manager is added to an Entity, this System will be called](#when-a-component-from-this-component-manager-is-added-to-an-entity-this-system-will-be-called) +* [When a Component from this Component Manager is removed from an Entity, this System will be called](#when-a-component-from-this-component-manager-is-removed-from-an-entity-this-system-will-be-called) +* [When this Component's health attribute from this Component Manager is changed, this System will be called](#when-this-components-health-attribute-from-this-component-manager-is-changed-this-system-will-be-called) * [Clearing Alternative Executions](#clearing-alternative-executions) +* [clears ALL triggers with this system](#clears-all-triggers-with-this-system) +* [clears ALL triggers with this Component Manager](#clears-all-triggers-with-this-component-manager) +* [clear the 'trigger_when_added' for this Component](#clear-the-trigger_when_added-for-this-component) +* [clear the 'trigger_when_removed' for this Component](#clear-the-trigger_when_removed-for-this-component) +* [clear the 'trigger_when_is_set' for this Component specifically for the health attribute](#clear-the-trigger_when_is_set-for-this-component-specifically-for-the-health-attribute) +* [clears ALL triggers with this Component](#clears-all-triggers-with-this-component) +* [clear the 'trigger_when_added' for this Component Manager](#clear-the-trigger_when_added-for-this-component-manager) +* [clear the 'trigger_when_removed' for this Component Manager](#clear-the-trigger_when_removed-for-this-component-manager) +* [clear the 'trigger_when_is_set' for this Component Manager specifically for the health attribute](#clear-the-trigger_when_is_set-for-this-component-manager-specifically-for-the-health-attribute) * [Redefinition](#redefinition) +* [Some new logic or code](#some-new-logic-or-code) * [Scenes](#scenes-1) * [Creation](#creation-2) * [Accessing](#accessing-2) @@ -59,407 +80,407 @@ <!-- vim-markdown-toc --> -# What is FelFlame? +# What is FelECS? -FelFlame is an ECS framework for developing games in the Ruby language. FelFlame has been designed from the ground up with these three ideas in mind: + 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: -1. **Engine Agnostic:** FelFlame has been designed to be rendering engine agnostic as long as the target rendering engine is written in Ruby. This means that this framework can be dropped into existing rendering engines such as [Ruby2D](http://www.ruby2d.com) or [DRGTK](https://dragonruby.org/toolkit/game) with little modifications. -2. **Easily Extensible:** FelFlame has been designed such that extensions to its capabilities can be easily added. Extensions such as rendering engine wrappers, premade systems, premade components, etcetera can be easily coded and then distributed as gems. -3. **Principle of (My) Least Astonishment:** I want to develop games using a language and framework I love and makes sense to me, inspired by the [Philosophy of the creator of Ruby](https://en.wikipedia.org/wiki/Ruby_(programming_language)#Philosophy). + 1. **Engine Agnostic:** 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 [Ruby2D](http://www.ruby2d.com) or [DRGTK](https://dragonruby.org/toolkit/game) with little modifications. + 2. **Easily Extensible:** 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. + 3. **Principle of (My) Least Astonishment:** I want to develop games using a language and framework I love and makes sense to me, inspired by the [Philosophy of the creator of Ruby](https://en.wikipedia.org/wiki/Ruby_(programming_language)#Philosophy). # What is ECS? -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. -ECS stands for Entity, Component, and System. + 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. + ECS stands for Entity, Component, and System. ---- + --- ### Components -This is where the data or information of a given "object" is stored. There is no logic or code here. + This is where the data or information of a given "object" is stored. There is no logic or code here. ### Entities -Entities will contain one or more Components, but contains no logic or data otherwise + Entities will contain one or more Components, but contains no logic or data otherwise ### Systems -Systems are where all the logic or code is kept. There is no data stored in here. + Systems are where all the logic or code is kept. There is no data stored in here. ---- + --- -By using this pattern it allows programmers to easily control what an "object" 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. + By using this pattern it allows programmers to easily control what an "object" 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. -**"But your framework also has `Scenes`, `Stage`, and `Order`, what is that about?"** + **"But your framework also has `Scenes`, `Stage`, and `Order`, what is that about?"** ---- + --- ### Scenes -Scenes are simply a collection or subset of Systems. This allows for an easy way to activate and deactivate Systems. + Scenes are simply a collection or subset of Systems. This allows for an easy way to activate and deactivate Systems. ### Stage -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. + 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. ### Order -Order is a helper class which can set the priority of Scenes and Systems. + Order is a helper class which can set the priority of Scenes and Systems. ---- + --- # Usage -There are 2 ways of using FelFlame. You can either `include` it as a gem in your project if your game engine supports this. The other option is to download the single file export of FelFlame and then `require_relative` 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. + There are 2 ways of using FelECS. You can either `include` 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 `require_relative` 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. -To use the gem method you can do the following: install the gem using `gem install felflame` or using bundler `bundle add felflame` and then require it in your project like so: `require 'felflame'`. + To use the gem method you can do the following: install the gem using `gem install felflame` or using bundler `bundle add felflame` and then require it in your project like so: `require 'felflame'`. -To use the single file export method you simply download the felflame.rb file from the [releases page on Github](https://github.com/realtradam/FelFlame/releases) and add it to your source folder and add a `require relative 'felflame.rb'` line or wherever you have placed the file to use it. + To use the single file export method you simply download the felflame.rb file from the [releases page on Github](https://github.com/realtradam/FelECS/releases) and add it to your source folder and add a `require relative 'felflame.rb'` line or wherever you have placed the file to use it. ## Entities ### Creation -Entities are essentially "objects" in the game world. To create a new Entity we do the following: + Entities are essentially "objects" in the game world. To create a new Entity we do the following: -```ruby -@entity = FelFlame::Entities.new -``` -or if we want to add (any number of)components to it when creating it: + ```ruby + @entity = FelECS::Entities.new + ``` + or if we want to add (any number of)components to it when creating it: -```ruby -@entity = FelFlame::Entites.new( - FelFlame::Components::Health.new, - @component, - FelFlame::Components::EnemyTeam.first -) -``` + ```ruby +@entity = FelECS::Entites.new( + FelECS::Components::Health.new, + @component, + FelECS::Components::EnemyTeam.first + ) + ``` ### Accessing -Oftentimes you will not be accessing an Entity this way. Later we will shows you a more common way of accessing entities. -If you need to you can access Entities using the `Entities` module: + Oftentimes you will not be accessing an Entity this way. Later we will shows you a more common way of accessing entities. + If you need to you can access Entities using the `Entities` module: -```ruby -@entity = FelFlame::Entities[2] -@entity = FelFlame::Entities.first -@entity = FelFlame::Entities.each # you can iterate over all entities this way. Any valid array method can be used -``` + ```ruby + @entity = FelECS::Entities[2] + @entity = FelECS::Entities.first + @entity = FelECS::Entities.each # you can iterate over all entities this way. Any valid array method can be used + ``` ### Adding and Removing Components -We can still add or remove Components from an Entity after it has been created. Here is how: + We can still add or remove Components from an Entity after it has been created. Here is how: -```ruby [email protected] @component [email protected] @component -``` + ```ruby + @entity.add @component + @entity.remove @component + ``` ### Accessing Entities' Attached Components -This is the most common way of accessing an Entity + This is the most common way of accessing an Entity -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: + 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: -```ruby [email protected][@component_manager] # => [@component1, @component2, @component3] -``` + ```ruby + @entity.components[@component_manager] # => [@component1, @component2, @component3] + ``` ### Deletion -To have all Components from an Entity **removed** and the Entity deleted we do the following: + To have all Components from an Entity **removed** and the Entity deleted we do the following: -NOTE: The components will **not be deleted**. They are simply **removed** 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. + NOTE: The components will **not be deleted**. They are simply **removed** 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. -```ruby -``` + ```ruby + @entity.delete + ``` ## Components ### Creating a Component Manager -Components are where all the data is stored. The data is stored in variables or accessors in each component. -These accessors and their defaults are configured when a component manager is created, like so: + Components are where all the data is stored. The data is stored in variables or accessors in each component. + These accessors and their defaults are configured when a component manager is created, like so: -```ruby -@component_manager = FelFlame::Components.new('Stats', :armour, hp: 100) -``` + ```ruby + @component_manager = FelECS::Components.new('Stats', :armour, hp: 100) + ``` -In this example we created a component manager called "Stats". -The name given to component managers must follow the same rules for naming constants in ruby for a reason you will shortly see. -The parameters following are all creating the attributes we can set. -We can set any number of parameters we wish, in this example we define two. -The `:armour` parameter is being created without a default, it will equal to `nil` when a new component is created, while `hp` will be equal to 100 when a component is created. -When defining attributes symbols should be used. + In this example we created a component manager called "Stats". + The name given to component managers must follow the same rules for naming constants in ruby for a reason you will shortly see. + The parameters following are all creating the attributes we can set. + We can set any number of parameters we wish, in this example we define two. + The `:armour` parameter is being created without a default, it will equal to `nil` when a new component is created, while `hp` will be equal to 100 when a component is created. + When defining attributes symbols should be used. ### Creating a Component from a Component Manager -Now that we have a component manager we can make components from it like so: + Now that we have a component manager we can make components from it like so: -```ruby -@component = FelFlame::Components::Stats.new -``` + ```ruby + @component = FelECS::Components::Stats.new + ``` -Or we can even override the defaults when creating the component: + Or we can even override the defaults when creating the component: -```ruby -@component = FelFlame::Components::Stats.new(armour: 'steel') -``` + ```ruby + @component = FelECS::Components::Stats.new(armour: 'steel') + ``` ### Accessing -You can access components using any array method. + You can access components using any array method. -```ruby -@component = FelFlame::Components::Stats[2] -@component = FelFlame::Components::Stats.first -@component = FelFlame::Components::Stats.each # you can use iterators this way -``` + ```ruby + @component = FelECS::Components::Stats[2] + @component = FelECS::Components::Stats.first + @component = FelECS::Components::Stats.each # you can use iterators this way + ``` ### Accessing Attributes and Changing Them -There are a few different ways we can read or change the attributes of a component depending on what our needs are. -Here are the ways to edit attrubutes, followed by the ways to read them. -```ruby [email protected] = 'Mythril' [email protected]_attrs(armour: 'Leather', hp: 95) -``` -```ruby [email protected] # => 95 [email protected]_h # => {armour: 'Leather', hp: 95} -``` + There are a few different ways we can read or change the attributes of a component depending on what our needs are. + Here are the ways to edit attrubutes, followed by the ways to read them. + ```ruby + @component.armour = 'Mythril' + @component.update_attrs(armour: 'Leather', hp: 95) + ``` + ```ruby + @component.hp # => 95 + @component.to_h # => {armour: 'Leather', hp: 95} + ``` ### Deleting Components -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. + 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. -```ruby -``` + ```ruby + @component.delete + ``` ### Accessing Components' attached Entities -Components also keep track of what Entities are using it. To access this list we do the following: + Components also keep track of what Entities are using it. To access this list we do the following: -```ruby [email protected] # => [@entity1, @entity2, @entity3] + ```ruby + @component.entities # => [@entity1, @entity2, @entity3] # get the first entity attached. # this will throw a warning if there is more or less then # exactly one entity [email protected] # => @entity -``` + @component.entity # => @entity + ``` ## Systems ### Creation -We can create Systems like so: + We can create Systems like so: -```ruby -FelFlame::Systems.new('Render', priority: 2) do - # Code and Logic -end -``` + ```ruby + FelECS::Systems.new('Render', priority: 2) do +# Code and Logic + end + ``` -The name we assign is how we can access the System, like so: + The name we assign is how we can access the System, like so: -```ruby -FelFlame::Systems::Render -``` -Priority determines the order Systems should be executed, this is used for `Scenes` and the `Stage`. -The lower the number, the earlier a given System will be executed. -E.g priority 1 will go first, priority 2 will go second, etcetera. + ```ruby + FelECS::Systems::Render + ``` + Priority determines the order Systems should be executed, this is used for `Scenes` and the `Stage`. + The lower the number, the earlier a given System will be executed. + E.g priority 1 will go first, priority 2 will go second, etcetera. -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. + 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. -Often we will want to execute some logic on each Component in a given Component Manager so our code might look like this: + Often we will want to execute some logic on each Component in a given Component Manager so our code might look like this: -```ruby -FelFlame::Systems.new('Render', priority: 2) do - FelFlame::Components::Sprites.each do |component| - # do something with these components - end -end -``` + ```ruby + FelECS::Systems.new('Render', priority: 2) do + FelECS::Components::Sprites.each do |component| +# do something with these components + end + end + ``` ### Execution -After we create a System, it won't do anything on its own until we tell it to. Here is how: + After we create a System, it won't do anything on its own until we tell it to. Here is how: -```ruby -FelFlame::Systems::Render.call -``` + ```ruby + FelECS::Systems::Render.call + ``` -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. + 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. ### Alternative Execution -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: + 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: -```ruby + ```ruby # When this Component is added to an Entity, this System will be called -FelFlame::Systems::PassiveRegen.trigger_when_added(@component) +FelECS::Systems::PassiveRegen.trigger_when_added(@component) # When this Component is removed from an Entity, this System will be called -FelFlame::Systems::PassiveRegen.trigger_when_removed(@component) +FelECS::Systems::PassiveRegen.trigger_when_removed(@component) # When this Component's health attribute is changed, this System will be called -FelFlame::Systems::PassiveRegen.trigger_when_is_set(@component, :health) -``` +FelECS::Systems::PassiveRegen.trigger_when_is_set(@component, :health) + ``` -If we want these triggers to happen for all Components that belong to specific Component Manager then we can do that instead: + If we want these triggers to happen for all Components that belong to specific Component Manager then we can do that instead: -```ruby + ```ruby # When a Component from this Component Manager is added to an Entity, this System will be called -FelFlame::Systems::PassiveRegen.trigger_when_added(@component_manager) +FelECS::Systems::PassiveRegen.trigger_when_added(@component_manager) # When a Component from this Component Manager is removed from an Entity, this System will be called -FelFlame::Systems::PassiveRegen.trigger_when_removed(@component_manager) +FelECS::Systems::PassiveRegen.trigger_when_removed(@component_manager) # When this Component's health attribute from this Component Manager is changed, this System will be called -FelFlame::Systems::PassiveRegen.trigger_when_is_set(@component_manager, :health) -``` +FelECS::Systems::PassiveRegen.trigger_when_is_set(@component_manager, :health) + ``` -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 + 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 ### Clearing Alternative Executions -If we wish to remove these links that we created, we can do that using the follwing function in any of the following ways: + If we wish to remove these links that we created, we can do that using the follwing function in any of the following ways: -```ruby + ```ruby # clears ALL triggers with this system -FelFlame::Systems::PassiveRegen.clear_triggers + FelECS::Systems::PassiveRegen.clear_triggers # clears ALL triggers with this Component Manager -FelFlame::Systems::PassiveRegen.clear_triggers(@component) +FelECS::Systems::PassiveRegen.clear_triggers(@component) # clear the 'trigger_when_added' for this Component -FelFlame::Systems::PassiveRegen.clear_triggers(@component, :added) +FelECS::Systems::PassiveRegen.clear_triggers(@component, :added) # clear the 'trigger_when_removed' for this Component -FelFlame::Systems::PassiveRegen.clear_triggers(@component, :removed) +FelECS::Systems::PassiveRegen.clear_triggers(@component, :removed) # clear the 'trigger_when_is_set' for this Component specifically for the health attribute -FelFlame::Systems::PassiveRegen.clear_triggers(@component, :is_set, :health) -``` +FelECS::Systems::PassiveRegen.clear_triggers(@component, :is_set, :health) + ``` -Likewise we can do the same with Component Managers: + Likewise we can do the same with Component Managers: -```ruby + ```ruby # clears ALL triggers with this Component -FelFlame::Systems::PassiveRegen.clear_triggers(@component_manager) +FelECS::Systems::PassiveRegen.clear_triggers(@component_manager) # clear the 'trigger_when_added' for this Component Manager -FelFlame::Systems::PassiveRegen.clear_triggers(@component_manager, :added) +FelECS::Systems::PassiveRegen.clear_triggers(@component_manager, :added) # clear the 'trigger_when_removed' for this Component Manager -FelFlame::Systems::PassiveRegen.clear_triggers(@component_manager, :removed) +FelECS::Systems::PassiveRegen.clear_triggers(@component_manager, :removed) # clear the 'trigger_when_is_set' for this Component Manager specifically for the health attribute -FelFlame::Systems::PassiveRegen.clear_triggers(@component_manager, :is_set, :health) -``` +FelECS::Systems::PassiveRegen.clear_triggers(@component_manager, :is_set, :health) + ``` ### Redefinition -If we wanted to change what code or logic a given System executes, we could do that with: + If we wanted to change what code or logic a given System executes, we could do that with: -```ruby -FelFlame::Systems::PassiveRegen.redefine do - # Some new logic or code -end -``` + ```ruby + FelECS::Systems::PassiveRegen.redefine do +# Some new logic or code + end + ``` ## Scenes ### Creation -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 [Alternative Executions](#alternative-execution) will occur even if they are not part of a Scene. Here is how we make a new Scene: + 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 [Alternative Executions](#alternative-execution) will occur even if they are not part of a Scene. Here is how we make a new Scene: -```ruby -@scene = FelFlame::Scenes.new('ExampleScene', priority: 5) -``` + ```ruby + @scene = FelECS::Scenes.new('ExampleScene', priority: 5) + ``` ### Accessing -Just like other classes in FelFlame, the name we gave the Scene is how we access it: + Just like other classes in FelECS, the name we gave the Scene is how we access it: -```ruby -@scene = FelFlame::Scenes::ExampleScene -``` + ```ruby + @scene = FelECS::Scenes::ExampleScene + ``` ### Adding Systems -Adding Systems is simple. We can add as many as we want. In this example we add 3 different systems: + Adding Systems is simple. We can add as many as we want. In this example we add 3 different systems: -```ruby -FelFlame::Scenes::ExampleScene.add( - FelFlame::Systems::Render, - @system2, - @system3 -) -``` + ```ruby +FelECS::Scenes::ExampleScene.add( + FelECS::Systems::Render, + @system2, + @system3 + ) + ``` ### Removing Systems -Removing Systems works similarly: + Removing Systems works similarly: -```ruby -FelFlame::Scenes::ExampleScene.remove( - FelFlame::Systems::Render, - @system2, - @system3 -) -``` + ```ruby +FelECS::Scenes::ExampleScene.remove( + FelECS::Systems::Render, + @system2, + @system3 + ) + ``` ### Clearing -If you want to remove all Systems from a Scene here is how we do it: + If you want to remove all Systems from a Scene here is how we do it: -```ruby -``` + ```ruby + @scene.clear + ``` ### Execution -To execute all Systems within a scene once we can just do: + To execute all Systems within a scene once we can just do: -```ruby -``` + ```ruby + @scene.call + ``` -The Scene will make sure that the systems are executed in the correct order based on their given priorities + The Scene will make sure that the systems are executed in the correct order based on their given priorities ## Stage ### Adding Scenes -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: + 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: -```ruby -FelFlame::Stage.add FelFlame::Scene::ExampleScene -``` + ```ruby + FelECS::Stage.add FelECS::Scene::ExampleScene + ``` ### Removing Scenes -Likewise we can remove Scenes: + Likewise we can remove Scenes: -```ruby -FelFlame::Stage.remove FelFlame::Scene::ExampleScene -``` + ```ruby + FelECS::Stage.remove FelECS::Scene::ExampleScene + ``` ### Executing -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: + 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: -```ruby -FelFlame::Stage.call -``` + ```ruby + FelECS::Stage.call + ``` ## Order ### Setting the order -To set the order you just need to call `FelFlame::Order.sort` and pass Scenes or Systems in the parameters in the order you wish for them to execute + To set the order you just need to call `FelECS::Order.sort` and pass Scenes or Systems in the parameters in the order you wish for them to execute -```ruby -FelFlame::Order.sort( - @system1, - @system2, - @system3 -) -``` + ```ruby +FelECS::Order.sort( + @system1, + @system2, + @system3 + ) + ``` -If you want some Scenes or Systems to have the same priority then just pass them as an array: + If you want some Scenes or Systems to have the same priority then just pass them as an array: -```ruby -FelFlame::Order.sort( - @scene1, - [@scene2_1, @scene2_2], - @scene3 -) -``` + ```ruby +FelECS::Order.sort( + @scene1, + [@scene2_1, @scene2_2], + @scene3 + ) + ``` ## Closing Notes -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 [Documentation](https://felflame.tradam.fyi)! + 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 [Documentation](https://felflame.tradam.fyi)! # Contribution -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. + 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. -If you need help writing documentation or tests feel free to ask! + If you need help writing documentation or tests feel free to ask! -If you want to contribute to development with a thanks you can always [buy me a coffee ;^)](https://ko-fi.com/tradam) + If you want to contribute to development with a thanks you can always [buy me a coffee ;^)](https://ko-fi.com/tradam) diff --git a/docs/_index.html b/docs/_index.html index 3a4b9fb..f850b17 100644 --- a/docs/_index.html +++ b/docs/_index.html @@ -75,105 +75,6 @@ <tr> <td valign='top' width="33%"> - - <ul id="alpha_C" class="alpha"> - <li class="letter">C</li> - <ul> - - <li> - <span class='object_link'><a href="FelFlame/ComponentManager.html" title="FelFlame::ComponentManager (class)">ComponentManager</a></span> - - <small>(FelFlame)</small> - - </li> - - <li> - <span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span> - - <small>(FelFlame)</small> - - </li> - - </ul> - </ul> - - - <ul id="alpha_E" class="alpha"> - <li class="letter">E</li> - <ul> - - <li> - <span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span> - - <small>(FelFlame)</small> - - </li> - - </ul> - </ul> - - - <ul id="alpha_F" class="alpha"> - <li class="letter">F</li> - <ul> - - <li> - <span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span> - - </li> - - <li> - <span class='object_link'><a href="Felflame_.html" title="Felflame (module)">Felflame</a></span> - - </li> - - </ul> - </ul> - - - <ul id="alpha_O" class="alpha"> - <li class="letter">O</li> - <ul> - - <li> - <span class='object_link'><a href="FelFlame/Order.html" title="FelFlame::Order (module)">Order</a></span> - - <small>(FelFlame)</small> - - </li> - - </ul> - </ul> - - - <ul id="alpha_S" class="alpha"> - <li class="letter">S</li> - <ul> - - <li> - <span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span> - - <small>(FelFlame)</small> - - </li> - - <li> - <span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span> - - <small>(FelFlame)</small> - - </li> - - <li> - <span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span> - - <small>(FelFlame)</small> - - </li> - - </ul> - </ul> - </td> </tr> </table> @@ -183,7 +84,7 @@ </div> <div id="footer"> - Generated on Mon Jan 3 08:23:03 2022 by + Generated on Thu Jan 20 22:40:31 2022 by <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.26 (ruby-2.7.3). </div> diff --git a/docs/class_list.html b/docs/class_list.html index 8275577..3f4c240 100644 --- a/docs/class_list.html +++ b/docs/class_list.html @@ -43,7 +43,7 @@ <ul id="full_list" class="class"> <li id="object_" class="odd"><div class="item" style="padding-left:30px"><span class='object_link'><a href="top-level-namespace.html" title="Top Level Namespace (root)">Top Level Namespace</a></span></div></li> -<li id='object_FelFlame' class='even'><div class='item' style='padding-left:30px'><a class='toggle'></a> <span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span><small class='search_info'>Top Level Namespace</small></div><ul><li id='object_FelFlame::ComponentManager' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/ComponentManager.html" title="FelFlame::ComponentManager (class)">ComponentManager</a></span> < Object<small class='search_info'>FelFlame</small></div></li><li id='object_FelFlame::Components' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span><small class='search_info'>FelFlame</small></div></li><li id='object_FelFlame::Entities' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span> < Object<small class='search_info'>FelFlame</small></div></li><li id='object_FelFlame::Order' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/Order.html" title="FelFlame::Order (module)">Order</a></span><small class='search_info'>FelFlame</small></div></li><li id='object_FelFlame::Scenes' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span> < Object<small class='search_info'>FelFlame</small></div></li><li id='object_FelFlame::Stage' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span><small class='search_info'>FelFlame</small></div></li><li id='object_FelFlame::Systems' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span> < Object<small class='search_info'>FelFlame</small></div></li></ul></li><li id='object_Felflame' class='even'><div class='item' style='padding-left:30px'><span class='object_link'><a href="Felflame_.html" title="Felflame (module)">Felflame</a></span><small class='search_info'>Top Level Namespace</small></div></li> + </ul> </div> diff --git a/docs/file.README.html b/docs/file.README.html index f62e0db..fbe3543 100644 --- a/docs/file.README.html +++ b/docs/file.README.html @@ -57,14 +57,14 @@ <div class="clear"></div> </div> - <div id="content"><div id='filecontents'><p><img src="https://raw.githubusercontent.com/realtradam/FelFlame/master/logos/felflame-logo-text.png" alt="FelFlame"></p> + <div id="content"><div id='filecontents'><p><img src="https://raw.githubusercontent.com/realtradam/FelECS/master/logos/felecs-logo-text.png" alt="FelECS"></p> -<!--  --> +<!--  --> -<p><a href="https://codeclimate.com/github/realtradam/FelFlame/maintainability"><img src="https://api.codeclimate.com/v1/badges/56d425d9078e98efb74b/maintainability" alt="Maintainability"></a> -<a href="https://codeclimate.com/github/realtradam/FelFlame/test_coverage"><img src="https://api.codeclimate.com/v1/badges/56d425d9078e98efb74b/test_coverage" alt="Test Coverage"></a> -<a href="http://inch-ci.org/github/realtradam/FelFlame"><img src="http://inch-ci.org/github/realtradam/FelFlame.svg?branch=master" alt="Inline docs"></a> -<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> +<p><a href="https://codeclimate.com/github/realtradam/FelECS/maintainability"><img src="https://api.codeclimate.com/v1/badges/56d425d9078e98efb74b/maintainability" alt="Maintainability"></a> +<a href="https://codeclimate.com/github/realtradam/FelECS/test_coverage"><img src="https://api.codeclimate.com/v1/badges/56d425d9078e98efb74b/test_coverage" alt="Test Coverage"></a> +<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> +<a href="https://github.com/realtradam/FelECS/blob/master/LICENSE"><img src="https://img.shields.io/github/license/realtradam/FelECS?label=license&style=flat" alt="MIT License"></a> <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> <p><strong><a href="https://felflame.tradam.fyi/">Check out the comprehensive documentation here!</a></strong></p> @@ -74,7 +74,7 @@ <!-- vim-markdown-toc GFM --> <ul> -<li><a href="#what-is-felflame">What is FelFlame?</a></li> +<li><a href="#what-is-felecs">What is FelECS?</a></li> <li><a href="#what-is-ecs">What is ECS?</a> * <a href="#components">Components</a> * <a href="#entities">Entities</a> @@ -104,15 +104,42 @@ <li><a href="#deleting-components">Deleting Components</a></li> <li><a href="#accessing-components-attached-entities">Accessing Components' attached Entities</a></li> </ul></li> +</ul></li> +<li><a href="#get-the-first-entity-attached">get the first entity attached.</a></li> +<li><a href="#this-will-throw-a-warning-if-there-is-more-or-less-then">this will throw a warning if there is more or less then</a></li> +<li><a href="#exactly-one-entity">exactly one entity</a> + +<ul> <li><a href="#systems-1">Systems</a> <ul> <li><a href="#creation-1">Creation</a></li> -<li><a href="#execution">Execution</a></li> -<li><a href="#alternative-execution">Alternative Execution</a></li> -<li><a href="#clearing-alternative-executions">Clearing Alternative Executions</a></li> -<li><a href="#redefinition">Redefinition</a></li> </ul></li> +</ul></li> +<li><a href="#code-and-logic">Code and Logic</a></li> +<li><a href="#do-something-with-these-components">do something with these components</a> + * <a href="#execution">Execution</a> + * <a href="#alternative-execution">Alternative Execution</a></li> +<li><a href="#when-this-component-is-added-to-an-entity-this-system-will-be-called">When this Component is added to an Entity, this System will be called</a></li> +<li><a href="#when-this-component-is-removed-from-an-entity-this-system-will-be-called">When this Component is removed from an Entity, this System will be called</a></li> +<li><a href="#when-this-components-health-attribute-is-changed-this-system-will-be-called">When this Component's health attribute is changed, this System will be called</a></li> +<li><a href="#when-a-component-from-this-component-manager-is-added-to-an-entity-this-system-will-be-called">When a Component from this Component Manager is added to an Entity, this System will be called</a></li> +<li><a href="#when-a-component-from-this-component-manager-is-removed-from-an-entity-this-system-will-be-called">When a Component from this Component Manager is removed from an Entity, this System will be called</a></li> +<li><a href="#when-this-components-health-attribute-from-this-component-manager-is-changed-this-system-will-be-called">When this Component's health attribute from this Component Manager is changed, this System will be called</a> + * <a href="#clearing-alternative-executions">Clearing Alternative Executions</a></li> +<li><a href="#clears-all-triggers-with-this-system">clears ALL triggers with this system</a></li> +<li><a href="#clears-all-triggers-with-this-component-manager">clears ALL triggers with this Component Manager</a></li> +<li><a href="#clear-the-trigger_when_added-for-this-component">clear the 'trigger_when_added' for this Component</a></li> +<li><a href="#clear-the-trigger_when_removed-for-this-component">clear the 'trigger_when_removed' for this Component</a></li> +<li><a href="#clear-the-trigger_when_is_set-for-this-component-specifically-for-the-health-attribute">clear the 'trigger_when_is_set' for this Component specifically for the health attribute</a></li> +<li><a href="#clears-all-triggers-with-this-component">clears ALL triggers with this Component</a></li> +<li><a href="#clear-the-trigger_when_added-for-this-component-manager">clear the 'trigger_when_added' for this Component Manager</a></li> +<li><a href="#clear-the-trigger_when_removed-for-this-component-manager">clear the 'trigger_when_removed' for this Component Manager</a></li> +<li><a href="#clear-the-trigger_when_is_set-for-this-component-manager-specifically-for-the-health-attribute">clear the 'trigger_when_is_set' for this Component Manager specifically for the health attribute</a> + * <a href="#redefinition">Redefinition</a></li> +<li><a href="#some-new-logic-or-code">Some new logic or code</a> + +<ul> <li><a href="#scenes-1">Scenes</a> <ul> @@ -142,415 +169,522 @@ <!-- vim-markdown-toc --> -<h1 id="what-is-felflame">What is FelFlame?</h1> +<h1 id="what-is-felecs">What is FelECS?</h1> -<p>FelFlame is an ECS framework for developing games in the Ruby language. FelFlame has been designed from the ground up with these three ideas in mind:</p> +<pre class="code ruby"><code class="ruby">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: -<ol> -<li><strong>Engine Agnostic:</strong> FelFlame has been designed to be rendering engine agnostic as long as the target rendering engine is written in Ruby. This means that this framework can be dropped into existing rendering engines such as <a href="http://www.ruby2d.com">Ruby2D</a> or <a href="https://dragonruby.org/toolkit/game">DRGTK</a> with little modifications.</li> -<li><strong>Easily Extensible:</strong> FelFlame has been designed such that extensions to its capabilities can be easily added. Extensions such as rendering engine wrappers, premade systems, premade components, etcetera can be easily coded and then distributed as gems.</li> -<li><strong>Principle of (My) Least Astonishment:</strong> I want to develop games using a language and framework I love and makes sense to me, inspired by the <a href="https://en.wikipedia.org/wiki/Ruby_(programming_language)#Philosophy">Philosophy of the creator of Ruby</a>.</li> -</ol> +1. **Engine Agnostic:** 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 [Ruby2D](http://www.ruby2d.com) or [DRGTK](https://dragonruby.org/toolkit/game) with little modifications. +2. **Easily Extensible:** 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. +3. **Principle of (My) Least Astonishment:** I want to develop games using a language and framework I love and makes sense to me, inspired by the [Philosophy of the creator of Ruby](https://en.wikipedia.org/wiki/Ruby_(programming_language)#Philosophy). +</code></pre> <h1 id="what-is-ecs">What is ECS?</h1> -<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> -ECS stands for Entity, Component, and System.</p> +<pre class="code ruby"><code class="ruby">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. +ECS stands for Entity, Component, and System. -<hr> +--- +</code></pre> <h3 id="components">Components</h3> -<p>This is where the data or information of a given "object" is stored. There is no logic or code here. </p> +<pre class="code ruby"><code class="ruby">This is where the data or information of a given "object" is stored. There is no logic or code here. +</code></pre> <h3 id="entities">Entities</h3> -<p>Entities will contain one or more Components, but contains no logic or data otherwise</p> +<pre class="code ruby"><code class="ruby">Entities will contain one or more Components, but contains no logic or data otherwise +</code></pre> <h3 id="systems">Systems</h3> -<p>Systems are where all the logic or code is kept. There is no data stored in here.</p> +<pre class="code ruby"><code class="ruby">Systems are where all the logic or code is kept. There is no data stored in here. -<hr> +--- -<p>By using this pattern it allows programmers to easily control what an "object" 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> +By using this pattern it allows programmers to easily control what an "object" 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><strong>"But your framework also has <code>Scenes</code>, <code>Stage</code>, and <code>Order</code>, what is that about?"</strong> </p> +**"But your framework also has `Scenes`, `Stage`, and `Order`, what is that about?"** -<hr> +--- +</code></pre> <h3 id="scenes">Scenes</h3> -<p>Scenes are simply a collection or subset of Systems. This allows for an easy way to activate and deactivate Systems.</p> +<pre class="code ruby"><code class="ruby">Scenes are simply a collection or subset of Systems. This allows for an easy way to activate and deactivate Systems. +</code></pre> <h3 id="stage">Stage</h3> -<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> +<pre class="code ruby"><code class="ruby">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. +</code></pre> <h3 id="order">Order</h3> -<p>Order is a helper class which can set the priority of Scenes and Systems.</p> +<pre class="code ruby"><code class="ruby">Order is a helper class which can set the priority of Scenes and Systems. -<hr> +--- +</code></pre> <h1 id="usage">Usage</h1> -<p>There are 2 ways of using FelFlame. 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 FelFlame 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> +<pre class="code ruby"><code class="ruby">There are 2 ways of using FelECS. You can either `include` 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 `require_relative` 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>To use the gem method you can do the following: 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>.</p> +To use the gem method you can do the following: install the gem using `gem install felflame` or using bundler `bundle add felflame` and then require it in your project like so: `require 'felflame'`. -<p>To use the single file export method you simply download the felflame.rb file from the <a href="https://github.com/realtradam/FelFlame/releases">releases page on Github</a> and add it to your source folder and add a <code>require relative 'felflame.rb'</code> line or wherever you have placed the file to use it.</p> +To use the single file export method you simply download the felflame.rb file from the [releases page on Github](https://github.com/realtradam/FelECS/releases) and add it to your source folder and add a `require relative 'felflame.rb'` line or wherever you have placed the file to use it. +</code></pre> <h2 id="entities">Entities</h2> <h3 id="creation">Creation</h3> -<p>Entities are essentially "objects" in the game world. To create a new Entity we do the following:</p> - -<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Entities.html#initialize-instance_method" title="FelFlame::Entities#initialize (method)">new</a></span></span> -</code></pre> +<pre class="code ruby"><code class="ruby">Entities are essentially "objects" in the game world. To create a new Entity we do the following: -<p>or if we want to add (any number of)components to it when creating it:</p> +```ruby +@entity = FelECS::Entities.new +``` +or if we want to add (any number of)components to it when creating it: -<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'>Entites</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span> - <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Health</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='comma'>,</span> - <span class='ivar'>@component</span><span class='comma'>,</span> - <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>EnemyTeam</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> -<span class='rparen'>)</span> +```ruby </code></pre> +<p>@entity = FelECS::Entites.new( + FelECS::Components::Health.new, + @component, + FelECS::Components::EnemyTeam.first + ) + ```</p> + <h3 id="accessing">Accessing</h3> -<p>Oftentimes you will not be accessing an Entity this way. Later we will shows you a more common way of accessing entities. -If you need to you can access Entities using the <code>Entities</code> module:</p> +<pre class="code ruby"><code class="ruby">Oftentimes you will not be accessing an Entity this way. Later we will shows you a more common way of accessing entities. +If you need to you can access Entities using the `Entities` module: -<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span> -<span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> -<span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='comment'># you can iterate over all entities this way. Any valid array method can be used -</span></code></pre> +```ruby +@entity = FelECS::Entities[2] +@entity = FelECS::Entities.first +@entity = FelECS::Entities.each # you can iterate over all entities this way. Any valid array method can be used +``` +</code></pre> <h3 id="adding-and-removing-components">Adding and Removing Components</h3> -<p>We can still add or remove Components from an Entity after it has been created. Here is how:</p> +<pre class="code ruby"><code class="ruby">We can still add or remove Components from an Entity after it has been created. Here is how: -<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> -<span class='ivar'>@entity</span><span class='period'>.</span><span class='id identifier rubyid_remove'>remove</span> <span class='ivar'>@component</span> +```ruby [email protected] @component [email protected] @component +``` </code></pre> <h3 id="accessing-entities-attached-components">Accessing Entities' Attached Components</h3> -<p>This is the most common way of accessing an Entity</p> +<pre class="code ruby"><code class="ruby">This is the most common way of accessing an Entity -<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> +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: -<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] -</span></code></pre> +```ruby [email protected][@component_manager] # => [@component1, @component2, @component3] +``` +</code></pre> <h3 id="deletion">Deletion</h3> -<p>To have all Components from an Entity <strong>removed</strong> and the Entity deleted we do the following:</p> +<pre class="code ruby"><code class="ruby">To have all Components from an Entity **removed** and the Entity deleted we do the following: -<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> +NOTE: The components will **not be deleted**. They are simply **removed** 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. -<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> +```ruby +``` </code></pre> <h2 id="components">Components</h2> <h3 id="creating-a-component-manager">Creating a Component Manager</h3> -<p>Components are where all the data is stored. The data is stored in variables or accessors in each component. -These accessors and their defaults are configured when a component manager is created, like so:</p> +<pre class="code ruby"><code class="ruby">Components are where all the data is stored. The data is stored in variables or accessors in each component. +These accessors and their defaults are configured when a component manager is created, like so: -<pre class="code ruby"><code class="ruby"><span class='ivar'>@component_manager</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Components.html#new-class_method" title="FelFlame::Components.new (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Stats</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='symbol'>:armour</span><span class='comma'>,</span> <span class='label'>hp:</span> <span class='int'>100</span><span class='rparen'>)</span> -</code></pre> +```ruby +@component_manager = FelECS::Components.new('Stats', :armour, hp: 100) +``` -<p>In this example we created a component manager called "Stats". +In this example we created a component manager called "Stats". The name given to component managers must follow the same rules for naming constants in ruby for a reason you will shortly see. The parameters following are all creating the attributes we can set. We can set any number of parameters we wish, in this example we define two. -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. -When defining attributes symbols should be used.</p> +The `:armour` parameter is being created without a default, it will equal to `nil` when a new component is created, while `hp` will be equal to 100 when a component is created. +When defining attributes symbols should be used. +</code></pre> <h3 id="creating-a-component-from-a-component-manager">Creating a Component from a Component Manager</h3> -<p>Now that we have a component manager we can make components from it like so:</p> +<pre class="code ruby"><code class="ruby">Now that we have a component manager we can make components from it like so: -<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> -</code></pre> +```ruby +@component = FelECS::Components::Stats.new +``` -<p>Or we can even override the defaults when creating the component:</p> +Or we can even override the defaults when creating the component: -<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='label'>armour:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>steel</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> +```ruby +@component = FelECS::Components::Stats.new(armour: 'steel') +``` </code></pre> <h3 id="accessing">Accessing</h3> -<p>You can access components using any array method.</p> +<pre class="code ruby"><code class="ruby">You can access components using any array method. -<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span> -<span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> -<span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='comment'># you can use iterators this way -</span></code></pre> +```ruby +@component = FelECS::Components::Stats[2] +@component = FelECS::Components::Stats.first +@component = FelECS::Components::Stats.each # you can use iterators this way +``` +</code></pre> <h3 id="accessing-attributes-and-changing-them">Accessing Attributes and Changing Them</h3> -<p>There are a few different ways we can read or change the attributes of a component depending on what our needs are. -Here are the ways to edit attrubutes, followed by the ways to read them.</p> - -<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'>'</span><span class='tstring_content'>Mythril</span><span class='tstring_end'>'</span></span> -<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'>'</span><span class='tstring_content'>Leather</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>hp:</span> <span class='int'>95</span><span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby">There are a few different ways we can read or change the attributes of a component depending on what our needs are. +Here are the ways to edit attrubutes, followed by the ways to read them. +```ruby [email protected] = 'Mythril' [email protected]_attrs(armour: 'Leather', hp: 95) +``` +```ruby [email protected] # => 95 [email protected]_h # => {armour: 'Leather', hp: 95} +``` </code></pre> -<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'># => 95 -</span><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_to_h'>to_h</span> <span class='comment'># => {armour: 'Leather', hp: 95} -</span></code></pre> - <h3 id="deleting-components">Deleting Components</h3> -<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> +<pre class="code ruby"><code class="ruby">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. -<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> +```ruby +``` </code></pre> <h3 id="accessing-components-attached-entities">Accessing Components' attached Entities</h3> -<p>Components also keep track of what Entities are using it. To access this list we do the following:</p> +<pre class="code ruby"><code class="ruby">Components also keep track of what Entities are using it. To access this list we do the following: -<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] -</span> -<span class='comment'># get the first entity attached. -</span><span class='comment'># this will throw a warning if there is more or less then -</span><span class='comment'># exactly one entity -</span><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_entity'>entity</span> <span class='comment'># => @entity -</span></code></pre> +```ruby [email protected] # => [@entity1, @entity2, @entity3] +</code></pre> + +<h1 id="get-the-first-entity-attached">get the first entity attached.</h1> + +<h1 id="this-will-throw-a-warning-if-there-is-more-or-less-then">this will throw a warning if there is more or less then</h1> + +<h1 id="exactly-one-entity">exactly one entity</h1> + +<pre class="code ruby"><code class="ruby">@component.entity # => @entity +``` +</code></pre> <h2 id="systems">Systems</h2> <h3 id="creation">Creation</h3> -<p>We can create Systems like so:</p> +<pre class="code ruby"><code class="ruby">We can create Systems like so: -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Systems.html#initialize-instance_method" title="FelFlame::Systems#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Render</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>2</span><span class='rparen'>)</span> <span class='kw'>do</span> - <span class='comment'># Code and Logic -</span><span class='kw'>end</span> +```ruby +FelECS::Systems.new('Render', priority: 2) do </code></pre> -<p>The name we assign is how we can access the System, like so:</p> +<h1 id="code-and-logic">Code and Logic</h1> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span> -</code></pre> +<pre class="code ruby"><code class="ruby">end +``` + +The name we assign is how we can access the System, like so: -<p>Priority determines the order Systems should be executed, this is used for <code>Scenes</code> and the <code>Stage</code>. +```ruby +FelECS::Systems::Render +``` +Priority determines the order Systems should be executed, this is used for `Scenes` and the `Stage`. The lower the number, the earlier a given System will be executed. -E.g priority 1 will go first, priority 2 will go second, etcetera. </p> +E.g priority 1 will go first, priority 2 will go second, etcetera. -<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> +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>Often we will want to execute some logic on each Component in a given Component Manager so our code might look like this:</p> +Often we will want to execute some logic on each Component in a given Component Manager so our code might look like this: -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Systems.html#initialize-instance_method" title="FelFlame::Systems#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Render</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>2</span><span class='rparen'>)</span> <span class='kw'>do</span> - <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Sprites</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_component'>component</span><span class='op'>|</span> - <span class='comment'># do something with these components -</span> <span class='kw'>end</span> -<span class='kw'>end</span> +```ruby +FelECS::Systems.new('Render', priority: 2) do +FelECS::Components::Sprites.each do |component| +</code></pre> + +<h1 id="do-something-with-these-components">do something with these components</h1> + +<pre class="code ruby"><code class="ruby">end +end +``` </code></pre> <h3 id="execution">Execution</h3> -<p>After we create a System, it won't do anything on its own until we tell it to. Here is how:</p> +<pre class="code ruby"><code class="ruby">After we create a System, it won't do anything on its own until we tell it to. Here is how: -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span> -</code></pre> +```ruby +FelECS::Systems::Render.call +``` -<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> +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. +</code></pre> <h3 id="alternative-execution">Alternative Execution</h3> -<p>Sometimes you want a System to automatically trigger when a special even happens. FelFlame can keep track of when a Component is added, removed, or when an attribute is changed and then execute Systems linked to these events. Here is how to create these links:</p> +<pre class="code ruby"><code class="ruby">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: -<pre class="code ruby"><code class="ruby"><span class='comment'># When this Component is added to an Entity, this System will be called -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_added'>trigger_when_added</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='rparen'>)</span> +```ruby +</code></pre> -<span class='comment'># When this Component is removed from an Entity, this System will be called -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_removed'>trigger_when_removed</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='rparen'>)</span> +<h1 id="when-this-component-is-added-to-an-entity-this-system-will-be-called">When this Component is added to an Entity, this System will be called</h1> -<span class='comment'># When this Component's health attribute is changed, this System will be called -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_is_set'>trigger_when_is_set</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span> -</code></pre> +<p>FelECS::Systems::PassiveRegen.trigger_when_added(@component)</p> -<p>If we want these triggers to happen for all Components that belong to specific Component Manager then we can do that instead:</p> +<h1 id="when-this-component-is-removed-from-an-entity-this-system-will-be-called">When this Component is removed from an Entity, this System will be called</h1> -<pre class="code ruby"><code class="ruby"><span class='comment'># When a Component from this Component Manager is added to an Entity, this System will be called -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_added'>trigger_when_added</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='rparen'>)</span> +<p>FelECS::Systems::PassiveRegen.trigger_when_removed(@component)</p> -<span class='comment'># When a Component from this Component Manager is removed from an Entity, this System will be called -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_removed'>trigger_when_removed</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='rparen'>)</span> +<h1 id="when-this-components-health-attribute-is-changed-this-system-will-be-called">When this Component's health attribute is changed, this System will be called</h1> -<span class='comment'># When this Component's health attribute from this Component Manager is changed, this System will be called -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_is_set'>trigger_when_is_set</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span> +<p>FelECS::Systems::PassiveRegen.trigger_when_is_set(@component, :health) + ```</p> + +<pre class="code ruby"><code class="ruby">If we want these triggers to happen for all Components that belong to specific Component Manager then we can do that instead: + +```ruby </code></pre> -<p>We can create any number of these links between Systems, Components, and Component Manangers as we like, simply call the method again with our other Components and Component Managers</p> +<h1 id="when-a-component-from-this-component-manager-is-added-to-an-entity-this-system-will-be-called">When a Component from this Component Manager is added to an Entity, this System will be called</h1> -<h3 id="clearing-alternative-executions">Clearing Alternative Executions</h3> +<p>FelECS::Systems::PassiveRegen.trigger_when_added(@component_manager)</p> + +<h1 id="when-a-component-from-this-component-manager-is-removed-from-an-entity-this-system-will-be-called">When a Component from this Component Manager is removed from an Entity, this System will be called</h1> + +<p>FelECS::Systems::PassiveRegen.trigger_when_removed(@component_manager)</p> -<p>If we wish to remove these links that we created, we can do that using the follwing function in any of the following ways:</p> +<h1 id="when-this-components-health-attribute-from-this-component-manager-is-changed-this-system-will-be-called">When this Component's health attribute from this Component Manager is changed, this System will be called</h1> -<pre class="code ruby"><code class="ruby"><span class='comment'># clears ALL triggers with this system -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span> +<p>FelECS::Systems::PassiveRegen.trigger_when_is_set(@component_manager, :health) + ```</p> -<span class='comment'># clears ALL triggers with this Component Manager -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby">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 +</code></pre> + +<h3 id="clearing-alternative-executions">Clearing Alternative Executions</h3> -<span class='comment'># clear the 'trigger_when_added' for this Component -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:added</span><span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby">If we wish to remove these links that we created, we can do that using the follwing function in any of the following ways: + +```ruby +</code></pre> -<span class='comment'># clear the 'trigger_when_removed' for this Component -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:removed</span><span class='rparen'>)</span> +<h1 id="clears-all-triggers-with-this-system">clears ALL triggers with this system</h1> -<span class='comment'># clear the 'trigger_when_is_set' for this Component specifically for the health attribute -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:is_set</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby"><span class='const'>FelECS</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> </code></pre> -<p>Likewise we can do the same with Component Managers:</p> +<h1 id="clears-all-triggers-with-this-component-manager">clears ALL triggers with this Component Manager</h1> + +<p>FelECS::Systems::PassiveRegen.clear_triggers(@component)</p> + +<h1 id="clear-the-trigger_when_added-for-this-component">clear the 'trigger_when_added' for this Component</h1> + +<p>FelECS::Systems::PassiveRegen.clear_triggers(@component, :added)</p> + +<h1 id="clear-the-trigger_when_removed-for-this-component">clear the 'trigger_when_removed' for this Component</h1> + +<p>FelECS::Systems::PassiveRegen.clear_triggers(@component, :removed)</p> -<pre class="code ruby"><code class="ruby"><span class='comment'># clears ALL triggers with this Component -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='rparen'>)</span> +<h1 id="clear-the-trigger_when_is_set-for-this-component-specifically-for-the-health-attribute">clear the 'trigger_when_is_set' for this Component specifically for the health attribute</h1> -<span class='comment'># clear the 'trigger_when_added' for this Component Manager -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:added</span><span class='rparen'>)</span> +<p>FelECS::Systems::PassiveRegen.clear_triggers(@component, :is_set, :health) + ```</p> -<span class='comment'># clear the 'trigger_when_removed' for this Component Manager -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:removed</span><span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby">Likewise we can do the same with Component Managers: -<span class='comment'># clear the 'trigger_when_is_set' for this Component Manager specifically for the health attribute -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:is_set</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span> +```ruby </code></pre> +<h1 id="clears-all-triggers-with-this-component">clears ALL triggers with this Component</h1> + +<p>FelECS::Systems::PassiveRegen.clear_triggers(@component_manager) </p> + +<h1 id="clear-the-trigger_when_added-for-this-component-manager">clear the 'trigger_when_added' for this Component Manager</h1> + +<p>FelECS::Systems::PassiveRegen.clear_triggers(@component_manager, :added) </p> + +<h1 id="clear-the-trigger_when_removed-for-this-component-manager">clear the 'trigger_when_removed' for this Component Manager</h1> + +<p>FelECS::Systems::PassiveRegen.clear_triggers(@component_manager, :removed) </p> + +<h1 id="clear-the-trigger_when_is_set-for-this-component-manager-specifically-for-the-health-attribute">clear the 'trigger_when_is_set' for this Component Manager specifically for the health attribute</h1> + +<p>FelECS::Systems::PassiveRegen.clear_triggers(@component_manager, :is_set, :health) + ```</p> + <h3 id="redefinition">Redefinition</h3> -<p>If we wanted to change what code or logic a given System executes, we could do that with:</p> +<pre class="code ruby"><code class="ruby">If we wanted to change what code or logic a given System executes, we could do that with: -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_redefine'>redefine</span> <span class='kw'>do</span> - <span class='comment'># Some new logic or code -</span><span class='kw'>end</span> +```ruby +FelECS::Systems::PassiveRegen.redefine do +</code></pre> + +<h1 id="some-new-logic-or-code">Some new logic or code</h1> + +<pre class="code ruby"><code class="ruby">end +``` </code></pre> <h2 id="scenes">Scenes</h2> <h3 id="creation">Creation</h3> -<p>Once we have all the core parts of ECS, we will want to organize our Systems. To do this we will use Scenes to group up Systems so they can quickly be enabled or disabled. Note that <a href="#alternative-execution">Alternative Executions</a> will occur even if they are not part of a Scene. Here is how we make a new Scene:</p> +<pre class="code ruby"><code class="ruby">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 [Alternative Executions](#alternative-execution) will occur even if they are not part of a Scene. Here is how we make a new Scene: -<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Scenes.html#initialize-instance_method" title="FelFlame::Scenes#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ExampleScene</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>5</span><span class='rparen'>)</span> +```ruby +@scene = FelECS::Scenes.new('ExampleScene', priority: 5) +``` </code></pre> <h3 id="accessing">Accessing</h3> -<p>Just like other classes in FelFlame, the name we gave the Scene is how we access it:</p> +<pre class="code ruby"><code class="ruby">Just like other classes in FelECS, the name we gave the Scene is how we access it: -<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span> +```ruby +@scene = FelECS::Scenes::ExampleScene +``` </code></pre> <h3 id="adding-systems">Adding Systems</h3> -<p>Adding Systems is simple. We can add as many as we want. In this example we add 3 different systems:</p> +<pre class="code ruby"><code class="ruby">Adding Systems is simple. We can add as many as we want. In this example we add 3 different systems: -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span> - <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='comma'>,</span> - <span class='ivar'>@system2</span><span class='comma'>,</span> - <span class='ivar'>@system3</span> -<span class='rparen'>)</span> +```ruby </code></pre> +<p>FelECS::Scenes::ExampleScene.add( + FelECS::Systems::Render, + @system2, + @system3 + ) + ```</p> + <h3 id="removing-systems">Removing Systems</h3> -<p>Removing Systems works similarly:</p> +<pre class="code ruby"><code class="ruby">Removing Systems works similarly: -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span><span class='period'>.</span><span class='id identifier rubyid_remove'>remove</span><span class='lparen'>(</span> - <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='comma'>,</span> - <span class='ivar'>@system2</span><span class='comma'>,</span> - <span class='ivar'>@system3</span> -<span class='rparen'>)</span> +```ruby </code></pre> +<p>FelECS::Scenes::ExampleScene.remove( + FelECS::Systems::Render, + @system2, + @system3 + ) + ```</p> + <h3 id="clearing">Clearing</h3> -<p>If you want to remove all Systems from a Scene here is how we do it:</p> +<pre class="code ruby"><code class="ruby">If you want to remove all Systems from a Scene here is how we do it: -<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</span><span class='period'>.</span><span class='id identifier rubyid_clear'>clear</span> +```ruby +``` </code></pre> <h3 id="execution">Execution</h3> -<p>To execute all Systems within a scene once we can just do:</p> +<pre class="code ruby"><code class="ruby">To execute all Systems within a scene once we can just do: -<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span> -</code></pre> +```ruby +``` -<p>The Scene will make sure that the systems are executed in the correct order based on their given priorities</p> +The Scene will make sure that the systems are executed in the correct order based on their given priorities +</code></pre> <h2 id="stage">Stage</h2> <h3 id="adding-scenes">Adding Scenes</h3> -<p>Finally we have the Stage. There is only a single Stage and we do not have to create it as it exists by default. By adding a Scene to the Stage we are saying that the Scene is 'active'. To add a Scene we do the following:</p> +<pre class="code ruby"><code class="ruby">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: -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_add'><span class='object_link'><a href="FelFlame/Stage.html#add-class_method" title="FelFlame::Stage.add (method)">add</a></span></span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'>Scene</span><span class='op'>::</span><span class='const'>ExampleScene</span> +```ruby +FelECS::Stage.add FelECS::Scene::ExampleScene +``` </code></pre> <h3 id="removing-scenes">Removing Scenes</h3> -<p>Likewise we can remove Scenes:</p> +<pre class="code ruby"><code class="ruby">Likewise we can remove Scenes: -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_remove'><span class='object_link'><a href="FelFlame/Stage.html#remove-class_method" title="FelFlame::Stage.remove (method)">remove</a></span></span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'>Scene</span><span class='op'>::</span><span class='const'>ExampleScene</span> +```ruby +FelECS::Stage.remove FelECS::Scene::ExampleScene +``` </code></pre> <h3 id="executing">Executing</h3> -<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> +<pre class="code ruby"><code class="ruby">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: -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_call'><span class='object_link'><a href="FelFlame/Stage.html#call-class_method" title="FelFlame::Stage.call (method)">call</a></span></span> +```ruby +FelECS::Stage.call +``` </code></pre> <h2 id="order">Order</h2> <h3 id="setting-the-order">Setting the order</h3> -<p>To set the order you just need to call <code>FelFlame::Order.sort</code> and pass Scenes or Systems in the parameters in the order you wish for them to execute</p> +<pre class="code ruby"><code class="ruby">To set the order you just need to call `FelECS::Order.sort` and pass Scenes or Systems in the parameters in the order you wish for them to execute -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Order.html" title="FelFlame::Order (module)">Order</a></span></span><span class='period'>.</span><span class='id identifier rubyid_sort'><span class='object_link'><a href="FelFlame/Order.html#sort-class_method" title="FelFlame::Order.sort (method)">sort</a></span></span><span class='lparen'>(</span> - <span class='ivar'>@system1</span><span class='comma'>,</span> - <span class='ivar'>@system2</span><span class='comma'>,</span> - <span class='ivar'>@system3</span> -<span class='rparen'>)</span> +```ruby </code></pre> -<p>If you want some Scenes or Systems to have the same priority then just pass them as an array:</p> +<p>FelECS::Order.sort( + @system1, + @system2, + @system3 + ) + ```</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Order.html" title="FelFlame::Order (module)">Order</a></span></span><span class='period'>.</span><span class='id identifier rubyid_sort'><span class='object_link'><a href="FelFlame/Order.html#sort-class_method" title="FelFlame::Order.sort (method)">sort</a></span></span><span class='lparen'>(</span> - <span class='ivar'>@scene1</span><span class='comma'>,</span> - <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> - <span class='ivar'>@scene3</span> -<span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby">If you want some Scenes or Systems to have the same priority then just pass them as an array: + +```ruby </code></pre> +<p>FelECS::Order.sort( + @scene1, + [@scene2_1, @scene2_2], + @scene3 + ) + ```</p> + <h2 id="closing-notes">Closing Notes</h2> -<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> +<pre class="code ruby"><code class="ruby">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 [Documentation](https://felflame.tradam.fyi)! +</code></pre> <h1 id="contribution">Contribution</h1> -<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> +<pre class="code ruby"><code class="ruby">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>If you need help writing documentation or tests feel free to ask! </p> +If you need help writing documentation or tests feel free to ask! -<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> +If you want to contribute to development with a thanks you can always [buy me a coffee ;^)](https://ko-fi.com/tradam) +</code></pre> </div></div> <div id="footer"> - Generated on Mon Jan 3 08:23:03 2022 by + Generated on Thu Jan 20 22:40:31 2022 by <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.26 (ruby-2.7.3). </div> diff --git a/docs/index.html b/docs/index.html index 83af15a..e81dd9d 100644 --- a/docs/index.html +++ b/docs/index.html @@ -57,14 +57,14 @@ <div class="clear"></div> </div> - <div id="content"><div id='filecontents'><p><img src="https://raw.githubusercontent.com/realtradam/FelFlame/master/logos/felflame-logo-text.png" alt="FelFlame"></p> + <div id="content"><div id='filecontents'><p><img src="https://raw.githubusercontent.com/realtradam/FelECS/master/logos/felecs-logo-text.png" alt="FelECS"></p> -<!--  --> +<!--  --> -<p><a href="https://codeclimate.com/github/realtradam/FelFlame/maintainability"><img src="https://api.codeclimate.com/v1/badges/56d425d9078e98efb74b/maintainability" alt="Maintainability"></a> -<a href="https://codeclimate.com/github/realtradam/FelFlame/test_coverage"><img src="https://api.codeclimate.com/v1/badges/56d425d9078e98efb74b/test_coverage" alt="Test Coverage"></a> -<a href="http://inch-ci.org/github/realtradam/FelFlame"><img src="http://inch-ci.org/github/realtradam/FelFlame.svg?branch=master" alt="Inline docs"></a> -<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> +<p><a href="https://codeclimate.com/github/realtradam/FelECS/maintainability"><img src="https://api.codeclimate.com/v1/badges/56d425d9078e98efb74b/maintainability" alt="Maintainability"></a> +<a href="https://codeclimate.com/github/realtradam/FelECS/test_coverage"><img src="https://api.codeclimate.com/v1/badges/56d425d9078e98efb74b/test_coverage" alt="Test Coverage"></a> +<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> +<a href="https://github.com/realtradam/FelECS/blob/master/LICENSE"><img src="https://img.shields.io/github/license/realtradam/FelECS?label=license&style=flat" alt="MIT License"></a> <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> <p><strong><a href="https://felflame.tradam.fyi/">Check out the comprehensive documentation here!</a></strong></p> @@ -74,7 +74,7 @@ <!-- vim-markdown-toc GFM --> <ul> -<li><a href="#what-is-felflame">What is FelFlame?</a></li> +<li><a href="#what-is-felecs">What is FelECS?</a></li> <li><a href="#what-is-ecs">What is ECS?</a> * <a href="#components">Components</a> * <a href="#entities">Entities</a> @@ -104,15 +104,42 @@ <li><a href="#deleting-components">Deleting Components</a></li> <li><a href="#accessing-components-attached-entities">Accessing Components' attached Entities</a></li> </ul></li> +</ul></li> +<li><a href="#get-the-first-entity-attached">get the first entity attached.</a></li> +<li><a href="#this-will-throw-a-warning-if-there-is-more-or-less-then">this will throw a warning if there is more or less then</a></li> +<li><a href="#exactly-one-entity">exactly one entity</a> + +<ul> <li><a href="#systems-1">Systems</a> <ul> <li><a href="#creation-1">Creation</a></li> -<li><a href="#execution">Execution</a></li> -<li><a href="#alternative-execution">Alternative Execution</a></li> -<li><a href="#clearing-alternative-executions">Clearing Alternative Executions</a></li> -<li><a href="#redefinition">Redefinition</a></li> </ul></li> +</ul></li> +<li><a href="#code-and-logic">Code and Logic</a></li> +<li><a href="#do-something-with-these-components">do something with these components</a> + * <a href="#execution">Execution</a> + * <a href="#alternative-execution">Alternative Execution</a></li> +<li><a href="#when-this-component-is-added-to-an-entity-this-system-will-be-called">When this Component is added to an Entity, this System will be called</a></li> +<li><a href="#when-this-component-is-removed-from-an-entity-this-system-will-be-called">When this Component is removed from an Entity, this System will be called</a></li> +<li><a href="#when-this-components-health-attribute-is-changed-this-system-will-be-called">When this Component's health attribute is changed, this System will be called</a></li> +<li><a href="#when-a-component-from-this-component-manager-is-added-to-an-entity-this-system-will-be-called">When a Component from this Component Manager is added to an Entity, this System will be called</a></li> +<li><a href="#when-a-component-from-this-component-manager-is-removed-from-an-entity-this-system-will-be-called">When a Component from this Component Manager is removed from an Entity, this System will be called</a></li> +<li><a href="#when-this-components-health-attribute-from-this-component-manager-is-changed-this-system-will-be-called">When this Component's health attribute from this Component Manager is changed, this System will be called</a> + * <a href="#clearing-alternative-executions">Clearing Alternative Executions</a></li> +<li><a href="#clears-all-triggers-with-this-system">clears ALL triggers with this system</a></li> +<li><a href="#clears-all-triggers-with-this-component-manager">clears ALL triggers with this Component Manager</a></li> +<li><a href="#clear-the-trigger_when_added-for-this-component">clear the 'trigger_when_added' for this Component</a></li> +<li><a href="#clear-the-trigger_when_removed-for-this-component">clear the 'trigger_when_removed' for this Component</a></li> +<li><a href="#clear-the-trigger_when_is_set-for-this-component-specifically-for-the-health-attribute">clear the 'trigger_when_is_set' for this Component specifically for the health attribute</a></li> +<li><a href="#clears-all-triggers-with-this-component">clears ALL triggers with this Component</a></li> +<li><a href="#clear-the-trigger_when_added-for-this-component-manager">clear the 'trigger_when_added' for this Component Manager</a></li> +<li><a href="#clear-the-trigger_when_removed-for-this-component-manager">clear the 'trigger_when_removed' for this Component Manager</a></li> +<li><a href="#clear-the-trigger_when_is_set-for-this-component-manager-specifically-for-the-health-attribute">clear the 'trigger_when_is_set' for this Component Manager specifically for the health attribute</a> + * <a href="#redefinition">Redefinition</a></li> +<li><a href="#some-new-logic-or-code">Some new logic or code</a> + +<ul> <li><a href="#scenes-1">Scenes</a> <ul> @@ -142,415 +169,522 @@ <!-- vim-markdown-toc --> -<h1 id="what-is-felflame">What is FelFlame?</h1> +<h1 id="what-is-felecs">What is FelECS?</h1> -<p>FelFlame is an ECS framework for developing games in the Ruby language. FelFlame has been designed from the ground up with these three ideas in mind:</p> +<pre class="code ruby"><code class="ruby">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: -<ol> -<li><strong>Engine Agnostic:</strong> FelFlame has been designed to be rendering engine agnostic as long as the target rendering engine is written in Ruby. This means that this framework can be dropped into existing rendering engines such as <a href="http://www.ruby2d.com">Ruby2D</a> or <a href="https://dragonruby.org/toolkit/game">DRGTK</a> with little modifications.</li> -<li><strong>Easily Extensible:</strong> FelFlame has been designed such that extensions to its capabilities can be easily added. Extensions such as rendering engine wrappers, premade systems, premade components, etcetera can be easily coded and then distributed as gems.</li> -<li><strong>Principle of (My) Least Astonishment:</strong> I want to develop games using a language and framework I love and makes sense to me, inspired by the <a href="https://en.wikipedia.org/wiki/Ruby_(programming_language)#Philosophy">Philosophy of the creator of Ruby</a>.</li> -</ol> +1. **Engine Agnostic:** 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 [Ruby2D](http://www.ruby2d.com) or [DRGTK](https://dragonruby.org/toolkit/game) with little modifications. +2. **Easily Extensible:** 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. +3. **Principle of (My) Least Astonishment:** I want to develop games using a language and framework I love and makes sense to me, inspired by the [Philosophy of the creator of Ruby](https://en.wikipedia.org/wiki/Ruby_(programming_language)#Philosophy). +</code></pre> <h1 id="what-is-ecs">What is ECS?</h1> -<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> -ECS stands for Entity, Component, and System.</p> +<pre class="code ruby"><code class="ruby">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. +ECS stands for Entity, Component, and System. -<hr> +--- +</code></pre> <h3 id="components">Components</h3> -<p>This is where the data or information of a given "object" is stored. There is no logic or code here. </p> +<pre class="code ruby"><code class="ruby">This is where the data or information of a given "object" is stored. There is no logic or code here. +</code></pre> <h3 id="entities">Entities</h3> -<p>Entities will contain one or more Components, but contains no logic or data otherwise</p> +<pre class="code ruby"><code class="ruby">Entities will contain one or more Components, but contains no logic or data otherwise +</code></pre> <h3 id="systems">Systems</h3> -<p>Systems are where all the logic or code is kept. There is no data stored in here.</p> +<pre class="code ruby"><code class="ruby">Systems are where all the logic or code is kept. There is no data stored in here. -<hr> +--- -<p>By using this pattern it allows programmers to easily control what an "object" 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> +By using this pattern it allows programmers to easily control what an "object" 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><strong>"But your framework also has <code>Scenes</code>, <code>Stage</code>, and <code>Order</code>, what is that about?"</strong> </p> +**"But your framework also has `Scenes`, `Stage`, and `Order`, what is that about?"** -<hr> +--- +</code></pre> <h3 id="scenes">Scenes</h3> -<p>Scenes are simply a collection or subset of Systems. This allows for an easy way to activate and deactivate Systems.</p> +<pre class="code ruby"><code class="ruby">Scenes are simply a collection or subset of Systems. This allows for an easy way to activate and deactivate Systems. +</code></pre> <h3 id="stage">Stage</h3> -<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> +<pre class="code ruby"><code class="ruby">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. +</code></pre> <h3 id="order">Order</h3> -<p>Order is a helper class which can set the priority of Scenes and Systems.</p> +<pre class="code ruby"><code class="ruby">Order is a helper class which can set the priority of Scenes and Systems. -<hr> +--- +</code></pre> <h1 id="usage">Usage</h1> -<p>There are 2 ways of using FelFlame. 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 FelFlame 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> +<pre class="code ruby"><code class="ruby">There are 2 ways of using FelECS. You can either `include` 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 `require_relative` 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>To use the gem method you can do the following: 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>.</p> +To use the gem method you can do the following: install the gem using `gem install felflame` or using bundler `bundle add felflame` and then require it in your project like so: `require 'felflame'`. -<p>To use the single file export method you simply download the felflame.rb file from the <a href="https://github.com/realtradam/FelFlame/releases">releases page on Github</a> and add it to your source folder and add a <code>require relative 'felflame.rb'</code> line or wherever you have placed the file to use it.</p> +To use the single file export method you simply download the felflame.rb file from the [releases page on Github](https://github.com/realtradam/FelECS/releases) and add it to your source folder and add a `require relative 'felflame.rb'` line or wherever you have placed the file to use it. +</code></pre> <h2 id="entities">Entities</h2> <h3 id="creation">Creation</h3> -<p>Entities are essentially "objects" in the game world. To create a new Entity we do the following:</p> - -<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Entities.html#initialize-instance_method" title="FelFlame::Entities#initialize (method)">new</a></span></span> -</code></pre> +<pre class="code ruby"><code class="ruby">Entities are essentially "objects" in the game world. To create a new Entity we do the following: -<p>or if we want to add (any number of)components to it when creating it:</p> +```ruby +@entity = FelECS::Entities.new +``` +or if we want to add (any number of)components to it when creating it: -<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'>Entites</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span> - <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Health</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='comma'>,</span> - <span class='ivar'>@component</span><span class='comma'>,</span> - <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>EnemyTeam</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> -<span class='rparen'>)</span> +```ruby </code></pre> +<p>@entity = FelECS::Entites.new( + FelECS::Components::Health.new, + @component, + FelECS::Components::EnemyTeam.first + ) + ```</p> + <h3 id="accessing">Accessing</h3> -<p>Oftentimes you will not be accessing an Entity this way. Later we will shows you a more common way of accessing entities. -If you need to you can access Entities using the <code>Entities</code> module:</p> +<pre class="code ruby"><code class="ruby">Oftentimes you will not be accessing an Entity this way. Later we will shows you a more common way of accessing entities. +If you need to you can access Entities using the `Entities` module: -<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span> -<span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> -<span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='comment'># you can iterate over all entities this way. Any valid array method can be used -</span></code></pre> +```ruby +@entity = FelECS::Entities[2] +@entity = FelECS::Entities.first +@entity = FelECS::Entities.each # you can iterate over all entities this way. Any valid array method can be used +``` +</code></pre> <h3 id="adding-and-removing-components">Adding and Removing Components</h3> -<p>We can still add or remove Components from an Entity after it has been created. Here is how:</p> +<pre class="code ruby"><code class="ruby">We can still add or remove Components from an Entity after it has been created. Here is how: -<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> -<span class='ivar'>@entity</span><span class='period'>.</span><span class='id identifier rubyid_remove'>remove</span> <span class='ivar'>@component</span> +```ruby [email protected] @component [email protected] @component +``` </code></pre> <h3 id="accessing-entities-attached-components">Accessing Entities' Attached Components</h3> -<p>This is the most common way of accessing an Entity</p> +<pre class="code ruby"><code class="ruby">This is the most common way of accessing an Entity -<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> +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: -<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] -</span></code></pre> +```ruby [email protected][@component_manager] # => [@component1, @component2, @component3] +``` +</code></pre> <h3 id="deletion">Deletion</h3> -<p>To have all Components from an Entity <strong>removed</strong> and the Entity deleted we do the following:</p> +<pre class="code ruby"><code class="ruby">To have all Components from an Entity **removed** and the Entity deleted we do the following: -<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> +NOTE: The components will **not be deleted**. They are simply **removed** 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. -<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> +```ruby +``` </code></pre> <h2 id="components">Components</h2> <h3 id="creating-a-component-manager">Creating a Component Manager</h3> -<p>Components are where all the data is stored. The data is stored in variables or accessors in each component. -These accessors and their defaults are configured when a component manager is created, like so:</p> +<pre class="code ruby"><code class="ruby">Components are where all the data is stored. The data is stored in variables or accessors in each component. +These accessors and their defaults are configured when a component manager is created, like so: -<pre class="code ruby"><code class="ruby"><span class='ivar'>@component_manager</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Components.html#new-class_method" title="FelFlame::Components.new (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Stats</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='symbol'>:armour</span><span class='comma'>,</span> <span class='label'>hp:</span> <span class='int'>100</span><span class='rparen'>)</span> -</code></pre> +```ruby +@component_manager = FelECS::Components.new('Stats', :armour, hp: 100) +``` -<p>In this example we created a component manager called "Stats". +In this example we created a component manager called "Stats". The name given to component managers must follow the same rules for naming constants in ruby for a reason you will shortly see. The parameters following are all creating the attributes we can set. We can set any number of parameters we wish, in this example we define two. -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. -When defining attributes symbols should be used.</p> +The `:armour` parameter is being created without a default, it will equal to `nil` when a new component is created, while `hp` will be equal to 100 when a component is created. +When defining attributes symbols should be used. +</code></pre> <h3 id="creating-a-component-from-a-component-manager">Creating a Component from a Component Manager</h3> -<p>Now that we have a component manager we can make components from it like so:</p> +<pre class="code ruby"><code class="ruby">Now that we have a component manager we can make components from it like so: -<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> -</code></pre> +```ruby +@component = FelECS::Components::Stats.new +``` -<p>Or we can even override the defaults when creating the component:</p> +Or we can even override the defaults when creating the component: -<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='label'>armour:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>steel</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> +```ruby +@component = FelECS::Components::Stats.new(armour: 'steel') +``` </code></pre> <h3 id="accessing">Accessing</h3> -<p>You can access components using any array method.</p> +<pre class="code ruby"><code class="ruby">You can access components using any array method. -<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span> -<span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> -<span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='comment'># you can use iterators this way -</span></code></pre> +```ruby +@component = FelECS::Components::Stats[2] +@component = FelECS::Components::Stats.first +@component = FelECS::Components::Stats.each # you can use iterators this way +``` +</code></pre> <h3 id="accessing-attributes-and-changing-them">Accessing Attributes and Changing Them</h3> -<p>There are a few different ways we can read or change the attributes of a component depending on what our needs are. -Here are the ways to edit attrubutes, followed by the ways to read them.</p> - -<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'>'</span><span class='tstring_content'>Mythril</span><span class='tstring_end'>'</span></span> -<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'>'</span><span class='tstring_content'>Leather</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>hp:</span> <span class='int'>95</span><span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby">There are a few different ways we can read or change the attributes of a component depending on what our needs are. +Here are the ways to edit attrubutes, followed by the ways to read them. +```ruby [email protected] = 'Mythril' [email protected]_attrs(armour: 'Leather', hp: 95) +``` +```ruby [email protected] # => 95 [email protected]_h # => {armour: 'Leather', hp: 95} +``` </code></pre> -<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'># => 95 -</span><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_to_h'>to_h</span> <span class='comment'># => {armour: 'Leather', hp: 95} -</span></code></pre> - <h3 id="deleting-components">Deleting Components</h3> -<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> +<pre class="code ruby"><code class="ruby">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. -<pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> +```ruby +``` </code></pre> <h3 id="accessing-components-attached-entities">Accessing Components' attached Entities</h3> -<p>Components also keep track of what Entities are using it. To access this list we do the following:</p> +<pre class="code ruby"><code class="ruby">Components also keep track of what Entities are using it. To access this list we do the following: -<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] -</span> -<span class='comment'># get the first entity attached. -</span><span class='comment'># this will throw a warning if there is more or less then -</span><span class='comment'># exactly one entity -</span><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_entity'>entity</span> <span class='comment'># => @entity -</span></code></pre> +```ruby [email protected] # => [@entity1, @entity2, @entity3] +</code></pre> + +<h1 id="get-the-first-entity-attached">get the first entity attached.</h1> + +<h1 id="this-will-throw-a-warning-if-there-is-more-or-less-then">this will throw a warning if there is more or less then</h1> + +<h1 id="exactly-one-entity">exactly one entity</h1> + +<pre class="code ruby"><code class="ruby">@component.entity # => @entity +``` +</code></pre> <h2 id="systems">Systems</h2> <h3 id="creation">Creation</h3> -<p>We can create Systems like so:</p> +<pre class="code ruby"><code class="ruby">We can create Systems like so: -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Systems.html#initialize-instance_method" title="FelFlame::Systems#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Render</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>2</span><span class='rparen'>)</span> <span class='kw'>do</span> - <span class='comment'># Code and Logic -</span><span class='kw'>end</span> +```ruby +FelECS::Systems.new('Render', priority: 2) do </code></pre> -<p>The name we assign is how we can access the System, like so:</p> +<h1 id="code-and-logic">Code and Logic</h1> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span> -</code></pre> +<pre class="code ruby"><code class="ruby">end +``` + +The name we assign is how we can access the System, like so: -<p>Priority determines the order Systems should be executed, this is used for <code>Scenes</code> and the <code>Stage</code>. +```ruby +FelECS::Systems::Render +``` +Priority determines the order Systems should be executed, this is used for `Scenes` and the `Stage`. The lower the number, the earlier a given System will be executed. -E.g priority 1 will go first, priority 2 will go second, etcetera. </p> +E.g priority 1 will go first, priority 2 will go second, etcetera. -<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> +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>Often we will want to execute some logic on each Component in a given Component Manager so our code might look like this:</p> +Often we will want to execute some logic on each Component in a given Component Manager so our code might look like this: -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Systems.html#initialize-instance_method" title="FelFlame::Systems#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Render</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>2</span><span class='rparen'>)</span> <span class='kw'>do</span> - <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Sprites</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_component'>component</span><span class='op'>|</span> - <span class='comment'># do something with these components -</span> <span class='kw'>end</span> -<span class='kw'>end</span> +```ruby +FelECS::Systems.new('Render', priority: 2) do +FelECS::Components::Sprites.each do |component| +</code></pre> + +<h1 id="do-something-with-these-components">do something with these components</h1> + +<pre class="code ruby"><code class="ruby">end +end +``` </code></pre> <h3 id="execution">Execution</h3> -<p>After we create a System, it won't do anything on its own until we tell it to. Here is how:</p> +<pre class="code ruby"><code class="ruby">After we create a System, it won't do anything on its own until we tell it to. Here is how: -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span> -</code></pre> +```ruby +FelECS::Systems::Render.call +``` -<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> +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. +</code></pre> <h3 id="alternative-execution">Alternative Execution</h3> -<p>Sometimes you want a System to automatically trigger when a special even happens. FelFlame can keep track of when a Component is added, removed, or when an attribute is changed and then execute Systems linked to these events. Here is how to create these links:</p> +<pre class="code ruby"><code class="ruby">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: -<pre class="code ruby"><code class="ruby"><span class='comment'># When this Component is added to an Entity, this System will be called -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_added'>trigger_when_added</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='rparen'>)</span> +```ruby +</code></pre> -<span class='comment'># When this Component is removed from an Entity, this System will be called -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_removed'>trigger_when_removed</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='rparen'>)</span> +<h1 id="when-this-component-is-added-to-an-entity-this-system-will-be-called">When this Component is added to an Entity, this System will be called</h1> -<span class='comment'># When this Component's health attribute is changed, this System will be called -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_is_set'>trigger_when_is_set</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span> -</code></pre> +<p>FelECS::Systems::PassiveRegen.trigger_when_added(@component)</p> -<p>If we want these triggers to happen for all Components that belong to specific Component Manager then we can do that instead:</p> +<h1 id="when-this-component-is-removed-from-an-entity-this-system-will-be-called">When this Component is removed from an Entity, this System will be called</h1> -<pre class="code ruby"><code class="ruby"><span class='comment'># When a Component from this Component Manager is added to an Entity, this System will be called -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_added'>trigger_when_added</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='rparen'>)</span> +<p>FelECS::Systems::PassiveRegen.trigger_when_removed(@component)</p> -<span class='comment'># When a Component from this Component Manager is removed from an Entity, this System will be called -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_removed'>trigger_when_removed</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='rparen'>)</span> +<h1 id="when-this-components-health-attribute-is-changed-this-system-will-be-called">When this Component's health attribute is changed, this System will be called</h1> -<span class='comment'># When this Component's health attribute from this Component Manager is changed, this System will be called -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_trigger_when_is_set'>trigger_when_is_set</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span> +<p>FelECS::Systems::PassiveRegen.trigger_when_is_set(@component, :health) + ```</p> + +<pre class="code ruby"><code class="ruby">If we want these triggers to happen for all Components that belong to specific Component Manager then we can do that instead: + +```ruby </code></pre> -<p>We can create any number of these links between Systems, Components, and Component Manangers as we like, simply call the method again with our other Components and Component Managers</p> +<h1 id="when-a-component-from-this-component-manager-is-added-to-an-entity-this-system-will-be-called">When a Component from this Component Manager is added to an Entity, this System will be called</h1> -<h3 id="clearing-alternative-executions">Clearing Alternative Executions</h3> +<p>FelECS::Systems::PassiveRegen.trigger_when_added(@component_manager)</p> + +<h1 id="when-a-component-from-this-component-manager-is-removed-from-an-entity-this-system-will-be-called">When a Component from this Component Manager is removed from an Entity, this System will be called</h1> + +<p>FelECS::Systems::PassiveRegen.trigger_when_removed(@component_manager)</p> -<p>If we wish to remove these links that we created, we can do that using the follwing function in any of the following ways:</p> +<h1 id="when-this-components-health-attribute-from-this-component-manager-is-changed-this-system-will-be-called">When this Component's health attribute from this Component Manager is changed, this System will be called</h1> -<pre class="code ruby"><code class="ruby"><span class='comment'># clears ALL triggers with this system -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span> +<p>FelECS::Systems::PassiveRegen.trigger_when_is_set(@component_manager, :health) + ```</p> -<span class='comment'># clears ALL triggers with this Component Manager -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby">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 +</code></pre> + +<h3 id="clearing-alternative-executions">Clearing Alternative Executions</h3> -<span class='comment'># clear the 'trigger_when_added' for this Component -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:added</span><span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby">If we wish to remove these links that we created, we can do that using the follwing function in any of the following ways: + +```ruby +</code></pre> -<span class='comment'># clear the 'trigger_when_removed' for this Component -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:removed</span><span class='rparen'>)</span> +<h1 id="clears-all-triggers-with-this-system">clears ALL triggers with this system</h1> -<span class='comment'># clear the 'trigger_when_is_set' for this Component specifically for the health attribute -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component</span><span class='comma'>,</span> <span class='symbol'>:is_set</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby"><span class='const'>FelECS</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> </code></pre> -<p>Likewise we can do the same with Component Managers:</p> +<h1 id="clears-all-triggers-with-this-component-manager">clears ALL triggers with this Component Manager</h1> + +<p>FelECS::Systems::PassiveRegen.clear_triggers(@component)</p> + +<h1 id="clear-the-trigger_when_added-for-this-component">clear the 'trigger_when_added' for this Component</h1> + +<p>FelECS::Systems::PassiveRegen.clear_triggers(@component, :added)</p> + +<h1 id="clear-the-trigger_when_removed-for-this-component">clear the 'trigger_when_removed' for this Component</h1> + +<p>FelECS::Systems::PassiveRegen.clear_triggers(@component, :removed)</p> -<pre class="code ruby"><code class="ruby"><span class='comment'># clears ALL triggers with this Component -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='rparen'>)</span> +<h1 id="clear-the-trigger_when_is_set-for-this-component-specifically-for-the-health-attribute">clear the 'trigger_when_is_set' for this Component specifically for the health attribute</h1> -<span class='comment'># clear the 'trigger_when_added' for this Component Manager -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:added</span><span class='rparen'>)</span> +<p>FelECS::Systems::PassiveRegen.clear_triggers(@component, :is_set, :health) + ```</p> -<span class='comment'># clear the 'trigger_when_removed' for this Component Manager -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:removed</span><span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby">Likewise we can do the same with Component Managers: -<span class='comment'># clear the 'trigger_when_is_set' for this Component Manager specifically for the health attribute -</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='comma'>,</span> <span class='symbol'>:is_set</span><span class='comma'>,</span> <span class='symbol'>:health</span><span class='rparen'>)</span> +```ruby </code></pre> +<h1 id="clears-all-triggers-with-this-component">clears ALL triggers with this Component</h1> + +<p>FelECS::Systems::PassiveRegen.clear_triggers(@component_manager) </p> + +<h1 id="clear-the-trigger_when_added-for-this-component-manager">clear the 'trigger_when_added' for this Component Manager</h1> + +<p>FelECS::Systems::PassiveRegen.clear_triggers(@component_manager, :added) </p> + +<h1 id="clear-the-trigger_when_removed-for-this-component-manager">clear the 'trigger_when_removed' for this Component Manager</h1> + +<p>FelECS::Systems::PassiveRegen.clear_triggers(@component_manager, :removed) </p> + +<h1 id="clear-the-trigger_when_is_set-for-this-component-manager-specifically-for-the-health-attribute">clear the 'trigger_when_is_set' for this Component Manager specifically for the health attribute</h1> + +<p>FelECS::Systems::PassiveRegen.clear_triggers(@component_manager, :is_set, :health) + ```</p> + <h3 id="redefinition">Redefinition</h3> -<p>If we wanted to change what code or logic a given System executes, we could do that with:</p> +<pre class="code ruby"><code class="ruby">If we wanted to change what code or logic a given System executes, we could do that with: -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>PassiveRegen</span><span class='period'>.</span><span class='id identifier rubyid_redefine'>redefine</span> <span class='kw'>do</span> - <span class='comment'># Some new logic or code -</span><span class='kw'>end</span> +```ruby +FelECS::Systems::PassiveRegen.redefine do +</code></pre> + +<h1 id="some-new-logic-or-code">Some new logic or code</h1> + +<pre class="code ruby"><code class="ruby">end +``` </code></pre> <h2 id="scenes">Scenes</h2> <h3 id="creation">Creation</h3> -<p>Once we have all the core parts of ECS, we will want to organize our Systems. To do this we will use Scenes to group up Systems so they can quickly be enabled or disabled. Note that <a href="#alternative-execution">Alternative Executions</a> will occur even if they are not part of a Scene. Here is how we make a new Scene:</p> +<pre class="code ruby"><code class="ruby">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 [Alternative Executions](#alternative-execution) will occur even if they are not part of a Scene. Here is how we make a new Scene: -<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Scenes.html#initialize-instance_method" title="FelFlame::Scenes#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ExampleScene</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>5</span><span class='rparen'>)</span> +```ruby +@scene = FelECS::Scenes.new('ExampleScene', priority: 5) +``` </code></pre> <h3 id="accessing">Accessing</h3> -<p>Just like other classes in FelFlame, the name we gave the Scene is how we access it:</p> +<pre class="code ruby"><code class="ruby">Just like other classes in FelECS, the name we gave the Scene is how we access it: -<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span> +```ruby +@scene = FelECS::Scenes::ExampleScene +``` </code></pre> <h3 id="adding-systems">Adding Systems</h3> -<p>Adding Systems is simple. We can add as many as we want. In this example we add 3 different systems:</p> +<pre class="code ruby"><code class="ruby">Adding Systems is simple. We can add as many as we want. In this example we add 3 different systems: -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span> - <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='comma'>,</span> - <span class='ivar'>@system2</span><span class='comma'>,</span> - <span class='ivar'>@system3</span> -<span class='rparen'>)</span> +```ruby </code></pre> +<p>FelECS::Scenes::ExampleScene.add( + FelECS::Systems::Render, + @system2, + @system3 + ) + ```</p> + <h3 id="removing-systems">Removing Systems</h3> -<p>Removing Systems works similarly:</p> +<pre class="code ruby"><code class="ruby">Removing Systems works similarly: -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span><span class='period'>.</span><span class='id identifier rubyid_remove'>remove</span><span class='lparen'>(</span> - <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='comma'>,</span> - <span class='ivar'>@system2</span><span class='comma'>,</span> - <span class='ivar'>@system3</span> -<span class='rparen'>)</span> +```ruby </code></pre> +<p>FelECS::Scenes::ExampleScene.remove( + FelECS::Systems::Render, + @system2, + @system3 + ) + ```</p> + <h3 id="clearing">Clearing</h3> -<p>If you want to remove all Systems from a Scene here is how we do it:</p> +<pre class="code ruby"><code class="ruby">If you want to remove all Systems from a Scene here is how we do it: -<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</span><span class='period'>.</span><span class='id identifier rubyid_clear'>clear</span> +```ruby +``` </code></pre> <h3 id="execution">Execution</h3> -<p>To execute all Systems within a scene once we can just do:</p> +<pre class="code ruby"><code class="ruby">To execute all Systems within a scene once we can just do: -<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span> -</code></pre> +```ruby +``` -<p>The Scene will make sure that the systems are executed in the correct order based on their given priorities</p> +The Scene will make sure that the systems are executed in the correct order based on their given priorities +</code></pre> <h2 id="stage">Stage</h2> <h3 id="adding-scenes">Adding Scenes</h3> -<p>Finally we have the Stage. There is only a single Stage and we do not have to create it as it exists by default. By adding a Scene to the Stage we are saying that the Scene is 'active'. To add a Scene we do the following:</p> +<pre class="code ruby"><code class="ruby">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: -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_add'><span class='object_link'><a href="FelFlame/Stage.html#add-class_method" title="FelFlame::Stage.add (method)">add</a></span></span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'>Scene</span><span class='op'>::</span><span class='const'>ExampleScene</span> +```ruby +FelECS::Stage.add FelECS::Scene::ExampleScene +``` </code></pre> <h3 id="removing-scenes">Removing Scenes</h3> -<p>Likewise we can remove Scenes:</p> +<pre class="code ruby"><code class="ruby">Likewise we can remove Scenes: -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_remove'><span class='object_link'><a href="FelFlame/Stage.html#remove-class_method" title="FelFlame::Stage.remove (method)">remove</a></span></span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'>Scene</span><span class='op'>::</span><span class='const'>ExampleScene</span> +```ruby +FelECS::Stage.remove FelECS::Scene::ExampleScene +``` </code></pre> <h3 id="executing">Executing</h3> -<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> +<pre class="code ruby"><code class="ruby">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: -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_call'><span class='object_link'><a href="FelFlame/Stage.html#call-class_method" title="FelFlame::Stage.call (method)">call</a></span></span> +```ruby +FelECS::Stage.call +``` </code></pre> <h2 id="order">Order</h2> <h3 id="setting-the-order">Setting the order</h3> -<p>To set the order you just need to call <code>FelFlame::Order.sort</code> and pass Scenes or Systems in the parameters in the order you wish for them to execute</p> +<pre class="code ruby"><code class="ruby">To set the order you just need to call `FelECS::Order.sort` and pass Scenes or Systems in the parameters in the order you wish for them to execute -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Order.html" title="FelFlame::Order (module)">Order</a></span></span><span class='period'>.</span><span class='id identifier rubyid_sort'><span class='object_link'><a href="FelFlame/Order.html#sort-class_method" title="FelFlame::Order.sort (method)">sort</a></span></span><span class='lparen'>(</span> - <span class='ivar'>@system1</span><span class='comma'>,</span> - <span class='ivar'>@system2</span><span class='comma'>,</span> - <span class='ivar'>@system3</span> -<span class='rparen'>)</span> +```ruby </code></pre> -<p>If you want some Scenes or Systems to have the same priority then just pass them as an array:</p> +<p>FelECS::Order.sort( + @system1, + @system2, + @system3 + ) + ```</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Order.html" title="FelFlame::Order (module)">Order</a></span></span><span class='period'>.</span><span class='id identifier rubyid_sort'><span class='object_link'><a href="FelFlame/Order.html#sort-class_method" title="FelFlame::Order.sort (method)">sort</a></span></span><span class='lparen'>(</span> - <span class='ivar'>@scene1</span><span class='comma'>,</span> - <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> - <span class='ivar'>@scene3</span> -<span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby">If you want some Scenes or Systems to have the same priority then just pass them as an array: + +```ruby </code></pre> +<p>FelECS::Order.sort( + @scene1, + [@scene2_1, @scene2_2], + @scene3 + ) + ```</p> + <h2 id="closing-notes">Closing Notes</h2> -<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> +<pre class="code ruby"><code class="ruby">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 [Documentation](https://felflame.tradam.fyi)! +</code></pre> <h1 id="contribution">Contribution</h1> -<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> +<pre class="code ruby"><code class="ruby">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>If you need help writing documentation or tests feel free to ask! </p> +If you need help writing documentation or tests feel free to ask! -<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> +If you want to contribute to development with a thanks you can always [buy me a coffee ;^)](https://ko-fi.com/tradam) +</code></pre> </div></div> <div id="footer"> - Generated on Mon Jan 3 08:23:03 2022 by + Generated on Thu Jan 20 22:40:31 2022 by <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.26 (ruby-2.7.3). </div> diff --git a/docs/method_list.html b/docs/method_list.html index 5f38f92..48eea1f 100644 --- a/docs/method_list.html +++ b/docs/method_list.html @@ -44,374 +44,6 @@ <ul id="full_list" class="method"> - <li class="odd "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Scenes.html#add-instance_method" title="FelFlame::Scenes#add (method)">#add</a></span> - <small>FelFlame::Scenes</small> - </div> - </li> - - - <li class="even "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Stage.html#add-class_method" title="FelFlame::Stage.add (method)">add</a></span> - <small>FelFlame::Stage</small> - </div> - </li> - - - <li class="odd "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Entities.html#add-instance_method" title="FelFlame::Entities#add (method)">#add</a></span> - <small>FelFlame::Entities</small> - </div> - </li> - - - <li class="even "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Systems.html#addition_triggers-instance_method" title="FelFlame::Systems#addition_triggers (method)">#addition_triggers</a></span> - <small>FelFlame::Systems</small> - </div> - </li> - - - <li class="odd "> - <div class="item"> - <span class='object_link'><a href="FelFlame/ComponentManager.html#addition_triggers-instance_method" title="FelFlame::ComponentManager#addition_triggers (method)">#addition_triggers</a></span> - <small>FelFlame::ComponentManager</small> - </div> - </li> - - - <li class="even "> - <div class="item"> - <span class='object_link'><a href="FelFlame/ComponentManager.html#addition_triggers-class_method" title="FelFlame::ComponentManager.addition_triggers (method)">addition_triggers</a></span> - <small>FelFlame::ComponentManager</small> - </div> - </li> - - - <li class="odd "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Systems.html#attr_triggers-instance_method" title="FelFlame::Systems#attr_triggers (method)">#attr_triggers</a></span> - <small>FelFlame::Systems</small> - </div> - </li> - - - <li class="even "> - <div class="item"> - <span class='object_link'><a href="FelFlame/ComponentManager.html#attr_triggers-instance_method" title="FelFlame::ComponentManager#attr_triggers (method)">#attr_triggers</a></span> - <small>FelFlame::ComponentManager</small> - </div> - </li> - - - <li class="odd "> - <div class="item"> - <span class='object_link'><a href="FelFlame/ComponentManager.html#attr_triggers-class_method" title="FelFlame::ComponentManager.attr_triggers (method)">attr_triggers</a></span> - <small>FelFlame::ComponentManager</small> - </div> - </li> - - - <li class="even "> - <div class="item"> - <span class='object_link'><a href="FelFlame.html#call-class_method" title="FelFlame.call (method)">call</a></span> - <small>FelFlame</small> - </div> - </li> - - - <li class="odd "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Scenes.html#call-instance_method" title="FelFlame::Scenes#call (method)">#call</a></span> - <small>FelFlame::Scenes</small> - </div> - </li> - - - <li class="even "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Stage.html#call-class_method" title="FelFlame::Stage.call (method)">call</a></span> - <small>FelFlame::Stage</small> - </div> - </li> - - - <li class="odd "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Systems.html#call-instance_method" title="FelFlame::Systems#call (method)">#call</a></span> - <small>FelFlame::Systems</small> - </div> - </li> - - - <li class="even "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Scenes.html#clear-instance_method" title="FelFlame::Scenes#clear (method)">#clear</a></span> - <small>FelFlame::Scenes</small> - </div> - </li> - - - <li class="odd "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Stage.html#clear-class_method" title="FelFlame::Stage.clear (method)">clear</a></span> - <small>FelFlame::Stage</small> - </div> - </li> - - - <li class="even "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Systems.html#clear_triggers-instance_method" title="FelFlame::Systems#clear_triggers (method)">#clear_triggers</a></span> - <small>FelFlame::Systems</small> - </div> - </li> - - - <li class="odd "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Entities.html#component-instance_method" title="FelFlame::Entities#component (method)">#component</a></span> - <small>FelFlame::Entities</small> - </div> - </li> - - - <li class="even "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Entities.html#components-instance_method" title="FelFlame::Entities#components (method)">#components</a></span> - <small>FelFlame::Entities</small> - </div> - </li> - - - <li class="odd "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Systems.html#const_cache-class_method" title="FelFlame::Systems.const_cache (method)">const_cache</a></span> - <small>FelFlame::Systems</small> - </div> - </li> - - - <li class="even "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Entities.html#delete-instance_method" title="FelFlame::Entities#delete (method)">#delete</a></span> - <small>FelFlame::Entities</small> - </div> - </li> - - - <li class="odd "> - <div class="item"> - <span class='object_link'><a href="FelFlame/ComponentManager.html#delete-instance_method" title="FelFlame::ComponentManager#delete (method)">#delete</a></span> - <small>FelFlame::ComponentManager</small> - </div> - </li> - - - <li class="even "> - <div class="item"> - <span class='object_link'><a href="FelFlame/ComponentManager.html#entities-instance_method" title="FelFlame::ComponentManager#entities (method)">#entities</a></span> - <small>FelFlame::ComponentManager</small> - </div> - </li> - - - <li class="odd "> - <div class="item"> - <span class='object_link'><a href="FelFlame/ComponentManager.html#entity-instance_method" title="FelFlame::ComponentManager#entity (method)">#entity</a></span> - <small>FelFlame::ComponentManager</small> - </div> - </li> - - - <li class="even "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Scenes.html#initialize-instance_method" title="FelFlame::Scenes#initialize (method)">#initialize</a></span> - <small>FelFlame::Scenes</small> - </div> - </li> - - - <li class="odd "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Entities.html#initialize-instance_method" title="FelFlame::Entities#initialize (method)">#initialize</a></span> - <small>FelFlame::Entities</small> - </div> - </li> - - - <li class="even "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Systems.html#initialize-instance_method" title="FelFlame::Systems#initialize (method)">#initialize</a></span> - <small>FelFlame::Systems</small> - </div> - </li> - - - <li class="odd "> - <div class="item"> - <span class='object_link'><a href="FelFlame/ComponentManager.html#initialize-instance_method" title="FelFlame::ComponentManager#initialize (method)">#initialize</a></span> - <small>FelFlame::ComponentManager</small> - </div> - </li> - - - <li class="even "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Components.html#new-class_method" title="FelFlame::Components.new (method)">new</a></span> - <small>FelFlame::Components</small> - </div> - </li> - - - <li class="odd "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Scenes.html#priority-instance_method" title="FelFlame::Scenes#priority (method)">#priority</a></span> - <small>FelFlame::Scenes</small> - </div> - </li> - - - <li class="even "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Systems.html#priority-instance_method" title="FelFlame::Systems#priority (method)">#priority</a></span> - <small>FelFlame::Systems</small> - </div> - </li> - - - <li class="odd "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Systems.html#redefine-instance_method" title="FelFlame::Systems#redefine (method)">#redefine</a></span> - <small>FelFlame::Systems</small> - </div> - </li> - - - <li class="even "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Systems.html#removal_triggers-instance_method" title="FelFlame::Systems#removal_triggers (method)">#removal_triggers</a></span> - <small>FelFlame::Systems</small> - </div> - </li> - - - <li class="odd "> - <div class="item"> - <span class='object_link'><a href="FelFlame/ComponentManager.html#removal_triggers-instance_method" title="FelFlame::ComponentManager#removal_triggers (method)">#removal_triggers</a></span> - <small>FelFlame::ComponentManager</small> - </div> - </li> - - - <li class="even "> - <div class="item"> - <span class='object_link'><a href="FelFlame/ComponentManager.html#removal_triggers-class_method" title="FelFlame::ComponentManager.removal_triggers (method)">removal_triggers</a></span> - <small>FelFlame::ComponentManager</small> - </div> - </li> - - - <li class="odd "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Scenes.html#remove-instance_method" title="FelFlame::Scenes#remove (method)">#remove</a></span> - <small>FelFlame::Scenes</small> - </div> - </li> - - - <li class="even "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Stage.html#remove-class_method" title="FelFlame::Stage.remove (method)">remove</a></span> - <small>FelFlame::Stage</small> - </div> - </li> - - - <li class="odd "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Entities.html#remove-instance_method" title="FelFlame::Entities#remove (method)">#remove</a></span> - <small>FelFlame::Entities</small> - </div> - </li> - - - <li class="even "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Stage.html#scenes-class_method" title="FelFlame::Stage.scenes (method)">scenes</a></span> - <small>FelFlame::Stage</small> - </div> - </li> - - - <li class="odd "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Systems.html#scenes-instance_method" title="FelFlame::Systems#scenes (method)">#scenes</a></span> - <small>FelFlame::Systems</small> - </div> - </li> - - - <li class="even "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Order.html#sort-class_method" title="FelFlame::Order.sort (method)">sort</a></span> - <small>FelFlame::Order</small> - </div> - </li> - - - <li class="odd "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Scenes.html#systems-instance_method" title="FelFlame::Scenes#systems (method)">#systems</a></span> - <small>FelFlame::Scenes</small> - </div> - </li> - - - <li class="even "> - <div class="item"> - <span class='object_link'><a href="FelFlame/ComponentManager.html#to_h-instance_method" title="FelFlame::ComponentManager#to_h (method)">#to_h</a></span> - <small>FelFlame::ComponentManager</small> - </div> - </li> - - - <li class="odd "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Systems.html#trigger_when_added-instance_method" title="FelFlame::Systems#trigger_when_added (method)">#trigger_when_added</a></span> - <small>FelFlame::Systems</small> - </div> - </li> - - - <li class="even "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Systems.html#trigger_when_is_changed-instance_method" title="FelFlame::Systems#trigger_when_is_changed (method)">#trigger_when_is_changed</a></span> - <small>FelFlame::Systems</small> - </div> - </li> - - - <li class="odd "> - <div class="item"> - <span class='object_link'><a href="FelFlame/Systems.html#trigger_when_removed-instance_method" title="FelFlame::Systems#trigger_when_removed (method)">#trigger_when_removed</a></span> - <small>FelFlame::Systems</small> - </div> - </li> - - - <li class="even "> - <div class="item"> - <span class='object_link'><a href="FelFlame/ComponentManager.html#update_attrs-instance_method" title="FelFlame::ComponentManager#update_attrs (method)">#update_attrs</a></span> - <small>FelFlame::ComponentManager</small> - </div> - </li> - - </ul> </div> diff --git a/docs/top-level-namespace.html b/docs/top-level-namespace.html index cc16af8..6ab8ca4 100644 --- a/docs/top-level-namespace.html +++ b/docs/top-level-namespace.html @@ -78,43 +78,6 @@ </div> -<h2>Defined Under Namespace</h2> -<p class="children"> - - - <strong class="modules">Modules:</strong> <span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span>, <span class='object_link'><a href="Felflame_.html" title="Felflame (module)">Felflame</a></span> - - - - -</p> - - - <h2> - Constant Summary - <small><a href="#" class="constants_summary_toggle">collapse</a></small> - </h2> - - <dl class="constants"> - - <dt id="FF-constant" class="">FF = - <div class="docstring"> - <div class="discussion"> - -<p>An alias for <span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></p> - - - </div> -</div> -<div class="tags"> - - -</div> - </dt> - <dd><pre class="code"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span></pre></dd> - - </dl> - @@ -127,7 +90,7 @@ </div> <div id="footer"> - Generated on Mon Jan 3 08:23:04 2022 by + Generated on Thu Jan 20 22:40:31 2022 by <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.26 (ruby-2.7.3). </div> diff --git a/felflame.gemspec b/felecs.gemspec index 6f26e6f..6fe379a 100644 --- a/felflame.gemspec +++ b/felecs.gemspec @@ -1,10 +1,10 @@ # frozen_string_literal: true -require_relative 'lib/felflame/version' +require_relative 'lib/felecs/version' Gem::Specification.new do |spec| - spec.name = 'felflame' - spec.version = Felflame::VERSION + spec.name = 'felecs' + spec.version = FelECS::VERSION spec.authors = ['Tradam'] spec.email = ['[email protected]'] diff --git a/lib/felflame.rb b/lib/felecs.rb index 21a6eaf..e00c9d2 100644 --- a/lib/felflame.rb +++ b/lib/felecs.rb @@ -1,22 +1,22 @@ # frozen_string_literal: true -require_relative 'felflame/entity_manager' -require_relative 'felflame/component_manager' -require_relative 'felflame/system_manager' -require_relative 'felflame/scene_manager' -require_relative 'felflame/stage_manager' -require_relative 'felflame/order' +require_relative 'felecs/entity_manager' +require_relative 'felecs/component_manager' +require_relative 'felecs/system_manager' +require_relative 'felecs/scene_manager' +require_relative 'felecs/stage_manager' +require_relative 'felecs/order' -require_relative 'felflame/version' +require_relative 'felecs/version' -# The FelFlame namespace where all its functionality resides under. -module FelFlame +# The FelECS namespace where all its functionality resides under. +module FelECS class << self # :nocov: - # An alias for {FelFlame::Stage.call}. It executes a single frame in the game. + # An alias for {FelECS::Stage.call}. It executes a single frame in the game. def call - FelFlame::Stage.call + FelECS::Stage.call end # :nocov: end @@ -25,17 +25,17 @@ module FelFlame # You can use array methods directly on this class to access Entities. class Entities; end - # Creates component managers and allows accessing them them under the {FelFlame::Components} namespace as Constants. + # Creates component managers and allows accessing them them under the {FelECS::Components} namespace as Constants. # You can use array methods directly on this class to access Component Managers. # - # To see how component managers are used please look at the {FelFlame::ComponentManager} documentation. + # To see how component managers are used please look at the {FelECS::ComponentManager} documentation. module Components; end - # Creates and manages Systems. Systems are the logic of the game and do not contain any data within them. Any systems you create are accessable under the {FelFlame::Systems} namespace as Constants. + # Creates and manages Systems. Systems are the logic of the game and do not contain any data within them. Any systems you create are accessable under the {FelECS::Systems} namespace as Constants. # You can use array methods directly on this class to access Systems. class Systems; end - # Creates and manages Scenes. Scenes are collections of Systems, and execute all the Systems when called upon. Any scenes you create are accessable under the {FelFlame::Scenes} namespace as Constants. + # Creates and manages Scenes. Scenes are collections of Systems, and execute all the Systems when called upon. Any scenes you create are accessable under the {FelECS::Scenes} namespace as Constants. class Scenes; end # Stores Scenes you add to it which you want to execute on each frame. When called upon will execute all Systems in the Scenes in the Stage and will execute them according to their priority order. @@ -45,23 +45,23 @@ module FelFlame module Order; end end -# An alias for {FelFlame} -FF = FelFlame +# An alias for {FelECS} +FECS = FelECS -# An alias for {FelFlame::Entities} -FF::Ent = FelFlame::Entities +# An alias for {FelECS::Entities} +FECS::Ent = FelECS::Entities -# An alias for {FelFlame::Components} -FF::Cmp = FelFlame::Components +# An alias for {FelECS::Components} +FECS::Cmp = FelECS::Components -# An alias for {FelFlame::Systems} -FF::Sys = FelFlame::Systems +# An alias for {FelECS::Systems} +FECS::Sys = FelECS::Systems -# An alias for {FelFlame::Scenes} -FF::Scn = FelFlame::Scenes +# An alias for {FelECS::Scenes} +FECS::Scn = FelECS::Scenes -# An alias for {FelFlame::Stage} -FF::Stg = FelFlame::Stage +# An alias for {FelECS::Stage} +FECS::Stg = FelECS::Stage -# An alias for {FelFlame:: -FF::Odr = FelFlame::Order +# An alias for {FelECS:: +FECS::Odr = FelECS::Order diff --git a/lib/felflame/component_manager.rb b/lib/felecs/component_manager.rb index 6ac7463..36916cb 100644 --- a/lib/felflame/component_manager.rb +++ b/lib/felecs/component_manager.rb @@ -1,55 +1,55 @@ # frozen_string_literal: true -module FelFlame +module FelECS module Components @component_map = [] class << self - # Creates a new {FelFlame::ComponentManager component manager}. + # Creates a new {FelECS::ComponentManager component manager}. # # @example # # Here color is set to default to red # # while max and current are nil until set. # # When you make a new component using this component manager # # these are the values and accessors it will have. - # FelFlame::Component.new('Health', :max, :current, color: 'red') + # FelECS::Component.new('Health', :max, :current, color: 'red') # # @param component_name [String] Name of your new component manager. Must be stylized in the format of constants in Ruby # @param attrs [:Symbols] New components made with this manager will include these symbols as accessors, the values of these accessors will default to nil # @param attrs_with_defaults [Keyword: DefaultValue] New components made with this manager will include these keywords as accessors, their defaults set to the values given to the keywords # @return [ComponentManager] def new(component_name, *attrs, **attrs_with_defaults) - if FelFlame::Components.const_defined?(component_name) + if FelECS::Components.const_defined?(component_name) raise(NameError.new, "Component Manager '#{component_name}' is already defined") end - const_set(component_name, Class.new(FelFlame::ComponentManager) {}) + const_set(component_name, Class.new(FelECS::ComponentManager) {}) update_const_cache attrs.each do |attr| - if FelFlame::Components.const_get(component_name).method_defined?(attr.to_s) || FelFlame::Components.const_get(component_name).method_defined?("#{attr}=") + if FelECS::Components.const_get(component_name).method_defined?(attr.to_s) || FelECS::Components.const_get(component_name).method_defined?("#{attr}=") raise NameError, "The attribute name \"#{attr}\" is already a method" end - FelFlame::Components.const_get(component_name).attr_accessor attr + FelECS::Components.const_get(component_name).attr_accessor attr end attrs_with_defaults.each do |attr, _default| attrs_with_defaults[attr] = _default.dup - FelFlame::Components.const_get(component_name).attr_reader attr - FelFlame::Components.const_get(component_name).define_method("#{attr}=") do |value| + FelECS::Components.const_get(component_name).attr_reader attr + FelECS::Components.const_get(component_name).define_method("#{attr}=") do |value| attr_changed_trigger_systems(attr) unless value.equal? send(attr) instance_variable_set("@#{attr}", value) end end - FelFlame::Components.const_get(component_name).define_method(:set_defaults) do + FelECS::Components.const_get(component_name).define_method(:set_defaults) do attrs_with_defaults.each do |attr, default| instance_variable_set("@#{attr}", default.dup) end end - FelFlame::Components.const_get(component_name) + FelECS::Components.const_get(component_name) end - # Stores the components managers in {FelFlame::Components}. This - # is needed because calling `FelFlame::Components.constants` + # Stores the components managers in {FelECS::Components}. This + # is needed because calling `FelECS::Components.constants` # will not let you iterate over the value of the constants # but will instead give you an array of symbols. This caches # the convertion of those symbols to the actual value of the @@ -60,7 +60,7 @@ module FelFlame end # Updates the array that stores the constants. - # Used internally by FelFlame + # Used internally by FelECS # @!visibility private def update_const_cache @const_cache = constants.map do |constant| @@ -104,7 +104,7 @@ module FelFlame # Stores references to systems that should be triggered when a # component from this manager is added. - # Do not edit this array as it is managed by FelFlame automatically. + # Do not edit this array as it is managed by FelECS automatically. # @return [Array<System>] def addition_triggers @addition_triggers ||= [] @@ -112,7 +112,7 @@ module FelFlame # Stores references to systems that should be triggered when a # component from this manager is removed. - # Do not edit this array as it is managed by FelFlame automatically. + # Do not edit this array as it is managed by FelECS automatically. # @return [Array<System>] def removal_triggers @removal_triggers ||= [] @@ -120,7 +120,7 @@ module FelFlame # Stores references to systems that should be triggered when an # attribute from this manager is changed. - # Do not edit this hash as it is managed by FelFlame automatically. + # Do not edit this hash as it is managed by FelECS automatically. # @return [Hash<Symbol, Array<System>>] def attr_triggers @attr_triggers ||= {} @@ -132,7 +132,7 @@ module FelFlame def initialize(**attrs) # Prepare the object # (this is a function created with metaprogramming - # in FelFlame::Components) + # in FelECS::Components) set_defaults # Fill params @@ -175,7 +175,7 @@ module FelFlame # Stores references to systems that should be triggered when this # component is added to an enitity. - # Do not edit this array as it is managed by FelFlame automatically. + # Do not edit this array as it is managed by FelECS automatically. # @return [Array<System>] def addition_triggers @addition_triggers ||= [] @@ -183,7 +183,7 @@ module FelFlame # Stores references to systems that should be triggered when this # component is removed from an enitity. - # Do not edit this array as it is managed by FelFlame automatically. + # Do not edit this array as it is managed by FelECS automatically. # @return [Array<System>] def removal_triggers @removal_triggers ||= [] @@ -191,7 +191,7 @@ module FelFlame # Stores references to systems that should be triggered when an # attribute from this component changed. - # Do not edit this hash as it is managed by FelFlame automatically. + # Do not edit this hash as it is managed by FelECS automatically. # @return [Hash<Symbol, System>] def attr_triggers @attr_triggers ||= {} diff --git a/lib/felflame/entity_manager.rb b/lib/felecs/entity_manager.rb index ef70510..a457ed2 100644 --- a/lib/felflame/entity_manager.rb +++ b/lib/felecs/entity_manager.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module FelFlame +module FelECS class Entities # Creating a new Entity # @param components [Components] Can be any number of components, identical duplicates will be automatically purged however different components from the same component manager are allowed. @@ -25,8 +25,8 @@ module FelFlame # @return [Component] def component(manager = nil) if manager.nil? - FelFlame::Entities.component_redirect.entity = self - FelFlame::Entities.component_redirect + FelECS::Entities.component_redirect.entity = self + FelECS::Entities.component_redirect else if components[manager].nil? raise "This entity(#{self}) doesnt have any components of this type: #{manager}" @@ -46,7 +46,7 @@ module FelFlame component.entities.delete(self) end end - FelFlame::Entities._data.delete self + FelECS::Entities._data.delete self @components = {} true end @@ -152,8 +152,8 @@ module FelFlame # Creates a new entity using the data from a JSON string # TODO: This function is not yet complete - # @param json_string [String] A string that was exported originally using the {FelFlame::Entities#to_json to_json} function - # @param opts [Keywords] What values(its {FelFlame::Entities#id ID} or the {FelFlame::ComponentManager#id component IDs}) should be overwritten TODO: this might change + # @param json_string [String] A string that was exported originally using the {FelECS::Entities#to_json to_json} function + # @param opts [Keywords] What values(its {FelECS::Entities#id ID} or the {FelECS::ComponentManager#id component IDs}) should be overwritten TODO: this might change # def from_json(json_string, **opts) end end end diff --git a/lib/felflame/order.rb b/lib/felecs/order.rb index c11438d..3e9b656 100644 --- a/lib/felflame/order.rb +++ b/lib/felecs/order.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module FelFlame +module FelECS module Order # Sets the priority of all items passed into this method # according to the order they were passed. diff --git a/lib/felflame/scene_manager.rb b/lib/felecs/scene_manager.rb index 0024815..af61b9c 100644 --- a/lib/felflame/scene_manager.rb +++ b/lib/felecs/scene_manager.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module FelFlame +module FelECS class Scenes # Allows overwriting the storage of systems, such as for clearing. # This method should generally only need to be used internally and @@ -13,7 +13,7 @@ module FelFlame def priority=(priority) @priority = priority - FelFlame::Stage.scenes = FelFlame::Stage.scenes.sort_by(&:priority) + FelECS::Stage.scenes = FelECS::Stage.scenes.sort_by(&:priority) priority end @@ -21,7 +21,7 @@ module FelFlame # @param name [String] String format must follow requirements of a constant def initialize(name, priority: 0) self.priority = priority - FelFlame::Scenes.const_set(name, self) + FelECS::Scenes.const_set(name, self) end # The list of Systems this Scene contains @@ -62,7 +62,7 @@ module FelFlame system.scenes.delete self end systems.clear - # FelFlame::Stage.update_systems_list if FelFlame::Stage.scenes.include? self + # FelECS::Stage.update_systems_list if FelECS::Stage.scenes.include? self true end end diff --git a/lib/felflame/stage_manager.rb b/lib/felecs/stage_manager.rb index a192b67..b2a5b7c 100644 --- a/lib/felflame/stage_manager.rb +++ b/lib/felecs/stage_manager.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -module FelFlame +module FelECS module Stage class << self # Allows clearing of scenes and systems. - # Used internally by FelFlame and shouldn't need to be ever used by developers + # Used internally by FelECS and shouldn't need to be ever used by developers # @!visibility private attr_writer :scenes diff --git a/lib/felflame/system_manager.rb b/lib/felecs/system_manager.rb index 8982589..6cd260b 100644 --- a/lib/felflame/system_manager.rb +++ b/lib/felecs/system_manager.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module FelFlame +module FelECS class Systems # How early this System should be executed in a list of Systems attr_accessor :priority @@ -30,7 +30,7 @@ module FelFlame # Stores references to components or their managers that trigger # this component when a component or component from that manager # is added to an entity. - # Do not edit this hash as it is managed by FelFlame automatically. + # Do not edit this hash as it is managed by FelECS automatically. # @return [Array<Component>] def addition_triggers @addition_triggers ||= [] @@ -39,7 +39,7 @@ module FelFlame # Stores references to components or their managers that trigger # this component when a component or component from that manager # is removed from an entity. - # Do not edit this hash as it is managed by FelFlame automatically. + # Do not edit this hash as it is managed by FelECS automatically. # @return [Array<Component>] def removal_triggers @removal_triggers ||= [] @@ -47,15 +47,15 @@ module FelFlame # Stores references to systems that should be triggered when an # attribute from this manager is changed - # Do not edit this hash as it is managed by FelFlame automatically. + # Do not edit this hash as it is managed by FelECS automatically. # @return [Hash<Symbol, Array<Symbol>>] def attr_triggers @attr_triggers ||= {} end class << self - # Stores the systems in {FelFlame::Components}. This - # is needed because calling `FelFlame::Components.constants` + # Stores the systems in {FelECS::Components}. This + # is needed because calling `FelECS::Components.constants` # will not let you iterate over the value of the constants # but will instead give you an array of symbols. This caches # the convertion of those symbols to the actual value of the @@ -65,7 +65,7 @@ module FelFlame end # Updates the array that stores the constants. - # Used internally by FelFlame + # Used internally by FelECS # @!visibility private def update_const_cache @const_cache = constants.map do |constant| @@ -97,12 +97,12 @@ module FelFlame end end - # Creates a new System which can be accessed as a constant under the namespace {FelFlame::Systems}. + # Creates a new System which can be accessed as a constant under the namespace {FelECS::Systems}. # The name given is what constant the system is assigned to # # @example - # FelFlame::Systems.new('PassiveHeal', priority: -2) do - # FelFlame::Components::Health.each do |component| + # FelECS::Systems.new('PassiveHeal', priority: -2) do + # FelECS::Components::Health.each do |component| # component.hp += 5 # end # end @@ -113,8 +113,8 @@ module FelFlame # @param priority [Integer] Which priority order this system should be executed in relative to other systems. Higher means executed earlier. # @param block [Proc] The code you wish to be executed when the system is triggered. Can be defined by using a +do end+ block or using +{ }+ braces. def initialize(name, priority: 0, &block) - FelFlame::Systems.const_set(name, self) - FelFlame::Systems.update_const_cache + FelECS::Systems.const_set(name, self) + FelECS::Systems.update_const_cache @priority = priority @block = block @scenes = [] @@ -138,19 +138,19 @@ module FelFlame # For attr_triggers # @example # # To clear all triggers that execute this system when a component is added: - # FelFlame::Systems::ExampleSystem.clear_triggers :addition_triggers + # FelECS::Systems::ExampleSystem.clear_triggers :addition_triggers # # Same as above but for when a component is removed instead - # FelFlame::Systems::ExampleSystem.clear_triggers :removal_triggers + # FelECS::Systems::ExampleSystem.clear_triggers :removal_triggers # # Same as above but for when a component has a certain attribute changed - # FelFlame::Systems::ExampleSystem.clear_triggers :attr_triggers + # FelECS::Systems::ExampleSystem.clear_triggers :attr_triggers # # # Clear a trigger from a specific component - # FelFlame::Systems::ExampleSystem.clear_triggers :addition_triggers, FelFlame::Component::ExampleComponent[0] + # FelECS::Systems::ExampleSystem.clear_triggers :addition_triggers, FelECS::Component::ExampleComponent[0] # # Clear a trigger from a specific component manager - # FelFlame::Systems::ExampleSystem.clear_triggers :addition_triggers, FelFlame::Component::ExampleComponent + # FelECS::Systems::ExampleSystem.clear_triggers :addition_triggers, FelECS::Component::ExampleComponent # # # Clear the trigger that executes a system when the ':example_attr' is changes - # FelFlame::Systems::ExampleSystem.clear_triggers :attr_triggers, :example_attr + # FelECS::Systems::ExampleSystem.clear_triggers :attr_triggers, :example_attr # @param trigger_types [:Symbols] One or more of the following trigger types: +:addition_triggers+, +:removal_triggers+, or +:attr_triggers+. If attr_triggers is used then you may pass attributes you wish to be cleared as symbols in this parameter as well # @param component_or_manager [Component or ComponentManager] The object to clear triggers from. Use Nil to clear triggers from all components associated with this system. # @return [Boolean] +true+ @@ -159,28 +159,28 @@ module FelFlame if trigger_types.include? :attr_triggers if (trigger_types - %i[addition_triggers - removal_triggers - attr_triggers]).empty? + removal_triggers + attr_triggers]).empty? - if component_or_manager.nil? - # remove all attrs - attr_triggers.each do |cmp_or_mgr, attrs| - attrs.each do |attr| - next if cmp_or_mgr.attr_triggers[attr].nil? + if component_or_manager.nil? + # remove all attrs + attr_triggers.each do |cmp_or_mgr, attrs| + attrs.each do |attr| + next if cmp_or_mgr.attr_triggers[attr].nil? - cmp_or_mgr.attr_triggers[attr].delete self + cmp_or_mgr.attr_triggers[attr].delete self + end + self.attr_triggers = {} end - self.attr_triggers = {} - end - else - # remove attrs relevant to comp_or_man - unless attr_triggers[component_or_manager].nil? - attr_triggers[component_or_manager].each do |attr| - component_or_manager.attr_triggers[attr].delete self + else + # remove attrs relevant to comp_or_man + unless attr_triggers[component_or_manager].nil? + attr_triggers[component_or_manager].each do |attr| + component_or_manager.attr_triggers[attr].delete self + end + attr_triggers[component_or_manager] = [] end - attr_triggers[component_or_manager] = [] end - end elsif component_or_manager.nil? @@ -191,8 +191,8 @@ module FelFlame end end attr_triggers.delete(trigger_types - %i[addition_triggers - removal_triggers - attr_triggers]) + removal_triggers + attr_triggers]) else # remove attr from component_or_manager (trigger_types - %i[addition_triggers removal_triggers attr_triggers]).each do |attr| diff --git a/lib/felflame/version.rb b/lib/felecs/version.rb index 9f7f09e..295b905 100644 --- a/lib/felflame/version.rb +++ b/lib/felecs/version.rb @@ -2,8 +2,8 @@ # :nocov: # Keeps the version of the Gem -module Felflame +module FelECS # The version of the Gem - VERSION = '4.0.0' + VERSION = '5.0.0' end # :nocov: diff --git a/logos/felecs-logo-text.png.png b/logos/felecs-logo-text.png Binary files differindex cf17250..cf17250 100644 --- a/logos/felecs-logo-text.png.png +++ b/logos/felecs-logo-text.png diff --git a/spec/component_manager_spec.rb b/spec/component_manager_spec.rb index 9bf9b9e..bd1df38 100644 --- a/spec/component_manager_spec.rb +++ b/spec/component_manager_spec.rb @@ -1,22 +1,22 @@ # frozen_string_literal: true -require_relative '../lib/felflame' +require_relative '../lib/felecs' describe 'Components' do # let :component_manager do - # @component_manager ||= FelFlame::Components.new('TestComponents', :param1, param2: 'def') + # @component_manager ||= FelECS::Components.new('TestComponents', :param1, param2: 'def') # end before :all do - @component_manager ||= FelFlame::Components.new('TestComponents', :param1, param2: 'def') + @component_manager ||= FelECS::Components.new('TestComponents', :param1, param2: 'def') end before :each do @orig_stderr = $stderr $stderr = StringIO.new - @ent0 = FelFlame::Entities.new - @ent1 = FelFlame::Entities.new - @ent2 = FelFlame::Entities.new + @ent0 = FelECS::Entities.new + @ent1 = FelECS::Entities.new + @ent2 = FelECS::Entities.new @cmp0 = @component_manager.new @cmp1 = @component_manager.new @cmp2 = @component_manager.new @@ -24,7 +24,7 @@ describe 'Components' do after :each do $stderr = @orig_stderr - FelFlame::Entities.reverse_each(&:delete) + FelECS::Entities.reverse_each(&:delete) @component_manager.reverse_each(&:delete) end @@ -57,19 +57,19 @@ describe 'Components' do end it 'Component module responds to array methods' do - expect(FelFlame::Components.respond_to?(:[])).to be true - expect(FelFlame::Components.respond_to?(:each)).to be true - FelFlame::Components.each do |component_manager| + expect(FelECS::Components.respond_to?(:[])).to be true + expect(FelECS::Components.respond_to?(:each)).to be true + FelECS::Components.each do |component_manager| expect(component_manager.respond_to?(:addition_triggers)).to be true end - expect(FelFlame::Components.respond_to?(:filter)).to be true - expect(FelFlame::Components.respond_to?(:first)).to be true - expect(FelFlame::Components.respond_to?(:last)).to be true - expect(FelFlame::Components.respond_to?(:somethingwrong)).to be false + expect(FelECS::Components.respond_to?(:filter)).to be true + expect(FelECS::Components.respond_to?(:first)).to be true + expect(FelECS::Components.respond_to?(:last)).to be true + expect(FelECS::Components.respond_to?(:somethingwrong)).to be false end it 'Component module doesnt respond to missing methods' do - expect { FelFlame::Components.somethingwrong }.to raise_error(NoMethodError) + expect { FelECS::Components.somethingwrong }.to raise_error(NoMethodError) end it 'can delete a component' do @@ -84,13 +84,13 @@ describe 'Components' do end it 'can iterate component managers' do - all_components_symbols = FelFlame::Components.constants + all_components_symbols = FelECS::Components.constants all_components = all_components_symbols.map do |symbol| - FelFlame::Components.const_get symbol + FelECS::Components.const_get symbol end - expect(all_components).to eq(FF::Components.each.to_a) + expect(all_components).to eq(FelECS::Components.each.to_a) expect(all_components.length).to be > 0 - expect(FelFlame::Components.each).to be_an Enumerator + expect(FelECS::Components.each).to be_an Enumerator end it 'can change params on initialization' do @@ -130,15 +130,15 @@ describe 'Components' do end it 'cant overwrite exiting component managers' do - FelFlame::Components.new('TestComponent1') - expect { FelFlame::Components.new('TestComponent1') }.to raise_error(NameError) + FelECS::Components.new('TestComponent1') + expect { FelECS::Components.new('TestComponent1') }.to raise_error(NameError) end it 'can\'t create an attribute when its name is an existing method' do - # expect { FelFlame::Components.new('TestComponent2', :id) }.to raise_error(NameError) - expect { FelFlame::Components.new('TestComponent2', :addition_triggers) }.to raise_error(NameError) - expect { FelFlame::Components.new('TestComponent2', :removal_triggers) }.to raise_error(NameError) - expect { FelFlame::Components.new('TestComponent2', :attr_triggers) }.to raise_error(NameError) - expect { FelFlame::Components.new('TestComponent3', :same, :same) }.to raise_error(NameError) + # expect { FelECS::Components.new('TestComponent2', :id) }.to raise_error(NameError) + expect { FelECS::Components.new('TestComponent2', :addition_triggers) }.to raise_error(NameError) + expect { FelECS::Components.new('TestComponent2', :removal_triggers) }.to raise_error(NameError) + expect { FelECS::Components.new('TestComponent2', :attr_triggers) }.to raise_error(NameError) + expect { FelECS::Components.new('TestComponent3', :same, :same) }.to raise_error(NameError) end end diff --git a/spec/entity_manager_spec.rb b/spec/entity_manager_spec.rb index 2068986..25afa45 100644 --- a/spec/entity_manager_spec.rb +++ b/spec/entity_manager_spec.rb @@ -1,21 +1,21 @@ # frozen_string_literal: true -require_relative '../lib/felflame' +require_relative '../lib/felecs' # class EntitiesTest < Minitest::Test describe 'Entities' do before :all do $VERBOSE = nil - @component_manager ||= FelFlame::Components.new('TestEntity', :param1, param2: 'def') + @component_manager ||= FelECS::Components.new('TestEntity', :param1, param2: 'def') end before :each do @orig_stderr = $stderr $stderr = StringIO.new - @ent0 = FelFlame::Entities.new - @ent1 = FelFlame::Entities.new - @ent2 = FelFlame::Entities.new + @ent0 = FelECS::Entities.new + @ent1 = FelECS::Entities.new + @ent2 = FelECS::Entities.new @cmp0 = @component_manager.new @cmp1 = @component_manager.new @cmp2 = @component_manager.new @@ -23,7 +23,7 @@ describe 'Entities' do after :each do $stderr = @orig_stderr - FelFlame::Entities.reverse_each(&:delete) + FelECS::Entities.reverse_each(&:delete) @component_manager.reverse_each(&:delete) end @@ -43,19 +43,19 @@ describe 'Entities' do end it 'responds to array methods' do - expect(FelFlame::Entities.respond_to?(:[])).to be true - expect(FelFlame::Entities.respond_to?(:each)).to be true - FelFlame::Entities.each do |entity| + expect(FelECS::Entities.respond_to?(:[])).to be true + expect(FelECS::Entities.respond_to?(:each)).to be true + FelECS::Entities.each do |entity| expect(entity.respond_to?(:components)).to be true end - expect(FelFlame::Entities.respond_to?(:filter)).to be true - expect(FelFlame::Entities.respond_to?(:first)).to be true - expect(FelFlame::Entities.respond_to?(:last)).to be true - expect(FelFlame::Entities.respond_to?(:somethingwrong)).to be false + expect(FelECS::Entities.respond_to?(:filter)).to be true + expect(FelECS::Entities.respond_to?(:first)).to be true + expect(FelECS::Entities.respond_to?(:last)).to be true + expect(FelECS::Entities.respond_to?(:somethingwrong)).to be false end it 'dont respond to missing methods' do - expect { FelFlame::Entities.somethingwrong }.to raise_error(NoMethodError) + expect { FelECS::Entities.somethingwrong }.to raise_error(NoMethodError) end it 'won\'t add duplicate entities' do @@ -64,9 +64,9 @@ describe 'Entities' do end it 'can be accessed' do - expect(FelFlame::Entities[0].respond_to?(:components)).to eq(true) - expect(FelFlame::Entities[1].respond_to?(:components)).to eq(true) - expect(FelFlame::Entities[2].respond_to?(:components)).to eq(true) + expect(FelECS::Entities[0].respond_to?(:components)).to eq(true) + expect(FelECS::Entities[1].respond_to?(:components)).to eq(true) + expect(FelECS::Entities[2].respond_to?(:components)).to eq(true) end it 'can have components attached' do @@ -108,7 +108,7 @@ describe 'Entities' do expect(@component_manager.empty?).to be true expect(@ent0.components).to eq({}) expect(@ent2.components).to eq({}) - FelFlame::Entities.reverse_each(&:delete) - expect(FelFlame::Entities.empty?).to be true + FelECS::Entities.reverse_each(&:delete) + expect(FelECS::Entities.empty?).to be true end end diff --git a/spec/order_spec.rb b/spec/order_spec.rb index fd104fc..0d89f15 100644 --- a/spec/order_spec.rb +++ b/spec/order_spec.rb @@ -1,24 +1,24 @@ # frozen_string_literal: true -require_relative '../lib/felflame' +require_relative '../lib/felecs' # class EntitiesTest < Minitest::Test describe 'Order' do before :all do @result = [] - @system0 = FelFlame::Systems.new('System1', priority: 0) do + @system0 = FelECS::Systems.new('System1', priority: 0) do @result.push 0 end - @system2 = FelFlame::Systems.new('System3', priority: 2) do + @system2 = FelECS::Systems.new('System3', priority: 2) do @result.push 2 end - @system1 = FelFlame::Systems.new('System2', priority: 1) do + @system1 = FelECS::Systems.new('System2', priority: 1) do @result.push 1 end - @scene1 = FelFlame::Scenes.new('Scene0', priority: 1) - @scene0 = FelFlame::Scenes.new('Scene0', priority: 0) + @scene1 = FelECS::Scenes.new('Scene0', priority: 1) + @scene0 = FelECS::Scenes.new('Scene0', priority: 0) end before :each do @@ -38,7 +38,7 @@ describe 'Order' do it 'can sort Scenes' do @scene0.add @system0 @scene1.add @system1 - FelFlame::Order.sort( + FelECS::Order.sort( @scene1, @scene0 ) @@ -47,7 +47,7 @@ describe 'Order' do it 'can sort Systems' do @scene0.add @system0, @system1, @system2 - FelFlame::Order.sort( + FelECS::Order.sort( @system2, @system0, @system1 @@ -57,7 +57,7 @@ describe 'Order' do end it 'can handle array' do - FelFlame::Order.sort( + FelECS::Order.sort( @system0, [ @system1, diff --git a/spec/scene_manager_spec.rb b/spec/scene_manager_spec.rb index e1984dc..51d74ef 100644 --- a/spec/scene_manager_spec.rb +++ b/spec/scene_manager_spec.rb @@ -1,28 +1,28 @@ # frozen_string_literal: true -require_relative '../lib/felflame' +require_relative '../lib/felecs' # class EntitiesTest < Minitest::Test describe 'Scenes' do before :all do - @component_manager ||= FelFlame::Components.new('TestScenes', order: []) - @system2 = FelFlame::Systems.new('Test', priority: 2) do + @component_manager ||= FelECS::Components.new('TestScenes', order: []) + @system2 = FelECS::Systems.new('Test', priority: 2) do @component_manager.each do |component| component.order.push 2 end end - @system1 = FelFlame::Systems.new('Mana', priority: 1) do + @system1 = FelECS::Systems.new('Mana', priority: 1) do @component_manager.each do |component| component.order.push 1 end end - @system3 = FelFlame::Systems.new('Spell', priority: 3) do + @system3 = FelECS::Systems.new('Spell', priority: 3) do @component_manager.each do |component| component.order.push 3 end end - @scene = FelFlame::Scenes.new('TestScene') + @scene = FelECS::Scenes.new('TestScene') end before :each do @@ -30,7 +30,7 @@ describe 'Scenes' do end after :each do - FelFlame::Entities.each(&:delete) + FelECS::Entities.each(&:delete) @component_manager.each(&:delete) @scene.clear end diff --git a/spec/stage_manager_spec.rb b/spec/stage_manager_spec.rb index 16f9080..928f4c1 100644 --- a/spec/stage_manager_spec.rb +++ b/spec/stage_manager_spec.rb @@ -1,27 +1,27 @@ # frozen_string_literal: true -require_relative '../lib/felflame' +require_relative '../lib/felecs' # class EntitiesTest < Minitest::Test describe 'Stage' do before :all do - @component_manager ||= FelFlame::Components.new('TestStage', order: []) - @system2 = FelFlame::Systems.new('StageTest', priority: 1) do + @component_manager ||= FelECS::Components.new('TestStage', order: []) + @system2 = FelECS::Systems.new('StageTest', priority: 1) do @component_manager.first.order.push 2 end - @system1 = FelFlame::Systems.new('StageMana', priority: 3) do + @system1 = FelECS::Systems.new('StageMana', priority: 3) do @component_manager.first.order.push 1 end - @system3 = FelFlame::Systems.new('StageSpell', priority: 2) do + @system3 = FelECS::Systems.new('StageSpell', priority: 2) do @scene1.add @system1 @scene2.add @system2 @scene3.add @system3 @component_manager.first.order.push 3 end - @scene1 = FelFlame::Scenes.new('TestStage1', priority: 1) - @scene2 = FelFlame::Scenes.new('TestStage2', priority: 2) - @scene3 = FelFlame::Scenes.new('TestStage3', priority: 3) + @scene1 = FelECS::Scenes.new('TestStage1', priority: 1) + @scene2 = FelECS::Scenes.new('TestStage2', priority: 2) + @scene3 = FelECS::Scenes.new('TestStage3', priority: 3) end before :each do @@ -29,37 +29,37 @@ describe 'Stage' do end after :each do - FelFlame::Entities.reverse_each(&:delete) + FelECS::Entities.reverse_each(&:delete) @component_manager.reverse_each(&:delete) @scene1.clear @scene2.clear @scene3.clear - FelFlame::Stage.clear + FelECS::Stage.clear end it 'can add Scenes' do - FelFlame::Stage.add @scene2, @scene1, @scene3 - expect(FelFlame::Stage.scenes).to eq([@scene1, @scene2, @scene3]) + FelECS::Stage.add @scene2, @scene1, @scene3 + expect(FelECS::Stage.scenes).to eq([@scene1, @scene2, @scene3]) end it 'can remove Scenes' do - FelFlame::Stage.add @scene1, @scene2, @scene3 - FelFlame::Stage.remove @scene1, @scene3 - expect(FelFlame::Stage.scenes).to eq([@scene2]) + FelECS::Stage.add @scene1, @scene2, @scene3 + FelECS::Stage.remove @scene1, @scene3 + expect(FelECS::Stage.scenes).to eq([@scene2]) end it 'can clear Scenes' do - FelFlame::Stage.add @scene1, @scene2, @scene3 - FelFlame::Stage.clear - expect(FelFlame::Stage.scenes).to eq([]) + FelECS::Stage.add @scene1, @scene2, @scene3 + FelECS::Stage.clear + expect(FelECS::Stage.scenes).to eq([]) end it 'can call Scenes in correct order' do - FelFlame::Stage.add @scene2, @scene1, @scene3 + FelECS::Stage.add @scene2, @scene1, @scene3 @scene1.add @system1 @scene2.add @system2 @scene3.add @system3 - FelFlame::Stage.call + FelECS::Stage.call expect(@component_manager.first.order).to eq([1, 2, 3]) end end diff --git a/spec/system_manager_spec.rb b/spec/system_manager_spec.rb index b7177af..3b36d34 100644 --- a/spec/system_manager_spec.rb +++ b/spec/system_manager_spec.rb @@ -1,16 +1,16 @@ # frozen_string_literal: true -require_relative '../lib/felflame' +require_relative '../lib/felecs' describe 'Systems' do before :all do - @component_manager ||= FelFlame::Components.new('TestSystems', health: 10, whatever: 'imp', mana: 10) + @component_manager ||= FelECS::Components.new('TestSystems', health: 10, whatever: 'imp', mana: 10) @@testitr = 999 end before :each do @@testitr += 1 - @system = FelFlame::Systems.new "Test#{@@testitr}" do + @system = FelECS::Systems.new "Test#{@@testitr}" do @component_manager.each do |component| component.health += 5 end @@ -19,13 +19,13 @@ describe 'Systems' do after :each do @component_manager.each(&:delete) - FelFlame::Entities.each(&:delete) - FelFlame::Systems.each(&:clear_triggers) + FelECS::Entities.each(&:delete) + FelECS::Systems.each(&:clear_triggers) end it 'can create a system' do @@testitr += 1 - sys = FelFlame::Systems.new("Test#{@@testitr}") do + sys = FelECS::Systems.new("Test#{@@testitr}") do 'Works' end expect(sys.call).to eq('Works') @@ -39,19 +39,19 @@ describe 'Systems' do end it 'responds to array methods' do - expect(FelFlame::Systems.respond_to?(:[])).to be true - expect(FelFlame::Systems.respond_to?(:each)).to be true - FelFlame::Systems.each do |system| + expect(FelECS::Systems.respond_to?(:[])).to be true + expect(FelECS::Systems.respond_to?(:each)).to be true + FelECS::Systems.each do |system| expect(system.respond_to?(:call)).to be true end - expect(FelFlame::Systems.respond_to?(:filter)).to be true - expect(FelFlame::Systems.respond_to?(:first)).to be true - expect(FelFlame::Systems.respond_to?(:last)).to be true - expect(FelFlame::Systems.respond_to?(:somethingwrong)).to be false + expect(FelECS::Systems.respond_to?(:filter)).to be true + expect(FelECS::Systems.respond_to?(:first)).to be true + expect(FelECS::Systems.respond_to?(:last)).to be true + expect(FelECS::Systems.respond_to?(:somethingwrong)).to be false end it 'dont respond to missing methods' do - expect { FelFlame::Systems.somethingwrong }.to raise_error(NoMethodError) + expect { FelECS::Systems.somethingwrong }.to raise_error(NoMethodError) end it 'can manipulate components' do @@ -92,8 +92,8 @@ describe 'Systems' do @system.trigger_when_added @cmp0 expect(@cmp0.health).to eq(10) expect(@cmp1.health).to eq(20) - @entity0 = FelFlame::Entities.new - @entity1 = FelFlame::Entities.new @cmp0 + @entity0 = FelECS::Entities.new + @entity1 = FelECS::Entities.new @cmp0 expect(@cmp0.health).to eq(15) expect(@cmp1.health).to eq(25) @entity0.add @cmp0 @@ -107,8 +107,8 @@ describe 'Systems' do @system.trigger_when_added @component_manager expect(@cmp1.health).to eq(10) expect(@cmp2.health).to eq(20) - @entity1 = FelFlame::Entities.new - @entity2 = FelFlame::Entities.new @cmp2 + @entity1 = FelECS::Entities.new + @entity2 = FelECS::Entities.new @cmp2 expect(@cmp1.health).to eq(15) expect(@cmp2.health).to eq(25) @system.trigger_when_added @cmp1 @@ -123,8 +123,8 @@ describe 'Systems' do @system.trigger_when_removed @cmp0 expect(@cmp0.health).to eq(10) expect(@cmp1.health).to eq(20) - @entity0 = FelFlame::Entities.new - @entity1 = FelFlame::Entities.new @cmp0 + @entity0 = FelECS::Entities.new + @entity1 = FelECS::Entities.new @cmp0 expect(@cmp0.health).to eq(10) expect(@cmp1.health).to eq(20) @entity1.remove @cmp0 @@ -147,8 +147,8 @@ describe 'Systems' do @system.trigger_when_removed @component_manager expect(@cmp0.health).to eq(10) expect(@cmp1.health).to eq(20) - @entity0 = FelFlame::Entities.new - @entity1 = FelFlame::Entities.new @cmp0 + @entity0 = FelECS::Entities.new + @entity1 = FelECS::Entities.new @cmp0 expect(@cmp0.health).to eq(10) expect(@cmp1.health).to eq(20) @entity1.remove @cmp0 @@ -172,8 +172,8 @@ describe 'Systems' do @system.trigger_when_is_changed @cmp0, :whatever expect(@cmp0.health).to eq(10) expect(@cmp1.health).to eq(20) - @entity0 = FelFlame::Entities.new - @entity1 = FelFlame::Entities.new @cmp0 + @entity0 = FelECS::Entities.new + @entity1 = FelECS::Entities.new @cmp0 expect(@cmp0.health).to eq(10) expect(@cmp1.health).to eq(20) @cmp0.whatever = 'different' @@ -187,7 +187,7 @@ describe 'Systems' do it 'can clear all triggers' do @cmp0 = @component_manager.new health: 10 @cmp1 = @component_manager.new health: 20 - @entity1 = FelFlame::Entities.new + @entity1 = FelECS::Entities.new @system.trigger_when_added @cmp0 @system.trigger_when_added @component_manager @system.trigger_when_removed @cmp0 @@ -208,7 +208,7 @@ describe 'Systems' do it 'can clear individual attr_triggers, without component or manager' do @cmp0 = @component_manager.new health: 10, mana: 10 @cmp1 = @component_manager.new health: 20, mana: 20 - @entity1 = FelFlame::Entities.new + @entity1 = FelECS::Entities.new @system.trigger_when_is_changed @cmp0, :whatever @system.trigger_when_is_changed @component_manager, :whatever @system.trigger_when_is_changed @cmp0, :mana @@ -229,7 +229,7 @@ describe 'Systems' do it 'can clear individual attr_triggers, with component' do @cmp0 = @component_manager.new health: 10, mana: 10 @cmp1 = @component_manager.new health: 20, mana: 20 - @entity1 = FelFlame::Entities.new + @entity1 = FelECS::Entities.new @system.trigger_when_is_changed @cmp0, :whatever @system.trigger_when_is_changed @cmp0, :mana # expect(@system.attr_triggers).to eq({@cmp0 => [:name, :mana]}) @@ -252,7 +252,7 @@ describe 'Systems' do it 'can clear individual attr_triggers, with manager' do @cmp0 = @component_manager.new health: 10, mana: 10 @cmp1 = @component_manager.new health: 20, mana: 20 - @entity1 = FelFlame::Entities.new + @entity1 = FelECS::Entities.new @system.trigger_when_is_changed @component_manager, :whatever @system.trigger_when_is_changed @component_manager, :mana @system.clear_triggers :attr_triggers, :whatever, component_or_manager: @component_manager @@ -271,7 +271,7 @@ describe 'Systems' do it 'can clear all attr_triggers, without component or manager' do @cmp0 = @component_manager.new health: 10, mana: 10 @cmp1 = @component_manager.new health: 20, mana: 20 - @entity1 = FelFlame::Entities.new + @entity1 = FelECS::Entities.new @system.trigger_when_is_changed @component_manager, :whatever @system.trigger_when_is_changed @cmp1, :mana @system.clear_triggers :attr_triggers @@ -290,7 +290,7 @@ describe 'Systems' do it 'can clear all attr_triggers, with component' do @cmp0 = @component_manager.new health: 10, mana: 10 @cmp1 = @component_manager.new health: 20, mana: 20 - @entity1 = FelFlame::Entities.new + @entity1 = FelECS::Entities.new @system.trigger_when_is_changed @component_manager, :whatever @system.trigger_when_is_changed @cmp1, :mana @system.clear_triggers :attr_triggers, component_or_manager: @cmp1 @@ -309,7 +309,7 @@ describe 'Systems' do it 'can clear all attr_triggers, with manager' do @cmp0 = @component_manager.new health: 10, mana: 10 @cmp1 = @component_manager.new health: 20, mana: 20 - @entity1 = FelFlame::Entities.new + @entity1 = FelECS::Entities.new @system.trigger_when_is_changed @component_manager, :whatever @system.trigger_when_is_changed @cmp1, :mana @system.clear_triggers :attr_triggers, component_or_manager: @component_manager @@ -328,7 +328,7 @@ describe 'Systems' do it 'can clear addition_trigger, without component or manager' do @cmp0 = @component_manager.new health: 10 @cmp1 = @component_manager.new health: 20 - @entity1 = FelFlame::Entities.new + @entity1 = FelECS::Entities.new @system.trigger_when_added @cmp0 @system.trigger_when_added @component_manager @system.clear_triggers(:addition_triggers) @@ -343,7 +343,7 @@ describe 'Systems' do it 'can clear addition_trigger, with component' do @cmp0 = @component_manager.new health: 10 @cmp1 = @component_manager.new health: 20 - @entity1 = FelFlame::Entities.new + @entity1 = FelECS::Entities.new @system.trigger_when_added @cmp0 @system.clear_triggers :addition_triggers, component_or_manager: @cmp0 expect(@cmp0.health).to eq(10) @@ -357,7 +357,7 @@ describe 'Systems' do it 'can clear addition_trigger, with manager' do @cmp0 = @component_manager.new health: 10 @cmp1 = @component_manager.new health: 20 - @entity1 = FelFlame::Entities.new + @entity1 = FelECS::Entities.new @system.trigger_when_added @component_manager @system.clear_triggers :addition_triggers, component_or_manager: @component_manager expect(@cmp0.health).to eq(10) @@ -371,7 +371,7 @@ describe 'Systems' do it 'can clear removal_trigger, without component or manager' do @cmp0 = @component_manager.new health: 10 @cmp1 = @component_manager.new health: 20 - @entity1 = FelFlame::Entities.new + @entity1 = FelECS::Entities.new @system.trigger_when_removed @cmp0 @system.trigger_when_removed @component_manager @system.clear_triggers(:removal_triggers) @@ -386,7 +386,7 @@ describe 'Systems' do it 'can clear removal_trigger, with component' do @cmp0 = @component_manager.new health: 10 @cmp1 = @component_manager.new health: 20 - @entity1 = FelFlame::Entities.new + @entity1 = FelECS::Entities.new @system.trigger_when_removed @cmp0 @system.clear_triggers :removal_triggers, component_or_manager: @cmp0 expect(@cmp0.health).to eq(10) @@ -400,7 +400,7 @@ describe 'Systems' do it 'can clear removal_trigger, with manager' do @cmp0 = @component_manager.new health: 10 @cmp1 = @component_manager.new health: 20 - @entity1 = FelFlame::Entities.new + @entity1 = FelECS::Entities.new @system.trigger_when_removed @component_manager @system.clear_triggers :removal_triggers, component_or_manager: @component_manager expect(@cmp0.health).to eq(10) |
