From a6004b2fccca58e528d24be5ba8afdf781666662 Mon Sep 17 00:00:00 2001 From: realtradam Date: Thu, 3 Feb 2022 04:12:35 -0500 Subject: added new group method for entity manager --- docs/CNAME | 1 - docs/FelECS.html | 2 +- docs/FelECS/ComponentManager.html | 2 +- docs/FelECS/Components.html | 2 +- docs/FelECS/Entities.html | 145 ++- docs/FelECS/Order.html | 2 +- docs/FelECS/Scenes.html | 2 +- docs/FelECS/Stage.html | 2 +- docs/FelECS/Systems.html | 2 +- docs/FelFlame.html | 319 ------ docs/FelFlame/ComponentManager.html | 1239 --------------------- docs/FelFlame/Components.html | 333 ------ docs/FelFlame/Entities.html | 792 -------------- docs/FelFlame/Helper.html | 142 --- docs/FelFlame/Helper/ComponentManager.html | 1627 ---------------------------- docs/FelFlame/Order.html | 251 ----- docs/FelFlame/Scenes.html | 765 ------------- docs/FelFlame/Stage.html | 572 ---------- docs/FelFlame/Systems.html | 1505 ------------------------- docs/Felflame_.html | 143 --- docs/_index.html | 2 +- docs/file.README.html | 2 +- docs/file.version.html | 74 -- docs/index.html | 2 +- docs/method_list.html | 52 +- docs/top-level-namespace.html | 2 +- 26 files changed, 185 insertions(+), 7797 deletions(-) delete mode 100644 docs/CNAME delete mode 100644 docs/FelFlame.html delete mode 100644 docs/FelFlame/ComponentManager.html delete mode 100644 docs/FelFlame/Components.html delete mode 100644 docs/FelFlame/Entities.html delete mode 100644 docs/FelFlame/Helper.html delete mode 100644 docs/FelFlame/Helper/ComponentManager.html delete mode 100644 docs/FelFlame/Order.html delete mode 100644 docs/FelFlame/Scenes.html delete mode 100644 docs/FelFlame/Stage.html delete mode 100644 docs/FelFlame/Systems.html delete mode 100644 docs/Felflame_.html delete mode 100644 docs/file.version.html (limited to 'docs') diff --git a/docs/CNAME b/docs/CNAME deleted file mode 100644 index 0b0c608..0000000 --- a/docs/CNAME +++ /dev/null @@ -1 +0,0 @@ -felflame.tradam.fyi \ No newline at end of file diff --git a/docs/FelECS.html b/docs/FelECS.html index 0e3e334..62efd37 100644 --- a/docs/FelECS.html +++ b/docs/FelECS.html @@ -325,7 +325,7 @@ diff --git a/docs/FelECS/ComponentManager.html b/docs/FelECS/ComponentManager.html index 5179b58..fb78748 100644 --- a/docs/FelECS/ComponentManager.html +++ b/docs/FelECS/ComponentManager.html @@ -1229,7 +1229,7 @@ diff --git a/docs/FelECS/Components.html b/docs/FelECS/Components.html index b1e0185..e58decc 100644 --- a/docs/FelECS/Components.html +++ b/docs/FelECS/Components.html @@ -327,7 +327,7 @@ diff --git a/docs/FelECS/Entities.html b/docs/FelECS/Entities.html index ac43403..6a5045c 100644 --- a/docs/FelECS/Entities.html +++ b/docs/FelECS/Entities.html @@ -120,6 +120,39 @@ +

+ Class Method Summary + collapse +

+ + +

Instance Method Summary collapse @@ -347,6 +380,116 @@ +
+

Class Method Details

+ + +
+

+ + .group(*component_managers, &block) ⇒ Nil + + + + + +

+
+ +

Selects every entity that has components of they type passed into this function and then executes the code block for those components and entities.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Nil) + + + +
  • + +
+ +
+ + + + +
+
+
+
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+
+
# File 'lib/felecs/entity_manager.rb', line 107
+
+def group(*component_managers, &block)
+  return nil if component_managers.empty?
+  if component_managers.length == 1
+    component_managers.first.each do |cmp|
+      block.call(cmp, cmp.entity)
+    end
+  else
+    arry = component_managers.first.select do |cmp|
+      ent = cmp.entity
+      keep = true
+      component_managers.drop(1).each do |mgr|
+        next unless ent.components[mgr].nil?
+        keep = false
+        break
+      end
+      keep
+    end
+    arry.each do |cmp|
+      ent = cmp.entity
+      cmp_arry = [cmp]
+      component_managers.drop(1).each do |cmp_mgr|
+        cmp_arry.push ent.component[cmp_mgr]
+      end
+      block.call(*cmp_arry, ent)
+    end
+  end
+  nil
+end
+
+
+ +
+

Instance Method Details

@@ -782,7 +925,7 @@
diff --git a/docs/FelECS/Order.html b/docs/FelECS/Order.html index 9438239..6dd5c97 100644 --- a/docs/FelECS/Order.html +++ b/docs/FelECS/Order.html @@ -241,7 +241,7 @@ diff --git a/docs/FelECS/Scenes.html b/docs/FelECS/Scenes.html index c42be77..d11b129 100644 --- a/docs/FelECS/Scenes.html +++ b/docs/FelECS/Scenes.html @@ -755,7 +755,7 @@ diff --git a/docs/FelECS/Stage.html b/docs/FelECS/Stage.html index 4386c1a..02b1f70 100644 --- a/docs/FelECS/Stage.html +++ b/docs/FelECS/Stage.html @@ -562,7 +562,7 @@ diff --git a/docs/FelECS/Systems.html b/docs/FelECS/Systems.html index 9024a56..f4ef7ac 100644 --- a/docs/FelECS/Systems.html +++ b/docs/FelECS/Systems.html @@ -1495,7 +1495,7 @@ diff --git a/docs/FelFlame.html b/docs/FelFlame.html deleted file mode 100644 index 439094e..0000000 --- a/docs/FelFlame.html +++ /dev/null @@ -1,319 +0,0 @@ - - - - - - - Module: FelFlame - - — Documentation by YARD 0.9.26 - - - - - - - - - - - - - - - - - - - -
- - -

Module: FelFlame - - - -

-
- - - - - - - - - - - -
-
Defined in:
-
lib/felflame.rb,
- lib/felflame/order.rb,
lib/felflame/scene_manager.rb,
lib/felflame/stage_manager.rb,
lib/felflame/entity_manager.rb,
lib/felflame/system_manager.rb,
lib/felflame/component_manager.rb
-
-
- -
- -

Overview

-
- -

The FelFlame namespace where all its functionality resides under.

- - -
-
-
- - -

Defined Under Namespace

-

- - - Modules: Components, Order, Stage - - - - Classes: ComponentManager, Entities, Scenes, Systems - - -

- - -

- Constant Summary - collapse -

- -
- -
Ent = -
-
- -

An alias for Entities

- - -
-
-
- - -
-
-
FelFlame::Entities
- -
Cmp = -
-
- -

An alias for Components

- - -
-
-
- - -
-
-
FelFlame::Components
- -
Sys = -
-
- -

An alias for Systems

- - -
-
-
- - -
-
-
FelFlame::Systems
- -
Scn = -
-
- -

An alias for Scenes

- - -
-
-
- - -
-
-
FelFlame::Scenes
- -
Stg = -
-
- -

An alias for Stage

