From a0f792d8feadf919290b8349dbc0eac143545927 Mon Sep 17 00:00:00 2001 From: _Tradam Date: Mon, 3 Jan 2022 08:26:24 -0500 Subject: Major 4.0 Update (#16) See Changelog --- .rubocop.yml | 4 +- .ruby-version | 1 + CHANGELOG.mdown | 74 ++-- Gemfile | 5 +- Gemfile.lock | 2 +- README.mdown | 187 +++++---- Rakefile | 38 +- bin/console | 6 +- codeclimate/env.rb | 2 + codeclimate/export-coverage.rb | 5 +- deprecated/components/00_renderable.rb | 36 +- deprecated/components/01_sprite.rb | 103 +++-- deprecated/components/03_player_control.rb | 47 +-- deprecated/components/04_map.rb | 3 +- deprecated/components/05_interactable.rb | 4 +- deprecated/components/06_collidable.rb | 10 +- deprecated/components/07_battle.rb | 2 + deprecated/components/07_indoor.rb | 2 + deprecated/components/07_overworld.rb | 4 +- deprecated/components/debug_singleton.rb | 4 +- deprecated/helpers/00_tileset.rb | 28 +- deprecated/helpers/01_component.rb | 131 +++--- deprecated/systems/00_update_levels.rb | 4 +- deprecated/systems/10_player.rb | 44 +- deprecated/systems/99_render.rb | 38 +- docs/FelFlame.html | 62 +-- docs/FelFlame/ComponentManager.html | 648 ++++++----------------------- docs/FelFlame/Components.html | 142 +------ docs/FelFlame/Entities.html | 494 ++++++---------------- docs/FelFlame/Order.html | 251 +++++++++++ docs/FelFlame/Scenes.html | 134 +++--- docs/FelFlame/Stage.html | 82 ++-- docs/FelFlame/Systems.html | 448 +++++++++----------- docs/Felflame_.html | 4 +- docs/_index.html | 23 +- docs/class_list.html | 2 +- docs/file.README.html | 212 ++++++---- docs/index.html | 212 ++++++---- docs/method_list.html | 130 ++---- docs/top-level-namespace.html | 10 +- felflame.gemspec | 42 +- lib/felflame.rb | 36 +- lib/felflame/component_manager.rb | 169 ++++---- lib/felflame/entity_manager.rb | 124 +++--- lib/felflame/order.rb | 24 ++ lib/felflame/scene_manager.rb | 35 +- lib/felflame/stage_manager.rb | 43 +- lib/felflame/system_manager.rb | 139 ++++--- lib/felflame/version.rb | 2 +- spec/component_manager_spec.rb | 110 +++-- spec/entity_manager_spec.rb | 105 +++-- spec/order_spec.rb | 71 ++++ spec/scene_manager_spec.rb | 26 +- spec/spec_helper.rb | 114 ++--- spec/stage_manager_spec.rb | 88 ++-- spec/system_manager_spec.rb | 67 +-- 56 files changed, 2324 insertions(+), 2509 deletions(-) create mode 100644 .ruby-version create mode 100644 docs/FelFlame/Order.html create mode 100644 lib/felflame/order.rb create mode 100644 spec/order_spec.rb diff --git a/.rubocop.yml b/.rubocop.yml index bfef2d0..2cfd5d4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,9 +1,9 @@ AllCops: - TargetRubyVersion: 2.4 + TargetRubyVersion: 2.7 Style/StringLiterals: Enabled: true - EnforcedStyle: double_quotes + EnforcedStyle: single_quotes Style/StringLiteralsInInterpolation: Enabled: true diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..2c9b4ef --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.7.3 diff --git a/CHANGELOG.mdown b/CHANGELOG.mdown index 6f34a95..454c4b8 100644 --- a/CHANGELOG.mdown +++ b/CHANGELOG.mdown @@ -8,46 +8,66 @@ ![Deprecated](https://img.shields.io/badge/-Deprecated-orange) ![Removed](https://img.shields.io/badge/-Removed-red) -## [3.0.0](https://github.com/realtradam/FelFlame/releases/tag/3.0.0) - 2021-07-12 +## [4.0.0](https://github.com/realtradam/FelFlame/releases/tag/4.0.0) - 2021-12-30 +![Removed](https://img.shields.io/badge/-Removed-red) +- Removed all ids as they were not used + ![Changed](https://img.shields.io/badge/-Changed-yellow) -- The Scene alias was changed from ```FelFlame::Sce``` to ```FelFlame::Scn``` as it is more intuitive. +- Scenes now have their own priority attribute +- Stages now sort and execute by Scenes, rather then the net Systems in the Scenes +- Component method `.attrs` was renamed to `.to_h` +- Renamed the `data` accessor to `._data` +- Various arrays are automatically compacted + +![Added](https://img.shields.io/badge/-Added-brightgreen) + - Classes and Modules which used a data array now have the entire set of array methods available to their respective Classes and Modules +- Convenience methods for accessing a single entity in a component(`@component.entity`) and accessing a single entity in a component(`@entity.component[@component_manager]`) + - `FelFlame::Order` class which can set the order if your Scenes and Systems + + ![Fixed](https://img.shields.io/badge/-Fixed-blue) + - Replaced all instances of `sort_by!` with `sort_by` for compatibility with mruby + - Minor optimizations such as less array duplication + +## [3.0.0](https://github.com/realtradam/FelFlame/releases/tag/3.0.0) - 2021-07-12 + ![Changed](https://img.shields.io/badge/-Changed-yellow) + - The Scene alias was changed from ```FelFlame::Sce``` to ```FelFlame::Scn``` as it is more intuitive ## [2.0.0](https://github.com/realtradam/FelFlame/releases/tag/2.0.0) - 2021-07-10 -![Changed](https://img.shields.io/badge/-Changed-yellow) -- Entities and Components now reference each other using the objects themselves rather then their id's -```ruby + ![Changed](https://img.shields.io/badge/-Changed-yellow) + - Entities and Components now reference each other using the objects themselves rather then their id's + ```ruby # before: -@entity.components[@component_manager].each do |component_id| - # iterate over id's, usually would need to do a lookup to get the component itself -end + @entity.components[@component_manager].each do |component_id| +# iterate over id's, usually would need to do a lookup to get the component itself + end # after: -@entity.components[@component_manager].each do |component| - # iterate over the components themselves! No need for lookup anymore -end -``` -```ruby + @entity.components[@component_manager].each do |component| +# iterate over the components themselves! No need for lookup anymore + end + ``` + ```ruby # same for components referencing entities # before: -@component.entities.each do |entity_id| - #iterate over id's -end + @component.entities.each do |entity_id| +#iterate over id's + end # after: -@component.entities.each do |entity| - # directly iterate over entities themselves! -end -``` - + @component.entities.each do |entity| +# directly iterate over entities themselves! + end + ``` + ## [1.0.2](https://github.com/realtradam/FelFlame/releases/tag/1.0.2) - 2021-07-09 -![Fixed](https://img.shields.io/badge/-Fixed-blue) -- Stripped superflous files shrinking gem size significantly + ![Fixed](https://img.shields.io/badge/-Fixed-blue) + - Stripped superflous files shrinking gem size significantly ## [1.0.1](https://github.com/realtradam/FelFlame/releases/tag/1.0.1) - 2021-07-09 -![Fixed](https://img.shields.io/badge/-Fixed-blue) -- Defining attributes in components are no longer allowed to overwrite methods + ![Fixed](https://img.shields.io/badge/-Fixed-blue) + - Defining attributes in components are no longer allowed to overwrite methods ## [1.0.0](https://github.com/realtradam/FelFlame/releases/tag/1.0.0) - 2021-07-09 -![Added](https://img.shields.io/badge/-Added-brightgreen) -- Initial release + ![Added](https://img.shields.io/badge/-Added-brightgreen) + - Initial release diff --git a/Gemfile b/Gemfile index 57f3b06..ffcd824 100644 --- a/Gemfile +++ b/Gemfile @@ -1,11 +1,10 @@ # frozen_string_literal: true -source "https://rubygems.org" +source 'https://rubygems.org' # Specify your gem's dependencies in felflame.gemspec gemspec ruby '2.7.3' -gem "rake", "~> 13.0" - +gem 'rake', '~> 13.0' diff --git a/Gemfile.lock b/Gemfile.lock index c25006c..7b5b5fe 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - felflame (3.0.0) + felflame (4.0.0) GEM remote: https://rubygems.org/ diff --git a/README.mdown b/README.mdown index 45b5b35..acae578 100644 --- a/README.mdown +++ b/README.mdown @@ -13,48 +13,49 @@ -+ [What is FelFlame?](#what-is-felflame) -+ [What is ECS?](#what-is-ecs) - - [Components](#components) - - [Entities](#entities) - - [Systems](#systems) - - [Scenes](#scenes) - - [Stage](#stage) -+ [Usage](#usage) +* [What is FelFlame?](#what-is-felflame) +* [What is ECS?](#what-is-ecs) + * [Components](#components) + * [Entities](#entities) + * [Systems](#systems) + * [Scenes](#scenes) + * [Stage](#stage) + * [Order](#order) +* [Usage](#usage) * [Entities](#entities-1) - - [Creation](#creation) - - [Accessing](#accessing) - - [Get ID](#get-id) - - [Adding and Removing Components](#adding-and-removing-components) - - [Accessing Entities' Attached Components](#accessing-entities-attached-components) - - [Deletion](#deletion) + * [Creation](#creation) + * [Accessing](#accessing) + * [Adding and Removing Components](#adding-and-removing-components) + * [Accessing Entities' Attached Components](#accessing-entities-attached-components) + * [Deletion](#deletion) * [Components](#components-1) - - [Creating a Component Manager](#creating-a-component-manager) - - [Creating a Component from a Component Manager](#creating-a-component-from-a-component-manager) - - [Accessing and Getting ID](#accessing-and-getting-id) - - [Accessing Attributes and Changing Them](#accessing-attributes-and-changing-them) - - [Deleting Components](#deleting-components) - - [Iterating over Components](#iterating-over-components) - - [Accessing Components' attached Entities](#accessing-components-attached-entities) + * [Creating a Component Manager](#creating-a-component-manager) + * [Creating a Component from a Component Manager](#creating-a-component-from-a-component-manager) + * [Accessing](#accessing-1) + * [Accessing Attributes and Changing Them](#accessing-attributes-and-changing-them) + * [Deleting Components](#deleting-components) + * [Accessing Components' attached Entities](#accessing-components-attached-entities) * [Systems](#systems-1) - - [Creation](#creation-1) - - [Execution](#execution) - - [Alternative Execution](#alternative-execution) - - [Clearing Alternative Executions](#clearing-alternative-executions) - - [Redefinition](#redefinition) + * [Creation](#creation-1) + * [Execution](#execution) + * [Alternative Execution](#alternative-execution) + * [Clearing Alternative Executions](#clearing-alternative-executions) + * [Redefinition](#redefinition) * [Scenes](#scenes-1) - - [Creation](#creation-2) - - [Accessing](#accessing-1) - - [Adding Systems](#adding-systems) - - [Removing Systems](#removing-systems) - - [Clearing](#clearing) - - [Execution](#execution-1) + * [Creation](#creation-2) + * [Accessing](#accessing-2) + * [Adding Systems](#adding-systems) + * [Removing Systems](#removing-systems) + * [Clearing](#clearing) + * [Execution](#execution-1) * [Stage](#stage-1) - - [Adding Scenes](#adding-scenes) - - [Removing Scenes](#removing-scenes) - - [Executing](#executing) + * [Adding Scenes](#adding-scenes) + * [Removing Scenes](#removing-scenes) + * [Executing](#executing) + * [Order](#order-1) + * [Setting the order](#setting-the-order) * [Closing Notes](#closing-notes) -+ [Contribution](#contribution) +* [Contribution](#contribution) @@ -85,7 +86,7 @@ Systems are where all the logic or code is kept. There is no data stored in here By using this pattern it allows programmers to easily control what an "object" or entity can do and how much data it needs to have. It avoids the issue of inhertance as no inhertance is ever required in this system. If you need a certain entity to have a certain functionality you just add the relevant component to it, and the systems that automatically go over specific components will give your entitiy the desired functionality. -**"But your framework also has `Scenes` and a `Stage`, what is that about?"** +**"But your framework also has `Scenes`, `Stage`, and `Order`, what is that about?"** --- @@ -95,13 +96,19 @@ Scenes are simply a collection or subset of Systems. This allows for an easy way ### Stage The Stage is Scenes which are activated. This means any Scenes on the Stage are executed each frame, while the rest of the Systems are not. +### Order +Order is a helper class which can set the priority of Scenes and Systems. + --- -If all of this sounds very confusing, don't worry. A video tutorial series is in the works where I will build a game using this framework and explain every step of the way. You can also read some examples and explanations below. # Usage -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. +There are 2 ways of using FelFlame. You can either `include` it as a gem in your project if your game engine supports this. The other option is to download the single file export of FelFlame and then `require_relative` this file in your project. The single file export takes all the ruby code in the various files and concatenates them into a single file so it is more portable and easy to add. + +To use the gem method you can do the following: install the gem using `gem install felflame` or using bundler `bundle add felflame` and then require it in your project like so: `require 'felflame'`. + +To use the single file export method you simply download the felflame.rb file from the [releases page on Github](https://github.com/realtradam/FelFlame/releases) and add it to your source folder and add a `require relative 'felflame.rb'` line or wherever you have placed the file to use it. ## Entities @@ -111,29 +118,24 @@ Entities are essentially "objects" in the game world. To create a new Entity we ```ruby @entity = FelFlame::Entities.new ``` -or if we want to add (any number of)components to it: +or if we want to add (any number of)components to it when creating it: ```ruby @entity = FelFlame::Entites.new( FelFlame::Components::Health.new, @component, - FelFlame::Components::Armour[7] + FelFlame::Components::EnemyTeam.first ) ``` ### Accessing -Once components are created we can access them using their ID like so: +Oftentimes you will not be accessing an Entity this way. Later we will shows you a more common way of accessing entities. +If you need to you can access Entities using the `Entities` module: ```ruby @entity = FelFlame::Entities[2] -``` - -### Get ID -Entity ID's are generated starting from 0 and ascending, unless if there is a missing ID because of a deleted -entity where a new entity will claim that ID. To get the ID of an Entity: - -```ruby -@entity.id +@entity = FelFlame::Entities.first +@entity = FelFlame::Entities.each # you can iterate over all entities this way. Any valid array method can be used ``` ### Adding and Removing Components @@ -145,14 +147,18 @@ We can still add or remove Components from an Entity after it has been created. ``` ### Accessing Entities' Attached Components +This is the most common way of accessing an Entity + When Components are added to Entities, they can be accessed from the Entity. By using a Component Manager as a key we can access an array of all components created from that Component Manager that are attached to an entity: ```ruby -@entity.components[@component_manager] # => [@component1, @component2, component3] +@entity.components[@component_manager] # => [@component1, @component2, @component3] ``` ### Deletion -To have all Components from an Entity removed and the Entity deleted we do the following: +To have all Components from an Entity **removed** and the Entity deleted we do the following: + +NOTE: The components will **not be deleted**. They are simply **removed** from the entity and then the entity is destroyed. You must handle component deletion yourself as for example singleton components need to removed instead of deleted. ```ruby @entity.delete @@ -182,20 +188,19 @@ Now that we have a component manager we can make components from it like so: @component = FelFlame::Components::Stats.new ``` -Or we can even change the defaults: +Or we can even override the defaults when creating the component: ```ruby @component = FelFlame::Components::Stats.new(armour: 'steel') ``` -### Accessing and Getting ID -Just like Entities, Components have IDs. -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. +### Accessing +You can access components using any array method. ```ruby @component = FelFlame::Components::Stats[2] -@component.id # => 2 +@component = FelFlame::Components::Stats.first +@component = FelFlame::Components::Stats.each # you can use iterators this way ``` ### Accessing Attributes and Changing Them @@ -207,30 +212,26 @@ Here are the ways to edit attrubutes, followed by the ways to read them. ``` ```ruby @component.hp # => 95 -@component.attrs # => {armour: 'Leather', hp: 95} +@component.to_h # => {armour: 'Leather', hp: 95} ``` ### Deleting Components -Deleting a Component is the same format as deleting an Entity. When a Component is deleted referenced to it such as to entities are automatically cleared. +Deleting a Component is the same convention as deleting an Entity. When a Component is deleted referenced to it such as to entities are automatically cleared. ```ruby @component.delete ``` -### Iterating over Components -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: - -```ruby -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: ```ruby @component.entities # => [@entity1, @entity2, @entity3] + +# get the first entity attached. +# this will throw a warning if there is more or less then +# exactly one entity +@component.entity # => @entity ``` @@ -252,7 +253,9 @@ FelFlame::Systems::Render ``` Priority determines the order Systems should be executed, this is used for `Scenes` and the `Stage`. The lower the number, the earlier a given System will be executed. -E.g priority 1 will go first, priority 2 will go second, etcetera. +E.g priority 1 will go first, priority 2 will go second, etcetera. + +Both Scenes and Systems have a priority. System priority will decide the order it will be called inside of a Scene, which the Scene priority will decide the order it will be called inside of the Stage. Often we will want to execute some logic on each Component in a given Component Manager so our code might look like this: @@ -355,7 +358,7 @@ end Once we have all the core parts of ECS, we will want to organize our Systems. To do this we will use Scenes to group up Systems so they can quickly be enabled or disabled. Note that [Alternative Executions](#alternative-execution) will occur even if they are not part of a Scene. Here is how we make a new Scene: ```ruby -@scene = FelFlame::Scenes.new('ExampleScene') +@scene = FelFlame::Scenes.new('ExampleScene', priority: 5) ``` ### Accessing @@ -369,14 +372,22 @@ Just like other classes in FelFlame, the name we gave the Scene is how we access Adding Systems is simple. We can add as many as we want. In this example we add 3 different systems: ```ruby -FelFlame::Scenes::ExampleScene.add(FelFlame::Systems::Render, @system2, @system3) +FelFlame::Scenes::ExampleScene.add( + FelFlame::Systems::Render, + @system2, + @system3 +) ``` ### Removing Systems -Removing Systems works simularly: +Removing Systems works similarly: ```ruby -FelFlame::Scenes::ExampleScene.remove(FelFlame::Systems::Render, @system2, @system3) +FelFlame::Scenes::ExampleScene.remove( + FelFlame::Systems::Render, + @system2, + @system3 +) ``` ### Clearing @@ -398,7 +409,7 @@ The Scene will make sure that the systems are executed in the correct order base ## Stage ### Adding Scenes -Finally we have the Stage. There is only a single Stage and we do not have to create it as it exists by default. By adding a Scene to the Stage we are saying that the Scene is active. To add a Scene we do the following: +Finally we have the Stage. There is only a single Stage and we do not have to create it as it exists by default. By adding a Scene to the Stage we are saying that the Scene is 'active'. To add a Scene we do the following: ```ruby FelFlame::Stage.add FelFlame::Scene::ExampleScene @@ -412,12 +423,36 @@ 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: +On each frame of the game generally we will want to execute the Stage once. When the Stage is executed it is progressing your game 1 frame forward. The Stage will call all Scenes you added to it in the order of their priority. Here is how we do it: ```ruby FelFlame::Stage.call ``` +## Order + +### Setting the order + +To set the order you just need to call `FelFlame::Order.sort` and pass Scenes or Systems in the parameters in the order you wish for them to execute + +```ruby +FelFlame::Order.sort( + @system1, + @system2, + @system3 +) +``` + +If you want some Scenes or Systems to have the same priority then just pass them as an array: + +```ruby +FelFlame::Order.sort( + @scene1, + [@scene2_1, @scene2_2], + @scene3 +) +``` + ## Closing Notes There are some methods I haven't gone over in the overview. If you want to see everything and read in more detail check out the [Documentation](https://felflame.tradam.fyi)! diff --git a/Rakefile b/Rakefile index edf99bc..b4ba44b 100644 --- a/Rakefile +++ b/Rakefile @@ -1,15 +1,35 @@ # frozen_string_literal: true -# + require 'rubygems' require 'bundler/setup' require 'rspec/core/rake_task' require 'yard' require_relative './codeclimate/export-coverage' -require "bundler/gem_tasks" -require "rubocop/rake_task" +require 'bundler/gem_tasks' +require 'rubocop/rake_task' + +task default: [:spec, :yard, 'coverage:format'] +# task default: :rubocop + +desc 'Export to single file' +task :buildfile do + result = '' + main = File.read('lib/felflame.rb') + tmp = main.lines(chomp: true).select do |line| + line.include? 'require_relative ' + end + tmp.each do |file| + file.delete_prefix!('require_relative ') + result += "#{File.read("lib/#{file[1, file.length - 2]}.rb")}\n" + end -task :default => [:spec, :yard, 'coverage:format'] -#task default: :rubocop + result += main.lines.reject do |line| + line.include? 'require_relative ' + end.join + + `mkdir pkg` + File.write('pkg/felflame.rb', result) +end RuboCop::RakeTask.new @@ -31,15 +51,15 @@ YARD::Rake::YardocTask.new do |t| t.stats_options = ['--list-undoc'] end -#Rake::TestTask.new do |t| +# Rake::TestTask.new do |t| # t.pattern = "tests/**/*_test.rb" -#end +# end RSpec::Core::RakeTask.new :spec # For installing FelPacks -#Gem::Specification.find_all.each do |a_gem| +# Gem::Specification.find_all.each do |a_gem| # next unless a_gem.name.include? 'felpack-' # # Dir.glob("#{a_gem.gem_dir}/lib/#{a_gem.name.gsub('-', '/')}/tasks/*.rake").each { |r| load r } -#end +# end diff --git a/bin/console b/bin/console index c0dca2c..9e87c14 100755 --- a/bin/console +++ b/bin/console @@ -1,8 +1,8 @@ #!/usr/bin/env ruby # frozen_string_literal: true -require "bundler/setup" -require "felflame" +require 'bundler/setup' +require 'felflame' # You can add fixtures and/or initialization code here to make experimenting # with your gem easier. You can also use a different console, if you like. @@ -11,5 +11,5 @@ require "felflame" # require "pry" # Pry.start -require "irb" +require 'irb' IRB.start(__FILE__) diff --git a/codeclimate/env.rb b/codeclimate/env.rb index 0a0ad43..25bae9e 100644 --- a/codeclimate/env.rb +++ b/codeclimate/env.rb @@ -1 +1,3 @@ +# frozen_string_literal: true + ENV['CC_TEST_REPORTER_ID'] = '48d1c389052ea205cb4d72b05f7606fc53a9b5def70c2bfdd957efb73657d32c' diff --git a/codeclimate/export-coverage.rb b/codeclimate/export-coverage.rb index 7a63acd..74b0cbd 100644 --- a/codeclimate/export-coverage.rb +++ b/codeclimate/export-coverage.rb @@ -1,8 +1,9 @@ -require_relative 'env' +# frozen_string_literal: true +require_relative 'env' class ReportCoverage - class < 1 + return {} end - json_tiles = self.get_json_tiles(json_name) - raise Exception.new "Error, json file not a tileset" unless json_tiles['type'] == 'tileset' + json_tiles = get_json_tiles(json_name) + raise StandardError, 'Error, json file not a tileset' unless json_tiles['type'] == 'tileset' return tile_index - json_tiles['tilecount'] if tile_index > json_tiles['tilecount'] - source_height_tiles = (tile_index.to_i / json_tiles['columns'].to_i).to_i# * json_tiles['tileheight'] + + source_height_tiles = (tile_index.to_i / json_tiles['columns'].to_i).to_i # * json_tiles['tileheight'] { w: json_tiles['tilewidth'], h: json_tiles['tileheight'], path: json_tiles['image'].split('mygame/').last.delete('\\'), diff --git a/deprecated/helpers/01_component.rb b/deprecated/helpers/01_component.rb index 2065d0c..12cce09 100644 --- a/deprecated/helpers/01_component.rb +++ b/deprecated/helpers/01_component.rb @@ -1,74 +1,67 @@ +# frozen_string_literal: true + class FelFlame class Helper + # # Unused: + # class Level < FelFlame::Helper::ComponentManager + # class <= Components::Map.data[key].json['tilesets'].count - end - unless tile.empty? - tile[:x] = Components::Map.data[key].x + (Components::Map.data[key].tilewidth * column_index) + chunk['x'] - tile[:y] = Components::Map.data[key].y + (Components::Map.data[key].tileheight * row_index) + chunk['y'] - tile[:w] = Components::Map.data[key].tilewidth - tile[:h] = Components::Map.data[key].tileheight - $gtk.args.outputs.sprites << tile + next if tile.zero? + + iter = 0 + loop do + tile = Helper.get_tile( + json_name: Components::Map.data[key].json['tilesets'][iter]['source'].split('/').last.delete('\\').delete_suffix('.tsx'), tile_index: tile + ) + break if tile.is_a?(Hash) + + if (iter += 1) >= Components::Map.data[key].json['tilesets'].count + raise StandardError, + "#{Components::Map.data[key].json["json_name"]} not valid map, exceeded tile range" end end + next if tile.empty? + + tile[:x] = + Components::Map.data[key].x + (Components::Map.data[key].tilewidth * column_index) + chunk['x'] + tile[:y] = + Components::Map.data[key].y + (Components::Map.data[key].tileheight * row_index) + chunk['y'] + tile[:w] = Components::Map.data[key].tilewidth + tile[:h] = Components::Map.data[key].tileheight + $gtk.args.outputs.sprites << tile end end end diff --git a/docs/FelFlame.html b/docs/FelFlame.html index 16bb6f9..439094e 100644 --- a/docs/FelFlame.html +++ b/docs/FelFlame.html @@ -4,7 +4,7 @@ - Class: FelFlame + Module: FelFlame — Documentation by YARD 0.9.26 @@ -59,29 +59,13 @@ <div class="clear"></div> </div> - <div id="content"><h1>Class: FelFlame + <div id="content"><h1>Module: FelFlame </h1> <div class="box_info"> - <dl> - <dt>Inherits:</dt> - <dd> - <span class="inheritName">Object</span> - - <ul class="fullTree"> - <li>Object</li> - - <li class="next">FelFlame</li> - - </ul> - <a href="#" class="inheritanceTree">show all</a> - - </dd> - </dl> - @@ -95,7 +79,7 @@ <dl> <dt>Defined in:</dt> <dd>lib/felflame.rb<span class="defines">,<br /> - lib/felflame/scene_manager.rb,<br /> lib/felflame/stage_manager.rb,<br /> lib/felflame/entity_manager.rb,<br /> lib/felflame/system_manager.rb,<br /> lib/felflame/component_manager.rb</span> + lib/felflame/order.rb,<br /> lib/felflame/scene_manager.rb,<br /> lib/felflame/stage_manager.rb,<br /> lib/felflame/entity_manager.rb,<br /> lib/felflame/system_manager.rb,<br /> lib/felflame/component_manager.rb</span> </dd> </dl> @@ -116,9 +100,11 @@ <p class="children"> + <strong class="modules">Modules:</strong> <span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span>, <span class='object_link'><a href="FelFlame/Order.html" title="FelFlame::Order (module)">Order</a></span>, <span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span> + - <strong class="classes">Classes:</strong> <span class='object_link'><a href="FelFlame/ComponentManager.html" title="FelFlame::ComponentManager (class)">ComponentManager</a></span>, <span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (class)">Components</a></span>, <span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span>, <span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span>, <span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (class)">Stage</a></span>, <span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span> + <strong class="classes">Classes:</strong> <span class='object_link'><a href="FelFlame/ComponentManager.html" title="FelFlame::ComponentManager (class)">ComponentManager</a></span>, <span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span>, <span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span>, <span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span> </p> @@ -151,7 +137,7 @@ <div class="docstring"> <div class="discussion"> -<p>An alias for <span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (class)">Components</a></span></p> +<p>An alias for <span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></p> </div> @@ -161,7 +147,7 @@ </div> </dt> - <dd><pre class="code"><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (class)">Components</a></span></span></pre></dd> + <dd><pre class="code"><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span></pre></dd> <dt id="Sys-constant" class="">Sys = <div class="docstring"> @@ -199,7 +185,23 @@ <div class="docstring"> <div class="discussion"> -<p>An alias for <span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (class)">Stage</a></span></p> +<p>An alias for <span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span></p> + + + </div> +</div> +<div class="tags"> + + +</div> + </dt> + <dd><pre class="code"><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span></pre></dd> + + <dt id="Odr-constant" class="">Odr = + <div class="docstring"> + <div class="discussion"> + <dl class="rdoc-list note-list"><dt>An alias for {FelFlame +<dd></dd></dl> </div> @@ -209,7 +211,7 @@ </div> </dt> - <dd><pre class="code"><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (class)">Stage</a></span></span></pre></dd> + <dd><pre class="code"><span class='const'>FelFlame</span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Order.html" title="FelFlame::Order (module)">Order</a></span></span></pre></dd> </dl> @@ -287,15 +289,15 @@ <pre class="lines"> -15 -16 -17</pre> +18 +19 +20</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame.rb', line 15</span> + <pre class="code"><span class="info file"># File 'lib/felflame.rb', line 18</span> <span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span> - <span class='const'><span class='object_link'><a href="" title="FelFlame (class)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (class)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_call'><span class='object_link'><a href="FelFlame/Stage.html#call-class_method" title="FelFlame::Stage.call (method)">call</a></span></span> + <span class='const'><span class='object_link'><a href="" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_call'><span class='object_link'><a href="FelFlame/Stage.html#call-class_method" title="FelFlame::Stage.call (method)">call</a></span></span> <span class='kw'>end</span></pre> </td> </tr> @@ -307,7 +309,7 @@ </div> <div id="footer"> - Generated on Mon Jul 12 18:28:27 2021 by + Generated on Mon Jan 3 08:23:04 2022 by <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.26 (ruby-2.7.3). </div> diff --git a/docs/FelFlame/ComponentManager.html b/docs/FelFlame/ComponentManager.html index 1da6816..19891af 100644 --- a/docs/FelFlame/ComponentManager.html +++ b/docs/FelFlame/ComponentManager.html @@ -37,7 +37,7 @@ <div id="menu"> <a href="../_index.html">Index (C)</a> » - <span class='title'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span> + <span class='title'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span> » <span class="title">ComponentManager</span> @@ -102,7 +102,7 @@ <h2>Overview</h2><div class="docstring"> <div class="discussion"> -<p>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 <tt>@component.var = 5</tt>), or by using the <span class='object_link'><a href="#attrs-instance_method" title="FelFlame::ComponentManager#attrs (method)">#attrs</a></span> and <span class='object_link'><a href="#update_attrs-instance_method" title="FelFlame::ComponentManager#update_attrs (method)">#update_attrs</a></span> methods instead.</p> +<p>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 <tt>@component.var = 5</tt>), or by using the <span class='object_link'><a href="#to_h-instance_method" title="FelFlame::ComponentManager#to_h (method)">#to_h</a></span> and <span class='object_link'><a href="#update_attrs-instance_method" title="FelFlame::ComponentManager#update_attrs (method)">#update_attrs</a></span> methods instead.</p> </div> @@ -264,35 +264,6 @@ <p>Stores references to systems that should be triggered when an attribute from this manager is changed.</p> </div></span> -</li> - - - <li class="public "> - <span class="summary_signature"> - - <a href="#id-instance_method" title="#id (instance method)">#<strong>id</strong> ⇒ Integer </a> - - - - </span> - - - - - <span class="note title readonly">readonly</span> - - - - - - - - - - <span class="summary_desc"><div class='inline'> -<p>Holds the <span class='object_link'><a href="#id-instance_method" title="FelFlame::ComponentManager#id (method)">unique ID</a></span> of a component.</p> -</div></span> - </li> @@ -331,63 +302,6 @@ - <h2> - Class Method Summary - <small><a href="#" class="summary_toggle">collapse</a></small> - </h2> - - <ul class="summary"> - - <li class="public "> - <span class="summary_signature"> - - <a href="#[]-class_method" title="[] (class method)">.<strong>[]</strong>(component_id) ⇒ Component </a> - - - - </span> - - - - - - - - - - <span class="summary_desc"><div class='inline'> -<p>Gets a Component from the given <span class='object_link'><a href="#id-instance_method" title="FelFlame::ComponentManager#id (method)">unique ID</a></span>.</p> -</div></span> - -</li> - - - <li class="public "> - <span class="summary_signature"> - - <a href="#each-class_method" title="each (class method)">.<strong>each</strong>(&block) ⇒ Enumerator </a> - - - - </span> - - - - - - - - - - <span class="summary_desc"><div class='inline'> -<p>Iterates over all components within the component manager.</p> -</div></span> - -</li> - - - </ul> - <h2> Instance Method Summary <small><a href="#" class="summary_toggle">collapse</a></small> @@ -398,31 +312,7 @@ <li class="public "> <span class="summary_signature"> - <a href="#attr_changed_trigger_systems-instance_method" title="#attr_changed_trigger_systems (instance method)">#<strong>attr_changed_trigger_systems</strong>(attr) ⇒ Boolean </a> - - - - </span> - - - - - - - - - - <span class="summary_desc"><div class='inline'> -<p>Execute systems that have been added to execute on variable change.</p> -</div></span> - -</li> - - - <li class="public "> - <span class="summary_signature"> - - <a href="#attrs-instance_method" title="#attrs (instance method)">#<strong>attrs</strong> ⇒ Hash<Symbol, Value> </a> + <a href="#delete-instance_method" title="#delete (instance method)">#<strong>delete</strong> ⇒ Boolean </a> @@ -437,7 +327,7 @@ <span class="summary_desc"><div class='inline'> -<p>A hash, where all the keys are attributes linked to their respective values.</p> +<p>Removes this component from the list and purges all references to this Component from other Entities, as well as its data.</p> </div></span> </li> @@ -446,7 +336,7 @@ <li class="public "> <span class="summary_signature"> - <a href="#delete-instance_method" title="#delete (instance method)">#<strong>delete</strong> ⇒ Boolean </a> + <a href="#entities-instance_method" title="#entities (instance method)">#<strong>entities</strong> ⇒ Array<Component> </a> @@ -461,7 +351,7 @@ <span class="summary_desc"><div class='inline'> -<p>Removes this component from the list and purges all references to this Component from other Entities, as well as its <span class='object_link'><a href="#id-instance_method" title="FelFlame::ComponentManager#id (method)">ID</a></span> and data.</p> +<p>Entities that have this component.</p> </div></span> </li> @@ -470,7 +360,7 @@ <li class="public "> <span class="summary_signature"> - <a href="#entities-instance_method" title="#entities (instance method)">#<strong>entities</strong> ⇒ Array<Integer> </a> + <a href="#entity-instance_method" title="#entity (instance method)">#<strong>entity</strong> ⇒ Component </a> @@ -485,7 +375,7 @@ <span class="summary_desc"><div class='inline'> -<p>A list of entity ids that are linked to the component.</p> +<p>A single entity.</p> </div></span> </li> @@ -520,7 +410,7 @@ <li class="public "> <span class="summary_signature"> - <a href="#to_i-instance_method" title="#to_i (instance method)">#<strong>to_i</strong> ⇒ Integer </a> + <a href="#to_h-instance_method" title="#to_h (instance method)">#<strong>to_h</strong> ⇒ Hash<Symbol, Value> </a> @@ -535,7 +425,7 @@ <span class="summary_desc"><div class='inline'> -<p>An alias for the <span class='object_link'><a href="#id-instance_method" title="FelFlame::ComponentManager#id (method)">ID Reader</a></span>.</p> +<p>A hash, where all the keys are attributes storing their respective values.</p> </div></span> </li> @@ -617,47 +507,37 @@ <pre class="lines"> -104 -105 -106 -107 -108 -109 -110 -111 -112 -113 -114 -115 -116 -117 -118 -119 -120 -121 -122</pre> +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 104</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 132</span> <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_attrs'>attrs</span><span class='rparen'>)</span> <span class='comment'># Prepare the object </span> <span class='comment'># (this is a function created with metaprogramming -</span> <span class='comment'># in FelFlame::Components +</span> <span class='comment'># in FelFlame::Components) </span> <span class='id identifier rubyid_set_defaults'>set_defaults</span> - <span class='comment'># Generate ID -</span> <span class='id identifier rubyid_new_id'>new_id</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_find_index'>find_index</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_i'>i</span><span class='op'>|</span> <span class='id identifier rubyid_i'>i</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='rbrace'>}</span> - <span class='id identifier rubyid_new_id'>new_id</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='kw'>if</span> <span class='id identifier rubyid_new_id'>new_id</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> - <span class='ivar'>@id</span> <span class='op'>=</span> <span class='id identifier rubyid_new_id'>new_id</span> - <span class='comment'># Fill params </span> <span class='id identifier rubyid_attrs'>attrs</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span> <span class='id identifier rubyid_send'>send</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span> <span class='kw'>end</span> <span class='comment'># Save Component -</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_new_id'>new_id</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='kw'>self</span> +</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span> <span class='kw'>self</span> <span class='kw'>end</span></pre> </td> </tr> @@ -710,12 +590,12 @@ <pre class="lines"> -136 -137 -138</pre> +180 +181 +182</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 136</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 180</span> <span class='kw'>def</span> <span class='id identifier rubyid_addition_triggers'>addition_triggers</span> <span class='ivar'>@addition_triggers</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> @@ -766,12 +646,12 @@ <pre class="lines"> -152 -153 -154</pre> +196 +197 +198</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 152</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 196</span> <span class='kw'>def</span> <span class='id identifier rubyid_attr_triggers'>attr_triggers</span> <span class='ivar'>@attr_triggers</span> <span class='op'>||=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span> @@ -822,12 +702,12 @@ <pre class="lines"> -144 -145 -146</pre> +188 +189 +190</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 144</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 188</span> <span class='kw'>def</span> <span class='id identifier rubyid_removal_triggers'>removal_triggers</span> <span class='ivar'>@removal_triggers</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> @@ -883,12 +763,12 @@ <pre class="lines"> -81 -82 -83</pre> +109 +110 +111</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 81</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 109</span> <span class='kw'>def</span> <span class='id identifier rubyid_addition_triggers'>addition_triggers</span> <span class='ivar'>@addition_triggers</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> @@ -939,12 +819,12 @@ <pre class="lines"> -97 -98 -99</pre> +125 +126 +127</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 97</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 125</span> <span class='kw'>def</span> <span class='id identifier rubyid_attr_triggers'>attr_triggers</span> <span class='ivar'>@attr_triggers</span> <span class='op'>||=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span> @@ -955,62 +835,6 @@ </div> - <span id="id=-instance_method"></span> - <div class="method_details "> - <h3 class="signature " id="id-instance_method"> - - #<strong>id</strong> ⇒ <tt>Integer</tt> - - - - - -</h3><div class="docstring"> - <div class="discussion"> - -<p>Holds the <span class='object_link'><a href="#id-instance_method" title="FelFlame::ComponentManager#id (method)">unique ID</a></span> of a component. The <span class='object_link'><a href="#id-instance_method" title="FelFlame::ComponentManager#id (method)">ID</a></span> is only unique within the scope of the component manager it was created from.</p> - - - </div> -</div> -<div class="tags"> - -<p class="tag_title">Returns:</p> -<ul class="return"> - - <li> - - - <span class='type'>(<tt>Integer</tt>)</span> - - - - </li> - -</ul> - -</div><table class="source_code"> - <tr> - <td> - <pre class="lines"> - - -63 -64 -65</pre> - </td> - <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 63</span> - -<span class='kw'>def</span> <span class='id identifier rubyid_id'>id</span> - <span class='ivar'>@id</span> -<span class='kw'>end</span></pre> - </td> - </tr> -</table> -</div> - - <span id="removal_triggers=-instance_method"></span> <div class="method_details "> <h3 class="signature " id="removal_triggers-instance_method"> @@ -1051,12 +875,12 @@ <pre class="lines"> -89 -90 -91</pre> +117 +118 +119</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 89</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 117</span> <span class='kw'>def</span> <span class='id identifier rubyid_removal_triggers'>removal_triggers</span> <span class='ivar'>@removal_triggers</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> @@ -1069,157 +893,14 @@ </div> - <div id="class_method_details" class="method_details_list"> - <h2>Class Method Details</h2> - - - <div class="method_details first"> - <h3 class="signature first" id="[]-class_method"> - - .<strong>[]</strong>(component_id) ⇒ <tt>Component</tt> - - - - - -</h3><div class="docstring"> - <div class="discussion"> - -<p>Gets a Component from the given <span class='object_link'><a href="#id-instance_method" title="FelFlame::ComponentManager#id (method)">unique ID</a></span>. Usage is simular to how an Array lookup works.</p> - - - </div> -</div> -<div class="tags"> - - <div class="examples"> - <p class="tag_title">Examples:</p> - - - <pre class="example code"><code><span class='comment'># this gets the 'Health' Component with ID 7 -</span><span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Components.html" title="FelFlame::Components (class)">Components</a></span></span><span class='op'>::</span><span class='const'>Health</span><span class='lbracket'>[</span><span class='int'>7</span><span class='rbracket'>]</span></code></pre> - - </div> -<p class="tag_title">Parameters:</p> -<ul class="param"> - - <li> - - <span class='name'>component_id</span> - - - <span class='type'>(<tt>Integer</tt>)</span> - - - - </li> - -</ul> - -<p class="tag_title">Returns:</p> -<ul class="return"> - - <li> - - - <span class='type'>(<tt>Component</tt>)</span> - - - - — - <div class='inline'> -<p>Returns the Component that uses the given unique <span class='object_link'><a href="#id-instance_method" title="FelFlame::ComponentManager#id (method)">ID</a></span>, nil if there is no Component associated with the given <span class='object_link'><a href="#id-instance_method" title="FelFlame::ComponentManager#id (method)">ID</a></span></p> -</div> - - </li> - -</ul> - -</div><table class="source_code"> - <tr> - <td> - <pre class="lines"> - - -169 -170 -171</pre> - </td> - <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 169</span> - -<span class='kw'>def</span> <span class='op'>[]</span><span class='lparen'>(</span><span class='id identifier rubyid_component_id'>component_id</span><span class='rparen'>)</span> - <span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_component_id'>component_id</span><span class='rbracket'>]</span> -<span class='kw'>end</span></pre> - </td> - </tr> -</table> -</div> - - <div class="method_details "> - <h3 class="signature " id="each-class_method"> - - .<strong>each</strong>(&block) ⇒ <tt>Enumerator</tt> - - - - - -</h3><div class="docstring"> - <div class="discussion"> - -<p>Iterates over all components within the component manager. Special Enumerable methods like <code>map</code> or <code>each_with_index</code> are not implemented</p> - - - </div> -</div> -<div class="tags"> - -<p class="tag_title">Returns:</p> -<ul class="return"> - - <li> - - - <span class='type'>(<tt>Enumerator</tt>)</span> - - - - </li> - -</ul> - -</div><table class="source_code"> - <tr> - <td> - <pre class="lines"> - - -176 -177 -178</pre> - </td> - <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 176</span> - -<span class='kw'>def</span> <span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span> - <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span> -<span class='kw'>end</span></pre> - </td> - </tr> -</table> -</div> - - </div> - <div id="instance_method_details" class="method_details_list"> <h2>Instance Method Details</h2> <div class="method_details first"> - <h3 class="signature first" id="attr_changed_trigger_systems-instance_method"> + <h3 class="signature first" id="delete-instance_method"> - #<strong>attr_changed_trigger_systems</strong>(attr) ⇒ <tt>Boolean</tt> + #<strong>delete</strong> ⇒ <tt>Boolean</tt> @@ -1228,7 +909,7 @@ </h3><div class="docstring"> <div class="discussion"> -<p>Execute systems that have been added to execute on variable change</p> +<p>Removes this component from the list and purges all references to this Component from other Entities, as well as its data.</p> </div> @@ -1247,7 +928,7 @@ — <div class='inline'> -<p><code>true</code></p> +<p><code>true</code>.</p> </div> </li> @@ -1260,26 +941,34 @@ <pre class="lines"> -203 -204 -205 -206 -207 -208 -209 -210 -211</pre> +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 203</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 247</span> -<span class='kw'>def</span> <span class='id identifier rubyid_attr_changed_trigger_systems'>attr_changed_trigger_systems</span><span class='lparen'>(</span><span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span> - <span class='id identifier rubyid_systems_to_execute'>systems_to_execute</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_attr_triggers'>attr_triggers</span><span class='lbracket'>[</span><span class='id identifier rubyid_attr'>attr</span><span class='rbracket'>]</span> - <span class='id identifier rubyid_systems_to_execute'>systems_to_execute</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='id identifier rubyid_systems_to_execute'>systems_to_execute</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> - - <span class='id identifier rubyid_systems_to_execute'>systems_to_execute</span> <span class='op'>|=</span> <span class='id identifier rubyid_attr_triggers'>attr_triggers</span><span class='lbracket'>[</span><span class='id identifier rubyid_attr'>attr</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_attr_triggers'>attr_triggers</span><span class='lbracket'>[</span><span class='id identifier rubyid_attr'>attr</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> - - <span class='id identifier rubyid_systems_to_execute'>systems_to_execute</span><span class='period'>.</span><span class='id identifier rubyid_sort_by'>sort_by</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:priority</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_reverse'>reverse</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:call</span><span class='rparen'>)</span> +<span class='kw'>def</span> <span class='id identifier rubyid_delete'>delete</span> + <span class='id identifier rubyid_addition_triggers'>addition_triggers</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_system'>system</span><span class='op'>|</span> + <span class='id identifier rubyid_system'>system</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span> <span class='label'>component_or_manager:</span> <span class='kw'>self</span> + <span class='kw'>end</span> + <span class='id identifier rubyid_entities'>entities</span><span class='period'>.</span><span class='id identifier rubyid_reverse_each'>reverse_each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_entity'>entity</span><span class='op'>|</span> + <span class='id identifier rubyid_entity'>entity</span><span class='period'>.</span><span class='id identifier rubyid_remove'>remove</span> <span class='kw'>self</span> + <span class='kw'>end</span> + <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid__data'>_data</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='kw'>self</span> + <span class='id identifier rubyid_instance_variables'>instance_variables</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_var'>var</span><span class='op'>|</span> + <span class='id identifier rubyid_instance_variable_set'>instance_variable_set</span><span class='lparen'>(</span><span class='id identifier rubyid_var'>var</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='rparen'>)</span> + <span class='kw'>end</span> <span class='kw'>true</span> <span class='kw'>end</span></pre> </td> @@ -1288,9 +977,9 @@ </div> <div class="method_details "> - <h3 class="signature " id="attrs-instance_method"> + <h3 class="signature " id="entities-instance_method"> - #<strong>attrs</strong> ⇒ <tt>Hash<Symbol, Value></tt> + #<strong>entities</strong> ⇒ <tt>Array<Component></tt> @@ -1299,7 +988,7 @@ </h3><div class="docstring"> <div class="discussion"> -<p>Returns A hash, where all the keys are attributes linked to their respective values.</p> +<p>Entities that have this component</p> </div> @@ -1312,14 +1001,9 @@ <li> - <span class='type'>(<tt>Hash<Symbol, Value></tt>)</span> - + <span class='type'>(<tt>Array<Component></tt>)</span> - — - <div class='inline'> -<p>A hash, where all the keys are attributes linked to their respective values.</p> -</div> </li> @@ -1331,23 +1015,15 @@ <pre class="lines"> -235 -236 -237 -238 -239 -240 -241</pre> +209 +210 +211</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 235</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 209</span> -<span class='kw'>def</span> <span class='id identifier rubyid_attrs'>attrs</span> - <span class='id identifier rubyid_return_hash'>return_hash</span> <span class='op'>=</span> <span class='id identifier rubyid_instance_variables'>instance_variables</span><span class='period'>.</span><span class='id identifier rubyid_each_with_object'>each_with_object</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_final'>final</span><span class='op'>|</span> - <span class='id identifier rubyid_final'>final</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_delete_prefix'>delete_prefix</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>@</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_instance_variable_get'>instance_variable_get</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span> - <span class='kw'>end</span> - <span class='id identifier rubyid_return_hash'>return_hash</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:attr_triggers</span><span class='rparen'>)</span> - <span class='id identifier rubyid_return_hash'>return_hash</span> +<span class='kw'>def</span> <span class='id identifier rubyid_entities'>entities</span> + <span class='ivar'>@entities</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> <span class='kw'>end</span></pre> </td> </tr> @@ -1355,9 +1031,9 @@ </div> <div class="method_details "> - <h3 class="signature " id="delete-instance_method"> + <h3 class="signature " id="entity-instance_method"> - #<strong>delete</strong> ⇒ <tt>Boolean</tt> + #<strong>entity</strong> ⇒ <tt>Component</tt> @@ -1366,7 +1042,7 @@ </h3><div class="docstring"> <div class="discussion"> -<p>Removes this component from the list and purges all references to this Component from other Entities, as well as its <span class='object_link'><a href="#id-instance_method" title="FelFlame::ComponentManager#id (method)">ID</a></span> and data.</p> +<p>A single entity. Use this if you expect the component to only belong to one entity and you want to access it.</p> </div> @@ -1379,14 +1055,9 @@ <li> - <span class='type'>(<tt>Boolean</tt>)</span> - + <span class='type'>(<tt>Component</tt>)</span> - — - <div class='inline'> -<p><code>true</code>.</p> -</div> </li> @@ -1405,38 +1076,18 @@ 219 220 221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232</pre> +222</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 215</span> -<span class='kw'>def</span> <span class='id identifier rubyid_delete'>delete</span> - <span class='id identifier rubyid_addition_triggers'>addition_triggers</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_system'>system</span><span class='op'>|</span> - <span class='id identifier rubyid_system'>system</span><span class='period'>.</span><span class='id identifier rubyid_clear_triggers'>clear_triggers</span> <span class='label'>component_or_manager:</span> <span class='kw'>self</span> - <span class='kw'>end</span> - <span class='comment'># This needs to be cloned because indices get deleted as -</span> <span class='comment'># the remove command is called, breaking the loop if it -</span> <span class='comment'># wasn't referencing a clone(will get Nil errors) -</span> <span class='id identifier rubyid_iter'>iter</span> <span class='op'>=</span> <span class='id identifier rubyid_entities'>entities</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:clone</span><span class='rparen'>)</span> - <span class='id identifier rubyid_iter'>iter</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_entity'>entity</span><span class='op'>|</span> - <span class='comment'>#FelFlame::Entities[entity_id].remove self #unless FelFlame::Entities[entity_id].nil? -</span> <span class='id identifier rubyid_entity'>entity</span><span class='period'>.</span><span class='id identifier rubyid_remove'>remove</span> <span class='kw'>self</span> - <span class='kw'>end</span> - <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_id'>id</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='kw'>nil</span> - <span class='id identifier rubyid_instance_variables'>instance_variables</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_var'>var</span><span class='op'>|</span> - <span class='id identifier rubyid_instance_variable_set'>instance_variable_set</span><span class='lparen'>(</span><span class='id identifier rubyid_var'>var</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='rparen'>)</span> +<span class='kw'>def</span> <span class='id identifier rubyid_entity'>entity</span> + <span class='kw'>if</span> <span class='id identifier rubyid_entities'>entities</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> + <span class='const'>Warning</span><span class='period'>.</span><span class='id identifier rubyid_warn'>warn</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>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.</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> + <span class='kw'>elsif</span> <span class='id identifier rubyid_entities'>entities</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>></span> <span class='int'>1</span> + <span class='const'>Warning</span><span class='period'>.</span><span class='id identifier rubyid_warn'>warn</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>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.</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>end</span> - <span class='kw'>true</span> + <span class='id identifier rubyid_entities'>entities</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> <span class='kw'>end</span></pre> </td> </tr> @@ -1444,9 +1095,9 @@ </div> <div class="method_details "> - <h3 class="signature " id="entities-instance_method"> + <h3 class="signature " id="to_h-instance_method"> - #<strong>entities</strong> ⇒ <tt>Array<Integer></tt> + #<strong>to_h</strong> ⇒ <tt>Hash<Symbol, Value></tt> @@ -1455,7 +1106,7 @@ </h3><div class="docstring"> <div class="discussion"> -<p>A list of entity ids that are linked to the component</p> +<p>Returns A hash, where all the keys are attributes storing their respective values.</p> </div> @@ -1468,63 +1119,14 @@ <li> - <span class='type'>(<tt>Array<Integer></tt>)</span> + <span class='type'>(<tt>Hash<Symbol, Value></tt>)</span> - </li> - -</ul> - -</div><table class="source_code"> - <tr> - <td> - <pre class="lines"> - - -189 -190 -191</pre> - </td> - <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 189</span> - -<span class='kw'>def</span> <span class='id identifier rubyid_entities'>entities</span> - <span class='ivar'>@entities</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> -<span class='kw'>end</span></pre> - </td> - </tr> -</table> -</div> - - <div class="method_details "> - <h3 class="signature " id="to_i-instance_method"> - - #<strong>to_i</strong> ⇒ <tt>Integer</tt> - - - - - -</h3><div class="docstring"> - <div class="discussion"> - -<p>An alias for the <span class='object_link'><a href="#id-instance_method" title="FelFlame::ComponentManager#id (method)">ID Reader</a></span></p> - - - </div> + — + <div class='inline'> +<p>A hash, where all the keys are attributes storing their respective values.</p> </div> -<div class="tags"> - -<p class="tag_title">Returns:</p> -<ul class="return"> - - <li> - - - <span class='type'>(<tt>Integer</tt>)</span> - - </li> @@ -1536,15 +1138,23 @@ <pre class="lines"> -183 -184 -185</pre> +262 +263 +264 +265 +266 +267 +268</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 183</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 262</span> -<span class='kw'>def</span> <span class='id identifier rubyid_to_i'>to_i</span> - <span class='id identifier rubyid_id'>id</span> +<span class='kw'>def</span> <span class='id identifier rubyid_to_h'>to_h</span> + <span class='id identifier rubyid_return_hash'>return_hash</span> <span class='op'>=</span> <span class='id identifier rubyid_instance_variables'>instance_variables</span><span class='period'>.</span><span class='id identifier rubyid_each_with_object'>each_with_object</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_final'>final</span><span class='op'>|</span> + <span class='id identifier rubyid_final'>final</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_delete_prefix'>delete_prefix</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>@</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_instance_variable_get'>instance_variable_get</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span> + <span class='kw'>end</span> + <span class='id identifier rubyid_return_hash'>return_hash</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:attr_triggers</span><span class='rparen'>)</span> + <span class='id identifier rubyid_return_hash'>return_hash</span> <span class='kw'>end</span></pre> </td> </tr> @@ -1595,14 +1205,14 @@ <pre class="lines"> -195 -196 -197 -198 -199</pre> +226 +227 +228 +229 +230</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 195</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 226</span> <span class='kw'>def</span> <span class='id identifier rubyid_update_attrs'>update_attrs</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_opts'>opts</span><span class='rparen'>)</span> <span class='id identifier rubyid_opts'>opts</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span> @@ -1619,7 +1229,7 @@ </div> <div id="footer"> - Generated on Mon Jul 12 18:28:27 2021 by + Generated on Mon Jan 3 08:23:04 2022 by <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.26 (ruby-2.7.3). </div> diff --git a/docs/FelFlame/Components.html b/docs/FelFlame/Components.html index a44ec31..be924da 100644 --- a/docs/FelFlame/Components.html +++ b/docs/FelFlame/Components.html @@ -4,7 +4,7 @@ <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title> - Class: FelFlame::Components + Module: FelFlame::Components — Documentation by YARD 0.9.26 @@ -37,7 +37,7 @@ <div id="menu"> <a href="../_index.html">Index (C)</a> » - <span class='title'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span> + <span class='title'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span> » <span class="title">Components</span> @@ -59,37 +59,16 @@ <div class="clear"></div> </div> - <div id="content"><h1>Class: FelFlame::Components + <div id="content"><h1>Module: FelFlame::Components </h1> <div class="box_info"> - <dl> - <dt>Inherits:</dt> - <dd> - <span class="inheritName">Object</span> - - <ul class="fullTree"> - <li>Object</li> - - <li class="next">FelFlame::Components</li> - - </ul> - <a href="#" class="inheritanceTree">show all</a> - - </dd> - </dl> - - <dl> - <dt>Extended by:</dt> - <dd>Enumerable</dd> - </dl> - @@ -109,7 +88,7 @@ <h2>Overview</h2><div class="docstring"> <div class="discussion"> -<p>Creates component managers and allows accessing them them under the <span class='object_link'><a href="" title="FelFlame::Components (class)">Components</a></span> namespace as Constants</p> +<p>Creates component managers and allows accessing them them under the <span class='object_link'><a href="" title="FelFlame::Components (module)">Components</a></span> namespace as Constants. You can use array methods directly on this class to access Component Managers.</p> <p>To see how component managers are used please look at the <span class='object_link'><a href="ComponentManager.html" title="FelFlame::ComponentManager (class)">ComponentManager</a></span> documentation.</p> @@ -137,30 +116,6 @@ <li class="public "> <span class="summary_signature"> - <a href="#each-class_method" title="each (class method)">.<strong>each</strong>(&block) ⇒ Enumerator </a> - - - - </span> - - - - - - - - - - <span class="summary_desc"><div class='inline'> -<p>Iterate over all existing component managers.</p> -</div></span> - -</li> - - - <li class="public "> - <span class="summary_signature"> - <a href="#new-class_method" title="new (class method)">.<strong>new</strong>(component_name, *attrs, **attrs_with_defaults) ⇒ ComponentManager </a> @@ -186,68 +141,13 @@ - <div id="class_method_details" class="method_details_list"> <h2>Class Method Details</h2> <div class="method_details first"> - <h3 class="signature first" id="each-class_method"> - - .<strong>each</strong>(&block) ⇒ <tt>Enumerator</tt> - - - - - -</h3><div class="docstring"> - <div class="discussion"> - -<p>Iterate over all existing component managers. You also call other enumerable methods instead of each, such as <code>each_with_index</code> or <code>select</code></p> - - - </div> -</div> -<div class="tags"> - -<p class="tag_title">Returns:</p> -<ul class="return"> - - <li> - - - <span class='type'>(<tt>Enumerator</tt>)</span> - - - - </li> - -</ul> - -</div><table class="source_code"> - <tr> - <td> - <pre class="lines"> - - -51 -52 -53</pre> - </td> - <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 51</span> - -<span class='kw'>def</span> <span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span> - <span class='id identifier rubyid_constants'>constants</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span> -<span class='kw'>end</span></pre> - </td> - </tr> -</table> -</div> - - <div class="method_details "> - <h3 class="signature " id="new-class_method"> + <h3 class="signature first" id="new-class_method"> .<strong>new</strong>(component_name, *attrs, **attrs_with_defaults) ⇒ <tt><span class='object_link'><a href="ComponentManager.html" title="FelFlame::ComponentManager (class)">ComponentManager</a></span></tt> @@ -273,7 +173,7 @@ </span><span class='comment'># while max and current are nil until set. </span><span class='comment'># When you make a new component using this component manager </span><span class='comment'># these are the values and accessors it will have. -</span><span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span><span class='op'>::</span><span class='const'>Component</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Health</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='symbol'>:max</span><span class='comma'>,</span> <span class='symbol'>:current</span><span class='comma'>,</span> <span class='label'>color:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>red</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span></code></pre> +</span><span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'>Component</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Health</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='symbol'>:max</span><span class='comma'>,</span> <span class='symbol'>:current</span><span class='comma'>,</span> <span class='label'>color:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>red</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span></code></pre> </div> <p class="tag_title">Parameters:</p> @@ -349,7 +249,6 @@ <pre class="lines"> -19 20 21 22 @@ -377,39 +276,42 @@ 44 45 46 -47</pre> +47 +48 +49</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 19</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 20</span> <span class='kw'>def</span> <span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_attrs'>attrs</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_attrs_with_defaults'>attrs_with_defaults</span><span class='rparen'>)</span> - <span class='kw'>if</span> <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Components (class)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_defined?'>const_defined?</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span> + <span class='kw'>if</span> <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Components (module)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_defined?'>const_defined?</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span> <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'>NameError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Component Manager '</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_component_name'>component_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>' is already defined</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>end</span> - - <span class='id identifier rubyid_const_set'>const_set</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='comma'>,</span> <span class='const'>Class</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="ComponentManager.html" title="FelFlame::ComponentManager (class)">ComponentManager</a></span></span><span class='rparen'>)</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span> + <span class='id identifier rubyid_const_set'>const_set</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='comma'>,</span> <span class='const'>Class</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="ComponentManager.html" title="FelFlame::ComponentManager (class)">ComponentManager</a></span></span><span class='rparen'>)</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span> + <span class='id identifier rubyid_update_const_cache'>update_const_cache</span> <span class='id identifier rubyid_attrs'>attrs</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_attr'>attr</span><span class='op'>|</span> - <span class='kw'>if</span> <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Components (class)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_method_defined?'>method_defined?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attr'>attr</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='op'>||</span> <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Components (class)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_method_defined?'>method_defined?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attr'>attr</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> - <span class='id identifier rubyid_raise'>raise</span> <span class='const'>NameError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>The attribute name \"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attr'>attr</span><span class='embexpr_end'>}</span><span class='tstring_content'>\" is already a method</span><span class='tstring_end'>"</span></span> + <span class='kw'>if</span> <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Components (module)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_method_defined?'>method_defined?</span><span class='lparen'>(</span><span class='id identifier rubyid_attr'>attr</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Components (module)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_method_defined?'>method_defined?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attr'>attr</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> + <span class='id identifier rubyid_raise'>raise</span> <span class='const'>NameError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>The attribute name \"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attr'>attr</span><span class='embexpr_end'>}</span><span class='tstring_content'>\" is already a method</span><span class='tstring_end'>"</span></span> <span class='kw'>end</span> - <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Components (class)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='id identifier rubyid_attr'>attr</span> + + <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Components (module)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='id identifier rubyid_attr'>attr</span> <span class='kw'>end</span> <span class='id identifier rubyid_attrs_with_defaults'>attrs_with_defaults</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_attr'>attr</span><span class='comma'>,</span> <span class='id identifier rubyid__default'>_default</span><span class='op'>|</span> <span class='id identifier rubyid_attrs_with_defaults'>attrs_with_defaults</span><span class='lbracket'>[</span><span class='id identifier rubyid_attr'>attr</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid__default'>_default</span><span class='period'>.</span><span class='id identifier rubyid_dup'>dup</span> - <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Components (class)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_attr_reader'>attr_reader</span> <span class='id identifier rubyid_attr'>attr</span> - <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Components (class)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_define_method'>define_method</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attr'>attr</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_value'>value</span><span class='op'>|</span> + <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Components (module)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_attr_reader'>attr_reader</span> <span class='id identifier rubyid_attr'>attr</span> + <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Components (module)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_define_method'>define_method</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attr'>attr</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_value'>value</span><span class='op'>|</span> <span class='id identifier rubyid_attr_changed_trigger_systems'>attr_changed_trigger_systems</span><span class='lparen'>(</span><span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_equal?'>equal?</span> <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span> <span class='id identifier rubyid_instance_variable_set'>instance_variable_set</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>@</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attr'>attr</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span> <span class='kw'>end</span> <span class='kw'>end</span> - <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Components (class)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_define_method'>define_method</span><span class='lparen'>(</span><span class='symbol'>:set_defaults</span><span class='rparen'>)</span> <span class='kw'>do</span> + <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Components (module)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_define_method'>define_method</span><span class='lparen'>(</span><span class='symbol'>:set_defaults</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='id identifier rubyid_attrs_with_defaults'>attrs_with_defaults</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_attr'>attr</span><span class='comma'>,</span> <span class='id identifier rubyid_default'>default</span><span class='op'>|</span> <span class='id identifier rubyid_instance_variable_set'>instance_variable_set</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>@</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attr'>attr</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_default'>default</span><span class='period'>.</span><span class='id identifier rubyid_dup'>dup</span><span class='rparen'>)</span> <span class='kw'>end</span> <span class='kw'>end</span> - <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Components (class)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span> + <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Components (module)">Components</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_component_name'>component_name</span><span class='rparen'>)</span> <span class='kw'>end</span></pre> </td> </tr> @@ -421,7 +323,7 @@ </div> <div id="footer"> - Generated on Mon Jul 12 18:28:27 2021 by + Generated on Mon Jan 3 08:23:04 2022 by <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.26 (ruby-2.7.3). </div> diff --git a/docs/FelFlame/Entities.html b/docs/FelFlame/Entities.html index 9d10529..37a9d84 100644 --- a/docs/FelFlame/Entities.html +++ b/docs/FelFlame/Entities.html @@ -37,7 +37,7 @@ <div id="menu"> <a href="../_index.html">Index (E)</a> » - <span class='title'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span> + <span class='title'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span> » <span class="title">Entities</span> @@ -85,11 +85,6 @@ - <dl> - <dt>Extended by:</dt> - <dd>Enumerable</dd> - </dl> - @@ -109,7 +104,7 @@ <h2>Overview</h2><div class="docstring"> <div class="discussion"> -<p>Creates and manages Entities. Allows accessing Entities using their <span class='object_link'><a href="#id-instance_method" title="FelFlame::Entities#id (method)">ID</a></span>. Entities are just collections of Components.</p> +<p>Creates and manages Entities. Entities are just collections of Components. You can use array methods directly on this class to access Entities.</p> </div> @@ -121,46 +116,12 @@ - <h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2> - <ul class="summary"> - - <li class="public "> - <span class="summary_signature"> - - <a href="#id-instance_method" title="#id (instance method)">#<strong>id</strong> ⇒ Integer </a> - - - - </span> - - - - - <span class="note title readonly">readonly</span> - - - - - - - - - - <span class="summary_desc"><div class='inline'> -<p>Holds the unique ID of this entity.</p> -</div></span> - -</li> - - - </ul> - <h2> - Class Method Summary + Instance Method Summary <small><a href="#" class="summary_toggle">collapse</a></small> </h2> @@ -169,31 +130,7 @@ <li class="public "> <span class="summary_signature"> - <a href="#[]-class_method" title="[] (class method)">.<strong>[]</strong>(entity_id) ⇒ Entity </a> - - - - </span> - - - - - - - - - - <span class="summary_desc"><div class='inline'> -<p>Gets an Entity from the given <span class='object_link'><a href="#id-instance_method" title="FelFlame::Entities#id (method)">unique ID</a></span>.</p> -</div></span> - -</li> - - - <li class="public "> - <span class="summary_signature"> - - <a href="#each-class_method" title="each (class method)">.<strong>each</strong>(&block) ⇒ Enumerator </a> + <a href="#add-instance_method" title="#add (instance method)">#<strong>add</strong>(*components_to_add) ⇒ Boolean </a> @@ -208,25 +145,16 @@ <span class="summary_desc"><div class='inline'> -<p>Iterates over all entities.</p> +<p>Add any number components to the Entity.</p> </div></span> </li> - </ul> - - <h2> - Instance Method Summary - <small><a href="#" class="summary_toggle">collapse</a></small> - </h2> - - <ul class="summary"> - <li class="public "> <span class="summary_signature"> - <a href="#add-instance_method" title="#add (instance method)">#<strong>add</strong>(*components_to_add) ⇒ Boolean </a> + <a href="#component-instance_method" title="#component (instance method)">#<strong>component</strong>(manager = nil) ⇒ Component </a> @@ -241,7 +169,7 @@ <span class="summary_desc"><div class='inline'> -<p>Add any number components to the Entity.</p> +<p>A single component from a component manager.</p> </div></span> </li> @@ -265,7 +193,7 @@ <span class="summary_desc"><div class='inline'> -<p>A hash that uses component manager constant names as keys, and where the values of those keys are arrays that contain the <span class='object_link'><a href="ComponentManager.html#id-instance_method" title="FelFlame::ComponentManager#id (method)">IDs</a></span> of the components attached to this entity.</p> +<p>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.</p> </div></span> </li> @@ -289,7 +217,7 @@ <span class="summary_desc"><div class='inline'> -<p>Removes this Entity from the list and purges all references to this Entity from other Components, as well as its <span class='object_link'><a href="#id-instance_method" title="FelFlame::Entities#id (method)">ID</a></span> and data.</p> +<p>Removes this Entity from the list and purges all references to this Entity from other Components, as well as its data.</p> </div></span> </li> @@ -342,38 +270,13 @@ <p>Remove a component from the Entity.</p> </div></span> -</li> - - - <li class="public "> - <span class="summary_signature"> - - <a href="#to_i-instance_method" title="#to_i (instance method)">#<strong>to_i</strong> ⇒ Integer </a> - - - - </span> - - - - - - - - - - <span class="summary_desc"><div class='inline'> -<p>An alias for the <span class='object_link'><a href="#id-instance_method" title="FelFlame::Entities#id (method)">ID reader</a></span>.</p> -</div></span> - </li> </ul> - - <div id="constructor_details" class="method_details_list"> +<div id="constructor_details" class="method_details_list"> <h2>Constructor Details</h2> <div class="method_details first"> @@ -402,7 +305,7 @@ <span class='name'>components</span> - <span class='type'>(<tt><span class='object_link'><a href="Components.html" title="FelFlame::Components (class)">Components</a></span></tt>)</span> + <span class='type'>(<tt><span class='object_link'><a href="Components.html" title="FelFlame::Components (module)">Components</a></span></tt>)</span> @@ -422,31 +325,19 @@ <pre class="lines"> -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26</pre> +8 +9 +10 +11 +12</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 16</span> + <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 8</span> <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_components'>components</span><span class='rparen'>)</span> - <span class='comment'># Assign new unique ID -</span> <span class='id identifier rubyid_new_id'>new_id</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_find_index'>find_index</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:nil?</span><span class='rparen'>)</span> - <span class='id identifier rubyid_new_id'>new_id</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_size'>size</span> <span class='kw'>if</span> <span class='id identifier rubyid_new_id'>new_id</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> - <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span> <span class='op'>=</span> <span class='id identifier rubyid_new_id'>new_id</span> - <span class='comment'># Add each component </span> <span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_components'>components</span><span class='rparen'>)</span> - - <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_id'>id</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='kw'>self</span> + <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid__data'>_data</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span> <span class='kw'>self</span> <span class='kw'>end</span></pre> </td> </tr> @@ -455,76 +346,15 @@ </div> - <div id="instance_attr_details" class="attr_details"> - <h2>Instance Attribute Details</h2> - - - <span id="id=-instance_method"></span> - <div class="method_details first"> - <h3 class="signature first" id="id-instance_method"> - - #<strong>id</strong> ⇒ <tt>Integer</tt> - - - - - -</h3><div class="docstring"> - <div class="discussion"> - -<p>Holds the unique ID of this entity</p> - - - </div> -</div> -<div class="tags"> - -<p class="tag_title">Returns:</p> -<ul class="return"> - - <li> - - - <span class='type'>(<tt>Integer</tt>)</span> - - - - </li> - -</ul> - -</div><table class="source_code"> - <tr> - <td> - <pre class="lines"> - -5 -6 -7</pre> - </td> - <td> - <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 5</span> - -<span class='kw'>def</span> <span class='id identifier rubyid_id'>id</span> - <span class='ivar'>@id</span> -<span class='kw'>end</span></pre> - </td> - </tr> -</table> -</div> - - </div> - - - <div id="class_method_details" class="method_details_list"> - <h2>Class Method Details</h2> + <div id="instance_method_details" class="method_details_list"> + <h2>Instance Method Details</h2> <div class="method_details first"> - <h3 class="signature first" id="[]-class_method"> + <h3 class="signature first" id="add-instance_method"> - .<strong>[]</strong>(entity_id) ⇒ <tt>Entity</tt> + #<strong>add</strong>(*components_to_add) ⇒ <tt>Boolean</tt> @@ -533,33 +363,29 @@ </h3><div class="docstring"> <div class="discussion"> -<p>Gets an Entity from the given <span class='object_link'><a href="#id-instance_method" title="FelFlame::Entities#id (method)">unique ID</a></span>. Usage is simular to how an Array lookup works</p> +<p>Add any number components to the Entity.</p> </div> </div> <div class="tags"> - - <div class="examples"> - <p class="tag_title">Examples:</p> - - - <pre class="example code"><code><span class='comment'># This gets the Entity with ID 7 -</span><span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Entities (class)">Entities</a></span></span><span class='lbracket'>[</span><span class='int'>7</span><span class='rbracket'>]</span></code></pre> - - </div> -<p class="tag_title">Parameters:</p> + <p class="tag_title">Parameters:</p> <ul class="param"> <li> - <span class='name'>entity_id</span> + <span class='name'>components_to_add</span> - <span class='type'>(<tt>Integer</tt>)</span> + <span class='type'>(<tt>Component</tt>)</span> + — + <div class='inline'> +<p>Any number of components created from any component manager</p> +</div> + </li> </ul> @@ -570,13 +396,13 @@ <li> - <span class='type'>(<tt>Entity</tt>)</span> + <span class='type'>(<tt>Boolean</tt>)</span> — <div class='inline'> -<p>returns the Entity that uses the given unique ID, nil if there is no Entity associated with the given ID</p> +<p><code>true</code></p> </div> </li> @@ -589,15 +415,37 @@ <pre class="lines"> -116 -117 -118</pre> +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 116</span> + <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 57</span> -<span class='kw'>def</span> <span class='op'>[]</span><span class='lparen'>(</span><span class='id identifier rubyid_entity_id'>entity_id</span><span class='rparen'>)</span> - <span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_entity_id'>entity_id</span><span class='rbracket'>]</span> +<span class='kw'>def</span> <span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_components_to_add'>components_to_add</span><span class='rparen'>)</span> + <span class='id identifier rubyid_components_to_add'>components_to_add</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_component'>component</span><span class='op'>|</span> + <span class='kw'>if</span> <span class='id identifier rubyid_components'>components</span><span class='lbracket'>[</span><span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> + <span class='id identifier rubyid_components'>components</span><span class='lbracket'>[</span><span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_component'>component</span><span class='rbracket'>]</span> + <span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_entities'>entities</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span> <span class='kw'>self</span> + <span class='id identifier rubyid_check_systems'>check_systems</span> <span class='id identifier rubyid_component'>component</span><span class='comma'>,</span> <span class='symbol'>:addition_triggers</span> + <span class='kw'>elsif</span> <span class='op'>!</span><span class='id identifier rubyid_components'>components</span><span class='lbracket'>[</span><span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='id identifier rubyid_component'>component</span> + <span class='id identifier rubyid_components'>components</span><span class='lbracket'>[</span><span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span> <span class='id identifier rubyid_component'>component</span> + <span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_entities'>entities</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span> <span class='kw'>self</span> + <span class='id identifier rubyid_check_systems'>check_systems</span> <span class='id identifier rubyid_component'>component</span><span class='comma'>,</span> <span class='symbol'>:addition_triggers</span> + <span class='kw'>end</span> + <span class='kw'>end</span> + <span class='kw'>true</span> <span class='kw'>end</span></pre> </td> </tr> @@ -605,9 +453,9 @@ </div> <div class="method_details "> - <h3 class="signature " id="each-class_method"> + <h3 class="signature " id="component-instance_method"> - .<strong>each</strong>(&block) ⇒ <tt>Enumerator</tt> + #<strong>component</strong>(manager = nil) ⇒ <tt>Component</tt> @@ -616,87 +464,38 @@ </h3><div class="docstring"> <div class="discussion"> -<p>Iterates over all entities. The data is compacted so that means index does not correlate to ID. You also call other enumerable methods instead of each, such as <code>each_with_index</code> or <code>select</code></p> +<p>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.</p> </div> </div> <div class="tags"> -<p class="tag_title">Returns:</p> -<ul class="return"> - - <li> - - - <span class='type'>(<tt>Enumerator</tt>)</span> - - - - </li> - -</ul> - -</div><table class="source_code"> - <tr> - <td> - <pre class="lines"> - - -123 -124 -125</pre> - </td> - <td> - <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 123</span> - -<span class='kw'>def</span> <span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span> - <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span> -<span class='kw'>end</span></pre> - </td> - </tr> -</table> -</div> - - </div> - - <div id="instance_method_details" class="method_details_list"> - <h2>Instance Method Details</h2> - + <div class="examples"> + <p class="tag_title">Examples:</p> - <div class="method_details first"> - <h3 class="signature first" id="add-instance_method"> - - #<strong>add</strong>(*components_to_add) ⇒ <tt>Boolean</tt> - - - - - -</h3><div class="docstring"> - <div class="discussion"> + + <pre class="example code"><code><span class='ivar'>@entity</span><span class='period'>.</span><span class='id identifier rubyid_component'>component</span><span class='lbracket'>[</span><span class='ivar'>@component_manager</span><span class='rbracket'>]</span> <span class='comment'># array notation(the standard) +</span><span class='ivar'>@entity</span><span class='period'>.</span><span class='id identifier rubyid_component'>component</span><span class='lparen'>(</span><span class='ivar'>@component_manager</span><span class='rparen'>)</span> <span class='comment'># method notation</span></code></pre> -<p>Add any number components to the Entity.</p> - - </div> -</div> -<div class="tags"> - <p class="tag_title">Parameters:</p> +<p class="tag_title">Parameters:</p> <ul class="param"> <li> - <span class='name'>components_to_add</span> + <span class='name'>manager</span> - <span class='type'>(<tt>Component</tt>)</span> + <span class='type'>(<tt><span class='object_link'><a href="ComponentManager.html" title="FelFlame::ComponentManager (class)">ComponentManager</a></span></tt>)</span> + <em class="default">(defaults to: <tt>nil</tt>)</em> + — <div class='inline'> -<p>Any number of components created from any component manager</p> +<p>If you pass nil you can then use array notation to access the same value.</p> </div> </li> @@ -709,14 +508,9 @@ <li> - <span class='type'>(<tt>Boolean</tt>)</span> - + <span class='type'>(<tt>Component</tt>)</span> - — - <div class='inline'> -<p><code>true</code></p> -</div> </li> @@ -728,37 +522,37 @@ <pre class="lines"> -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70</pre> +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 57</span> - -<span class='kw'>def</span> <span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_components_to_add'>components_to_add</span><span class='rparen'>)</span> - <span class='id identifier rubyid_components_to_add'>components_to_add</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_component'>component</span><span class='op'>|</span> - <span class='kw'>if</span> <span class='id identifier rubyid_components'>components</span><span class='lbracket'>[</span><span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> - <span class='id identifier rubyid_components'>components</span><span class='lbracket'>[</span><span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_component'>component</span><span class='rbracket'>]</span> - <span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_entities'>entities</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span> <span class='kw'>self</span> - <span class='id identifier rubyid_check_systems'>check_systems</span> <span class='id identifier rubyid_component'>component</span><span class='comma'>,</span> <span class='symbol'>:addition_triggers</span> - <span class='kw'>elsif</span> <span class='op'>!</span><span class='id identifier rubyid_components'>components</span><span class='lbracket'>[</span><span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='id identifier rubyid_component'>component</span> - <span class='id identifier rubyid_components'>components</span><span class='lbracket'>[</span><span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span> <span class='id identifier rubyid_component'>component</span> - <span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_entities'>entities</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span> <span class='kw'>self</span> - <span class='id identifier rubyid_check_systems'>check_systems</span> <span class='id identifier rubyid_component'>component</span><span class='comma'>,</span> <span class='symbol'>:addition_triggers</span> + <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 26</span> + +<span class='kw'>def</span> <span class='id identifier rubyid_component'>component</span><span class='lparen'>(</span><span class='id identifier rubyid_manager'>manager</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span> + <span class='kw'>if</span> <span class='id identifier rubyid_manager'>manager</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> + <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Entities (class)">Entities</a></span></span><span class='period'>.</span><span class='id identifier rubyid_component_redirect'>component_redirect</span><span class='period'>.</span><span class='id identifier rubyid_entity'>entity</span> <span class='op'>=</span> <span class='kw'>self</span> + <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Entities (class)">Entities</a></span></span><span class='period'>.</span><span class='id identifier rubyid_component_redirect'>component_redirect</span> + <span class='kw'>else</span> + <span class='kw'>if</span> <span class='id identifier rubyid_components'>components</span><span class='lbracket'>[</span><span class='id identifier rubyid_manager'>manager</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> + <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>This entity(</span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='embexpr_end'>}</span><span class='tstring_content'>) doesnt have any components of this type: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_manager'>manager</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span> + <span class='kw'>elsif</span> <span class='id identifier rubyid_components'>components</span><span class='lbracket'>[</span><span class='id identifier rubyid_manager'>manager</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>></span> <span class='int'>1</span> + <span class='const'>Warning</span><span class='period'>.</span><span class='id identifier rubyid_warn'>warn</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>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.</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>end</span> + + <span class='id identifier rubyid_components'>components</span><span class='lbracket'>[</span><span class='id identifier rubyid_manager'>manager</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> <span class='kw'>end</span> - <span class='kw'>true</span> <span class='kw'>end</span></pre> </td> </tr> @@ -777,7 +571,7 @@ </h3><div class="docstring"> <div class="discussion"> -<p>A hash that uses component manager constant names as keys, and where the values of those keys are arrays that contain the <span class='object_link'><a href="ComponentManager.html#id-instance_method" title="FelFlame::ComponentManager#id (method)">IDs</a></span> of the components attached to this entity.</p> +<p>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.</p> </div> @@ -804,12 +598,12 @@ <pre class="lines"> -30 -31 -32</pre> +16 +17 +18</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 30</span> + <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 16</span> <span class='kw'>def</span> <span class='id identifier rubyid_components'>components</span> <span class='ivar'>@components</span> <span class='op'>||=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span> @@ -831,7 +625,7 @@ </h3><div class="docstring"> <div class="discussion"> -<p>Removes this Entity from the list and purges all references to this Entity from other Components, as well as its <span class='object_link'><a href="#id-instance_method" title="FelFlame::Entities#id (method)">ID</a></span> and data.</p> +<p>Removes this Entity from the list and purges all references to this Entity from other Components, as well as its data.</p> </div> @@ -863,7 +657,6 @@ <pre class="lines"> -42 43 44 45 @@ -876,17 +669,16 @@ 52</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 42</span> + <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 43</span> <span class='kw'>def</span> <span class='id identifier rubyid_delete'>delete</span> - <span class='id identifier rubyid_components'>components</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_component_manager'>component_manager</span><span class='comma'>,</span> <span class='id identifier rubyid_component_array'>component_array</span><span class='op'>|</span> - <span class='id identifier rubyid_component_array'>component_array</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_component'>component</span><span class='op'>|</span> + <span class='id identifier rubyid_components'>components</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid__component_manager'>_component_manager</span><span class='comma'>,</span> <span class='id identifier rubyid_component_array'>component_array</span><span class='op'>|</span> + <span class='id identifier rubyid_component_array'>component_array</span><span class='period'>.</span><span class='id identifier rubyid_reverse_each'>reverse_each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_component'>component</span><span class='op'>|</span> <span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_entities'>entities</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span> <span class='kw'>end</span> <span class='kw'>end</span> - <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (class)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Entities (class)">Entities</a></span></span><span class='period'>.</span><span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_id'>id</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='kw'>nil</span> + <span class='const'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="FelFlame::Entities (class)">Entities</a></span></span><span class='period'>.</span><span class='id identifier rubyid__data'>_data</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='kw'>self</span> <span class='ivar'>@components</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span> - <span class='ivar'>@id</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>true</span> <span class='kw'>end</span></pre> </td> @@ -965,7 +757,8 @@ 91 92 93 -94</pre> +94 +95</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 87</span> @@ -975,66 +768,13 @@ <span class='id identifier rubyid_check_systems'>check_systems</span> <span class='id identifier rubyid_component'>component</span><span class='comma'>,</span> <span class='symbol'>:removal_triggers</span> <span class='kw'>if</span> <span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_entities'>entities</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='kw'>self</span> <span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_entities'>entities</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='kw'>self</span> <span class='id identifier rubyid_components'>components</span><span class='lbracket'>[</span><span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='id identifier rubyid_component'>component</span> + <span class='id identifier rubyid_components'>components</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span> <span class='kw'>if</span> <span class='id identifier rubyid_components'>components</span><span class='lbracket'>[</span><span class='id identifier rubyid_component'>component</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='kw'>end</span> <span class='kw'>true</span> <span class='kw'>end</span></pre> </td> </tr> </table> -</div> - - <div class="method_details "> - <h3 class="signature " id="to_i-instance_method"> - - #<strong>to_i</strong> ⇒ <tt>Integer</tt> - - - - - -</h3><div class="docstring"> - <div class="discussion"> - -<p>An alias for the <span class='object_link'><a href="#id-instance_method" title="FelFlame::Entities#id (method)">ID reader</a></span></p> - - - </div> -</div> -<div class="tags"> - -<p class="tag_title">Returns:</p> -<ul class="return"> - - <li> - - - <span class='type'>(<tt>Integer</tt>)</span> - - - - </li> - -</ul> - -</div><table class="source_code"> - <tr> - <td> - <pre class="lines"> - - -36 -37 -38</pre> - </td> - <td> - <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 36</span> - -<span class='kw'>def</span> <span class='id identifier rubyid_to_i'>to_i</span> - <span class='id identifier rubyid_id'>id</span> -<span class='kw'>end</span></pre> - </td> - </tr> -</table> </div> </div> @@ -1042,7 +782,7 @@ </div> <div id="footer"> - Generated on Mon Jul 12 18:28:27 2021 by + Generated on Mon Jan 3 08:23:04 2022 by <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.26 (ruby-2.7.3). </div> diff --git a/docs/FelFlame/Order.html b/docs/FelFlame/Order.html new file mode 100644 index 0000000..832e16f --- /dev/null +++ b/docs/FelFlame/Order.html @@ -0,0 +1,251 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> +<title> + 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 index 41e369e..68f4ece 100644 --- a/docs/FelFlame/Scenes.html +++ b/docs/FelFlame/Scenes.html @@ -37,7 +37,7 @@