From aab35c0f098d695b7cf53c14a8b08a9b4a24550d Mon Sep 17 00:00:00 2001
From: realtradam
@@ -163,7 +84,7 @@
diff --git a/docs/class_list.html b/docs/class_list.html
index fcc39cb..3f4c240 100644
--- a/docs/class_list.html
+++ b/docs/class_list.html
@@ -43,7 +43,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/docs/file.README.html b/docs/file.README.html
index 7066296..67e4cc5 100644
--- a/docs/file.README.html
+++ b/docs/file.README.html
@@ -65,6 +65,10 @@
Check out the comprehensive documentation here!
+ +To use FelFlame simply install the gem using gem install felflame or using bundler bundle add felflame and then require it in your project like so: require 'felflame'. Working outside of the gem for rendering engines that do not support the usage of gems is a planned feature in the works.
Entities are essentially "objects" in the game world. To create a new Entity we do the following:
-@entity = FelFlame::Entities.new
+@entity = FelFlame::Entities.new
or if we want to add (any number of)components to it:
-@entity = FelFlame::Entites.new(FelFlame::Components::Health.new,
- @component,
- FelFlame::Components::Armour[7])
+@entity = FelFlame::Entites.new(
+ FelFlame::Components::Health.new,
+ @component,
+ FelFlame::Components::Armour[7]
+)
Accessing
Once components are created we can access them using their ID like so:
-@entity = FelFlame::Entities[2]
+@entity = FelFlame::Entities[2]
Get ID
@@ -220,6 +230,13 @@ entity where a new entity will claim that ID. To get the ID of an Entity:
@entity.remove @component
+Accessing Entities' Attached Components
+
+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:
+
+@entity.components[@component_manager] # => [@component1, @component2, component3]
+
+
Deletion
To have all Components from an Entity removed and the Entity deleted we do the following:
@@ -234,7 +251,7 @@ entity where a new entity will claim that ID. To get the ID of an Entity:
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:
-@component_manager = FelFlame::Components.new('Stats', :armour, hp: 100)
+@component_manager = FelFlame::Components.new('Stats', :armour, hp: 100)
In this example we created a component manager called "Stats".
@@ -248,12 +265,12 @@ When defining attributes symbols should be used.
Now that we have a component manager we can make components from it like so:
-@component = FelFlame::Components::Stats.new
+@component = FelFlame::Components::Stats.new
Or we can even change the defaults:
-@component = FelFlame::Components::Stats.new(armour: 'steel')
+@component = FelFlame::Components::Stats.new(armour: 'steel')
Accessing and Getting ID
@@ -262,7 +279,7 @@ When defining attributes symbols should be used.
These IDs are only unique within the scope of their respective Component Managers.
Here is how we can get the ID, as well as how to access a Component from its Component Manager.
-@component = FelFlame::Components::Stats[2]
+@component = FelFlame::Components::Stats[2]
@component.id # => 2
@@ -290,25 +307,32 @@ Here are the ways to edit attrubutes, followed by the ways to read them.
When you make Systems you will want to be able to iterate over all Components of the same Component Manager(for example iterating over all sprites to render them). Here is how we do that:
-FelFlame::Components::Sprites.each do |component|
+FelFlame::Components::Sprites.each do |component|
#do something with components
end
+Accessing Components' attached Entities
+
+Components also keep track of what Entities are using it. To access this list we do the following:
+
+@component.entities # => [@entity1, @entity2, @entity3]
+
+
Systems
Creation
We can create Systems like so:
-FelFlame::Systems.new(name: 'Render', priority: 2) do
+FelFlame::Systems.new(name: 'Render', priority: 2) do
# Code and Logic
end
The name we assign is how we can access the System, like so:
-FelFlame::Systems::Render
+FelFlame::Systems::Render
Priority determines the order Systems should be executed, this is used for Scenes and the Stage.
@@ -317,8 +341,8 @@ E.g priority 1 will go first, priority 2 will go second, etcetera.
Often we will want to execute some logic on each Component in a given Component Manager so our code might look like this:
-FelFlame::Systems.new(name: 'Render', priority: 2) do
- FelFlame::Components::Sprites.each do |component|
+FelFlame::Systems.new(name: 'Render', priority: 2) do
+ FelFlame::Components::Sprites.each do |component|
# do something with these components
end
end
@@ -328,7 +352,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera.
After we create a System, it won't do anything on its own until we tell it to. Here is how:
-FelFlame::Systems::Render.call
+FelFlame::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.
@@ -338,25 +362,25 @@ E.g priority 1 will go first, priority 2 will go second, etcetera.
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:
# When this Component is added to an Entity, this System will be called
-FelFlame::Systems::PassiveRegen.trigger_when_added(@component)
+FelFlame::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)
+FelFlame::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)
+FelFlame::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:
# 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)
+FelFlame::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)
+FelFlame::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)
+FelFlame::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
@@ -366,41 +390,41 @@ E.g priority 1 will go first, priority 2 will go second, etcetera.
If we wish to remove these links that we created, we can do that using the follwing function in any of the following ways:
# clears ALL triggers with this system
-FelFlame::Systems::PassiveRegen.clear_triggers
+FelFlame::Systems::PassiveRegen.clear_triggers
# clears ALL triggers with this Component Manager
-FelFlame::Systems::PassiveRegen.clear_triggers(@component)
+FelFlame::Systems::PassiveRegen.clear_triggers(@component)
# clear the 'trigger_when_added' for this Component
-FelFlame::Systems::PassiveRegen.clear_triggers(@component, :added)
+FelFlame::Systems::PassiveRegen.clear_triggers(@component, :added)
# clear the 'trigger_when_removed' for this Component
-FelFlame::Systems::PassiveRegen.clear_triggers(@component, :removed)
+FelFlame::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)
+FelFlame::Systems::PassiveRegen.clear_triggers(@component, :is_set, :health)
Likewise we can do the same with Component Managers:
# clears ALL triggers with this Component
-FelFlame::Systems::PassiveRegen.clear_triggers(@component_manager)
+FelFlame::Systems::PassiveRegen.clear_triggers(@component_manager)
# clear the 'trigger_when_added' for this Component Manager
-FelFlame::Systems::PassiveRegen.clear_triggers(@component_manager, :added)
+FelFlame::Systems::PassiveRegen.clear_triggers(@component_manager, :added)
# clear the 'trigger_when_removed' for this Component Manager
-FelFlame::Systems::PassiveRegen.clear_triggers(@component_manager, :removed)
+FelFlame::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)
+FelFlame::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:
-FelFlame::Systems::PassiveRegen.redefine do
+FelFlame::Systems::PassiveRegen.redefine do
# Some new logic or code
end
@@ -411,28 +435,28 @@ E.g priority 1 will go first, priority 2 will go second, etcetera.
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 will occur even if they are not part of a Scene. Here is how we make a new Scene:
-@scene = FelFlame::Scenes.new('ExampleScene')
+@scene = FelFlame::Scenes.new('ExampleScene')
Accessing
Just like other classes in FelFlame, the name we gave the Scene is how we access it:
-@scene = FelFlame::Scenes::ExampleScene
+@scene = FelFlame::Scenes::ExampleScene
Adding Systems
Adding Systems is simple. We can add as many as we want. In this example we add 3 different systems:
-FelFlame::Scenes::ExampleScene.add(FelFlame::Systems::Render, @system2, @system3)
+FelFlame::Scenes::ExampleScene.add(FelFlame::Systems::Render, @system2, @system3)
Removing Systems
Removing Systems works simularly:
-FelFlame::Scenes::ExampleScene.remove(FelFlame::Systems::Render, @system2, @system3)
+FelFlame::Scenes::ExampleScene.remove(FelFlame::Systems::Render, @system2, @system3)
Clearing
@@ -457,26 +481,26 @@ E.g priority 1 will go first, priority 2 will go second, etcetera.
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:
-FelFlame::Stage.add FelFlame::Scene::ExampleScene
+FelFlame::Stage.add FelFlame::Scene::ExampleScene
Removing Scenes
Likewise we can remove Scenes:
-FelFlame::Stage.remove FelFlame::Scene::ExampleScene
+FelFlame::Stage.remove FelFlame::Scene::ExampleScene
Executing
On each frame of the game we want to execute the Stage once. When the Stage is executed it is progressing your game 1 frame forward. The Stage will make sure for you that all the Systems from all Scenes added will be executed in the correct order according to their priority. Here is how we do it:
-FelFlame::Stage.call
+FelFlame::Stage.call
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!
+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!
Contribution
@@ -488,7 +512,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera.
diff --git a/docs/index.html b/docs/index.html
index 0e56dcd..94feb86 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -65,6 +65,10 @@
+Check out the comprehensive documentation here!
+
+
+
@@ -85,6 +89,7 @@
- Accessing
- Get ID
- Adding and Removing Components
+- Accessing Entities' Attached Components
- Deletion
To use FelFlame simply install the gem using gem install felflame or using bundler bundle add felflame and then require it in your project like so: require 'felflame'. Working outside of the gem for rendering engines that do not support the usage of gems is a planned feature in the works.
Entities are essentially "objects" in the game world. To create a new Entity we do the following:
-@entity = FelFlame::Entities.new
+@entity = FelFlame::Entities.new
or if we want to add (any number of)components to it:
-@entity = FelFlame::Entites.new(FelFlame::Components::Health.new,
- @component,
- FelFlame::Components::Armour[7])
+@entity = FelFlame::Entites.new(
+ FelFlame::Components::Health.new,
+ @component,
+ FelFlame::Components::Armour[7]
+)
Accessing
Once components are created we can access them using their ID like so:
-@entity = FelFlame::Entities[2]
+@entity = FelFlame::Entities[2]
Get ID
@@ -220,6 +230,13 @@ entity where a new entity will claim that ID. To get the ID of an Entity:
@entity.remove @component
+Accessing Entities' Attached Components
+
+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:
+
+@entity.components[@component_manager] # => [@component1, @component2, component3]
+
+
Deletion
To have all Components from an Entity removed and the Entity deleted we do the following:
@@ -234,7 +251,7 @@ entity where a new entity will claim that ID. To get the ID of an Entity:
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:
-@component_manager = FelFlame::Components.new('Stats', :armour, hp: 100)
+@component_manager = FelFlame::Components.new('Stats', :armour, hp: 100)
In this example we created a component manager called "Stats".
@@ -248,12 +265,12 @@ When defining attributes symbols should be used.
Now that we have a component manager we can make components from it like so:
-@component = FelFlame::Components::Stats.new
+@component = FelFlame::Components::Stats.new
Or we can even change the defaults:
-@component = FelFlame::Components::Stats.new(armour: 'steel')
+@component = FelFlame::Components::Stats.new(armour: 'steel')
Accessing and Getting ID
@@ -262,7 +279,7 @@ When defining attributes symbols should be used.
These IDs are only unique within the scope of their respective Component Managers.
Here is how we can get the ID, as well as how to access a Component from its Component Manager.
-@component = FelFlame::Components::Stats[2]
+@component = FelFlame::Components::Stats[2]
@component.id # => 2
@@ -290,25 +307,32 @@ Here are the ways to edit attrubutes, followed by the ways to read them.
When you make Systems you will want to be able to iterate over all Components of the same Component Manager(for example iterating over all sprites to render them). Here is how we do that:
-FelFlame::Components::Sprites.each do |component|
+FelFlame::Components::Sprites.each do |component|
#do something with components
end
+Accessing Components' attached Entities
+
+Components also keep track of what Entities are using it. To access this list we do the following:
+
+@component.entities # => [@entity1, @entity2, @entity3]
+
+
Systems
Creation
We can create Systems like so:
-FelFlame::Systems.new(name: 'Render', priority: 2) do
+FelFlame::Systems.new(name: 'Render', priority: 2) do
# Code and Logic
end
The name we assign is how we can access the System, like so:
-FelFlame::Systems::Render
+FelFlame::Systems::Render
Priority determines the order Systems should be executed, this is used for Scenes and the Stage.
@@ -317,8 +341,8 @@ E.g priority 1 will go first, priority 2 will go second, etcetera.
Often we will want to execute some logic on each Component in a given Component Manager so our code might look like this:
-FelFlame::Systems.new(name: 'Render', priority: 2) do
- FelFlame::Components::Sprites.each do |component|
+FelFlame::Systems.new(name: 'Render', priority: 2) do
+ FelFlame::Components::Sprites.each do |component|
# do something with these components
end
end
@@ -328,7 +352,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera.
After we create a System, it won't do anything on its own until we tell it to. Here is how:
-FelFlame::Systems::Render.call
+FelFlame::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.
@@ -338,25 +362,25 @@ E.g priority 1 will go first, priority 2 will go second, etcetera.
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:
# When this Component is added to an Entity, this System will be called
-FelFlame::Systems::PassiveRegen.trigger_when_added(@component)
+FelFlame::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)
+FelFlame::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)
+FelFlame::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:
# 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)
+FelFlame::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)
+FelFlame::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)
+FelFlame::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
@@ -366,41 +390,41 @@ E.g priority 1 will go first, priority 2 will go second, etcetera.
If we wish to remove these links that we created, we can do that using the follwing function in any of the following ways:
# clears ALL triggers with this system
-FelFlame::Systems::PassiveRegen.clear_triggers
+FelFlame::Systems::PassiveRegen.clear_triggers
# clears ALL triggers with this Component Manager
-FelFlame::Systems::PassiveRegen.clear_triggers(@component)
+FelFlame::Systems::PassiveRegen.clear_triggers(@component)
# clear the 'trigger_when_added' for this Component
-FelFlame::Systems::PassiveRegen.clear_triggers(@component, :added)
+FelFlame::Systems::PassiveRegen.clear_triggers(@component, :added)
# clear the 'trigger_when_removed' for this Component
-FelFlame::Systems::PassiveRegen.clear_triggers(@component, :removed)
+FelFlame::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)
+FelFlame::Systems::PassiveRegen.clear_triggers(@component, :is_set, :health)
Likewise we can do the same with Component Managers:
# clears ALL triggers with this Component
-FelFlame::Systems::PassiveRegen.clear_triggers(@component_manager)
+FelFlame::Systems::PassiveRegen.clear_triggers(@component_manager)
# clear the 'trigger_when_added' for this Component Manager
-FelFlame::Systems::PassiveRegen.clear_triggers(@component_manager, :added)
+FelFlame::Systems::PassiveRegen.clear_triggers(@component_manager, :added)
# clear the 'trigger_when_removed' for this Component Manager
-FelFlame::Systems::PassiveRegen.clear_triggers(@component_manager, :removed)
+FelFlame::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)
+FelFlame::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:
-FelFlame::Systems::PassiveRegen.redefine do
+FelFlame::Systems::PassiveRegen.redefine do
# Some new logic or code
end
@@ -411,28 +435,28 @@ E.g priority 1 will go first, priority 2 will go second, etcetera.
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 will occur even if they are not part of a Scene. Here is how we make a new Scene:
-@scene = FelFlame::Scenes.new('ExampleScene')
+@scene = FelFlame::Scenes.new('ExampleScene')
Accessing
Just like other classes in FelFlame, the name we gave the Scene is how we access it:
-@scene = FelFlame::Scenes::ExampleScene
+@scene = FelFlame::Scenes::ExampleScene
Adding Systems
Adding Systems is simple. We can add as many as we want. In this example we add 3 different systems:
-FelFlame::Scenes::ExampleScene.add(FelFlame::Systems::Render, @system2, @system3)
+FelFlame::Scenes::ExampleScene.add(FelFlame::Systems::Render, @system2, @system3)
Removing Systems
Removing Systems works simularly:
-FelFlame::Scenes::ExampleScene.remove(FelFlame::Systems::Render, @system2, @system3)
+FelFlame::Scenes::ExampleScene.remove(FelFlame::Systems::Render, @system2, @system3)
Clearing
@@ -457,26 +481,26 @@ E.g priority 1 will go first, priority 2 will go second, etcetera.
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:
-FelFlame::Stage.add FelFlame::Scene::ExampleScene
+FelFlame::Stage.add FelFlame::Scene::ExampleScene
Removing Scenes
Likewise we can remove Scenes:
-FelFlame::Stage.remove FelFlame::Scene::ExampleScene
+FelFlame::Stage.remove FelFlame::Scene::ExampleScene
Executing
On each frame of the game we want to execute the Stage once. When the Stage is executed it is progressing your game 1 frame forward. The Stage will make sure for you that all the Systems from all Scenes added will be executed in the correct order according to their priority. Here is how we do it:
-FelFlame::Stage.call
+FelFlame::Stage.call
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!
+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!
Contribution
@@ -488,7 +512,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera.
diff --git a/docs/method_list.html b/docs/method_list.html
index d8804ef..48eea1f 100644
--- a/docs/method_list.html
+++ b/docs/method_list.html
@@ -44,430 +44,6 @@
- -
-
- []
- FelFlame::ComponentManager
-
-
-
-
- -
-
- []
- FelFlame::Entities
-
-
-
-
- -
-
- #add
- FelFlame::Entities
-
-
-
-
- -
-
- #add
- FelFlame::Scenes
-
-
-
-
- -
-
- add
- FelFlame::Stage
-
-
-
-
- -
-
- #addition_triggers
- FelFlame::Systems
-
-
-
-
- -
-
- #addition_triggers
- FelFlame::ComponentManager
-
-
-
-
- -
-
- addition_triggers
- FelFlame::ComponentManager
-
-
-
-
- -
-
- #attr_changed_trigger_systems
- FelFlame::ComponentManager
-
-
-
-
- -
-
- #attr_triggers
- FelFlame::Systems
-
-
-
-
- -
-
- #attr_triggers
- FelFlame::ComponentManager
-
-
-
-
- -
-
- attr_triggers
- FelFlame::ComponentManager
-
-
-
-
- -
-
- #attrs
- FelFlame::ComponentManager
-
-
-
-
- -
-
- #call
- FelFlame::Systems
-
-
-
-
- -
-
- #call
- FelFlame::Scenes
-
-
-
-
- -
-
- call
- FelFlame::Stage
-
-
-
-
- -
-
- call
- FelFlame
-
-
-
-
- -
-
- #clear
- FelFlame::Scenes
-
-
-
-
- -
-
- clear
- FelFlame::Stage
-
-
-
-
- -
-
- #clear_triggers
- FelFlame::Systems
-
-
-
-
- -
-
- #components
- FelFlame::Entities
-
-
-
-
- -
-
- #const_name
- FelFlame::Systems
-
-
-
-
- -
-
- #const_name
- FelFlame::Scenes
-
-
-
-
- -
-
- #delete
- FelFlame::ComponentManager
-
-
-
-
- -
-
- #delete
- FelFlame::Entities
-
-
-
-
- -
-
- each
- FelFlame::Systems
-
-
-
-
- -
-
- each
- FelFlame::Components
-
-
-
-
- -
-
- each
- FelFlame::ComponentManager
-
-
-
-
- -
-
- each
- FelFlame::Entities
-
-
-
-
- -
-
- #entities
- FelFlame::ComponentManager
-
-
-
-
- -
-
- #id
- FelFlame::ComponentManager
-
-
-
-
- -
-
- #id
- FelFlame::Entities
-
-
-
-
- -
-
- #initialize
- FelFlame::Systems
-
-
-
-
- -
-
- #initialize
- FelFlame::ComponentManager
-
-
-
-
- -
-
- #initialize
- FelFlame::Entities
-
-
-
-
- -
-
- #initialize
- FelFlame::Scenes
-
-
-
-
- -
-
- new
- FelFlame::Components
-
-
-
-
- -
-
- #priority
- FelFlame::Systems
-
-
-
-
- -
-
- #redefine
- FelFlame::Systems
-
-
-
-
- -
-
- #removal_triggers
- FelFlame::Systems
-
-
-
-
- -
-
- #removal_triggers
- FelFlame::ComponentManager
-
-
-
-
- -
-
- removal_triggers
- FelFlame::ComponentManager
-
-
-
-
- -
-
- #remove
- FelFlame::Entities
-
-
-
-
- -
-
- #remove
- FelFlame::Scenes
-
-
-
-
- -
-
- remove
- FelFlame::Stage
-
-
-
-
- -
-
- scenes
- FelFlame::Stage
-
-
-
-
- -
-
- #systems
- FelFlame::Scenes
-
-
-
-
- -
-
- #to_i
- FelFlame::ComponentManager
-
-
-
-
- -
-
- #to_i
- FelFlame::Entities
-
-
-
-
- -
-
- #trigger_when_added
- FelFlame::Systems
-
-
-
-
- -
-
- #trigger_when_is_changed
- FelFlame::Systems
-
-
-
-
- -
-
- #trigger_when_removed
- FelFlame::Systems
-
-
-
-
- -
-
- #update_attrs
- FelFlame::ComponentManager
-
-
-
-
diff --git a/docs/top-level-namespace.html b/docs/top-level-namespace.html
index 3443369..6fbfabe 100644
--- a/docs/top-level-namespace.html
+++ b/docs/top-level-namespace.html
@@ -78,43 +78,6 @@
-Defined Under Namespace
-
-
-
-
-
- Classes: FelFlame
-
-
-
-
-
-
- Constant Summary
- collapse
-
-
-
-
@@ -127,7 +90,7 @@
diff --git a/lib/felflame/component_manager.rb b/lib/felflame/component_manager.rb
index e6c6d91..43932d2 100644
--- a/lib/felflame/component_manager.rb
+++ b/lib/felflame/component_manager.rb
@@ -220,8 +220,9 @@ class FelFlame
# the remove command is called, breaking the loop if it
# wasn't referencing a clone(will get Nil errors)
iter = entities.map(&:clone)
- iter.each do |entity_id|
- FelFlame::Entities[entity_id].remove self #unless FelFlame::Entities[entity_id].nil?
+ iter.each do |entity|
+ #FelFlame::Entities[entity_id].remove self #unless FelFlame::Entities[entity_id].nil?
+ entity.remove self
end
self.class.data[id] = nil
instance_variables.each do |var|
diff --git a/lib/felflame/entity_manager.rb b/lib/felflame/entity_manager.rb
index 74fc4c3..a05ef93 100644
--- a/lib/felflame/entity_manager.rb
+++ b/lib/felflame/entity_manager.rb
@@ -41,9 +41,8 @@ class FelFlame
# @return [Boolean] +true+
def delete
components.each do |component_manager, component_array|
- component_array.each do |component_id|
- component_manager[component_id].entities.delete(id)
- #self.remove FelFlame::Components.const_get(component_manager.name)[component_id]
+ component_array.each do |component|
+ component.entities.delete(self)
end
end
FelFlame::Entities.data[id] = nil
@@ -58,12 +57,12 @@ class FelFlame
def add(*components_to_add)
components_to_add.each do |component|
if components[component.class].nil?
- components[component.class] = [component.id]
- component.entities.push id
+ components[component.class] = [component]
+ component.entities.push self
check_systems component, :addition_triggers
- elsif !components[component.class].include? component.id
- components[component.class].push component.id
- component.entities.push id
+ elsif !components[component.class].include? component
+ components[component.class].push component
+ component.entities.push self
check_systems component, :addition_triggers
end
end
@@ -87,9 +86,9 @@ class FelFlame
# @return [Boolean] +true+
def remove(*components_to_remove)
components_to_remove.each do |component|
- check_systems component, :removal_triggers if component.entities.include? id
- component.entities.delete id
- components[component.class].delete component.id
+ check_systems component, :removal_triggers if component.entities.include? self
+ component.entities.delete self
+ components[component.class].delete component
end
true
end
diff --git a/lib/felflame/version.rb b/lib/felflame/version.rb
index f69ea19..8483c07 100644
--- a/lib/felflame/version.rb
+++ b/lib/felflame/version.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
module Felflame
- VERSION = "1.0.2"
+ VERSION = "2.0.0"
end
diff --git a/spec/entity_manager_spec.rb b/spec/entity_manager_spec.rb
index 78300c2..ef638c0 100644
--- a/spec/entity_manager_spec.rb
+++ b/spec/entity_manager_spec.rb
@@ -46,12 +46,12 @@ describe 'Entities' do
it 'can have components attached' do
@ent0.add @cmp0
- expect(@ent0.components[@component_manager][0]).to eq(@cmp0.id)
+ expect(@ent0.components[@component_manager][0]).to eq(@cmp0)
@ent1.add @cmp1, @cmp2
expect(@ent1.components[@component_manager].length).to eq(2)
- expect(@ent1.components[@component_manager].include?(@cmp1.id)).to be true
- expect(@ent1.components[@component_manager].include?(@cmp2.id)).to be true
+ expect(@ent1.components[@component_manager].include?(@cmp1)).to be true
+ expect(@ent1.components[@component_manager].include?(@cmp2)).to be true
end
it 'can get id from to_i' do
@@ -71,16 +71,16 @@ describe 'Entities' do
@ent0.add @cmp0, @cmp1, @cmp2
@ent1.add @cmp0, @cmp1
@ent2.add @cmp1, @cmp2
- expect(@ent0.components).to eq({@component_manager => [0,1,2]})
- expect(@cmp0.entities).to eq([0,1])
- expect(@cmp1.entities).to eq([0,1,2])
- expect(@cmp2.entities).to eq([0,2])
+ expect(@ent0.components).to eq({@component_manager => [@cmp0,@cmp1,@cmp2]})
+ expect(@cmp0.entities).to eq([@ent0,@ent1])
+ expect(@cmp1.entities).to eq([@ent0,@ent1,@ent2])
+ expect(@cmp2.entities).to eq([@ent0,@ent2])
@ent1.delete
- expect(@cmp0.entities).to eq([0])
- expect(@cmp1.entities).to eq([0,2])
- expect(@cmp2.entities).to eq([0,2])
+ expect(@cmp0.entities).to eq([@ent0])
+ expect(@cmp1.entities).to eq([@ent0,@ent2])
+ expect(@cmp2.entities).to eq([@ent0,@ent2])
@cmp1.delete
- expect(@ent0.components).to eq({@component_manager => [0,2]})
+ expect(@ent0.components).to eq({@component_manager => [@cmp0,@cmp2]})
@component_manager.each(&:delete)
expect(@component_manager.each.to_a).to eq([])
expect(@ent0.components).to eq({@component_manager => []})
--
cgit v1.2.3