- - -
-
-
- - -
-
-
FelFlame::Stage
- -
Odr = -
-
-
An alias for {FelFlame -
- - -
-
-
- - -
-
-
FelFlame::Order
- -
- - - - - - - - - -

- Class Method Summary - collapse -

- - - - - - -
-

Class Method Details

- - -
-

- - .callObject - - - - - -

-
- -

An alias for FelFlame::Stage.call. It executes a single frame in the game.

- - -
-
-
- - -
- - - - -
-
-
-
-18
-19
-20
-
-
# File 'lib/felflame.rb', line 18
-
-def call
-  FelFlame::Stage.call
-end
-
-
- -
- -
- - - -
- - \ No newline at end of file diff --git a/docs/FelFlame/ComponentManager.html b/docs/FelFlame/ComponentManager.html deleted file mode 100644 index 19891af..0000000 --- a/docs/FelFlame/ComponentManager.html +++ /dev/null @@ -1,1239 +0,0 @@ - - - - - - - Class: FelFlame::ComponentManager - - — Documentation by YARD 0.9.26 - - - - - - - - - - - - - - - - - - - -
- - -

Class: FelFlame::ComponentManager - - - -

-
- -
-
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
-
- - - - - - - - - - - -
-
Defined in:
-
lib/felflame/component_manager.rb
-
- -
- -

Overview

-
- -

Component Managers are what is used to create individual components which can be attached to entities. When a Component is created from a Component Manager that has accessors given to it, you can set or get the values of those accessors using standard ruby message sending (e.g @component.var = 5), or by using the #to_h and #update_attrs methods instead.

- - -
-
-
- - -
- - - -

Class Attribute Summary collapse

-
    - -
  • - - - .addition_triggers ⇒ Array<System> - - - - - - - - - readonly - - - - - - - - - -
    -

    Stores references to systems that should be triggered when this component is added to an enitity.

    -
    - -
  • - - -
  • - - - .attr_triggers ⇒ Hash<Symbol, System> - - - - - - - - - readonly - - - - - - - - - -
    -

    Stores references to systems that should be triggered when an attribute from this component changed.

    -
    - -
  • - - -
  • - - - .removal_triggers ⇒ Array<System> - - - - - - - - - readonly - - - - - - - - - -
    -

    Stores references to systems that should be triggered when this component is removed from an enitity.

    -
    - -
  • - - -
- -

Instance Attribute Summary collapse

-
    - -
  • - - - #addition_triggers ⇒ Array<System> - - - - - - - - - readonly - - - - - - - - - -
    -

    Stores references to systems that should be triggered when a component from this manager is added.

    -
    - -
  • - - -
  • - - - #attr_triggers ⇒ Hash<Symbol, Array<System>> - - - - - - - - - readonly - - - - - - - - - -
    -

    Stores references to systems that should be triggered when an attribute from this manager is changed.

    -
    - -
  • - - -
  • - - - #removal_triggers ⇒ Array<System> - - - - - - - - - readonly - - - - - - - - - -
    -

    Stores references to systems that should be triggered when a component from this manager is removed.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - collapse -

- - - - -
-

Constructor Details

- -
-

- - #initialize(**attrs) ⇒ Component - - - - - -

-
- -

Creates a new component and sets the values of the attributes given to it. If an attritbute is not passed then it will remain as the default.

- - -
-
-
-

Parameters:

-
    - -
  • - - attrs - - - (Keyword: Value) - - - - — -
    -

    You can pass any number of Keyword-Value pairs

    -
    - -
  • - -
- - -
- - - - -
-
-
-
-132
-133
-134
-135
-136
-137
-138
-139
-140
-141
-142
-143
-144
-145
-
-
# File 'lib/felflame/component_manager.rb', line 132
-
-def initialize(**attrs)
-  # Prepare the object
-  # (this is a function created with metaprogramming
-  # in FelFlame::Components)
-  set_defaults
-
-  # Fill params
-  attrs.each do |key, value|
-    send "#{key}=", value
-  end
-
-  # Save Component
-  self.class.push self
-end
-
-
- -
- -
-

Class Attribute Details

- - - -
-

- - .addition_triggersArray<System> - - - - - -

-
- -

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.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Array<System>) - - - -
  • - -
- -
- - - - -
-
-
-
-180
-181
-182
-
-
# File 'lib/felflame/component_manager.rb', line 180
-
-def addition_triggers
-  @addition_triggers ||= []
-end
-
-
- - - -
-

- - .attr_triggersHash<Symbol, System> - - - - - -

-
- -

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.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Hash<Symbol, System>) - - - -
  • - -
- -
- - - - -
-
-
-
-196
-197
-198
-
-
# File 'lib/felflame/component_manager.rb', line 196
-
-def attr_triggers
-  @attr_triggers ||= {}
-end
-
-
- - - -
-

- - .removal_triggersArray<System> - - - - - -

-
- -

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.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Array<System>) - - - -
  • - -
- -
- - - - -
-
-
-
-188
-189
-190
-
-
# File 'lib/felflame/component_manager.rb', line 188
-
-def removal_triggers
-  @removal_triggers ||= []
-end
-
-
- -
- -
-

Instance Attribute Details

- - - -
-

- - #addition_triggersArray<System> - - - - - -

-
- -

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.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Array<System>) - - - -
  • - -
- -
- - - - -
-
-
-
-109
-110
-111
-
-
# File 'lib/felflame/component_manager.rb', line 109
-
-def addition_triggers
-  @addition_triggers ||= []
-end
-
-
- - - -
-

- - #attr_triggersHash<Symbol, Array<System>> - - - - - -

-
- -

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.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Hash<Symbol, Array<System>>) - - - -
  • - -
- -
- - - - -
-
-
-
-125
-126
-127
-
-
# File 'lib/felflame/component_manager.rb', line 125
-
-def attr_triggers
-  @attr_triggers ||= {}
-end
-
-
- - - -
-

- - #removal_triggersArray<System> - - - - - -

-
- -

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.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Array<System>) - - - -
  • - -
- -
- - - - -
-
-
-
-117
-118
-119
-
-
# File 'lib/felflame/component_manager.rb', line 117
-
-def removal_triggers
-  @removal_triggers ||= []
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - #deleteBoolean - - - - - -

-
- -

Removes this component from the list and purges all references to this Component from other Entities, as well as its data.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -
    -

    true.

    -
    - -
  • - -
- -
- - - - -
-
-
-
-247
-248
-249
-250
-251
-252
-253
-254
-255
-256
-257
-258
-259
-
-
# File 'lib/felflame/component_manager.rb', line 247
-
-def delete
-  addition_triggers.each do |system|
-    system.clear_triggers component_or_manager: self
-  end
-  entities.reverse_each do |entity|
-    entity.remove self
-  end
-  self.class._data.delete self
-  instance_variables.each do |var|
-    instance_variable_set(var, nil)
-  end
-  true
-end
-
-
- -
-

- - #entitiesArray<Component> - - - - - -

-
- -

Entities that have this component

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Array<Component>) - - - -
  • - -
- -
- - - - -
-
-
-
-209
-210
-211
-
-
# File 'lib/felflame/component_manager.rb', line 209
-
-def entities
-  @entities ||= []
-end
-
-
- -
-

- - #entityComponent - - - - - -

-
- -

A single entity. Use this if you expect the component to only belong to one entity and you want to access it.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Component) - - - -
  • - -
- -
- - - - -
-
-
-
-215
-216
-217
-218
-219
-220
-221
-222
-
-
# File 'lib/felflame/component_manager.rb', line 215
-
-def entity
-  if entities.empty?
-    Warning.warn("This component belongs to NO entities but you called the method that is intended for components belonging to a single entity.\nYou may have a bug in your logic.")
-  elsif entities.length > 1
-    Warning.warn("This component belongs to MANY entities but you called the method that is intended for components belonging to a single entity.\nYou may have a bug in your logic.")
-  end
-  entities.first
-end
-
-
- -
-

- - #to_hHash<Symbol, Value> - - - - - -

-
- -

Returns A hash, where all the keys are attributes storing their respective values.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Hash<Symbol, Value>) - - - - — -
    -

    A hash, where all the keys are attributes storing their respective values.

    -
    - -
  • - -
- -
- - - - -
-
-
-
-262
-263
-264
-265
-266
-267
-268
-
-
# File 'lib/felflame/component_manager.rb', line 262
-
-def to_h
-  return_hash = instance_variables.each_with_object({}) do |key, final|
-    final[key.to_s.delete_prefix('@').to_sym] = instance_variable_get(key)
-  end
-  return_hash.delete(:attr_triggers)
-  return_hash
-end
-
-
- -
-

- - #update_attrs(**opts) ⇒ Hash<Symbol, Value> - - - - - -

-
- -

Update attribute values using a hash or keywords.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Hash<Symbol, Value>) - - - - — -
    -

    Hash of updated attributes

    -
    - -
  • - -
- -
- - - - -
-
-
-
-226
-227
-228
-229
-230
-
-
# File 'lib/felflame/component_manager.rb', line 226
-
-def update_attrs(**opts)
-  opts.each do |key, value|
-    send "#{key}=", value
-  end
-end
-
-
- -
- -
- - - -
- - \ No newline at end of file diff --git a/docs/FelFlame/Components.html b/docs/FelFlame/Components.html deleted file mode 100644 index be924da..0000000 --- a/docs/FelFlame/Components.html +++ /dev/null @@ -1,333 +0,0 @@ - - - - - - - Module: FelFlame::Components - - — Documentation by YARD 0.9.26 - - - - - - - - - - - - - - - - - - - -
- - -

Module: FelFlame::Components - - - -

-
- - - - - - - - - - - -
-
Defined in:
-
lib/felflame.rb,
- lib/felflame/component_manager.rb
-
-
- -
- -

Overview

-
- -

Creates component managers and allows accessing them them under the 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 ComponentManager documentation.

- - -
-
-
- - -
- - - - - - - -

- Class Method Summary - collapse -

- - - - - - -
-

Class Method Details

- - -
-

- - .new(component_name, *attrs, **attrs_with_defaults) ⇒ ComponentManager - - - - - -

-
- -

Creates a new component manager.

- - -
-
-
- -
-

Examples:

- - -
# 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')
- -
-

Parameters:

-
    - -
  • - - component_name - - - (String) - - - - — -
    -

    Name of your new component manager. Must be stylized in the format of constants in Ruby

    -
    - -
  • - -
  • - - attrs - - - (:Symbols) - - - - — -
    -

    New components made with this manager will include these symbols as accessors, the values of these accessors will default to nil

    -
    - -
  • - -
  • - - 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

    -
    - -
  • - -
- -

Returns:

- - -
- - - - -
-
-
-
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
-37
-38
-39
-40
-41
-42
-43
-44
-45
-46
-47
-48
-49
-
-
# File 'lib/felflame/component_manager.rb', line 20
-
-def new(component_name, *attrs, **attrs_with_defaults)
-  if FelFlame::Components.const_defined?(component_name)
-    raise(NameError.new, "Component Manager '#{component_name}' is already defined")
-  end
-
-  const_set(component_name, Class.new(FelFlame::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}=")
-      raise NameError, "The attribute name \"#{attr}\" is already a method"
-    end
-
-    FelFlame::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|
-      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
-    attrs_with_defaults.each do |attr, default|
-      instance_variable_set("@#{attr}", default.dup)
-    end
-  end
-  FelFlame::Components.const_get(component_name)
-end
-
-
- -
- -
- - - -
- - \ No newline at end of file diff --git a/docs/FelFlame/Entities.html b/docs/FelFlame/Entities.html deleted file mode 100644 index 37a9d84..0000000 --- a/docs/FelFlame/Entities.html +++ /dev/null @@ -1,792 +0,0 @@ - - - - - - - Class: FelFlame::Entities - - — Documentation by YARD 0.9.26 - - - - - - - - - - - - - - - - - - - -
- - -

Class: FelFlame::Entities - - - -

-
- -
-
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
-
- - - - - - - - - - - -
-
Defined in:
-
lib/felflame.rb,
- lib/felflame/entity_manager.rb
-
-
- -
- -

Overview

-
- -

Creates and manages Entities. Entities are just collections of Components. You can use array methods directly on this class to access Entities.

- - -
-
-
- - -
- - - - - - - -

- Instance Method Summary - collapse -

- - - - -
-

Constructor Details

- -
-

- - #initialize(*components) ⇒ Entity - - - - - -

-
- -

Creating a new Entity

- - -
-
-
-

Parameters:

-
    - -
  • - - components - - - (Components) - - - - — -
    -

    Can be any number of components, identical duplicates will be automatically purged however different components from the same component manager are allowed.

    -
    - -
  • - -
- - -
- - - - -
-
-
-
-8
-9
-10
-11
-12
-
-
# File 'lib/felflame/entity_manager.rb', line 8
-
-def initialize(*components)
-  # Add each component
-  add(*components)
-  self.class._data.push self
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - #add(*components_to_add) ⇒ Boolean - - - - - -

-
- -

Add any number components to the Entity.

- - -
-
-
-

Parameters:

-
    - -
  • - - components_to_add - - - (Component) - - - - — -
    -

    Any number of components created from any component manager

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -
    -

    true

    -
    - -
  • - -
- -
- - - - -
-
-
-
-57
-58
-59
-60
-61
-62
-63
-64
-65
-66
-67
-68
-69
-70
-
-
# File 'lib/felflame/entity_manager.rb', line 57
-
-def add(*components_to_add)
-  components_to_add.each do |component|
-    if components[component.class].nil?
-      components[component.class] = [component]
-      component.entities.push self
-      check_systems component, :addition_triggers
-    elsif !components[component.class].include? component
-      components[component.class].push component
-      component.entities.push self
-      check_systems component, :addition_triggers
-    end
-  end
-  true
-end
-
-
- -
-

- - #component(manager = nil) ⇒ Component - - - - - -

-
- -

A single component from a component manager. Use this if you expect the component to only belong to one entity and you want to access it. Access the component using either parameter notation or array notation. Array notation is conventional for better readablility.

- - -
-
-
- -
-

Examples:

- - -
@entity.component[@component_manager] # array notation(the standard)
-@entity.component(@component_manager) # method notation
- -
-

Parameters:

-
    - -
  • - - manager - - - (ComponentManager) - - - (defaults to: nil) - - - — -
    -

    If you pass nil you can then use array notation to access the same value.

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Component) - - - -
  • - -
- -
- - - - -
-
-
-
-26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
-37
-38
-39
-
-
# File 'lib/felflame/entity_manager.rb', line 26
-
-def component(manager = nil)
-  if manager.nil?
-    FelFlame::Entities.component_redirect.entity = self
-    FelFlame::Entities.component_redirect
-  else
-    if components[manager].nil?
-      raise "This entity(#{self}) doesnt have any components of this type: #{manager}"
-    elsif components[manager].length > 1
-      Warning.warn("This entity has MANY of this component but you called the method that is intended for having a single of this component type.\nYou may have a bug in your logic.")
-    end
-
-    components[manager].first
-  end
-end
-
-
- -
-

- - #componentsHash<Component_Manager, Array<Integer>> - - - - - -

-
- -

A hash that uses component manager constant names as keys, and where the values of those keys are arrays that contain the the components attached to this entity.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Hash<Component_Manager, Array<Integer>>) - - - -
  • - -
- -
- - - - -
-
-
-
-16
-17
-18
-
-
# File 'lib/felflame/entity_manager.rb', line 16
-
-def components
-  @components ||= {}
-end
-
-
- -
-

- - #deleteBoolean - - - - - -

-
- -

Removes this Entity from the list and purges all references to this Entity from other Components, as well as its data.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -
    -

    true

    -
    - -
  • - -
- -
- - - - -
-
-
-
-43
-44
-45
-46
-47
-48
-49
-50
-51
-52
-
-
# File 'lib/felflame/entity_manager.rb', line 43
-
-def delete
-  components.each do |_component_manager, component_array|
-    component_array.reverse_each do |component|
-      component.entities.delete(self)
-    end
-  end
-  FelFlame::Entities._data.delete self
-  @components = {}
-  true
-end
-
-
- -
-

- - #remove(*components_to_remove) ⇒ Boolean - - - - - -

-
- -

Remove a component from the Entity

- - -
-
-
-

Parameters:

-
    - -
  • - - components_to_remove - - - (Component) - - - - — -
    -

    A component created from any component manager

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -
    -

    true

    -
    - -
  • - -
- -
- - - - -
-
-
-
-87
-88
-89
-90
-91
-92
-93
-94
-95
-
-
# File 'lib/felflame/entity_manager.rb', line 87
-
-def remove(*components_to_remove)
-  components_to_remove.each do |component|
-    check_systems component, :removal_triggers if component.entities.include? self
-    component.entities.delete self
-    components[component.class].delete component
-    components.delete component.class if components[component.class].empty?
-  end
-  true
-end
-
-
- -
- -
- - - -
- - \ No newline at end of file diff --git a/docs/FelFlame/Helper.html b/docs/FelFlame/Helper.html deleted file mode 100644 index acb3005..0000000 --- a/docs/FelFlame/Helper.html +++ /dev/null @@ -1,142 +0,0 @@ - - - - - - - Class: FelFlame::Helper - - — Documentation by YARD 0.9.26 - - - - - - - - - - - - - - - - - - - -
- - -

Class: FelFlame::Helper - - - -

-
- -
-
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
-
- - - - - - - - - - - -
-
Defined in:
-
component_manager.rb
-
- -
- -

Overview

-
- -

Namespace for helper functions and template classes

- - -
-
-
- - -

Defined Under Namespace

-

- - - - - Classes: ComponentManager - - -

- - - - - - - - - -
- - - -
- - \ No newline at end of file diff --git a/docs/FelFlame/Helper/ComponentManager.html b/docs/FelFlame/Helper/ComponentManager.html deleted file mode 100644 index 1a04d45..0000000 --- a/docs/FelFlame/Helper/ComponentManager.html +++ /dev/null @@ -1,1627 +0,0 @@ - - - - - - - Class: FelFlame::Helper::ComponentManager - - — Documentation by YARD 0.9.26 - - - - - - - - - - - - - - - - - - - -
- - -

Class: FelFlame::Helper::ComponentManager - - - -

-
- -
-
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
-
- - - - - - - - - - - -
-
Defined in:
-
component_manager.rb
-
- -
- -

Overview

-
- -

Component Managers are what is used to create individual components which can be attached to entities. When a Component is created from a Component Manager that has accessors given to it, you can set or get the values of those accessors using standard ruby message sending (e.g @component.var = 5), or by using the #attrs and #update_attrs methods instead.

- - -
-
-
- - -
- - - -

Class Attribute Summary collapse

-
    - -
  • - - - .addition_triggers ⇒ Array<System> - - - - - - - - - readonly - - - - - - - - - -
    -

    Stores references to systems that should be triggered when this component is added to an enitity.

    -
    - -
  • - - -
  • - - - .attr_triggers ⇒ Hash<Symbol, System> - - - - - - - - - readonly - - - - - - - - - -
    -

    Stores references to systems that should be triggered when an attribute from this component changed.

    -
    - -
  • - - -
  • - - - .removal_triggers ⇒ Array<System> - - - - - - - - - readonly - - - - - - - - - -
    -

    Stores references to systems that should be triggered when this component is removed from an enitity.

    -
    - -
  • - - -
- -

Instance Attribute Summary collapse

-
    - -
  • - - - #addition_triggers ⇒ Array<System> - - - - - - - - - readonly - - - - - - - - - -
    -

    Stores references to systems that should be triggered when a component from this manager is added.

    -
    - -
  • - - -
  • - - - #attr_triggers ⇒ Hash<Symbol, Array<System>> - - - - - - - - - readonly - - - - - - - - - -
    -

    Stores references to systems that should be triggered when an attribute from this manager is changed.

    -
    - -
  • - - -
  • - - - #id ⇒ Integer - - - - - - - - - readonly - - - - - - - - - -
    -

    Holds the unique ID of a component.

    -
    - -
  • - - -
  • - - - #removal_triggers ⇒ Array<System> - - - - - - - - - readonly - - - - - - - - - -
    -

    Stores references to systems that should be triggered when a component from this manager is removed.

    -
    - -
  • - - -
- - - - - -

- Class Method Summary - collapse -

- - - -

- Instance Method Summary - collapse -

- - - - -
-

Constructor Details

- -
-

- - #initialize(**attrs) ⇒ Component - - - - - -

-
- -

Creates a new component and sets the values of the attributes given to it. If an attritbute is not passed then it will remain as the default.

- - -
-
-
-

Parameters:

-
    - -
  • - - attrs - - - (Keyword: Value) - - - - — -
    -

    You can pass any number of Keyword-Value pairs

    -
    - -
  • - -
- - -
- - - - -
-
-
-
-104
-105
-106
-107
-108
-109
-110
-111
-112
-113
-114
-115
-116
-117
-118
-119
-120
-121
-122
-
-
# File 'component_manager.rb', line 104
-
-def initialize(**attrs)
-  # Prepare the object
-  # (this is a function created with metaprogramming
-  # in FelFlame::Components
-  set_defaults
-
-  # Generate ID
-  new_id = self.class.data.find_index { |i| i.nil? }
-  new_id = self.class.data.size if new_id.nil?
-  @id = new_id
-
-  # Fill params
-  attrs.each do |key, value|
-    send "#{key}=", value
-  end
-
-  # Save Component
-  self.class.data[new_id] = self
-end
-
-
- -
- -
-

Class Attribute Details

- - - -
-

- - .addition_triggersArray<System> - - - - - -

-
- -

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.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Array<System>) - - - -
  • - -
- -
- - - - -
-
-
-
-136
-137
-138
-
-
# File 'component_manager.rb', line 136
-
-def addition_triggers
-  @addition_triggers ||= []
-end
-
-
- - - -
-

- - .attr_triggersHash<Symbol, System> - - - - - -

-
- -

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.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Hash<Symbol, System>) - - - -
  • - -
- -
- - - - -
-
-
-
-152
-153
-154
-
-
# File 'component_manager.rb', line 152
-
-def attr_triggers
-  @attr_triggers ||= {}
-end
-
-
- - - -
-

- - .removal_triggersArray<System> - - - - - -

-
- -

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.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Array<System>) - - - -
  • - -
- -
- - - - -
-
-
-
-144
-145
-146
-
-
# File 'component_manager.rb', line 144
-
-def removal_triggers
-  @removal_triggers ||= []
-end
-
-
- -
- -
-

Instance Attribute Details

- - - -
-

- - #addition_triggersArray<System> - - - - - -

-
- -

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.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Array<System>) - - - -
  • - -
- -
- - - - -
-
-
-
-81
-82
-83
-
-
# File 'component_manager.rb', line 81
-
-def addition_triggers
-  @addition_triggers ||= []
-end
-
-
- - - -
-

- - #attr_triggersHash<Symbol, Array<System>> - - - - - -

-
- -

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.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Hash<Symbol, Array<System>>) - - - -
  • - -
- -
- - - - -
-
-
-
-97
-98
-99
-
-
# File 'component_manager.rb', line 97
-
-def attr_triggers
-  @attr_triggers ||= {}
-end
-
-
- - - -
-

- - #idInteger - - - - - -

-
- -

Holds the unique ID of a component. The ID is only unique within the scope of the component manager it was created from.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Integer) - - - -
  • - -
- -
- - - - -
-
-
-
-63
-64
-65
-
-
# File 'component_manager.rb', line 63
-
-def id
-  @id
-end
-
-
- - - -
-

- - #removal_triggersArray<System> - - - - - -

-
- -

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.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Array<System>) - - - -
  • - -
- -
- - - - -
-
-
-
-89
-90
-91
-
-
# File 'component_manager.rb', line 89
-
-def removal_triggers
-  @removal_triggers ||= []
-end
-
-
- -
- - -
-

Class Method Details

- - -
-

- - .[](component_id) ⇒ Component - - - - - -

-
- -

Gets a Component from the given unique ID. Usage is simular to how an Array lookup works.

- - -
-
-
- -
-

Examples:

- - -
# this gets the 'Health' Component with ID 7
-FelFlame::Components::Health[7]
- -
-

Parameters:

-
    - -
  • - - component_id - - - (Integer) - - - -
  • - -
- -

Returns:

-
    - -
  • - - - (Component) - - - - — -
    -

    Returns the Component that uses the given unique ID, nil if there is no Component associated with the given ID

    -
    - -
  • - -
- -
- - - - -
-
-
-
-169
-170
-171
-
-
# File 'component_manager.rb', line 169
-
-def [](component_id)
-  data[component_id]
-end
-
-
- -
-

- - .each(&block) ⇒ Enumerator - - - - - -

-
- -

Iterates over all components within the component manager. Special Enumerable methods like map or each_with_index are not implemented

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Enumerator) - - - -
  • - -
- -
- - - - -
-
-
-
-176
-177
-178
-
-
# File 'component_manager.rb', line 176
-
-def each(&block)
-  data.compact.each(&block)
-end
-
-
- -
- -
-

Instance Method Details

- - -
-

- - #attr_changed_trigger_systems(attr) ⇒ Boolean - - - - - -

-
- -

Execute systems that have been added to execute on variable change

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -
    -

    true

    -
    - -
  • - -
- -
- - - - -
-
-
-
-203
-204
-205
-206
-207
-208
-209
-210
-211
-
-
# File 'component_manager.rb', line 203
-
-def attr_changed_trigger_systems(attr)
-  systems_to_execute = self.class.attr_triggers[attr]
-  systems_to_execute = [] if systems_to_execute.nil?
-
-  systems_to_execute |= attr_triggers[attr] unless attr_triggers[attr].nil?
-
-  systems_to_execute.sort_by(&:priority).reverse.each(&:call)
-  true
-end
-
-
- -
-

- - #attrsHash<Symbol, Value> - - - - - -

-
- -

Returns A hash, where all the keys are attributes linked to their respective values.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Hash<Symbol, Value>) - - - - — -
    -

    A hash, where all the keys are attributes linked to their respective values.

    -
    - -
  • - -
- -
- - - - -
-
-
-
-234
-235
-236
-237
-238
-239
-240
-
-
# File 'component_manager.rb', line 234
-
-def attrs
-  return_hash = instance_variables.each_with_object({}) do |key, final|
-    final[key.to_s.delete_prefix('@').to_sym] = instance_variable_get(key)
-  end
-  return_hash.delete(:attr_triggers)
-  return_hash
-end
-
-
- -
-

- - #deleteBoolean - - - - - -

-
- -

Removes this component from the list and purges all references to this Component from other Entities, as well as its ID and data.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -
    -

    true.

    -
    - -
  • - -
- -
- - - - -
-
-
-
-215
-216
-217
-218
-219
-220
-221
-222
-223
-224
-225
-226
-227
-228
-229
-230
-231
-
-
# File 'component_manager.rb', line 215
-
-def delete
-  addition_triggers.each do |system|
-    system.clear_triggers component_or_manager: self
-  end
-  # This needs to be cloned because indices get deleted as
-  # the remove command is called, breaking the loop if it
-  # wasn't referencing a clone(will get Nil errors)
-  iter = entities.map(&:clone)
-  iter.each do |entity_id|
-    FelFlame::Entities[entity_id].remove self #unless FelFlame::Entities[entity_id].nil?
-  end
-  self.class.data[id] = nil
-  instance_variables.each do |var|
-    instance_variable_set(var, nil)
-  end
-  true
-end
-
-
- -
-

- - #entitiesArray<Integer> - - - - - -

-
- -

A list of entity ids that are linked to the component

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Array<Integer>) - - - -
  • - -
- -
- - - - -
-
-
-
-189
-190
-191
-
-
# File 'component_manager.rb', line 189
-
-def entities
-  @entities ||= []
-end
-
-
- -
-

- - #to_iInteger - - - - - -

-
- -

An alias for the ID Reader

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Integer) - - - -
  • - -
- -
- - - - -
-
-
-
-183
-184
-185
-
-
# File 'component_manager.rb', line 183
-
-def to_i
-  id
-end
-
-
- -
-

- - #update_attrs(**opts) ⇒ Hash<Symbol, Value> - - - - - -

-
- -

Update attribute values using a hash or keywords.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Hash<Symbol, Value>) - - - - — -
    -

    Hash of updated attributes

    -
    - -
  • - -
- -
- - - - -
-
-
-
-195
-196
-197
-198
-199
-
-
# File 'component_manager.rb', line 195
-
-def update_attrs(**opts)
-  opts.each do |key, value|
-    send "#{key}=", value
-  end
-end
-
-
- -
- -
- - - -
- - \ No newline at end of file diff --git a/docs/FelFlame/Order.html b/docs/FelFlame/Order.html deleted file mode 100644 index 832e16f..0000000 --- a/docs/FelFlame/Order.html +++ /dev/null @@ -1,251 +0,0 @@ - - - - - - - Module: FelFlame::Order - - — Documentation by YARD 0.9.26 - - - - - - - - - - - - - - - - - - - -
- - -

Module: FelFlame::Order - - - -

-
- - - - - - - - - - - -
-
Defined in:
-
lib/felflame.rb,
- lib/felflame/order.rb
-
-
- -
- -

Overview

-
- -

Sets the priority of a list of Systems or Scenes for you in the order you pass them to this class.

- - -
-
-
- - -
- - - - - - - -

- Class Method Summary - collapse -

- -
    - -
  • - - - .sort(*sortables) ⇒ Boolean - - - - - - - - - - - - - -
    -

    Sets the priority of all items passed into this method according to the order they were passed.

    -
    - -
  • - - -
- - - - -
-

Class Method Details

- - -
-

- - .sort(*sortables) ⇒ Boolean - - - - - -

-
- -

Sets the priority of all items passed into this method according to the order they were passed. If an array is one of the elements then it will give all of those elements in the array the same priority.

- - -
-
-
-

Parameters:

- - -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -
    -

    true.

    -
    - -
  • - -
- -
- - - - -
-
-
-
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-
-
# File 'lib/felflame/order.rb', line 11
-
-def self.sort(*sortables)
-  sortables.each_with_index do |sorted, index|
-    if sorted.respond_to? :priority
-      sorted.priority = index
-    else
-      sorted.each do |item|
-        item.priority = index
-      end
-    end
-  end
-  true
-end
-
-
- -
- -
- - - -
- - \ No newline at end of file diff --git a/docs/FelFlame/Scenes.html b/docs/FelFlame/Scenes.html deleted file mode 100644 index 68f4ece..0000000 --- a/docs/FelFlame/Scenes.html +++ /dev/null @@ -1,765 +0,0 @@ - - - - - - - Class: FelFlame::Scenes - - — Documentation by YARD 0.9.26 - - - - - - - - - - - - - - - - - - - -
- - -

Class: FelFlame::Scenes - - - -

-
- -
-
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
-
- - - - - - - - - - - -
-
Defined in:
-
lib/felflame.rb,
- lib/felflame/scene_manager.rb
-
-
- -
- -

Overview

-
- -

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 Scenes namespace as Constants.

- - -
-
-
- - -
- - - -

Instance Attribute Summary collapse

-
    - -
  • - - - #priority ⇒ Object - - - - - - - - - - - - - - - - -
    -

    How early this Scene should be executed in a list of Scenes.

    -
    - -
  • - - -
  • - - - #systems ⇒ Array<System> - - - - - - - - - readonly - - - - - - - - - -
    -

    The list of Systems this Scene contains.

    -
    - -
  • - - -
- - - - - -

- Instance Method Summary - collapse -

- - - - -
-

Constructor Details

- -
-

- - #initialize(name, priority: 0) ⇒ Scenes - - - - - -

-
- -

Create a new Scene using the name given

- - -
-
-
-

Parameters:

-
    - -
  • - - name - - - (String) - - - - — -
    -

    String format must follow requirements of a constant

    -
    - -
  • - -
- - -
- - - - -
-
-
-
-22
-23
-24
-25
-
-
# File 'lib/felflame/scene_manager.rb', line 22
-
-def initialize(name, priority: 0)
-  self.priority = priority
-  FelFlame::Scenes.const_set(name, self)
-end
-
-
- -
- -
-

Instance Attribute Details

- - - -
-

- - #priorityObject - - - - - -

-
- -

How early this Scene should be executed in a list of Scenes

- - -
-
-
- - -
- - - - -
-
-
-
-12
-13
-14
-
-
# File 'lib/felflame/scene_manager.rb', line 12
-
-def priority
-  @priority
-end
-
-
- - - -
-

- - #systemsArray<System> - - - - - -

-
- -

The list of Systems this Scene contains

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Array<System>) - - - -
  • - -
- -
- - - - -
-
-
-
-29
-30
-31
-
-
# File 'lib/felflame/scene_manager.rb', line 29
-
-def systems
-  @systems ||= []
-end
-
-
- -
- - -
-

Instance Method Details

- - -
-

- - #add(*systems_to_add) ⇒ Boolean - - - - - -

-
- -

Adds any number of Systems to this Scene

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -
    -

    true

    -
    - -
  • - -
- -
- - - - -
-
-
-
-42
-43
-44
-45
-46
-47
-48
-49
-
-
# File 'lib/felflame/scene_manager.rb', line 42
-
-def add(*systems_to_add)
-  self.systems |= systems_to_add
-  self.systems = systems.sort_by(&:priority)
-  systems_to_add.each do |system|
-    system.scenes |= [self]
-  end
-  true
-end
-
-
- -
-

- - #callBoolean - - - - - -

-
- -

Execute all systems in this Scene, in the order of their priority

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -
    -

    true

    -
    - -
  • - -
- -
- - - - -
-
-
-
-35
-36
-37
-38
-
-
# File 'lib/felflame/scene_manager.rb', line 35
-
-def call
-  systems.each(&:call)
-  true
-end
-
-
- -
-

- - #clearBoolean - - - - - -

-
- -

Removes all Systems from this Scene

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -
    -

    true

    -
    - -
  • - -
- -
- - - - -
-
-
-
-60
-61
-62
-63
-64
-65
-66
-67
-
-
# File 'lib/felflame/scene_manager.rb', line 60
-
-def clear
-  systems.each do |system|
-    system.scenes.delete self
-  end
-  systems.clear
-  # FelFlame::Stage.update_systems_list if FelFlame::Stage.scenes.include? self
-  true
-end
-
-
- -
-

- - #remove(*systems_to_remove) ⇒ Boolean - - - - - -

-
- -

Removes any number of Systems from this Scene

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -
    -

    true

    -
    - -
  • - -
- -
- - - - -
-
-
-
-53
-54
-55
-56
-
-
# File 'lib/felflame/scene_manager.rb', line 53
-
-def remove(*systems_to_remove)
-  self.systems -= systems_to_remove
-  true
-end
-
-
- -
- -
- - - -
- - \ No newline at end of file diff --git a/docs/FelFlame/Stage.html b/docs/FelFlame/Stage.html deleted file mode 100644 index 7dd9b26..0000000 --- a/docs/FelFlame/Stage.html +++ /dev/null @@ -1,572 +0,0 @@ - - - - - - - Module: FelFlame::Stage - - — Documentation by YARD 0.9.26 - - - - - - - - - - - - - - - - - - - -
- - -

Module: FelFlame::Stage - - - -

-
- - - - - - - - - - - -
-
Defined in:
-
lib/felflame.rb,
- lib/felflame/stage_manager.rb
-
-
- -
- -

Overview

-
- -

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.

- - -
-
-
- - -
- - - -

Class Attribute Summary collapse

-
    - -
  • - - - .scenes ⇒ Array<Scene> - - - - - - - - - readonly - - - - - - - - - -
    -

    Contains all the Scenes added to the Stage.

    -
    - -
  • - - -
- - - - - -

- Class Method Summary - collapse -

- - - - - -
-

Class Attribute Details

- - - -
-

- - .scenesArray<Scene> - - - - - -

-
- -

Contains all the Scenes added to the Stage

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Array<Scene>) - - - -
  • - -
- -
- - - - -
-
-
-
-42
-43
-44
-
-
# File 'lib/felflame/stage_manager.rb', line 42
-
-def scenes
-  @scenes ||= []
-end
-
-
- -
- - -
-

Class Method Details

- - -
-

- - .add(*scenes_to_add) ⇒ Boolean - - - - - -

-
- -

Add any number of Scenes to the Stage

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -
    -

    true

    -
    - -
  • - -
- -
- - - - -
-
-
-
-13
-14
-15
-16
-17
-
-
# File 'lib/felflame/stage_manager.rb', line 13
-
-def add(*scenes_to_add)
-  self.scenes |= scenes_to_add
-  self.scenes = scenes.sort_by(&:priority)
-  true
-end
-
-
- -
-

- - .callBoolean - - - - - -

-
- -

Executes one frame of the game. This executes all the Scenes added to the Stage in order of their priority.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -
    -

    true

    -
    - -
  • - -
- -
- - - - -
-
-
-
-35
-36
-37
-38
-
-
# File 'lib/felflame/stage_manager.rb', line 35
-
-def call
-  self.scenes.each(&:call)
-  true
-end
-
-
- -
-

- - .clearBoolean - - - - - -

-
- -

Clears all Scenes that were added to the Stage

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -
    -

    true

    -
    - -
  • - -
- -
- - - - -
-
-
-
-28
-29
-30
-31
-
-
# File 'lib/felflame/stage_manager.rb', line 28
-
-def clear
-  self.scenes.clear
-  true
-end
-
-
- -
-

- - .remove(*scenes_to_remove) ⇒ Boolean - - - - - -

-
- -

Remove any number of Scenes from the Stage

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -
    -

    true

    -
    - -
  • - -
- -
- - - - -
-
-
-
-21
-22
-23
-24
-
-
# File 'lib/felflame/stage_manager.rb', line 21
-
-def remove(*scenes_to_remove)
-  self.scenes -= scenes_to_remove
-  true
-end
-
-
- -
- -
- - - -
- - \ No newline at end of file diff --git a/docs/FelFlame/Systems.html b/docs/FelFlame/Systems.html deleted file mode 100644 index d2fb24f..0000000 --- a/docs/FelFlame/Systems.html +++ /dev/null @@ -1,1505 +0,0 @@ - - - - - - - Class: FelFlame::Systems - - — Documentation by YARD 0.9.26 - - - - - - - - - - - - - - - - - - - -
- - -

Class: FelFlame::Systems - - - -

-
- -
-
Inherits:
-
- Object - -
    -
  • Object
  • - - - -
- show all - -
-
- - - - - - - - - - - -
-
Defined in:
-
lib/felflame.rb,
- lib/felflame/system_manager.rb
-
-
- -
- -

Overview

-
- -

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 Systems namespace as Constants. You can use array methods directly on this class to access Systems.

- - -
-
-
- - -
- - - -

Instance Attribute Summary collapse

-
    - -
  • - - - #addition_triggers ⇒ Array<Component> - - - - - - - - - readonly - - - - - - - - - -
    -

    Stores references to components or their managers that trigger this component when a component or component from that manager is added to an entity.

    -
    - -
  • - - -
  • - - - #attr_triggers ⇒ Hash<Symbol, Array<Symbol>> - - - - - - - - - readonly - - - - - - - - - -
    -

    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.

    -
    - -
  • - - -
  • - - - #priority ⇒ Object - - - - - - - - - - - - - - - - -
    -

    How early this System should be executed in a list of Systems.

    -
    - -
  • - - -
  • - - - #removal_triggers ⇒ Array<Component> - - - - - - - - - readonly - - - - - - - - - -
    -

    Stores references to components or their managers that trigger this component when a component or component from that manager is removed from an entity.

    -
    - -
  • - - -
  • - - - #scenes ⇒ Object - - - - - - - - - - - - - - - - -
    - -
  • - - -
- - - - - -

- Class Method Summary - collapse -

- - - -

- Instance Method Summary - collapse -

- - - - -
-

Constructor Details

- -
-

- - #initialize(name, priority: 0, &block) ⇒ Systems - - - - - -

-
- -

Creates a new System which can be accessed as a constant under the namespace FelFlame::Systems. The name given is what constant the system is assigned to

- - -
-
-
- -
-

Examples:

- - -
FelFlame::Systems.new('PassiveHeal', priority: -2) do
-  FelFlame::Components::Health.each do |component|
-    component.hp += 5
-  end
-end
-# Give it a low priority so other systems such as a
-#   Poison system would kill the player first
- -
-

Parameters:

-
    - -
  • - - name - - - (String) - - - - — -
    -

    The name this system will use. Needs to to be in the Ruby Constant format.

    -
    - -
  • - -
  • - - priority - - - (Integer) - - - (defaults to: 0) - - - — -
    -

    Which priority order this system should be executed in relative to other systems. Higher means executed earlier.

    -
    - -
  • - -
  • - - 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.

    -
    - -
  • - -
- - -
- - - - -
-
-
-
-115
-116
-117
-118
-119
-120
-121
-
-
# File 'lib/felflame/system_manager.rb', line 115
-
-def initialize(name, priority: 0, &block)
-  FelFlame::Systems.const_set(name, self)
-  FelFlame::Systems.update_const_cache
-  @priority = priority
-  @block = block
-  @scenes = []
-end
-
-
- -
- -
-

Instance Attribute Details

- - - -
-

- - #addition_triggersArray<Component> - - - - - -

-
- -

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.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Array<Component>) - - - -
  • - -
- -
- - - - -
-
-
-
-35
-36
-37
-
-
# File 'lib/felflame/system_manager.rb', line 35
-
-def addition_triggers
-  @addition_triggers ||= []
-end
-
-
- - - -
-

- - #attr_triggersHash<Symbol, Array<Symbol>> - - - - - -

-
- -

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.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Hash<Symbol, Array<Symbol>>) - - - -
  • - -
- -
- - - - -
-
-
-
-52
-53
-54
-
-
# File 'lib/felflame/system_manager.rb', line 52
-
-def attr_triggers
-  @attr_triggers ||= {}
-end
-
-
- - - -
-

- - #priorityObject - - - - - -

-
- -

How early this System should be executed in a list of Systems

- - -
-
-
- - -
- - - - -
-
-
-
-6
-7
-8
-
-
# File 'lib/felflame/system_manager.rb', line 6
-
-def priority
-  @priority
-end
-
-
- - - -
-

- - #removal_triggersArray<Component> - - - - - -

-
- -

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.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Array<Component>) - - - -
  • - -
- -
- - - - -
-
-
-
-44
-45
-46
-
-
# File 'lib/felflame/system_manager.rb', line 44
-
-def removal_triggers
-  @removal_triggers ||= []
-end
-
-
- - - -
-

- - #scenesObject - - - - - -

- - - - -
-
-
-
-19
-20
-21
-
-
# File 'lib/felflame/system_manager.rb', line 19
-
-def scenes
-  @scenes ||= []
-end
-
-
- -
- - -
-

Class Method Details

- - -
-

- - .const_cacheObject - - - - - -

-
- -

Stores the systems in Components. This is needed because calling `FelFlame::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 constants

- - -
-
-
- - -
- - - - -
-
-
-
-63
-64
-65
-
-
# File 'lib/felflame/system_manager.rb', line 63
-
-def const_cache
-  @const_cache || update_const_cache
-end
-
-
- -
- -
-

Instance Method Details

- - -
-

- - #callObject - - - - - -

-
- -

Manually execute the system a single time

- - -
-
-
- - -
- - - - -
-
-
-
-124
-125
-126
-
-
# File 'lib/felflame/system_manager.rb', line 124
-
-def call
-  @block.call
-end
-
-
- -
-

- - #clear_triggers(*trigger_types, component_or_manager: nil) ⇒ Boolean - - - - - -

-
- -

Removes triggers from this system. This function is fairly flexible so it can accept a few different inputs For addition and removal triggers, you can optionally pass in a component, or a manager to clear specifically the relevant triggers for that one component or manager. If you do not pass a component or manager then it will clear triggers for all components and managers. For attr_triggers

- - -
-
-
- -
-

Examples:

- - -
# To clear all triggers that execute this system when a component is added:
-FelFlame::Systems::ExampleSystem.clear_triggers :addition_triggers
-# Same as above but for when a component is removed instead
-FelFlame::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
-
-# Clear a trigger from a specific component
-FelFlame::Systems::ExampleSystem.clear_triggers :addition_triggers, FelFlame::Component::ExampleComponent[0]
-# Clear a trigger from a specific component manager
-FelFlame::Systems::ExampleSystem.clear_triggers :addition_triggers, FelFlame::Component::ExampleComponent
-
-# Clear the trigger that executes a system when the ':example_attr' is changes
-FelFlame::Systems::ExampleSystem.clear_triggers :attr_triggers, :example_attr
- -
-

Parameters:

-
    - -
  • - - 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

    -
    - -
  • - -
  • - - component_or_manager - - - (Component or ComponentManager) - - - (defaults to: nil) - - - — -
    -

    The object to clear triggers from. Use Nil to clear triggers from all components associated with this system.

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -
    -

    true

    -
    - -
  • - -
- -
- - - - -
-
-
-
-157
-158
-159
-160
-161
-162
-163
-164
-165
-166
-167
-168
-169
-170
-171
-172
-173
-174
-175
-176
-177
-178
-179
-180
-181
-182
-183
-184
-185
-186
-187
-188
-189
-190
-191
-192
-193
-194
-195
-196
-197
-198
-199
-200
-201
-202
-203
-204
-205
-206
-207
-208
-209
-210
-211
-212
-213
-214
-215
-216
-217
-218
-219
-220
-221
-222
-
-
# File 'lib/felflame/system_manager.rb', line 157
-
-def clear_triggers(*trigger_types, component_or_manager: nil)
-  trigger_types = %i[addition_triggers removal_triggers attr_triggers] if trigger_types.empty?
-
-  if trigger_types.include? :attr_triggers
-    if (trigger_types - %i[addition_triggers
-                           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?
-
-            cmp_or_mgr.attr_triggers[attr].delete self
-          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
-          end
-          attr_triggers[component_or_manager] = []
-        end
-      end
-
-    elsif component_or_manager.nil?
-
-      (trigger_types - %i[addition_triggers removal_triggers attr_triggers]).each do |attr|
-        # remove attr
-        attr_triggers.each do |cmp_or_mgr, _attrs|
-          cmp_or_mgr.attr_triggers[attr].delete self
-        end
-      end
-      attr_triggers.delete(trigger_types - %i[addition_triggers
-                                              removal_triggers
-                                              attr_triggers])
-    else
-      # remove attr from component_or_manager
-      (trigger_types - %i[addition_triggers removal_triggers attr_triggers]).each do |attr|
-        next if component_or_manager.attr_triggers[attr].nil?
-
-        component_or_manager.attr_triggers[attr].delete self
-      end
-      attr_triggers[component_or_manager] -= trigger_types unless attr_triggers[component_or_manager].nil?
-
-    end
-  end
-
-  (trigger_types & %i[removal_triggers addition_triggers] - [:attr_triggers]).each do |trigger_type|
-    if component_or_manager.nil?
-      # remove all removal triggers
-      send(trigger_type).each do |trigger|
-        trigger.send(trigger_type).delete self
-      end
-      send("#{trigger_type}=", [])
-    else
-      # remove removal trigger relevant to comp/man
-      send(trigger_type).delete component_or_manager
-      component_or_manager.send(trigger_type).delete self
-    end
-  end
-  true
-end
-
-
- -
-

- - #redefine(&block) ⇒ Object - - - - - -

-
- -

Redefine what code is executed by this System when it is called upon.

- - -
-
-
-

Parameters:

-
    - -
  • - - 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.

    -
    - -
  • - -
- - -
- - - - -
-
-
-
-130
-131
-132
-
-
# File 'lib/felflame/system_manager.rb', line 130
-
-def redefine(&block)
-  @block = block
-end
-
-
- -
-

- - #trigger_when_added(component_or_manager) ⇒ Boolean - - - - - -

-
- -

Add a component or component manager so that it triggers this system when the component or a component from the component manager is added to an entity

- - -
-
-
-

Parameters:

-
    - -
  • - - component_or_manager - - - (Component or ComponentManager) - - - - — -
    -

    The component or component manager to trigger this system when added

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -
    -

    true

    -
    - -
  • - -
- -
- - - - -
-
-
-
-227
-228
-229
-230
-231
-
-
# File 'lib/felflame/system_manager.rb', line 227
-
-def trigger_when_added(component_or_manager)
-  self.addition_triggers |= [component_or_manager]
-  component_or_manager.addition_triggers |= [self]
-  true
-end
-
-
- -
-

- - #trigger_when_is_changed(component_or_manager, attr) ⇒ Boolean - - - - - -

-
- -

Add a component or component manager so that it triggers this system when a component's attribute is changed.

- - -
-
-
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -
    -

    true

    -
    - -
  • - -
- -
- - - - -
-
-
-
-244
-245
-246
-247
-248
-249
-250
-251
-252
-253
-254
-255
-256
-
-
# File 'lib/felflame/system_manager.rb', line 244
-
-def trigger_when_is_changed(component_or_manager, attr)
-  if component_or_manager.attr_triggers[attr].nil?
-    component_or_manager.attr_triggers[attr] = [self]
-  else
-    component_or_manager.attr_triggers[attr] |= [self]
-  end
-  if attr_triggers[component_or_manager].nil?
-    attr_triggers[component_or_manager] = [attr]
-  else
-    attr_triggers[component_or_manager] |= [attr]
-  end
-  true
-end
-
-
- -
-

- - #trigger_when_removed(component_or_manager) ⇒ Boolean - - - - - -

-
- -

Add a component or component manager so that it triggers this system when the component or a component from the component manager is removed from an entity

- - -
-
-
-

Parameters:

-
    - -
  • - - component_or_manager - - - (Component or ComponentManager) - - - - — -
    -

    The component or component manager to trigger this system when removed

    -
    - -
  • - -
- -

Returns:

-
    - -
  • - - - (Boolean) - - - - — -
    -

    true

    -
    - -
  • - -
- -
- - - - -
-
-
-
-236
-237
-238
-239
-240
-
-
# File 'lib/felflame/system_manager.rb', line 236
-
-def trigger_when_removed(component_or_manager)
-  self.removal_triggers |= [component_or_manager]
-  component_or_manager.removal_triggers |= [self]
-  true
-end
-
-
- -
- -
- - - -
- - \ No newline at end of file diff --git a/docs/Felflame_.html b/docs/Felflame_.html deleted file mode 100644 index c748359..0000000 --- a/docs/Felflame_.html +++ /dev/null @@ -1,143 +0,0 @@ - - - - - - - Module: Felflame - - — Documentation by YARD 0.9.26 - - - - - - - - - - - - - - - - - - - -
- - -

Module: Felflame - - - -

-
- - - - - - - - - - - -
-
Defined in:
-
lib/felflame/version.rb
-
- -
- -

Overview

-
- -

:nocov: Keeps the version of the Gem

- - -
-
-
- - -
- -

- Constant Summary - collapse -

- -
- -
VERSION = -
-
- -

The version of the Gem

- - -
-
-
- - -
-
-
'4.0.0'
- -
- - - - - - - - - - -
- - - -
- - \ No newline at end of file diff --git a/docs/_index.html b/docs/_index.html index 513f06d..8e128ed 100644 --- a/docs/_index.html +++ b/docs/_index.html @@ -178,7 +178,7 @@ diff --git a/docs/file.README.html b/docs/file.README.html index fdf4b37..6da1a7c 100644 --- a/docs/file.README.html +++ b/docs/file.README.html @@ -550,7 +550,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera.

diff --git a/docs/file.version.html b/docs/file.version.html deleted file mode 100644 index 4bc29ad..0000000 --- a/docs/file.version.html +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - File: version - - — Documentation by YARD 0.9.26 - - - - - - - - - - - - - - - - - - - -
- - -
# frozen_string_literal: true
-
-module Felflame
-  VERSION = "2.0.0"
-end
- - - -
- - \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index a83a21f..2aeb172 100644 --- a/docs/index.html +++ b/docs/index.html @@ -550,7 +550,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 9df50e9..5c85d6f 100644 --- a/docs/method_list.html +++ b/docs/method_list.html @@ -229,6 +229,14 @@
  • +
    + group + FelECS::Entities +
    +
  • + + +
  • #initialize FelECS::Scenes @@ -236,7 +244,7 @@
  • -
  • +
  • #initialize FelECS::Entities @@ -244,7 +252,7 @@
  • -
  • +
  • #initialize FelECS::Systems @@ -252,7 +260,7 @@
  • -
  • +
  • #initialize FelECS::ComponentManager @@ -260,7 +268,7 @@
  • -
  • +
  • new FelECS::Components @@ -268,7 +276,7 @@
  • -
  • +
  • #priority FelECS::Scenes @@ -276,7 +284,7 @@
  • -
  • +
  • #priority FelECS::Systems @@ -284,7 +292,7 @@
  • -
  • +
  • #redefine FelECS::Systems @@ -292,7 +300,7 @@
  • -
  • +
  • #removal_triggers FelECS::Systems @@ -300,7 +308,7 @@
  • -
  • +
  • #removal_triggers FelECS::ComponentManager @@ -308,7 +316,7 @@
  • -
  • +
  • removal_triggers FelECS::ComponentManager @@ -316,7 +324,7 @@
  • -
  • +
  • #remove FelECS::Scenes @@ -324,7 +332,7 @@
  • -
  • +
  • remove FelECS::Stage @@ -332,7 +340,7 @@
  • -
  • +
  • #remove FelECS::Entities @@ -340,7 +348,7 @@
  • -
  • +
  • scenes FelECS::Stage @@ -348,7 +356,7 @@
  • -
  • +
  • #scenes FelECS::Systems @@ -356,7 +364,7 @@
  • -
  • +
  • sort FelECS::Order @@ -364,7 +372,7 @@
  • -
  • +
  • #systems FelECS::Scenes @@ -372,7 +380,7 @@
  • -
  • +
  • #to_h FelECS::ComponentManager @@ -380,7 +388,7 @@
  • -
  • +
  • #trigger_when_added FelECS::Systems @@ -388,7 +396,7 @@
  • -
  • +
  • #trigger_when_is_changed FelECS::Systems @@ -396,7 +404,7 @@
  • -
  • +
  • #trigger_when_removed FelECS::Systems @@ -404,7 +412,7 @@
  • -
  • +
  • #update_attrs FelECS::ComponentManager diff --git a/docs/top-level-namespace.html b/docs/top-level-namespace.html index 13472bf..b359611 100644 --- a/docs/top-level-namespace.html +++ b/docs/top-level-namespace.html @@ -127,7 +127,7 @@
    -- cgit v1.2.3