diff options
| author | realtradam <[email protected]> | 2022-01-03 07:34:38 -0500 |
|---|---|---|
| committer | realtradam <[email protected]> | 2022-01-03 07:34:38 -0500 |
| commit | 55f1db30e7a609cebd2fab27c55ece1da45be232 (patch) | |
| tree | 286045c958877ea872c69990d289dbf4c44c3c32 | |
| parent | 809028c3d89993b2bb0651076ba723c11734cf3c (diff) | |
| download | FelECS-55f1db30e7a609cebd2fab27c55ece1da45be232.tar.gz FelECS-55f1db30e7a609cebd2fab27c55ece1da45be232.zip | |
.
53 files changed, 1139 insertions, 1017 deletions
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/CHANGELOG.mdown b/CHANGELOG.mdown index 15f2392..e60824f 100644 --- a/CHANGELOG.mdown +++ b/CHANGELOG.mdown @@ -13,6 +13,8 @@ - Removed all ids as they were not used  +- 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 @@ -22,12 +24,12 @@ - Convenience methods for accessing a single entity in a component(`@component.entity`) and accessing a single entity in a component(`@entity.component[@component_manager]`)  -- Replaced all instances of `sort_by!` with `sort_by` for compatibility with DragonRuby +- 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  -- The Scene alias was changed from ```FelFlame::Sce``` to ```FelFlame::Scn``` as it is more intuitive. +- 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  @@ -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/README.mdown b/README.mdown index 45b5b35..e281b7e 100644 --- a/README.mdown +++ b/README.mdown @@ -13,48 +13,46 @@ <!-- vim-markdown-toc GFM --> -+ [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) +* [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) * [Closing Notes](#closing-notes) -+ [Contribution](#contribution) +* [Contribution](#contribution) <!-- vim-markdown-toc --> @@ -97,11 +95,14 @@ The Stage is Scenes which are activated. This means any Scenes on the Stage are --- -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 +112,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 = 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 +141,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 [email protected][@component_manager] # => [@component1, @component2, component3] [email protected][@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 +182,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] [email protected] # => 2 +@component = FelFlame::Components::Stats.first +@component = FelFlame::Components::Stats.each # you can use iterators this way ``` ### Accessing Attributes and Changing Them @@ -207,30 +206,26 @@ Here are the ways to edit attrubutes, followed by the ways to read them. ``` ```ruby @component.hp # => 95 [email protected] # => {armour: 'Leather', hp: 95} [email protected]_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 [email protected] # => @entity ``` @@ -252,7 +247,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 +352,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 +366,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 +403,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,7 +417,7 @@ 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 @@ -1,30 +1,30 @@ # 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 +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 " + 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" + file.delete_prefix!('require_relative ') + result += "#{File.read("lib/#{file[1, file.length - 2]}.rb")}\n" end result += main.lines.reject do |line| - line.include? "require_relative " + line.include? 'require_relative ' end.join `mkdir pkg` @@ -51,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 <<self + class << self def format puts puts 'Formatting Coverage...' diff --git a/deprecated/components/00_renderable.rb b/deprecated/components/00_renderable.rb index 1d34fbb..32c93b6 100644 --- a/deprecated/components/00_renderable.rb +++ b/deprecated/components/00_renderable.rb @@ -1,19 +1,19 @@ -FelFlame::Components.new('Renderable', z: 0) -=begin -class Components - # If an entity can be rendered on screen - class Renderable < Helper::BaseComponent - attr_accessor :z - - def initialize - @z = 0 - end +# frozen_string_literal: true - def set(**opts) - opts.each do |key, value| - self.send "#{key}=", value - end - end - end -end -=end +FelFlame::Components.new('Renderable', z: 0) +# class Components +# # If an entity can be rendered on screen +# class Renderable < Helper::BaseComponent +# attr_accessor :z +# +# def initialize +# @z = 0 +# end +# +# def set(**opts) +# opts.each do |key, value| +# self.send "#{key}=", value +# end +# end +# end +# end diff --git a/deprecated/components/01_sprite.rb b/deprecated/components/01_sprite.rb index c02a51b..4ae6713 100644 --- a/deprecated/components/01_sprite.rb +++ b/deprecated/components/01_sprite.rb @@ -1,57 +1,56 @@ +# frozen_string_literal: true FelFlame::Components.new('Sprite', :x, :y, :w, :h, :path, :angle, :a, :r, :g, :b, - :source_x, :source_y, :source_w, :source_h, - :tile_x, :tile_y, :tile_w, :tile_h, - :flip_horizontally, :flip_vertically, - :angle_anchor_x, :angle_anchor_y, primative_marker: :sprite) + :source_x, :source_y, :source_w, :source_h, + :tile_x, :tile_y, :tile_w, :tile_h, + :flip_horizontally, :flip_vertically, + :angle_anchor_x, :angle_anchor_y, primative_marker: :sprite) -#Components::Sprite.define_method('primative_marker') do +# Components::Sprite.define_method('primative_marker') do # :sprite -#end +# end -=begin -class Components - # If an entity can be rendered on screen - class Sprite < Helper::BaseComponent - - attr_accessor :x, :y, :w, :h, :path, :angle, :a, :r, :g, :b, - :source_x, :source_y, :source_w, :source_h, - :tile_x, :tile_y, :tile_w, :tile_h, - :flip_horizontally, :flip_vertically, - :angle_anchor_x, :angle_anchor_y - - def set(x: @x, y: @y, w: @w, h: @h, path: @path, angle: @angle, a: @a, r: @r, g: @g, b: @b, - source_x: @source_x, source_y: @source_y, source_w: @source_w, source_h: @source_h, - tile_x: @tile_x, tile_y: @tile_y, tile_w: @tile_w, tile_h: @tile_h, - flip_horizontally: @flip_horizontally, flip_vertically: @flip_vertically, - angle_anchor_x: @angle_anchor_x, angle_anchor_y: @angle_anchor_y) - {x: @x = x, - y: @y = y, - w: @w = w, - h: @h = h, - path: @path = path, - angle: @angle = angle, - a: @a = a, - r: @r = r, - g: @g = g, - b: @b = b, - source_x: @source_x = source_x, - source_y: @source_y = source_y, - source_w: @source_w = source_w, - source_h: @source_h = source_h, - tile_x: @tile_x = tile_x, - tile_y: @tile_y = tile_y, - tile_w: @tile_w = tile_w, - tile_h: @tile_h = tile_h, - flip_horizontally: @flip_horizontally = flip_horizontally, - flip_vertically: @flip_vertically = flip_vertically, - angle_anchor_x: @angle_anchor_x = angle_anchor_x, - angle_anchor_y: @angle_anchor_y = angle_anchor_y} - end - - def primative_marker - :sprite - end - end -end -=end +# class Components +# # If an entity can be rendered on screen +# class Sprite < Helper::BaseComponent +# +# attr_accessor :x, :y, :w, :h, :path, :angle, :a, :r, :g, :b, +# :source_x, :source_y, :source_w, :source_h, +# :tile_x, :tile_y, :tile_w, :tile_h, +# :flip_horizontally, :flip_vertically, +# :angle_anchor_x, :angle_anchor_y +# +# def set(x: @x, y: @y, w: @w, h: @h, path: @path, angle: @angle, a: @a, r: @r, g: @g, b: @b, +# source_x: @source_x, source_y: @source_y, source_w: @source_w, source_h: @source_h, +# tile_x: @tile_x, tile_y: @tile_y, tile_w: @tile_w, tile_h: @tile_h, +# flip_horizontally: @flip_horizontally, flip_vertically: @flip_vertically, +# angle_anchor_x: @angle_anchor_x, angle_anchor_y: @angle_anchor_y) +# {x: @x = x, +# y: @y = y, +# w: @w = w, +# h: @h = h, +# path: @path = path, +# angle: @angle = angle, +# a: @a = a, +# r: @r = r, +# g: @g = g, +# b: @b = b, +# source_x: @source_x = source_x, +# source_y: @source_y = source_y, +# source_w: @source_w = source_w, +# source_h: @source_h = source_h, +# tile_x: @tile_x = tile_x, +# tile_y: @tile_y = tile_y, +# tile_w: @tile_w = tile_w, +# tile_h: @tile_h = tile_h, +# flip_horizontally: @flip_horizontally = flip_horizontally, +# flip_vertically: @flip_vertically = flip_vertically, +# angle_anchor_x: @angle_anchor_x = angle_anchor_x, +# angle_anchor_y: @angle_anchor_y = angle_anchor_y} +# end +# +# def primative_marker +# :sprite +# end +# end +# end diff --git a/deprecated/components/03_player_control.rb b/deprecated/components/03_player_control.rb index f48b155..6414547 100644 --- a/deprecated/components/03_player_control.rb +++ b/deprecated/components/03_player_control.rb @@ -1,26 +1,25 @@ +# frozen_string_literal: true FelFlame::Components.new :PlayerControl, north: 'up', south: 'down', east: 'right', - west: 'left', interact: 'space', menu: 'enter' -=begin -class Components - # Gives control(keyboard or otherwise) over an object - class PlayerControl < Helper::BaseComponent - attr_accessor :north, :south, :east, :west, :interact, :menu - - def initialize - @north = 'up' - @south = 'down' - @east = 'right' - @west = 'left' - @interact = 'space' - @menu = 'enter' - end - - def set(**opts) - opts.each do |key, value| - send "#{key}=", value - end - end - end -end -=end + west: 'left', interact: 'space', menu: 'enter' +# class Components +# # Gives control(keyboard or otherwise) over an object +# class PlayerControl < Helper::BaseComponent +# attr_accessor :north, :south, :east, :west, :interact, :menu +# +# def initialize +# @north = 'up' +# @south = 'down' +# @east = 'right' +# @west = 'left' +# @interact = 'space' +# @menu = 'enter' +# end +# +# def set(**opts) +# opts.each do |key, value| +# send "#{key}=", value +# end +# end +# end +# end diff --git a/deprecated/components/04_map.rb b/deprecated/components/04_map.rb index 7700e9f..5d110f0 100644 --- a/deprecated/components/04_map.rb +++ b/deprecated/components/04_map.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true + class Components # dragonruby label wrapper class Map < Helper::BaseComponent - attr_accessor :json_name, :json, :x, :y, :tilewidth, :tileheight, :a, :r, :g, :b def set(json_name: @json_name, x: @x, y: @y, tilewidth: @tilewidth, diff --git a/deprecated/components/05_interactable.rb b/deprecated/components/05_interactable.rb index 636a216..bee91f6 100644 --- a/deprecated/components/05_interactable.rb +++ b/deprecated/components/05_interactable.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Components # If an entity can be rendered on screen class Interactable < Helper::BaseComponent @@ -9,7 +11,7 @@ class Components def set(**opts) opts.each do |key, value| - self.send "#{key}=", value + send "#{key}=", value end end end diff --git a/deprecated/components/06_collidable.rb b/deprecated/components/06_collidable.rb index 76ce51e..4fde638 100644 --- a/deprecated/components/06_collidable.rb +++ b/deprecated/components/06_collidable.rb @@ -1,11 +1,9 @@ +# frozen_string_literal: true + class Components # If an entity can be rendered on screen class Collidable < Helper::BaseComponent - class <<self - def add(entity_id) - super(entity_id) - #add to grid? - end + class << self end attr_accessor :grid @@ -15,7 +13,7 @@ class Components def set(**opts) opts.each do |key, value| - self.send "#{key}=", value + send "#{key}=", value end end end diff --git a/deprecated/components/07_battle.rb b/deprecated/components/07_battle.rb index b4ef622..996c03c 100644 --- a/deprecated/components/07_battle.rb +++ b/deprecated/components/07_battle.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Components class Battle < Helper::Level end diff --git a/deprecated/components/07_indoor.rb b/deprecated/components/07_indoor.rb index e409da8..762c239 100644 --- a/deprecated/components/07_indoor.rb +++ b/deprecated/components/07_indoor.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Components class Indoor < Helper::Level end diff --git a/deprecated/components/07_overworld.rb b/deprecated/components/07_overworld.rb index 55ab38a..cea11f5 100644 --- a/deprecated/components/07_overworld.rb +++ b/deprecated/components/07_overworld.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Components class Overworld < Helper::Level attr_accessor :x, :y @@ -9,7 +11,7 @@ class Components def set(**opts) opts.each do |key, value| - self.send "#{key}=", value + send "#{key}=", value end end end diff --git a/deprecated/components/debug_singleton.rb b/deprecated/components/debug_singleton.rb index f298172..e667191 100644 --- a/deprecated/components/debug_singleton.rb +++ b/deprecated/components/debug_singleton.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true + class Components # If an entity can be rendered on screen class DebugSingleton - class <<self + class << self @data = false attr_accessor :data diff --git a/deprecated/helpers/00_tileset.rb b/deprecated/helpers/00_tileset.rb index c4293cb..9d727f9 100644 --- a/deprecated/helpers/00_tileset.rb +++ b/deprecated/helpers/00_tileset.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Coverage Ignored because the functionality of this # code will not be used for the core of FelFlame. # It will most likely be released as a seperate package @@ -9,39 +11,39 @@ class Helper # If any are missing then it will load them from files @json_data = {} - class <<self + class << self attr_accessor :json_data def get_json_tiles(json_name, hitbox: false) - unless hitbox - return nil if json_name == 'hitbox' && !Components::DebugSingleton.data - end + return nil if !hitbox && (json_name == 'hitbox' && !Components::DebugSingleton.data) - if self.json_data[json_name].nil? - self.json_data[json_name] = $gtk.parse_json_file "assets/json/#{json_name}.json" - raise Exception.new "#{json_name} is null and not loaded. Cannot get json tile" if self.json_data[json_name].nil? + if json_data[json_name].nil? + json_data[json_name] = $gtk.parse_json_file "assets/json/#{json_name}.json" + raise StandardError, "#{json_name} is null and not loaded. Cannot get json tile" if json_data[json_name].nil? - if self.json_data[json_name]['type'] == 'map' #json_name.split("_").first == 'map' - self.json_data[json_name]['tilesets'].each do |tileset| + if json_data[json_name]['type'] == 'map' # json_name.split("_").first == 'map' + json_data[json_name]['tilesets'].each do |tileset| tileset = Helper.get_json_tiles(tileset['source'].split('/').last.delete_suffix('.tsx')) # download tileset here # $gtk.args.gtk.http_get 'https://mysite.net/#{tileset['name']}.png' end end end - self.json_data[json_name] + json_data[json_name] end def get_tile(json_name:, tile_index:) if json_name == 'hitbox' && !Components::DebugSingleton.data return tile_index - 1 if tile_index > 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 <<self + # def data + # @data ||= { add: [], remove: [], grid: FelFlame::Helper::Array2D.new } + # end + # + # def add(entity_id) + # super + # data[:add].push entity_id + # end + # + # def remove(entity_id) + # data[:remove].push entity_id + # super + # end + # end + # end + # class Array2D < Array + # def [](val) + # unless val.nil? + # return self[val] = [] if super.nil? + # end + # super + # end + # end + # class ArrayOfHashes < Array + # def [](val) + # unless val.nil? + # return self[val] = {} if super.nil? + # end + # super + # end + # end -=begin - # Unused: - class Level < FelFlame::Helper::ComponentManager - class <<self - def data - @data ||= { add: [], remove: [], grid: FelFlame::Helper::Array2D.new } - end - - def add(entity_id) - super - data[:add].push entity_id - end - - def remove(entity_id) - data[:remove].push entity_id - super - end - end - end -=end -=begin - class Array2D < Array - def [](val) - unless val.nil? - return self[val] = [] if super.nil? - end - super - end - end -=end -=begin - class ArrayOfHashes < Array - def [](val) - unless val.nil? - return self[val] = {} if super.nil? - end - super - end - end -=end - -=begin - module ComponentHelper - class <<self - def up? char - char == char.upcase - end - - def down? char - char == char.downcase - end - - def underscore(input) - output = input[0].downcase - (1...(input.length - 1)).each do |iter| - if down?(input[iter]) && up?(input[iter + 1]) - output += "#{input[iter].downcase}_" - elsif up?(input[iter - 1]) && up?(input[iter]) && down?(input[iter + 1]) - output += "_#{input[iter].downcase}" - else - output += input[iter].downcase - end - end - output += input[-1].downcase unless input.length == 1 - output - end - end - end -=end + # module ComponentHelper + # class <<self + # def up? char + # char == char.upcase + # end + # + # def down? char + # char == char.downcase + # end + # + # def underscore(input) + # output = input[0].downcase + # (1...(input.length - 1)).each do |iter| + # if down?(input[iter]) && up?(input[iter + 1]) + # output += "#{input[iter].downcase}_" + # elsif up?(input[iter - 1]) && up?(input[iter]) && down?(input[iter + 1]) + # output += "_#{input[iter].downcase}" + # else + # output += input[iter].downcase + # end + # end + # output += input[-1].downcase unless input.length == 1 + # output + # end + # end + # end end end diff --git a/deprecated/systems/00_update_levels.rb b/deprecated/systems/00_update_levels.rb index 6f3a056..5805123 100644 --- a/deprecated/systems/00_update_levels.rb +++ b/deprecated/systems/00_update_levels.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Systems class UpdateLevels @co = Components::Overworld @@ -6,7 +8,7 @@ class Systems @co.data[:add].delete(id) if !(Components::Sprite.id & Entity.signatures[id]).zero? @co.data[:grid][@co.data[id].x][@co.data[id].y] = {} if @co.data[:grid][@co.data[id].x][@co.data[id].y].nil? - #@co.data[:grid][@co.data[id].x][@co.data[id].y].merge!({ player: true }) + # @co.data[:grid][@co.data[id].x][@co.data[id].y].merge!({ player: true }) puts @co.data[:grid][@co.data[id].x][@co.data[id].y].inspect elsif !(Components::Map.id & Entity.signatures[id]).zero? if Components::Map.data[id].json['tilesets'].last['source'].split('/').last.delete('\\').delete_suffix('.tsx') == 'hitbox' diff --git a/deprecated/systems/10_player.rb b/deprecated/systems/10_player.rb index 307731a..ae8564d 100644 --- a/deprecated/systems/10_player.rb +++ b/deprecated/systems/10_player.rb @@ -1,39 +1,41 @@ +# frozen_string_literal: true + class Systems class Player @co = Components::Overworld def self.run Components::PlayerControl.data.each do |id, data| - puts6 "Right: #{@co.data[:grid][@co.data[id].x+1][@co.data[id].y]}" - puts6 "Left #{@co.data[:grid][@co.data[id].x-1][@co.data[id].y]}" - puts6 "Down #{@co.data[:grid][@co.data[id].x][@co.data[id].y+1]}" - puts6 "Up #{@co.data[:grid][@co.data[id].x][@co.data[id].y-1]}" - #puts6 @co.data[:grid][@co.data[id].x + 1][@co.data[id].y][:hitbox].nil? + puts6 "Right: #{@co.data[:grid][@co.data[id].x + 1][@co.data[id].y]}" + puts6 "Left #{@co.data[:grid][@co.data[id].x - 1][@co.data[id].y]}" + puts6 "Down #{@co.data[:grid][@co.data[id].x][@co.data[id].y + 1]}" + puts6 "Up #{@co.data[:grid][@co.data[id].x][@co.data[id].y - 1]}" + # puts6 @co.data[:grid][@co.data[id].x + 1][@co.data[id].y][:hitbox].nil? - if !(Components::Sprite.id & Entity.signatures[id]).zero? - if $gtk.args.inputs.keyboard.key_down.send(data.north) &&\ - (@co.data[:grid][@co.data[id].x][@co.data[id].y - 1].nil? ||\ - @co.data[:grid][@co.data[id].x][@co.data[id].y - 1][:hitbox].nil?) + unless (Components::Sprite.id & Entity.signatures[id]).zero? + if $gtk.args.inputs.keyboard.key_down.send(data.north) && \ + (@co.data[:grid][@co.data[id].x][@co.data[id].y - 1].nil? || \ + @co.data[:grid][@co.data[id].x][@co.data[id].y - 1][:hitbox].nil?) Components::Sprite.data[id].y -= 64 @co.data[id].y -= 1 - elsif $gtk.args.inputs.keyboard.key_down.send(data.south) &&\ - (@co.data[:grid][@co.data[id].x][@co.data[id].y + 1].nil? ||\ - @co.data[:grid][@co.data[id].x][@co.data[id].y + 1][:hitbox].nil?) + elsif $gtk.args.inputs.keyboard.key_down.send(data.south) && \ + (@co.data[:grid][@co.data[id].x][@co.data[id].y + 1].nil? || \ + @co.data[:grid][@co.data[id].x][@co.data[id].y + 1][:hitbox].nil?) Components::Sprite.data[id].y += 64 @co.data[id].y += 1 - elsif $gtk.args.inputs.keyboard.key_down.send(data.east) &&\ - (@co.data[:grid][@co.data[id].x + 1][@co.data[id].y].nil? ||\ - @co.data[:grid][@co.data[id].x + 1][@co.data[id].y][:hitbox].nil?) + elsif $gtk.args.inputs.keyboard.key_down.send(data.east) && \ + (@co.data[:grid][@co.data[id].x + 1][@co.data[id].y].nil? || \ + @co.data[:grid][@co.data[id].x + 1][@co.data[id].y][:hitbox].nil?) Components::Sprite.data[id].x += 64 @co.data[id].x += 1 - elsif $gtk.args.inputs.keyboard.key_down.send(data.west) &&\ - (@co.data[:grid][@co.data[id].x - 1][@co.data[id].y].nil? || @co.data[:grid][@co.data[id].x - 1][@co.data[id].y][:hitbox].nil?) + elsif $gtk.args.inputs.keyboard.key_down.send(data.west) && \ + (@co.data[:grid][@co.data[id].x - 1][@co.data[id].y].nil? || @co.data[:grid][@co.data[id].x - 1][@co.data[id].y][:hitbox].nil?) Components::Sprite.data[id].x -= 64 @co.data[id].x -= 1 end - #Components::Sprite.data[id].y -= 64 if $gtk.args.inputs.keyboard.key_down.send(data.north) - #Components::Sprite.data[id].y += 64 if $gtk.args.inputs.keyboard.key_down.send(data.south) - #Components::Sprite.data[id].x += 64 if $gtk.args.inputs.keyboard.key_down.send(data.east) - #Components::Sprite.data[id].x -= 64 if $gtk.args.inputs.keyboard.key_down.send(data.west) + # Components::Sprite.data[id].y -= 64 if $gtk.args.inputs.keyboard.key_down.send(data.north) + # Components::Sprite.data[id].y += 64 if $gtk.args.inputs.keyboard.key_down.send(data.south) + # Components::Sprite.data[id].x += 64 if $gtk.args.inputs.keyboard.key_down.send(data.east) + # Components::Sprite.data[id].x -= 64 if $gtk.args.inputs.keyboard.key_down.send(data.west) end end end diff --git a/deprecated/systems/99_render.rb b/deprecated/systems/99_render.rb index c71c6fc..dc1092e 100644 --- a/deprecated/systems/99_render.rb +++ b/deprecated/systems/99_render.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true + class Systems class Render def self.run - Components::Renderable.data.sort_by { |v| v[1].z }.each do |key, data| + Components::Renderable.data.sort_by { |v| v[1].z }.each do |key, _data| if !(Components::Sprite.id & Entity.signatures[key]).zero? $gtk.args.outputs.sprites << Components::Sprite.data[key].set elsif !(Components::Label.id & Entity.signatures[key]).zero? @@ -11,21 +13,29 @@ class Systems layer['chunks'].each do |chunk| chunk['data'].each_slice(chunk['width']).with_index do |row, row_index| row.each_with_index do |tile, column_index| - unless 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) - raise Exception.new "#{Components::Map.data[key].json['json_name']} not valid map, exceeded tile range" if (iter += 1) >= 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 ef9cb69..1ec7927 100644 --- a/docs/FelFlame.html +++ b/docs/FelFlame.html @@ -79,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> @@ -100,7 +100,7 @@ <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/Stage.html" title="FelFlame::Stage (module)">Stage</a></span> + <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> @@ -273,12 +273,12 @@ <pre class="lines"> -15 -16 -17</pre> +17 +18 +19</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 17</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 (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> @@ -293,7 +293,7 @@ </div> <div id="footer"> - Generated on Mon Jan 3 06:20:47 2022 by + Generated on Mon Jan 3 07:34:30 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 119a7ed..143fd3a 100644 --- a/docs/FelFlame/ComponentManager.html +++ b/docs/FelFlame/ComponentManager.html @@ -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 #attrs 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> @@ -312,30 +312,6 @@ <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="#delete-instance_method" title="#delete (instance method)">#<strong>delete</strong> ⇒ Boolean </a> @@ -449,7 +425,7 @@ <span class="summary_desc"><div class='inline'> -<p>A hash, where all the keys are attributes linked to their respective values.</p> +<p>A hash, where all the keys are attributes storing their respective values.</p> </div></span> </li> @@ -531,6 +507,8 @@ <pre class="lines"> +154 +155 156 157 158 @@ -542,12 +520,10 @@ 164 165 166 -167 -168 -169</pre> +167</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 156</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 154</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 @@ -614,12 +590,12 @@ <pre class="lines"> -206 -207 -208</pre> +202 +203 +204</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 206</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 202</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> @@ -670,12 +646,12 @@ <pre class="lines"> -222 -223 -224</pre> +218 +219 +220</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 222</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 218</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> @@ -726,12 +702,12 @@ <pre class="lines"> -214 -215 -216</pre> +210 +211 +212</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 214</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 210</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> @@ -787,12 +763,12 @@ <pre class="lines"> -133 -134 -135</pre> +131 +132 +133</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 133</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 131</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> @@ -843,12 +819,12 @@ <pre class="lines"> -149 -150 -151</pre> +147 +148 +149</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 149</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 147</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> @@ -899,12 +875,12 @@ <pre class="lines"> -141 -142 -143</pre> +139 +140 +141</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 141</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 139</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> @@ -922,78 +898,7 @@ <div class="method_details first"> - <h3 class="signature first" id="attr_changed_trigger_systems-instance_method"> - - #<strong>attr_changed_trigger_systems</strong>(attr) ⇒ <tt>Boolean</tt> - - - - - -</h3><div class="docstring"> - <div class="discussion"> - -<p>Execute systems that have been added to execute on variable change</p> - - - </div> -</div> -<div class="tags"> - -<p class="tag_title">Returns:</p> -<ul class="return"> - - <li> - - - <span class='type'>(<tt>Boolean</tt>)</span> - - - - — - <div class='inline'> -<p><code>true</code></p> -</div> - - </li> - -</ul> - -</div><table class="source_code"> - <tr> - <td> - <pre class="lines"> - - -260 -261 -262 -263 -264 -265 -266 -267 -268</pre> - </td> - <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 260</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_each'>reverse_each</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:call</span><span class='rparen'>)</span> - <span class='kw'>true</span> -<span class='kw'>end</span></pre> - </td> - </tr> -</table> -</div> - - <div class="method_details "> - <h3 class="signature " id="delete-instance_method"> + <h3 class="signature first" id="delete-instance_method"> #<strong>delete</strong> ⇒ <tt>Boolean</tt> @@ -1036,6 +941,8 @@ <pre class="lines"> +269 +270 271 272 273 @@ -1046,12 +953,10 @@ 278 279 280 -281 -282 -283</pre> +281</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 271</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 269</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> @@ -1110,12 +1015,12 @@ <pre class="lines"> -235 -236 -237</pre> +231 +232 +233</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 231</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> @@ -1164,17 +1069,17 @@ <pre class="lines"> +237 +238 +239 +240 241 242 243 -244 -245 -246 -247 -248</pre> +244</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 241</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 237</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> @@ -1201,7 +1106,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>Returns A hash, where all the keys are attributes storing their respective values.</p> </div> @@ -1220,7 +1125,7 @@ — <div class='inline'> -<p>A hash, where all the keys are attributes linked to their respective values.</p> +<p>A hash, where all the keys are attributes storing their respective values.</p> </div> </li> @@ -1233,16 +1138,16 @@ <pre class="lines"> +284 +285 286 287 288 289 -290 -291 -292</pre> +290</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 286</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 284</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> @@ -1300,14 +1205,14 @@ <pre class="lines"> -252 -253 -254 -255 -256</pre> +248 +249 +250 +251 +252</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 252</span> + <pre class="code"><span class="info file"># File 'lib/felflame/component_manager.rb', line 248</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> @@ -1324,7 +1229,7 @@ </div> <div id="footer"> - Generated on Mon Jan 3 06:20:47 2022 by + Generated on Mon Jan 3 07:34:30 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 33d82b3..37c11bf 100644 --- a/docs/FelFlame/Components.html +++ b/docs/FelFlame/Components.html @@ -88,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 (module)">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> @@ -249,8 +249,6 @@ <pre class="lines"> -18 -19 20 21 22 @@ -278,24 +276,26 @@ 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 18</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 (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 (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 (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_end'>"</span></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='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 (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> @@ -323,7 +323,7 @@ </div> <div id="footer"> - Generated on Mon Jan 3 06:20:47 2022 by + Generated on Mon Jan 3 07:34:30 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 4308d4b..43d61fa 100644 --- a/docs/FelFlame/Entities.html +++ b/docs/FelFlame/Entities.html @@ -104,7 +104,7 @@ <h2>Overview</h2><div class="docstring"> <div class="discussion"> -<p>Creates and manages Entities. Allows iterating or accessing Entities using array methods directly on the class. 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> @@ -325,14 +325,14 @@ <pre class="lines"> -7 8 9 10 -11</pre> +11 +12</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 7</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'># Add each component @@ -415,7 +415,6 @@ <pre class="lines"> -56 57 58 59 @@ -428,10 +427,11 @@ 66 67 68 -69</pre> +69 +70</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 56</span> + <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> @@ -464,7 +464,7 @@ </h3><div class="docstring"> <div class="discussion"> -<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.</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> @@ -475,7 +475,7 @@ <p class="tag_title">Examples:</p> - <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 + <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> </div> @@ -522,7 +522,6 @@ <pre class="lines"> -25 26 27 28 @@ -534,10 +533,12 @@ 34 35 36 -37</pre> +37 +38 +39</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 25</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> @@ -549,6 +550,7 @@ <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'>end</span></pre> @@ -596,12 +598,12 @@ <pre class="lines"> -15 16 -17</pre> +17 +18</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 15</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> @@ -655,7 +657,6 @@ <pre class="lines"> -42 43 44 45 @@ -664,13 +665,14 @@ 48 49 50 -51</pre> +51 +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_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> @@ -748,7 +750,6 @@ <pre class="lines"> -86 87 88 89 @@ -757,20 +758,17 @@ 92 93 94 -95 -96</pre> +95</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 86</span> + <pre class="code"><span class="info file"># File 'lib/felflame/entity_manager.rb', line 87</span> <span class='kw'>def</span> <span class='id identifier rubyid_remove'>remove</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_components_to_remove'>components_to_remove</span><span class='rparen'>)</span> <span class='id identifier rubyid_components_to_remove'>components_to_remove</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_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='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='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'>end</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> @@ -784,7 +782,7 @@ </div> <div id="footer"> - Generated on Mon Jan 3 06:20:47 2022 by + Generated on Mon Jan 3 07:34:30 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..b17a786 --- /dev/null +++ b/docs/FelFlame/Order.html @@ -0,0 +1,172 @@ +<!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 + +</title> + + <link rel="stylesheet" href="../css/style.css" type="text/css" /> + + <link rel="stylesheet" href="../css/common.css" type="text/css" /> + +<script type="text/javascript"> + pathId = "FelFlame::Order"; + relpath = '../'; +</script> + + + <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script> + + <script type="text/javascript" charset="utf-8" src="../js/app.js"></script> + + + </head> + <body> + <div class="nav_wrap"> + <iframe id="nav" src="../class_list.html?1"></iframe> + <div id="resizer"></div> + </div> + + <div id="main" tabindex="-1"> + <div id="header"> + <div id="menu"> + + <a href="../_index.html">Index (O)</a> » + <span class='title'><span class='object_link'><a href="../FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span> + » + <span class="title">Order</span> + +</div> + + <div id="search"> + + <a class="full_list_link" id="class_list_link" + href="../class_list.html"> + + <svg width="24" height="24"> + <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect> + <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect> + <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect> + </svg> + </a> + +</div> + <div class="clear"></div> + </div> + + <div id="content"><h1>Module: FelFlame::Order + + + +</h1> +<div class="box_info"> + + + + + + + + + + + + <dl> + <dt>Defined in:</dt> + <dd>lib/felflame/order.rb</dd> + </dl> + +</div> + + + + + + + + + + <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="#sort-instance_method" title="#sort (instance method)">#<strong>sort</strong>(*sortables) ⇒ Object </a> + + + + </span> + + + + + + + + + + <span class="summary_desc"><div class='inline'></div></span> + +</li> + + + </ul> + + + + + <div id="instance_method_details" class="method_details_list"> + <h2>Instance Method Details</h2> + + + <div class="method_details first"> + <h3 class="signature first" id="sort-instance_method"> + + #<strong>sort</strong>(*sortables) ⇒ <tt>Object</tt> + + + + + +</h3><table class="source_code"> + <tr> + <td> + <pre class="lines"> + + +3 +4</pre> + </td> + <td> + <pre class="code"><span class="info file"># File 'lib/felflame/order.rb', line 3</span> + +<span class='kw'>def</span> <span class='id identifier rubyid_sort'>sort</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_sortables'>sortables</span><span class='rparen'>)</span> +<span class='kw'>end</span></pre> + </td> + </tr> +</table> +</div> + + </div> + +</div> + + <div id="footer"> + Generated on Mon Jan 3 07:34:30 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> + + </div> + </body> +</html>
\ No newline at end of file diff --git a/docs/FelFlame/Scenes.html b/docs/FelFlame/Scenes.html index 5a73e20..6245fa6 100644 --- a/docs/FelFlame/Scenes.html +++ b/docs/FelFlame/Scenes.html @@ -106,8 +106,6 @@ <p>Creates and manages Scenes. Scenes are collections of Systems, and execute all the Systems when called upon. Any scenes you create are accessable under the <span class='object_link'><a href="" title="FelFlame::Scenes (class)">Scenes</a></span> namespace as Constants.</p> -<p>TODO: Improve Scenes overview</p> - </div> </div> @@ -364,13 +362,13 @@ <pre class="lines"> -20 -21 22 -23</pre> +23 +24 +25</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/scene_manager.rb', line 20</span> + <pre class="code"><span class="info file"># File 'lib/felflame/scene_manager.rb', line 22</span> <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>0</span><span class='rparen'>)</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_priority'>priority</span> <span class='op'>=</span> <span class='id identifier rubyid_priority'>priority</span> @@ -414,12 +412,12 @@ <pre class="lines"> -10 -11 -12</pre> +12 +13 +14</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/scene_manager.rb', line 10</span> + <pre class="code"><span class="info file"># File 'lib/felflame/scene_manager.rb', line 12</span> <span class='kw'>def</span> <span class='id identifier rubyid_priority'>priority</span> <span class='ivar'>@priority</span> @@ -470,12 +468,12 @@ <pre class="lines"> -27 -28 -29</pre> +29 +30 +31</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/scene_manager.rb', line 27</span> + <pre class="code"><span class="info file"># File 'lib/felflame/scene_manager.rb', line 29</span> <span class='kw'>def</span> <span class='id identifier rubyid_systems'>systems</span> <span class='ivar'>@systems</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> @@ -536,17 +534,17 @@ <pre class="lines"> -40 -41 42 43 44 45 46 -47</pre> +47 +48 +49</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/scene_manager.rb', line 40</span> + <pre class="code"><span class="info file"># File 'lib/felflame/scene_manager.rb', line 42</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_systems_to_add'>systems_to_add</span><span class='rparen'>)</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_systems'>systems</span> <span class='op'>|=</span> <span class='id identifier rubyid_systems_to_add'>systems_to_add</span> @@ -605,13 +603,13 @@ <pre class="lines"> -33 -34 35 -36</pre> +36 +37 +38</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/scene_manager.rb', line 33</span> + <pre class="code"><span class="info file"># File 'lib/felflame/scene_manager.rb', line 35</span> <span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span> <span class='id identifier rubyid_systems'>systems</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> @@ -666,24 +664,24 @@ <pre class="lines"> -58 -59 60 61 62 63 64 -65</pre> +65 +66 +67</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/scene_manager.rb', line 58</span> + <pre class="code"><span class="info file"># File 'lib/felflame/scene_manager.rb', line 60</span> <span class='kw'>def</span> <span class='id identifier rubyid_clear'>clear</span> <span class='id identifier rubyid_systems'>systems</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_scenes'>scenes</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='kw'>self</span> <span class='kw'>end</span> <span class='id identifier rubyid_systems'>systems</span><span class='period'>.</span><span class='id identifier rubyid_clear'>clear</span> - <span class='comment'>#FelFlame::Stage.update_systems_list if FelFlame::Stage.scenes.include? self + <span class='comment'># FelFlame::Stage.update_systems_list if FelFlame::Stage.scenes.include? self </span> <span class='kw'>true</span> <span class='kw'>end</span></pre> </td> @@ -735,13 +733,13 @@ <pre class="lines"> -51 -52 53 -54</pre> +54 +55 +56</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/scene_manager.rb', line 51</span> + <pre class="code"><span class="info file"># File 'lib/felflame/scene_manager.rb', line 53</span> <span class='kw'>def</span> <span class='id identifier rubyid_remove'>remove</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_systems_to_remove'>systems_to_remove</span><span class='rparen'>)</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_systems'>systems</span> <span class='op'>-=</span> <span class='id identifier rubyid_systems_to_remove'>systems_to_remove</span> @@ -757,7 +755,7 @@ </div> <div id="footer"> - Generated on Mon Jan 3 06:20:47 2022 by + Generated on Mon Jan 3 07:34:30 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/Stage.html b/docs/FelFlame/Stage.html index 892810b..e944f44 100644 --- a/docs/FelFlame/Stage.html +++ b/docs/FelFlame/Stage.html @@ -289,12 +289,12 @@ <pre class="lines"> -40 -41 -42</pre> +42 +43 +44</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/stage_manager.rb', line 40</span> + <pre class="code"><span class="info file"># File 'lib/felflame/stage_manager.rb', line 42</span> <span class='kw'>def</span> <span class='id identifier rubyid_scenes'>scenes</span> <span class='ivar'>@scenes</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> @@ -355,14 +355,14 @@ <pre class="lines"> -11 -12 13 14 -15</pre> +15 +16 +17</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/stage_manager.rb', line 11</span> + <pre class="code"><span class="info file"># File 'lib/felflame/stage_manager.rb', line 13</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_scenes_to_add'>scenes_to_add</span><span class='rparen'>)</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_scenes'>scenes</span> <span class='op'>|=</span> <span class='id identifier rubyid_scenes_to_add'>scenes_to_add</span> @@ -386,7 +386,7 @@ </h3><div class="docstring"> <div class="discussion"> -<p>Executes one frame of the game. This executes all the Systems in the Scenes added to the Stage. Systems that exist in two or more different Scenes will still only get executed once.</p> +<p>Executes one frame of the game. This executes all the Scenes added to the Stage in order of their priority.</p> </div> @@ -418,13 +418,13 @@ <pre class="lines"> -33 -34 35 -36</pre> +36 +37 +38</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/stage_manager.rb', line 33</span> + <pre class="code"><span class="info file"># File 'lib/felflame/stage_manager.rb', line 35</span> <span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_scenes'>scenes</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> @@ -479,13 +479,13 @@ <pre class="lines"> -26 -27 28 -29</pre> +29 +30 +31</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/stage_manager.rb', line 26</span> + <pre class="code"><span class="info file"># File 'lib/felflame/stage_manager.rb', line 28</span> <span class='kw'>def</span> <span class='id identifier rubyid_clear'>clear</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_scenes'>scenes</span><span class='period'>.</span><span class='id identifier rubyid_clear'>clear</span> @@ -540,13 +540,13 @@ <pre class="lines"> -19 -20 21 -22</pre> +22 +23 +24</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/stage_manager.rb', line 19</span> + <pre class="code"><span class="info file"># File 'lib/felflame/stage_manager.rb', line 21</span> <span class='kw'>def</span> <span class='id identifier rubyid_remove'>remove</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_scenes_to_remove'>scenes_to_remove</span><span class='rparen'>)</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_scenes'>scenes</span> <span class='op'>-=</span> <span class='id identifier rubyid_scenes_to_remove'>scenes_to_remove</span> @@ -562,7 +562,7 @@ </div> <div id="footer"> - Generated on Mon Jan 3 06:20:47 2022 by + Generated on Mon Jan 3 07:34:30 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/Systems.html b/docs/FelFlame/Systems.html index 7f5d18c..be6a374 100644 --- a/docs/FelFlame/Systems.html +++ b/docs/FelFlame/Systems.html @@ -104,9 +104,7 @@ <h2>Overview</h2><div class="docstring"> <div class="discussion"> -<p>Creates an manages Systems. Systems are the logic of the game and do not contain any data within them. Any systems you create are accessable under the <span class='object_link'><a href="" title="FelFlame::Systems (class)">Systems</a></span> namespace as Constants.</p> - -<p>TODO: Improve Systems overview</p> +<p>Creates and manages Systems. Systems are the logic of the game and do not contain any data within them. Any systems you create are accessable under the <span class='object_link'><a href="" title="FelFlame::Systems (class)">Systems</a></span> namespace as Constants. You can use array methods directly on this class to access Systems.</p> </div> @@ -576,16 +574,16 @@ <pre class="lines"> +115 116 117 118 119 120 -121 -122</pre> +121</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/system_manager.rb', line 116</span> + <pre class="code"><span class="info file"># File 'lib/felflame/system_manager.rb', line 115</span> <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>0</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</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::Systems (class)">Systems</a></span></span><span class='period'>.</span><span class='id identifier rubyid_const_set'>const_set</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span> @@ -645,12 +643,12 @@ <pre class="lines"> -33 -34 -35</pre> +35 +36 +37</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/system_manager.rb', line 33</span> + <pre class="code"><span class="info file"># File 'lib/felflame/system_manager.rb', line 35</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> @@ -701,12 +699,12 @@ <pre class="lines"> -51 52 -53</pre> +53 +54</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/system_manager.rb', line 51</span> + <pre class="code"><span class="info file"># File 'lib/felflame/system_manager.rb', line 52</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> @@ -744,12 +742,12 @@ <pre class="lines"> -4 -5 -6</pre> +6 +7 +8</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/system_manager.rb', line 4</span> + <pre class="code"><span class="info file"># File 'lib/felflame/system_manager.rb', line 6</span> <span class='kw'>def</span> <span class='id identifier rubyid_priority'>priority</span> <span class='ivar'>@priority</span> @@ -800,12 +798,12 @@ <pre class="lines"> -42 -43 -44</pre> +44 +45 +46</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/system_manager.rb', line 42</span> + <pre class="code"><span class="info file"># File 'lib/felflame/system_manager.rb', line 44</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> @@ -832,12 +830,12 @@ <pre class="lines"> -17 -18 -19</pre> +19 +20 +21</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/system_manager.rb', line 17</span> + <pre class="code"><span class="info file"># File 'lib/felflame/system_manager.rb', line 19</span> <span class='kw'>def</span> <span class='id identifier rubyid_scenes'>scenes</span> <span class='ivar'>@scenes</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> @@ -927,12 +925,12 @@ <pre class="lines"> +124 125 -126 -127</pre> +126</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/system_manager.rb', line 125</span> + <pre class="code"><span class="info file"># File 'lib/felflame/system_manager.rb', line 124</span> <span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span> <span class='ivar'>@block</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span> @@ -1110,23 +1108,22 @@ 219 220 221 -222 -223</pre> +222</pre> </td> <td> <pre class="code"><span class="info file"># File 'lib/felflame/system_manager.rb', line 157</span> <span class='kw'>def</span> <span class='id identifier rubyid_clear_triggers'>clear_triggers</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_trigger_types'>trigger_types</span><span class='comma'>,</span> <span class='label'>component_or_manager:</span> <span class='kw'>nil</span><span class='rparen'>)</span> - <span class='id identifier rubyid_trigger_types'>trigger_types</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='symbol'>:addition_triggers</span><span class='comma'>,</span> <span class='symbol'>:removal_triggers</span><span class='comma'>,</span> <span class='symbol'>:attr_triggers</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='id identifier rubyid_trigger_types'>trigger_types</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> + <span class='id identifier rubyid_trigger_types'>trigger_types</span> <span class='op'>=</span> <span class='qsymbols_beg'>%i[</span><span class='tstring_content'>addition_triggers</span><span class='words_sep'> </span><span class='tstring_content'>removal_triggers</span><span class='words_sep'> </span><span class='tstring_content'>attr_triggers</span><span class='tstring_end'>]</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_trigger_types'>trigger_types</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='kw'>if</span> <span class='id identifier rubyid_trigger_types'>trigger_types</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='symbol'>:attr_triggers</span> - <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_trigger_types'>trigger_types</span> <span class='op'>-</span> <span class='lbracket'>[</span><span class='symbol'>:addition_triggers</span><span class='comma'>,</span> - <span class='symbol'>:removal_triggers</span><span class='comma'>,</span> - <span class='symbol'>:attr_triggers</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> + <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_trigger_types'>trigger_types</span> <span class='op'>-</span> <span class='qsymbols_beg'>%i[</span><span class='tstring_content'>addition_triggers</span><span class='words_sep'> + </span><span class='tstring_content'>removal_triggers</span><span class='words_sep'> + </span><span class='tstring_content'>attr_triggers</span><span class='tstring_end'>]</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='kw'>if</span> <span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> - <span class='comment'>#remove all attrs -</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_attr_triggers'>attr_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_cmp_or_mgr'>cmp_or_mgr</span><span class='comma'>,</span> <span class='id identifier rubyid_attrs'>attrs</span><span class='op'>|</span> + <span class='comment'># remove all attrs +</span> <span class='id identifier rubyid_attr_triggers'>attr_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_cmp_or_mgr'>cmp_or_mgr</span><span class='comma'>,</span> <span class='id identifier rubyid_attrs'>attrs</span><span class='op'>|</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'>next</span> <span class='kw'>if</span> <span class='id identifier rubyid_cmp_or_mgr'>cmp_or_mgr</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='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> @@ -1135,49 +1132,48 @@ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_attr_triggers'>attr_triggers</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span> <span class='kw'>end</span> <span class='kw'>else</span> - <span class='comment'>#remove attrs relevant to comp_or_man -</span> <span class='kw'>unless</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_attr_triggers'>attr_triggers</span><span class='lbracket'>[</span><span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='rbracket'>]</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_attr_triggers'>attr_triggers</span><span class='lbracket'>[</span><span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='rbracket'>]</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='comment'># remove attrs relevant to comp_or_man +</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_component_or_manager'>component_or_manager</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> + <span class='id identifier rubyid_attr_triggers'>attr_triggers</span><span class='lbracket'>[</span><span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='rbracket'>]</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='id identifier rubyid_component_or_manager'>component_or_manager</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='period'>.</span><span class='id identifier rubyid_delete'>delete</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_attr_triggers'>attr_triggers</span><span class='lbracket'>[</span><span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> + <span class='id identifier rubyid_attr_triggers'>attr_triggers</span><span class='lbracket'>[</span><span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> <span class='kw'>end</span> <span class='kw'>end</span> - <span class='kw'>else</span> + <span class='kw'>elsif</span> <span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> - <span class='kw'>if</span> <span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> - <span class='lparen'>(</span><span class='id identifier rubyid_trigger_types'>trigger_types</span> <span class='op'>-</span> <span class='lbracket'>[</span><span class='symbol'>:addition_triggers</span><span class='comma'>,</span> <span class='symbol'>:removal_triggers</span><span class='comma'>,</span> <span class='symbol'>:attr_triggers</span><span class='rbracket'>]</span><span class='rparen'>)</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='comment'>#remove attr -</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_attr_triggers'>attr_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_cmp_or_mgr'>cmp_or_mgr</span><span class='comma'>,</span> <span class='id identifier rubyid_attrs'>attrs</span><span class='op'>|</span> - <span class='id identifier rubyid_cmp_or_mgr'>cmp_or_mgr</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='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='kw'>self</span> - <span class='kw'>end</span> + <span class='lparen'>(</span><span class='id identifier rubyid_trigger_types'>trigger_types</span> <span class='op'>-</span> <span class='qsymbols_beg'>%i[</span><span class='tstring_content'>addition_triggers</span><span class='words_sep'> </span><span class='tstring_content'>removal_triggers</span><span class='words_sep'> </span><span class='tstring_content'>attr_triggers</span><span class='tstring_end'>]</span></span><span class='rparen'>)</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='comment'># remove attr +</span> <span class='id identifier rubyid_attr_triggers'>attr_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_cmp_or_mgr'>cmp_or_mgr</span><span class='comma'>,</span> <span class='id identifier rubyid__attrs'>_attrs</span><span class='op'>|</span> + <span class='id identifier rubyid_cmp_or_mgr'>cmp_or_mgr</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='period'>.</span><span class='id identifier rubyid_delete'>delete</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_attr_triggers'>attr_triggers</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='lparen'>(</span><span class='id identifier rubyid_trigger_types'>trigger_types</span> <span class='op'>-</span> <span class='lbracket'>[</span><span class='symbol'>:addition_triggers</span><span class='comma'>,</span> - <span class='symbol'>:removal_triggers</span><span class='comma'>,</span> - <span class='symbol'>:attr_triggers</span><span class='rbracket'>]</span><span class='rparen'>)</span> - <span class='kw'>else</span> - <span class='comment'>#remove attr from component_or_manager -</span> <span class='lparen'>(</span><span class='id identifier rubyid_trigger_types'>trigger_types</span> <span class='op'>-</span> <span class='lbracket'>[</span><span class='symbol'>:addition_triggers</span><span class='comma'>,</span> <span class='symbol'>:removal_triggers</span><span class='comma'>,</span> <span class='symbol'>:attr_triggers</span><span class='rbracket'>]</span><span class='rparen'>)</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'>next</span> <span class='kw'>if</span> <span class='id identifier rubyid_component_or_manager'>component_or_manager</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='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> - <span class='id identifier rubyid_component_or_manager'>component_or_manager</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='period'>.</span><span class='id identifier rubyid_delete'>delete</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_attr_triggers'>attr_triggers</span><span class='lbracket'>[</span><span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='rbracket'>]</span> <span class='op'>-=</span> <span class='id identifier rubyid_trigger_types'>trigger_types</span> <span class='kw'>unless</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_attr_triggers'>attr_triggers</span><span class='lbracket'>[</span><span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='kw'>end</span> + <span class='id identifier rubyid_attr_triggers'>attr_triggers</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_trigger_types'>trigger_types</span> <span class='op'>-</span> <span class='qsymbols_beg'>%i[</span><span class='tstring_content'>addition_triggers</span><span class='words_sep'> + </span><span class='tstring_content'>removal_triggers</span><span class='words_sep'> + </span><span class='tstring_content'>attr_triggers</span><span class='tstring_end'>]</span></span><span class='rparen'>)</span> + <span class='kw'>else</span> + <span class='comment'># remove attr from component_or_manager +</span> <span class='lparen'>(</span><span class='id identifier rubyid_trigger_types'>trigger_types</span> <span class='op'>-</span> <span class='qsymbols_beg'>%i[</span><span class='tstring_content'>addition_triggers</span><span class='words_sep'> </span><span class='tstring_content'>removal_triggers</span><span class='words_sep'> </span><span class='tstring_content'>attr_triggers</span><span class='tstring_end'>]</span></span><span class='rparen'>)</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'>next</span> <span class='kw'>if</span> <span class='id identifier rubyid_component_or_manager'>component_or_manager</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='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> + + <span class='id identifier rubyid_component_or_manager'>component_or_manager</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='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='kw'>self</span> + <span class='kw'>end</span> + <span class='id identifier rubyid_attr_triggers'>attr_triggers</span><span class='lbracket'>[</span><span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='rbracket'>]</span> <span class='op'>-=</span> <span class='id identifier rubyid_trigger_types'>trigger_types</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_component_or_manager'>component_or_manager</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='kw'>end</span> <span class='kw'>end</span> - <span class='lparen'>(</span><span class='id identifier rubyid_trigger_types'>trigger_types</span> <span class='op'>&</span> <span class='lbracket'>[</span><span class='symbol'>:removal_triggers</span><span class='comma'>,</span> <span class='symbol'>:addition_triggers</span><span class='rbracket'>]</span> <span class='op'>-</span> <span class='lbracket'>[</span><span class='symbol'>:attr_triggers</span><span class='rbracket'>]</span><span class='rparen'>)</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_trigger_type'>trigger_type</span><span class='op'>|</span> + <span class='lparen'>(</span><span class='id identifier rubyid_trigger_types'>trigger_types</span> <span class='op'>&</span> <span class='qsymbols_beg'>%i[</span><span class='tstring_content'>removal_triggers</span><span class='words_sep'> </span><span class='tstring_content'>addition_triggers</span><span class='tstring_end'>]</span></span> <span class='op'>-</span> <span class='lbracket'>[</span><span class='symbol'>:attr_triggers</span><span class='rbracket'>]</span><span class='rparen'>)</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_trigger_type'>trigger_type</span><span class='op'>|</span> <span class='kw'>if</span> <span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> - <span class='comment'>#remove all removal triggers -</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_trigger_type'>trigger_type</span><span class='rparen'>)</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_trigger'>trigger</span><span class='op'>|</span> + <span class='comment'># remove all removal triggers +</span> <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_trigger_type'>trigger_type</span><span class='rparen'>)</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_trigger'>trigger</span><span class='op'>|</span> <span class='id identifier rubyid_trigger'>trigger</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_trigger_type'>trigger_type</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</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_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_trigger_type'>trigger_type</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span> + <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_trigger_type'>trigger_type</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='kw'>else</span> - <span class='comment'>#remove removal trigger relevant to comp/man -</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_trigger_type'>trigger_type</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='id identifier rubyid_component_or_manager'>component_or_manager</span> + <span class='comment'># remove removal trigger relevant to comp/man +</span> <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_trigger_type'>trigger_type</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='id identifier rubyid_component_or_manager'>component_or_manager</span> <span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_trigger_type'>trigger_type</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='kw'>self</span> <span class='kw'>end</span> <span class='kw'>end</span> @@ -1313,14 +1309,14 @@ <pre class="lines"> +227 228 229 230 -231 -232</pre> +231</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/system_manager.rb', line 228</span> + <pre class="code"><span class="info file"># File 'lib/felflame/system_manager.rb', line 227</span> <span class='kw'>def</span> <span class='id identifier rubyid_trigger_when_added'>trigger_when_added</span><span class='lparen'>(</span><span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='rparen'>)</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_addition_triggers'>addition_triggers</span> <span class='op'>|=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='rbracket'>]</span> @@ -1376,6 +1372,7 @@ <pre class="lines"> +244 245 246 247 @@ -1387,11 +1384,10 @@ 253 254 255 -256 -257</pre> +256</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/system_manager.rb', line 245</span> + <pre class="code"><span class="info file"># File 'lib/felflame/system_manager.rb', line 244</span> <span class='kw'>def</span> <span class='id identifier rubyid_trigger_when_is_changed'>trigger_when_is_changed</span><span class='lparen'>(</span><span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='comma'>,</span> <span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_component_or_manager'>component_or_manager</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='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> @@ -1399,10 +1395,10 @@ <span class='kw'>else</span> <span class='id identifier rubyid_component_or_manager'>component_or_manager</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='op'>|=</span> <span class='lbracket'>[</span><span class='kw'>self</span><span class='rbracket'>]</span> <span class='kw'>end</span> - <span class='kw'>if</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_attr_triggers'>attr_triggers</span><span class='lbracket'>[</span><span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='rbracket'>]</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_attr_triggers'>attr_triggers</span><span class='lbracket'>[</span><span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_attr'>attr</span><span class='rbracket'>]</span> + <span class='kw'>if</span> <span class='id identifier rubyid_attr_triggers'>attr_triggers</span><span class='lbracket'>[</span><span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> + <span class='id identifier rubyid_attr_triggers'>attr_triggers</span><span class='lbracket'>[</span><span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_attr'>attr</span><span class='rbracket'>]</span> <span class='kw'>else</span> - <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_attr_triggers'>attr_triggers</span><span class='lbracket'>[</span><span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='rbracket'>]</span> <span class='op'>|=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_attr'>attr</span><span class='rbracket'>]</span> + <span class='id identifier rubyid_attr_triggers'>attr_triggers</span><span class='lbracket'>[</span><span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='rbracket'>]</span> <span class='op'>|=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_attr'>attr</span><span class='rbracket'>]</span> <span class='kw'>end</span> <span class='kw'>true</span> <span class='kw'>end</span></pre> @@ -1475,14 +1471,14 @@ <pre class="lines"> +236 237 238 239 -240 -241</pre> +240</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/felflame/system_manager.rb', line 237</span> + <pre class="code"><span class="info file"># File 'lib/felflame/system_manager.rb', line 236</span> <span class='kw'>def</span> <span class='id identifier rubyid_trigger_when_removed'>trigger_when_removed</span><span class='lparen'>(</span><span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='rparen'>)</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_removal_triggers'>removal_triggers</span> <span class='op'>|=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_component_or_manager'>component_or_manager</span><span class='rbracket'>]</span> @@ -1499,7 +1495,7 @@ </div> <div id="footer"> - Generated on Mon Jan 3 06:20:47 2022 by + Generated on Mon Jan 3 07:34:30 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_.html b/docs/Felflame_.html index eda8518..ac59bac 100644 --- a/docs/Felflame_.html +++ b/docs/Felflame_.html @@ -117,7 +117,7 @@ </div> </dt> - <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>3.0.0</span><span class='tstring_end'>"</span></span></pre></dd> + <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>3.0.0</span><span class='tstring_end'>'</span></span></pre></dd> </dl> @@ -133,7 +133,7 @@ </div> <div id="footer"> - Generated on Mon Jan 3 06:20:47 2022 by + Generated on Mon Jan 3 07:34:30 2022 by <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.26 (ruby-2.7.3). </div> diff --git a/docs/_index.html b/docs/_index.html index a183a99..d3becf8 100644 --- a/docs/_index.html +++ b/docs/_index.html @@ -131,6 +131,21 @@ </ul> + <ul id="alpha_O" class="alpha"> + <li class="letter">O</li> + <ul> + + <li> + <span class='object_link'><a href="FelFlame/Order.html" title="FelFlame::Order (module)">Order</a></span> + + <small>(FelFlame)</small> + + </li> + + </ul> + </ul> + + <ul id="alpha_S" class="alpha"> <li class="letter">S</li> <ul> @@ -168,7 +183,7 @@ </div> <div id="footer"> - Generated on Mon Jan 3 06:20:46 2022 by + Generated on Mon Jan 3 07:34:30 2022 by <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.26 (ruby-2.7.3). </div> diff --git a/docs/class_list.html b/docs/class_list.html index 126406f..8275577 100644 --- a/docs/class_list.html +++ b/docs/class_list.html @@ -43,7 +43,7 @@ <ul id="full_list" class="class"> <li id="object_" class="odd"><div class="item" style="padding-left:30px"><span class='object_link'><a href="top-level-namespace.html" title="Top Level Namespace (root)">Top Level Namespace</a></span></div></li> -<li id='object_FelFlame' class='even'><div class='item' style='padding-left:30px'><a class='toggle'></a> <span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span><small class='search_info'>Top Level Namespace</small></div><ul><li id='object_FelFlame::ComponentManager' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/ComponentManager.html" title="FelFlame::ComponentManager (class)">ComponentManager</a></span> < Object<small class='search_info'>FelFlame</small></div></li><li id='object_FelFlame::Components' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span><small class='search_info'>FelFlame</small></div></li><li id='object_FelFlame::Entities' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span> < Object<small class='search_info'>FelFlame</small></div></li><li id='object_FelFlame::Scenes' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span> < Object<small class='search_info'>FelFlame</small></div></li><li id='object_FelFlame::Stage' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span><small class='search_info'>FelFlame</small></div></li><li id='object_FelFlame::Systems' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span> < Object<small class='search_info'>FelFlame</small></div></li></ul></li><li id='object_Felflame' class='odd'><div class='item' style='padding-left:30px'><span class='object_link'><a href="Felflame_.html" title="Felflame (module)">Felflame</a></span><small class='search_info'>Top Level Namespace</small></div></li> +<li id='object_FelFlame' class='even'><div class='item' style='padding-left:30px'><a class='toggle'></a> <span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span><small class='search_info'>Top Level Namespace</small></div><ul><li id='object_FelFlame::ComponentManager' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/ComponentManager.html" title="FelFlame::ComponentManager (class)">ComponentManager</a></span> < Object<small class='search_info'>FelFlame</small></div></li><li id='object_FelFlame::Components' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span><small class='search_info'>FelFlame</small></div></li><li id='object_FelFlame::Entities' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span> < Object<small class='search_info'>FelFlame</small></div></li><li id='object_FelFlame::Order' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/Order.html" title="FelFlame::Order (module)">Order</a></span><small class='search_info'>FelFlame</small></div></li><li id='object_FelFlame::Scenes' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span> < Object<small class='search_info'>FelFlame</small></div></li><li id='object_FelFlame::Stage' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span><small class='search_info'>FelFlame</small></div></li><li id='object_FelFlame::Systems' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span> < Object<small class='search_info'>FelFlame</small></div></li></ul></li><li id='object_Felflame' class='even'><div class='item' style='padding-left:30px'><span class='object_link'><a href="Felflame_.html" title="Felflame (module)">Felflame</a></span><small class='search_info'>Top Level Namespace</small></div></li> </ul> </div> diff --git a/docs/file.README.html b/docs/file.README.html index 11b0848..8565de7 100644 --- a/docs/file.README.html +++ b/docs/file.README.html @@ -76,11 +76,11 @@ <ul> <li><a href="#what-is-felflame">What is FelFlame?</a></li> <li><a href="#what-is-ecs">What is ECS?</a> - - <a href="#components">Components</a> - - <a href="#entities">Entities</a> - - <a href="#systems">Systems</a> - - <a href="#scenes">Scenes</a> - - <a href="#stage">Stage</a></li> + * <a href="#components">Components</a> + * <a href="#entities">Entities</a> + * <a href="#systems">Systems</a> + * <a href="#scenes">Scenes</a> + * <a href="#stage">Stage</a></li> <li><a href="#usage">Usage</a> <ul> @@ -89,7 +89,6 @@ <ul> <li><a href="#creation">Creation</a></li> <li><a href="#accessing">Accessing</a></li> -<li><a href="#get-id">Get ID</a></li> <li><a href="#adding-and-removing-components">Adding and Removing Components</a></li> <li><a href="#accessing-entities-attached-components">Accessing Entities' Attached Components</a></li> <li><a href="#deletion">Deletion</a></li> @@ -99,10 +98,9 @@ <ul> <li><a href="#creating-a-component-manager">Creating a Component Manager</a></li> <li><a href="#creating-a-component-from-a-component-manager">Creating a Component from a Component Manager</a></li> -<li><a href="#accessing-and-getting-id">Accessing and Getting ID</a></li> +<li><a href="#accessing-1">Accessing</a></li> <li><a href="#accessing-attributes-and-changing-them">Accessing Attributes and Changing Them</a></li> <li><a href="#deleting-components">Deleting Components</a></li> -<li><a href="#iterating-over-components">Iterating over Components</a></li> <li><a href="#accessing-components-attached-entities">Accessing Components' attached Entities</a></li> </ul></li> <li><a href="#systems-1">Systems</a> @@ -118,7 +116,7 @@ <ul> <li><a href="#creation-2">Creation</a></li> -<li><a href="#accessing-1">Accessing</a></li> +<li><a href="#accessing-2">Accessing</a></li> <li><a href="#adding-systems">Adding Systems</a></li> <li><a href="#removing-systems">Removing Systems</a></li> <li><a href="#clearing">Clearing</a></li> @@ -185,11 +183,13 @@ ECS stands for Entity, Component, and System.</p> <hr> -<p>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.</p> - <h1 id="usage">Usage</h1> -<p>To use FelFlame simply install the gem using <code>gem install felflame</code> or using bundler <code>bundle add felflame</code> and then require it in your project like so: <code>require 'felflame'</code>. Working outside of the gem for rendering engines that do not support the usage of gems is a planned feature in the works.</p> +<p>There are 2 ways of using FelFlame. You can either <code>include</code> it as a gem in your project if your game engine supports this. The other option is to download the single file export of FelFlame and then <code>require_relative</code> this file in your project. The single file export takes all the ruby code in the various files and concatenates them into a single file so it is more portable and easy to add.</p> + +<p>To use the gem method you can do the following: install the gem using <code>gem install felflame</code> or using bundler <code>bundle add felflame</code> and then require it in your project like so: <code>require 'felflame'</code>.</p> + +<p>To use the single file export method you simply download the felflame.rb file from the <a href="https://github.com/realtradam/FelFlame/releases">releases page on Github</a> and add it to your source folder and add a <code>require relative 'felflame.rb'</code> line or wherever you have placed the file to use it.</p> <h2 id="entities">Entities</h2> @@ -200,29 +200,24 @@ ECS stands for Entity, Component, and System.</p> <pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Entities.html#initialize-instance_method" title="FelFlame::Entities#initialize (method)">new</a></span></span> </code></pre> -<p>or if we want to add (any number of)components to it:</p> +<p>or if we want to add (any number of)components to it when creating it:</p> <pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'>Entites</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Health</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='comma'>,</span> <span class='ivar'>@component</span><span class='comma'>,</span> - <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Armour</span><span class='lbracket'>[</span><span class='int'>7</span><span class='rbracket'>]</span> + <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>EnemyTeam</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> <span class='rparen'>)</span> </code></pre> <h3 id="accessing">Accessing</h3> -<p>Once components are created we can access them using their ID like so:</p> +<p>Oftentimes you will not be accessing an Entity this way. Later we will shows you a more common way of accessing entities. +If you need to you can access Entities using the <code>Entities</code> module:</p> <pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span> -</code></pre> - -<h3 id="get-id">Get ID</h3> - -<p>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:</p> - -<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span> -</code></pre> +<span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> +<span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='comment'># you can iterate over all entities this way. Any valid array method can be used +</span></code></pre> <h3 id="adding-and-removing-components">Adding and Removing Components</h3> @@ -234,14 +229,18 @@ entity where a new entity will claim that ID. To get the ID of an Entity:</p> <h3 id="accessing-entities-attached-components">Accessing Entities' Attached Components</h3> +<p>This is the most common way of accessing an Entity</p> + <p>When Components are added to Entities, they can be accessed from the Entity. By using a Component Manager as a key we can access an array of all components created from that Component Manager that are attached to an entity:</p> -<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span><span class='period'>.</span><span class='id identifier rubyid_components'>components</span><span class='lbracket'>[</span><span class='ivar'>@component_manager</span><span class='rbracket'>]</span> <span class='comment'># => [@component1, @component2, component3] +<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span><span class='period'>.</span><span class='id identifier rubyid_components'>components</span><span class='lbracket'>[</span><span class='ivar'>@component_manager</span><span class='rbracket'>]</span> <span class='comment'># => [@component1, @component2, @component3] </span></code></pre> <h3 id="deletion">Deletion</h3> -<p>To have all Components from an Entity removed and the Entity deleted we do the following:</p> +<p>To have all Components from an Entity <strong>removed</strong> and the Entity deleted we do the following:</p> + +<p>NOTE: The components will <strong>not be deleted</strong>. They are simply <strong>removed</strong> from the entity and then the entity is destroyed. You must handle component deletion yourself as for example singleton components need to removed instead of deleted.</p> <pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> </code></pre> @@ -270,19 +269,18 @@ When defining attributes symbols should be used.</p> <pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> </code></pre> -<p>Or we can even change the defaults:</p> +<p>Or we can even override the defaults when creating the component:</p> <pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='label'>armour:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>steel</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> </code></pre> -<h3 id="accessing-and-getting-id">Accessing and Getting ID</h3> +<h3 id="accessing">Accessing</h3> -<p>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.</p> +<p>You can access components using any array method.</p> <pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span> -<span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span> <span class='comment'># => 2 +<span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> +<span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='comment'># you can use iterators this way </span></code></pre> <h3 id="accessing-attributes-and-changing-them">Accessing Attributes and Changing Them</h3> @@ -295,30 +293,26 @@ Here are the ways to edit attrubutes, followed by the ways to read them.</p> </code></pre> <pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_hp'>hp</span> <span class='comment'># => 95 -</span><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_attrs'>attrs</span> <span class='comment'># => {armour: 'Leather', hp: 95} +</span><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_to_h'>to_h</span> <span class='comment'># => {armour: 'Leather', hp: 95} </span></code></pre> <h3 id="deleting-components">Deleting Components</h3> -<p>Deleting a Component is the same format as deleting an Entity. When a Component is deleted referenced to it such as to entities are automatically cleared.</p> +<p>Deleting a Component is the same convention as deleting an Entity. When a Component is deleted referenced to it such as to entities are automatically cleared.</p> <pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> </code></pre> -<h3 id="iterating-over-components">Iterating over Components</h3> - -<p>When you make Systems you will want to be able to iterate over all Components of the same Component Manager(for example iterating over all sprites to render them). Here is how we do that:</p> - -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Sprites</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_component'>component</span><span class='op'>|</span> - <span class='comment'>#do something with components -</span><span class='kw'>end</span> -</code></pre> - <h3 id="accessing-components-attached-entities">Accessing Components' attached Entities</h3> <p>Components also keep track of what Entities are using it. To access this list we do the following:</p> <pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_entities'>entities</span> <span class='comment'># => [@entity1, @entity2, @entity3] +</span> +<span class='comment'># get the first entity attached. +</span><span class='comment'># this will throw a warning if there is more or less then +</span><span class='comment'># exactly one entity +</span><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_entity'>entity</span> <span class='comment'># => @entity </span></code></pre> <h2 id="systems">Systems</h2> @@ -339,7 +333,9 @@ Here are the ways to edit attrubutes, followed by the ways to read them.</p> <p>Priority determines the order Systems should be executed, this is used for <code>Scenes</code> and the <code>Stage</code>. The lower the number, the earlier a given System will be executed. -E.g priority 1 will go first, priority 2 will go second, etcetera. </p> +E.g priority 1 will go first, priority 2 will go second, etcetera. </p> + +<p>Both Scenes and Systems have a priority. System priority will decide the order it will be called inside of a Scene, which the Scene priority will decide the order it will be called inside of the Stage.</p> <p>Often we will want to execute some logic on each Component in a given Component Manager so our code might look like this:</p> @@ -437,7 +433,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p> <p>Once we have all the core parts of ECS, we will want to organize our Systems. To do this we will use Scenes to group up Systems so they can quickly be enabled or disabled. Note that <a href="#alternative-execution">Alternative Executions</a> will occur even if they are not part of a Scene. Here is how we make a new Scene:</p> -<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Scenes.html#initialize-instance_method" title="FelFlame::Scenes#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ExampleScene</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Scenes.html#initialize-instance_method" title="FelFlame::Scenes#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ExampleScene</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>5</span><span class='rparen'>)</span> </code></pre> <h3 id="accessing">Accessing</h3> @@ -451,14 +447,22 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p> <p>Adding Systems is simple. We can add as many as we want. In this example we add 3 different systems:</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='comma'>,</span> <span class='ivar'>@system2</span><span class='comma'>,</span> <span class='ivar'>@system3</span><span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span> + <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='comma'>,</span> + <span class='ivar'>@system2</span><span class='comma'>,</span> + <span class='ivar'>@system3</span> +<span class='rparen'>)</span> </code></pre> <h3 id="removing-systems">Removing Systems</h3> -<p>Removing Systems works simularly:</p> +<p>Removing Systems works similarly:</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span><span class='period'>.</span><span class='id identifier rubyid_remove'>remove</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='comma'>,</span> <span class='ivar'>@system2</span><span class='comma'>,</span> <span class='ivar'>@system3</span><span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span><span class='period'>.</span><span class='id identifier rubyid_remove'>remove</span><span class='lparen'>(</span> + <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='comma'>,</span> + <span class='ivar'>@system2</span><span class='comma'>,</span> + <span class='ivar'>@system3</span> +<span class='rparen'>)</span> </code></pre> <h3 id="clearing">Clearing</h3> @@ -481,7 +485,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p> <h3 id="adding-scenes">Adding Scenes</h3> -<p>Finally we have the Stage. There is only a single Stage and we do not have to create it as it exists by default. By adding a Scene to the Stage we are saying that the Scene is active. To add a Scene we do the following:</p> +<p>Finally we have the Stage. There is only a single Stage and we do not have to create it as it exists by default. By adding a Scene to the Stage we are saying that the Scene is 'active'. To add a Scene we do the following:</p> <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_add'><span class='object_link'><a href="FelFlame/Stage.html#add-class_method" title="FelFlame::Stage.add (method)">add</a></span></span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'>Scene</span><span class='op'>::</span><span class='const'>ExampleScene</span> </code></pre> @@ -495,7 +499,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p> <h3 id="executing">Executing</h3> -<p>On each frame of the game we want to execute the Stage once. When the Stage is executed it is progressing your game 1 frame forward. The Stage will make sure for you that all the Systems from all Scenes added will be executed in the correct order according to their priority. Here is how we do it:</p> +<p>On each frame of the game generally we will want to execute the Stage once. When the Stage is executed it is progressing your game 1 frame forward. The Stage will call all Scenes you added to it in the order of their priority. Here is how we do it:</p> <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_call'><span class='object_link'><a href="FelFlame/Stage.html#call-class_method" title="FelFlame::Stage.call (method)">call</a></span></span> </code></pre> @@ -514,7 +518,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p> </div></div> <div id="footer"> - Generated on Mon Jan 3 06:20:46 2022 by + Generated on Mon Jan 3 07:34:30 2022 by <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.26 (ruby-2.7.3). </div> diff --git a/docs/index.html b/docs/index.html index 5333a27..916cce2 100644 --- a/docs/index.html +++ b/docs/index.html @@ -76,11 +76,11 @@ <ul> <li><a href="#what-is-felflame">What is FelFlame?</a></li> <li><a href="#what-is-ecs">What is ECS?</a> - - <a href="#components">Components</a> - - <a href="#entities">Entities</a> - - <a href="#systems">Systems</a> - - <a href="#scenes">Scenes</a> - - <a href="#stage">Stage</a></li> + * <a href="#components">Components</a> + * <a href="#entities">Entities</a> + * <a href="#systems">Systems</a> + * <a href="#scenes">Scenes</a> + * <a href="#stage">Stage</a></li> <li><a href="#usage">Usage</a> <ul> @@ -89,7 +89,6 @@ <ul> <li><a href="#creation">Creation</a></li> <li><a href="#accessing">Accessing</a></li> -<li><a href="#get-id">Get ID</a></li> <li><a href="#adding-and-removing-components">Adding and Removing Components</a></li> <li><a href="#accessing-entities-attached-components">Accessing Entities' Attached Components</a></li> <li><a href="#deletion">Deletion</a></li> @@ -99,10 +98,9 @@ <ul> <li><a href="#creating-a-component-manager">Creating a Component Manager</a></li> <li><a href="#creating-a-component-from-a-component-manager">Creating a Component from a Component Manager</a></li> -<li><a href="#accessing-and-getting-id">Accessing and Getting ID</a></li> +<li><a href="#accessing-1">Accessing</a></li> <li><a href="#accessing-attributes-and-changing-them">Accessing Attributes and Changing Them</a></li> <li><a href="#deleting-components">Deleting Components</a></li> -<li><a href="#iterating-over-components">Iterating over Components</a></li> <li><a href="#accessing-components-attached-entities">Accessing Components' attached Entities</a></li> </ul></li> <li><a href="#systems-1">Systems</a> @@ -118,7 +116,7 @@ <ul> <li><a href="#creation-2">Creation</a></li> -<li><a href="#accessing-1">Accessing</a></li> +<li><a href="#accessing-2">Accessing</a></li> <li><a href="#adding-systems">Adding Systems</a></li> <li><a href="#removing-systems">Removing Systems</a></li> <li><a href="#clearing">Clearing</a></li> @@ -185,11 +183,13 @@ ECS stands for Entity, Component, and System.</p> <hr> -<p>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.</p> - <h1 id="usage">Usage</h1> -<p>To use FelFlame simply install the gem using <code>gem install felflame</code> or using bundler <code>bundle add felflame</code> and then require it in your project like so: <code>require 'felflame'</code>. Working outside of the gem for rendering engines that do not support the usage of gems is a planned feature in the works.</p> +<p>There are 2 ways of using FelFlame. You can either <code>include</code> it as a gem in your project if your game engine supports this. The other option is to download the single file export of FelFlame and then <code>require_relative</code> this file in your project. The single file export takes all the ruby code in the various files and concatenates them into a single file so it is more portable and easy to add.</p> + +<p>To use the gem method you can do the following: install the gem using <code>gem install felflame</code> or using bundler <code>bundle add felflame</code> and then require it in your project like so: <code>require 'felflame'</code>.</p> + +<p>To use the single file export method you simply download the felflame.rb file from the <a href="https://github.com/realtradam/FelFlame/releases">releases page on Github</a> and add it to your source folder and add a <code>require relative 'felflame.rb'</code> line or wherever you have placed the file to use it.</p> <h2 id="entities">Entities</h2> @@ -200,29 +200,24 @@ ECS stands for Entity, Component, and System.</p> <pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Entities.html#initialize-instance_method" title="FelFlame::Entities#initialize (method)">new</a></span></span> </code></pre> -<p>or if we want to add (any number of)components to it:</p> +<p>or if we want to add (any number of)components to it when creating it:</p> <pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'>Entites</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Health</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='comma'>,</span> <span class='ivar'>@component</span><span class='comma'>,</span> - <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Armour</span><span class='lbracket'>[</span><span class='int'>7</span><span class='rbracket'>]</span> + <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>EnemyTeam</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> <span class='rparen'>)</span> </code></pre> <h3 id="accessing">Accessing</h3> -<p>Once components are created we can access them using their ID like so:</p> +<p>Oftentimes you will not be accessing an Entity this way. Later we will shows you a more common way of accessing entities. +If you need to you can access Entities using the <code>Entities</code> module:</p> <pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span> -</code></pre> - -<h3 id="get-id">Get ID</h3> - -<p>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:</p> - -<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span> -</code></pre> +<span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> +<span class='ivar'>@entity</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Entities.html" title="FelFlame::Entities (class)">Entities</a></span></span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='comment'># you can iterate over all entities this way. Any valid array method can be used +</span></code></pre> <h3 id="adding-and-removing-components">Adding and Removing Components</h3> @@ -234,14 +229,18 @@ entity where a new entity will claim that ID. To get the ID of an Entity:</p> <h3 id="accessing-entities-attached-components">Accessing Entities' Attached Components</h3> +<p>This is the most common way of accessing an Entity</p> + <p>When Components are added to Entities, they can be accessed from the Entity. By using a Component Manager as a key we can access an array of all components created from that Component Manager that are attached to an entity:</p> -<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span><span class='period'>.</span><span class='id identifier rubyid_components'>components</span><span class='lbracket'>[</span><span class='ivar'>@component_manager</span><span class='rbracket'>]</span> <span class='comment'># => [@component1, @component2, component3] +<pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span><span class='period'>.</span><span class='id identifier rubyid_components'>components</span><span class='lbracket'>[</span><span class='ivar'>@component_manager</span><span class='rbracket'>]</span> <span class='comment'># => [@component1, @component2, @component3] </span></code></pre> <h3 id="deletion">Deletion</h3> -<p>To have all Components from an Entity removed and the Entity deleted we do the following:</p> +<p>To have all Components from an Entity <strong>removed</strong> and the Entity deleted we do the following:</p> + +<p>NOTE: The components will <strong>not be deleted</strong>. They are simply <strong>removed</strong> from the entity and then the entity is destroyed. You must handle component deletion yourself as for example singleton components need to removed instead of deleted.</p> <pre class="code ruby"><code class="ruby"><span class='ivar'>@entity</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> </code></pre> @@ -270,19 +269,18 @@ When defining attributes symbols should be used.</p> <pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> </code></pre> -<p>Or we can even change the defaults:</p> +<p>Or we can even override the defaults when creating the component:</p> <pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='label'>armour:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>steel</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> </code></pre> -<h3 id="accessing-and-getting-id">Accessing and Getting ID</h3> +<h3 id="accessing">Accessing</h3> -<p>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.</p> +<p>You can access components using any array method.</p> <pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span> -<span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span> <span class='comment'># => 2 +<span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> +<span class='ivar'>@component</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Stats</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='comment'># you can use iterators this way </span></code></pre> <h3 id="accessing-attributes-and-changing-them">Accessing Attributes and Changing Them</h3> @@ -295,30 +293,26 @@ Here are the ways to edit attrubutes, followed by the ways to read them.</p> </code></pre> <pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_hp'>hp</span> <span class='comment'># => 95 -</span><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_attrs'>attrs</span> <span class='comment'># => {armour: 'Leather', hp: 95} +</span><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_to_h'>to_h</span> <span class='comment'># => {armour: 'Leather', hp: 95} </span></code></pre> <h3 id="deleting-components">Deleting Components</h3> -<p>Deleting a Component is the same format as deleting an Entity. When a Component is deleted referenced to it such as to entities are automatically cleared.</p> +<p>Deleting a Component is the same convention as deleting an Entity. When a Component is deleted referenced to it such as to entities are automatically cleared.</p> <pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> </code></pre> -<h3 id="iterating-over-components">Iterating over Components</h3> - -<p>When you make Systems you will want to be able to iterate over all Components of the same Component Manager(for example iterating over all sprites to render them). Here is how we do that:</p> - -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Components.html" title="FelFlame::Components (module)">Components</a></span></span><span class='op'>::</span><span class='const'>Sprites</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_component'>component</span><span class='op'>|</span> - <span class='comment'>#do something with components -</span><span class='kw'>end</span> -</code></pre> - <h3 id="accessing-components-attached-entities">Accessing Components' attached Entities</h3> <p>Components also keep track of what Entities are using it. To access this list we do the following:</p> <pre class="code ruby"><code class="ruby"><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_entities'>entities</span> <span class='comment'># => [@entity1, @entity2, @entity3] +</span> +<span class='comment'># get the first entity attached. +</span><span class='comment'># this will throw a warning if there is more or less then +</span><span class='comment'># exactly one entity +</span><span class='ivar'>@component</span><span class='period'>.</span><span class='id identifier rubyid_entity'>entity</span> <span class='comment'># => @entity </span></code></pre> <h2 id="systems">Systems</h2> @@ -339,7 +333,9 @@ Here are the ways to edit attrubutes, followed by the ways to read them.</p> <p>Priority determines the order Systems should be executed, this is used for <code>Scenes</code> and the <code>Stage</code>. The lower the number, the earlier a given System will be executed. -E.g priority 1 will go first, priority 2 will go second, etcetera. </p> +E.g priority 1 will go first, priority 2 will go second, etcetera. </p> + +<p>Both Scenes and Systems have a priority. System priority will decide the order it will be called inside of a Scene, which the Scene priority will decide the order it will be called inside of the Stage.</p> <p>Often we will want to execute some logic on each Component in a given Component Manager so our code might look like this:</p> @@ -437,7 +433,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p> <p>Once we have all the core parts of ECS, we will want to organize our Systems. To do this we will use Scenes to group up Systems so they can quickly be enabled or disabled. Note that <a href="#alternative-execution">Alternative Executions</a> will occur even if they are not part of a Scene. Here is how we make a new Scene:</p> -<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Scenes.html#initialize-instance_method" title="FelFlame::Scenes#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ExampleScene</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby"><span class='ivar'>@scene</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="FelFlame/Scenes.html#initialize-instance_method" title="FelFlame::Scenes#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ExampleScene</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>priority:</span> <span class='int'>5</span><span class='rparen'>)</span> </code></pre> <h3 id="accessing">Accessing</h3> @@ -451,14 +447,22 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p> <p>Adding Systems is simple. We can add as many as we want. In this example we add 3 different systems:</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='comma'>,</span> <span class='ivar'>@system2</span><span class='comma'>,</span> <span class='ivar'>@system3</span><span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span> + <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='comma'>,</span> + <span class='ivar'>@system2</span><span class='comma'>,</span> + <span class='ivar'>@system3</span> +<span class='rparen'>)</span> </code></pre> <h3 id="removing-systems">Removing Systems</h3> -<p>Removing Systems works simularly:</p> +<p>Removing Systems works similarly:</p> -<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span><span class='period'>.</span><span class='id identifier rubyid_remove'>remove</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='comma'>,</span> <span class='ivar'>@system2</span><span class='comma'>,</span> <span class='ivar'>@system3</span><span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Scenes.html" title="FelFlame::Scenes (class)">Scenes</a></span></span><span class='op'>::</span><span class='const'>ExampleScene</span><span class='period'>.</span><span class='id identifier rubyid_remove'>remove</span><span class='lparen'>(</span> + <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Systems.html" title="FelFlame::Systems (class)">Systems</a></span></span><span class='op'>::</span><span class='const'>Render</span><span class='comma'>,</span> + <span class='ivar'>@system2</span><span class='comma'>,</span> + <span class='ivar'>@system3</span> +<span class='rparen'>)</span> </code></pre> <h3 id="clearing">Clearing</h3> @@ -481,7 +485,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p> <h3 id="adding-scenes">Adding Scenes</h3> -<p>Finally we have the Stage. There is only a single Stage and we do not have to create it as it exists by default. By adding a Scene to the Stage we are saying that the Scene is active. To add a Scene we do the following:</p> +<p>Finally we have the Stage. There is only a single Stage and we do not have to create it as it exists by default. By adding a Scene to the Stage we are saying that the Scene is 'active'. To add a Scene we do the following:</p> <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_add'><span class='object_link'><a href="FelFlame/Stage.html#add-class_method" title="FelFlame::Stage.add (method)">add</a></span></span> <span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'>Scene</span><span class='op'>::</span><span class='const'>ExampleScene</span> </code></pre> @@ -495,7 +499,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p> <h3 id="executing">Executing</h3> -<p>On each frame of the game we want to execute the Stage once. When the Stage is executed it is progressing your game 1 frame forward. The Stage will make sure for you that all the Systems from all Scenes added will be executed in the correct order according to their priority. Here is how we do it:</p> +<p>On each frame of the game generally we will want to execute the Stage once. When the Stage is executed it is progressing your game 1 frame forward. The Stage will call all Scenes you added to it in the order of their priority. Here is how we do it:</p> <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="FelFlame.html" title="FelFlame (module)">FelFlame</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FelFlame/Stage.html" title="FelFlame::Stage (module)">Stage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_call'><span class='object_link'><a href="FelFlame/Stage.html#call-class_method" title="FelFlame::Stage.call (method)">call</a></span></span> </code></pre> @@ -514,7 +518,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera. </p> </div></div> <div id="footer"> - Generated on Mon Jan 3 06:20:46 2022 by + Generated on Mon Jan 3 07:34:30 2022 by <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.26 (ruby-2.7.3). </div> diff --git a/docs/method_list.html b/docs/method_list.html index d8253e9..e0c8da1 100644 --- a/docs/method_list.html +++ b/docs/method_list.html @@ -94,21 +94,13 @@ <li class="odd "> <div class="item"> - <span class='object_link'><a href="FelFlame/ComponentManager.html#attr_changed_trigger_systems-instance_method" title="FelFlame::ComponentManager#attr_changed_trigger_systems (method)">#attr_changed_trigger_systems</a></span> - <small>FelFlame::ComponentManager</small> - </div> - </li> - - - <li class="even "> - <div class="item"> <span class='object_link'><a href="FelFlame/Systems.html#attr_triggers-instance_method" title="FelFlame::Systems#attr_triggers (method)">#attr_triggers</a></span> <small>FelFlame::Systems</small> </div> </li> - <li class="odd "> + <li class="even "> <div class="item"> <span class='object_link'><a href="FelFlame/ComponentManager.html#attr_triggers-instance_method" title="FelFlame::ComponentManager#attr_triggers (method)">#attr_triggers</a></span> <small>FelFlame::ComponentManager</small> @@ -116,7 +108,7 @@ </li> - <li class="even "> + <li class="odd "> <div class="item"> <span class='object_link'><a href="FelFlame/ComponentManager.html#attr_triggers-class_method" title="FelFlame::ComponentManager.attr_triggers (method)">attr_triggers</a></span> <small>FelFlame::ComponentManager</small> @@ -124,7 +116,7 @@ </li> - <li class="odd "> + <li class="even "> <div class="item"> <span class='object_link'><a href="FelFlame.html#call-class_method" title="FelFlame.call (method)">call</a></span> <small>FelFlame</small> @@ -132,7 +124,7 @@ </li> - <li class="even "> + <li class="odd "> <div class="item"> <span class='object_link'><a href="FelFlame/Scenes.html#call-instance_method" title="FelFlame::Scenes#call (method)">#call</a></span> <small>FelFlame::Scenes</small> @@ -140,7 +132,7 @@ </li> - <li class="odd "> + <li class="even "> <div class="item"> <span class='object_link'><a href="FelFlame/Stage.html#call-class_method" title="FelFlame::Stage.call (method)">call</a></span> <small>FelFlame::Stage</small> @@ -148,7 +140,7 @@ </li> - <li class="even "> + <li class="odd "> <div class="item"> <span class='object_link'><a href="FelFlame/Systems.html#call-instance_method" title="FelFlame::Systems#call (method)">#call</a></span> <small>FelFlame::Systems</small> @@ -156,7 +148,7 @@ </li> - <li class="odd "> + <li class="even "> <div class="item"> <span class='object_link'><a href="FelFlame/Scenes.html#clear-instance_method" title="FelFlame::Scenes#clear (method)">#clear</a></span> <small>FelFlame::Scenes</small> @@ -164,7 +156,7 @@ </li> - <li class="even "> + <li class="odd "> <div class="item"> <span class='object_link'><a href="FelFlame/Stage.html#clear-class_method" title="FelFlame::Stage.clear (method)">clear</a></span> <small>FelFlame::Stage</small> @@ -172,7 +164,7 @@ </li> - <li class="odd "> + <li class="even "> <div class="item"> <span class='object_link'><a href="FelFlame/Systems.html#clear_triggers-instance_method" title="FelFlame::Systems#clear_triggers (method)">#clear_triggers</a></span> <small>FelFlame::Systems</small> @@ -180,7 +172,7 @@ </li> - <li class="even "> + <li class="odd "> <div class="item"> <span class='object_link'><a href="FelFlame/Entities.html#component-instance_method" title="FelFlame::Entities#component (method)">#component</a></span> <small>FelFlame::Entities</small> @@ -188,7 +180,7 @@ </li> - <li class="odd "> + <li class="even "> <div class="item"> <span class='object_link'><a href="FelFlame/Entities.html#components-instance_method" title="FelFlame::Entities#components (method)">#components</a></span> <small>FelFlame::Entities</small> @@ -196,7 +188,7 @@ </li> - <li class="even "> + <li class="odd "> <div class="item"> <span class='object_link'><a href="FelFlame/Systems.html#const_cache-class_method" title="FelFlame::Systems.const_cache (method)">const_cache</a></span> <small>FelFlame::Systems</small> @@ -204,7 +196,7 @@ </li> - <li class="odd "> + <li class="even "> <div class="item"> <span class='object_link'><a href="FelFlame/Entities.html#delete-instance_method" title="FelFlame::Entities#delete (method)">#delete</a></span> <small>FelFlame::Entities</small> @@ -212,7 +204,7 @@ </li> - <li class="even "> + <li class="odd "> <div class="item"> <span class='object_link'><a href="FelFlame/ComponentManager.html#delete-instance_method" title="FelFlame::ComponentManager#delete (method)">#delete</a></span> <small>FelFlame::ComponentManager</small> @@ -220,7 +212,7 @@ </li> - <li class="odd "> + <li class="even "> <div class="item"> <span class='object_link'><a href="FelFlame/ComponentManager.html#entities-instance_method" title="FelFlame::ComponentManager#entities (method)">#entities</a></span> <small>FelFlame::ComponentManager</small> @@ -228,7 +220,7 @@ </li> - <li class="even "> + <li class="odd "> <div class="item"> <span class='object_link'><a href="FelFlame/ComponentManager.html#entity-instance_method" title="FelFlame::ComponentManager#entity (method)">#entity</a></span> <small>FelFlame::ComponentManager</small> @@ -236,7 +228,7 @@ </li> - <li class="odd "> + <li class="even "> <div class="item"> <span class='object_link'><a href="FelFlame/Scenes.html#initialize-instance_method" title="FelFlame::Scenes#initialize (method)">#initialize</a></span> <small>FelFlame::Scenes</small> @@ -244,7 +236,7 @@ </li> - <li class="even "> + <li class="odd "> <div class="item"> <span class='object_link'><a href="FelFlame/Entities.html#initialize-instance_method" title="FelFlame::Entities#initialize (method)">#initialize</a></span> <small>FelFlame::Entities</small> @@ -252,7 +244,7 @@ </li> - <li class="odd "> + <li class="even "> <div class="item"> <span class='object_link'><a href="FelFlame/Systems.html#initialize-instance_method" title="FelFlame::Systems#initialize (method)">#initialize</a></span> <small>FelFlame::Systems</small> @@ -260,7 +252,7 @@ </li> - <li class="even "> + <li class="odd "> <div class="item"> <span class='object_link'><a href="FelFlame/ComponentManager.html#initialize-instance_method" title="FelFlame::ComponentManager#initialize (method)">#initialize</a></span> <small>FelFlame::ComponentManager</small> @@ -268,7 +260,7 @@ </li> - <li class="odd "> + <li class="even "> <div class="item"> <span class='object_link'><a href="FelFlame/Components.html#new-class_method" title="FelFlame::Components.new (method)">new</a></span> <small>FelFlame::Components</small> @@ -276,7 +268,7 @@ </li> - <li class="even "> + <li class="odd "> <div class="item"> <span class='object_link'><a href="FelFlame/Scenes.html#priority-instance_method" title="FelFlame::Scenes#priority (method)">#priority</a></span> <small>FelFlame::Scenes</small> @@ -284,7 +276,7 @@ </li> - <li class="odd "> + <li class="even "> <div class="item"> <span class='object_link'><a href="FelFlame/Systems.html#priority-instance_method" title="FelFlame::Systems#priority (method)">#priority</a></span> <small>FelFlame::Systems</small> @@ -292,7 +284,7 @@ </li> - <li class="even "> + <li class="odd "> <div class="item"> <span class='object_link'><a href="FelFlame/Systems.html#redefine-instance_method" title="FelFlame::Systems#redefine (method)">#redefine</a></span> <small>FelFlame::Systems</small> @@ -300,7 +292,7 @@ </li> - <li class="odd "> + <li class="even "> <div class="item"> <span class='object_link'><a href="FelFlame/Systems.html#removal_triggers-instance_method" title="FelFlame::Systems#removal_triggers (method)">#removal_triggers</a></span> <small>FelFlame::Systems</small> @@ -308,7 +300,7 @@ </li> - <li class="even "> + <li class="odd "> <div class="item"> <span class='object_link'><a href="FelFlame/ComponentManager.html#removal_triggers-instance_method" title="FelFlame::ComponentManager#removal_triggers (method)">#removal_triggers</a></span> <small>FelFlame::ComponentManager</small> @@ -316,7 +308,7 @@ </li> - <li class="odd "> + <li class="even "> <div class="item"> <span class='object_link'><a href="FelFlame/ComponentManager.html#removal_triggers-class_method" title="FelFlame::ComponentManager.removal_triggers (method)">removal_triggers</a></span> <small>FelFlame::ComponentManager</small> @@ -324,7 +316,7 @@ </li> - <li class="even "> + <li class="odd "> <div class="item"> <span class='object_link'><a href="FelFlame/Scenes.html#remove-instance_method" title="FelFlame::Scenes#remove (method)">#remove</a></span> <small>FelFlame::Scenes</small> @@ -332,7 +324,7 @@ </li> - <li class="odd "> + <li class="even "> <div class="item"> <span class='object_link'><a href="FelFlame/Stage.html#remove-class_method" title="FelFlame::Stage.remove (method)">remove</a></span> <small>FelFlame::Stage</small> @@ -340,7 +332,7 @@ </li> - <li class="even "> + <li class="odd "> <div class="item"> <span class='object_link'><a href="FelFlame/Entities.html#remove-instance_method" title="FelFlame::Entities#remove (method)">#remove</a></span> <small>FelFlame::Entities</small> @@ -348,7 +340,7 @@ </li> - <li class="odd "> + <li class="even "> <div class="item"> <span class='object_link'><a href="FelFlame/Stage.html#scenes-class_method" title="FelFlame::Stage.scenes (method)">scenes</a></span> <small>FelFlame::Stage</small> @@ -356,7 +348,7 @@ </li> - <li class="even "> + <li class="odd "> <div class="item"> <span class='object_link'><a href="FelFlame/Systems.html#scenes-instance_method" title="FelFlame::Systems#scenes (method)">#scenes</a></span> <small>FelFlame::Systems</small> @@ -364,6 +356,14 @@ </li> + <li class="even "> + <div class="item"> + <span class='object_link'><a href="FelFlame/Order.html#sort-instance_method" title="FelFlame::Order#sort (method)">#sort</a></span> + <small>FelFlame::Order</small> + </div> + </li> + + <li class="odd "> <div class="item"> <span class='object_link'><a href="FelFlame/Scenes.html#systems-instance_method" title="FelFlame::Scenes#systems (method)">#systems</a></span> diff --git a/docs/top-level-namespace.html b/docs/top-level-namespace.html index 9462bb1..78ec112 100644 --- a/docs/top-level-namespace.html +++ b/docs/top-level-namespace.html @@ -127,7 +127,7 @@ </div> <div id="footer"> - Generated on Mon Jan 3 06:20:47 2022 by + Generated on Mon Jan 3 07:34:30 2022 by <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.9.26 (ruby-2.7.3). </div> diff --git a/felflame.gemspec b/felflame.gemspec index a0f8c7b..6f26e6f 100644 --- a/felflame.gemspec +++ b/felflame.gemspec @@ -1,44 +1,44 @@ # frozen_string_literal: true -require_relative "lib/felflame/version" +require_relative 'lib/felflame/version' Gem::Specification.new do |spec| - spec.name = "felflame" + spec.name = 'felflame' spec.version = Felflame::VERSION - spec.authors = ["Tradam"] - spec.email = ["[email protected]"] + spec.authors = ['Tradam'] + spec.email = ['[email protected]'] - spec.summary = "The Engine Agnostic ECS Ruby Framework" - #spec.description = "TODO: Write a longer description or delete this line." - spec.homepage = "https://felflame.tradam.fyi" - spec.license = "MIT" - spec.required_ruby_version = ">= 2.4.0" + spec.summary = 'The Engine Agnostic ECS Ruby Framework' + # spec.description = "TODO: Write a longer description or delete this line." + spec.homepage = 'https://felflame.tradam.fyi' + spec.license = 'MIT' + spec.required_ruby_version = '>= 2.4.0' - #spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'" + # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'" - spec.metadata["homepage_uri"] = spec.homepage - spec.metadata["source_code_uri"] = "https://github.com/realtradam/FelFlame" - #spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here." + spec.metadata['homepage_uri'] = spec.homepage + spec.metadata['source_code_uri'] = 'https://github.com/realtradam/FelFlame' + # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here." # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. spec.files = Dir.chdir(File.expand_path(__dir__)) do `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features|deprecated|codeclimate|logos)/}) } end - spec.bindir = "exe" + spec.bindir = 'exe' spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } - spec.require_paths = ["lib"] + spec.require_paths = ['lib'] # Uncomment to register a new dependency of your gem # spec.add_dependency "example-gem", "~> 1.0" - spec.add_development_dependency 'minitest-reporters', '~> 1.4', '>= 1.4.3'#, require: false + spec.add_development_dependency 'minitest-reporters', '~> 1.4', '>= 1.4.3' # , require: false + spec.add_development_dependency 'redcarpet', '~> 3.5', '>= 3.5.1' # , require: false spec.add_development_dependency 'rspec', '~> 3.10' - spec.add_development_dependency 'simplecov', '~> 0.21.2'#, require: false - spec.add_development_dependency 'simplecov-console', '~> 0.9.1' - spec.add_development_dependency 'simplecov_json_formatter', '~> 0.1.3'#, require: false - spec.add_development_dependency 'redcarpet', '~> 3.5', '>= 3.5.1'#, require: false - spec.add_development_dependency 'yard', '~> 0.9.26'#, require: false spec.add_development_dependency 'rubocop', '~> 1.7' + spec.add_development_dependency 'simplecov', '~> 0.21.2' # , require: false + spec.add_development_dependency 'simplecov-console', '~> 0.9.1' + spec.add_development_dependency 'simplecov_json_formatter', '~> 0.1.3' # , require: false + spec.add_development_dependency 'yard', '~> 0.9.26' # , require: false # For more information and examples about making a new gem, checkout our # guide at: https://bundler.io/guides/creating_gem.html diff --git a/lib/felflame.rb b/lib/felflame.rb index 54084bf..b7a386a 100644 --- a/lib/felflame.rb +++ b/lib/felflame.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative 'felflame/entity_manager' require_relative 'felflame/component_manager' require_relative 'felflame/system_manager' @@ -8,7 +10,7 @@ require_relative 'felflame/version' # The FelFlame namespace where all its functionality resides under. module FelFlame - class <<self + class << self # :nocov: # An alias for {FelFlame::Stage.call}. It executes a single frame in the game. @@ -18,22 +20,21 @@ module FelFlame # :nocov: end - # Creates and manages Entities. Allows iterating or accessing Entities using array methods directly on the class. Entities are just collections of Components. + # Creates and manages Entities. Entities are just collections of Components. + # You can use array methods directly on this class to access Entities. class Entities; end # Creates component managers and allows accessing them them under the {FelFlame::Components} namespace as Constants. + # You can use array methods directly on this class to access Component Managers. # # To see how component managers are used please look at the {FelFlame::ComponentManager} documentation. module Components; end - # Creates an manages Systems. Systems are the logic of the game and do not contain any data within them. Any systems you create are accessable under the {FelFlame::Systems} namespace as Constants. - # - # TODO: Improve Systems overview + # Creates and manages Systems. Systems are the logic of the game and do not contain any data within them. Any systems you create are accessable under the {FelFlame::Systems} namespace as Constants. + # You can use array methods directly on this class to access Systems. class Systems; end # Creates and manages Scenes. Scenes are collections of Systems, and execute all the Systems when called upon. Any scenes you create are accessable under the {FelFlame::Scenes} namespace as Constants. - # - # TODO: Improve Scenes overview class Scenes; end # Stores Scenes you add to it which you want to execute on each frame. When called upon will execute all Systems in the Scenes in the Stage and will execute them according to their priority order. diff --git a/lib/felflame/component_manager.rb b/lib/felflame/component_manager.rb index d015d99..04faccb 100644 --- a/lib/felflame/component_manager.rb +++ b/lib/felflame/component_manager.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true + module FelFlame module Components @component_map = [] - class <<self + class << self # Creates a new {FelFlame::ComponentManager component manager}. # # @example @@ -20,14 +22,14 @@ module FelFlame raise(NameError.new, "Component Manager '#{component_name}' is already defined") end - const_set(component_name, Class.new(FelFlame::ComponentManager) {}) update_const_cache attrs.each do |attr| - if FelFlame::Components.const_get(component_name).method_defined?("#{attr}") || FelFlame::Components.const_get(component_name).method_defined?("#{attr}=") - raise NameError.new "The attribute name \"#{attr}\" is already a method" + if FelFlame::Components.const_get(component_name).method_defined?(attr.to_s) || FelFlame::Components.const_get(component_name).method_defined?("#{attr}=") + raise NameError, "The attribute name \"#{attr}\" is already a method" end + FelFlame::Components.const_get(component_name).attr_accessor attr end attrs_with_defaults.each do |attr, _default| @@ -49,24 +51,24 @@ module FelFlame # Makes component module behave like an array of component # managers with additional methods for managing the array # @!visibility private - ##def respond_to_missing?(method, *) + # #def respond_to_missing?(method, *) # if constants.respond_to? method # true # else # super # end - #end + # end ## Makes component module behave like arrays with additional ## methods for managing the array ## @!visibility private - #def method_missing(method, *args, **kwargs, &block) + # def method_missing(method, *args, **kwargs, &block) # if constants.respond_to? method # constants.send(method, *args, **kwargs, &block) # else # super # end - #end + # end # Stores the components managers in {FelFlame::Components}. This # is needed because calling `FelFlame::Components.constants` @@ -83,8 +85,8 @@ module FelFlame # Used internally by FelFlame # @!visibility private def update_const_cache - @const_cache = self.constants.map do |constant| - self.const_get constant + @const_cache = constants.map do |constant| + const_get constant end end @@ -110,16 +112,12 @@ module FelFlame super end end - - - end end # 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 [email protected] = 5+), or by using the {#attrs} and {#update_attrs} methods instead. + # 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 [email protected] = 5+), or by using the {#to_h} and {#update_attrs} methods instead. class ComponentManager - # Allows overwriting the storage of triggers, such as for clearing. # This method should generally only need to be used internally and # not by a game developer. @@ -168,13 +166,12 @@ module FelFlame self.class.push self end - class <<self - + class << self # Makes component managers behave like arrays with additional # methods for managing the array # @!visibility private def respond_to_missing?(method, *) - if self._data.respond_to? method + if _data.respond_to? method true else super @@ -185,14 +182,13 @@ module FelFlame # methods for managing the array # @!visibility private def method_missing(method, *args, **kwargs, &block) - if self._data.respond_to? method - self._data.send(method, *args, **kwargs, &block) + if _data.respond_to? method + _data.send(method, *args, **kwargs, &block) else super end end - # Allows overwriting the storage of triggers, such as for clearing. # This method should generally only need to be used internally and # not by a game developer. @@ -257,6 +253,7 @@ module FelFlame # Execute systems that have been added to execute on variable change # @return [Boolean] +true+ + # @!visibility private def attr_changed_trigger_systems(attr) systems_to_execute = self.class.attr_triggers[attr] systems_to_execute = [] if systems_to_execute.nil? @@ -266,6 +263,7 @@ module FelFlame systems_to_execute.sort_by(&:priority).reverse_each(&:call) true end + # Removes this component from the list and purges all references to this Component from other Entities, as well as its data. # @return [Boolean] +true+. def delete @@ -282,7 +280,7 @@ module FelFlame true end - # @return [Hash<Symbol, Value>] A hash, where all the keys are attributes linked to their respective values. + # @return [Hash<Symbol, Value>] A hash, where all the keys are attributes storing their respective values. def to_h return_hash = instance_variables.each_with_object({}) do |key, final| final[key.to_s.delete_prefix('@').to_sym] = instance_variable_get(key) @@ -294,8 +292,8 @@ module FelFlame # Export all data into a JSON String, which could then later be loaded or saved to a file # TODO: This function is not yet complete # @return [String] a JSON formatted String - #def to_json + # def to_json # # should return a json or hash of all data in this component - #end + # end end end diff --git a/lib/felflame/entity_manager.rb b/lib/felflame/entity_manager.rb index 2ae0849..ef70510 100644 --- a/lib/felflame/entity_manager.rb +++ b/lib/felflame/entity_manager.rb @@ -1,6 +1,7 @@ +# frozen_string_literal: true + module FelFlame class Entities - # Creating a new Entity # @param components [Components] Can be any number of components, identical duplicates will be automatically purged however different components from the same component manager are allowed. # @return [Entity] @@ -16,9 +17,9 @@ module FelFlame @components ||= {} end - # 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. + # 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. # @example - # @entity.component[@component_manager] # array notation + # @entity.component[@component_manager] # array notation(the standard) # @entity.component(@component_manager) # method notation # @param manager [ComponentManager] If you pass nil you can then use array notation to access the same value. # @return [Component] @@ -32,15 +33,15 @@ module FelFlame elsif components[manager].length > 1 Warning.warn("This entity has MANY of this component but you called the method that is intended for having a single of this component type.\nYou may have a bug in your logic.") end + components[manager].first end end - # Removes this Entity from the list and purges all references to this Entity from other Components, as well as its data. # @return [Boolean] +true+ def delete - components.each do |component_manager, component_array| + components.each do |_component_manager, component_array| component_array.reverse_each do |component| component.entities.delete(self) end @@ -88,9 +89,7 @@ module FelFlame check_systems component, :removal_triggers if component.entities.include? self component.entities.delete self components[component.class].delete component - if components[component.class].empty? - components.delete component.class - end + components.delete component.class if components[component.class].empty? end true end @@ -98,14 +97,14 @@ module FelFlame # Export all data into a JSON String which can then be saved into a file # TODO: This function is not yet complete # @return [String] A JSON formatted String - #def to_json() end + # def to_json() end - class <<self + class << self # Makes component managers behave like arrays with additional # methods for managing the array # @!visibility private def respond_to_missing?(method, *) - if self._data.respond_to? method + if _data.respond_to? method true else super @@ -116,8 +115,8 @@ module FelFlame # methods for managing the array # @!visibility private def method_missing(method, *args, **kwargs, &block) - if self._data.respond_to? method - self._data.send(method, *args, **kwargs, &block) + if _data.respond_to? method + _data.send(method, *args, **kwargs, &block) else super end @@ -129,7 +128,6 @@ module FelFlame # @!visibility private def component_redirect if @component_redirect - @component_redirect else @component_redirect = Object.new @component_redirect.instance_variable_set(:@entity, nil) @@ -140,14 +138,12 @@ module FelFlame instance_variable_set(:@entity, value) end @component_redirect.define_singleton_method(:[]) do |component_manager| - self.entity.component(component_manager) + entity.component(component_manager) end - @component_redirect end + @component_redirect end - - # @return [Array<Entity>] Array of all Entities that exist # @!visibility private def _data @@ -158,7 +154,7 @@ module FelFlame # TODO: This function is not yet complete # @param json_string [String] A string that was exported originally using the {FelFlame::Entities#to_json to_json} function # @param opts [Keywords] What values(its {FelFlame::Entities#id ID} or the {FelFlame::ComponentManager#id component IDs}) should be overwritten TODO: this might change - #def from_json(json_string, **opts) end + # def from_json(json_string, **opts) end end end end diff --git a/lib/felflame/order.rb b/lib/felflame/order.rb new file mode 100644 index 0000000..0bed66b --- /dev/null +++ b/lib/felflame/order.rb @@ -0,0 +1,6 @@ +module FelFlame + module Order + def sort(*sortables) + end + end +end diff --git a/lib/felflame/scene_manager.rb b/lib/felflame/scene_manager.rb index 9ac7924..0024815 100644 --- a/lib/felflame/scene_manager.rb +++ b/lib/felflame/scene_manager.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FelFlame class Scenes # Allows overwriting the storage of systems, such as for clearing. @@ -60,7 +62,7 @@ module FelFlame system.scenes.delete self end systems.clear - #FelFlame::Stage.update_systems_list if FelFlame::Stage.scenes.include? self + # FelFlame::Stage.update_systems_list if FelFlame::Stage.scenes.include? self true end end diff --git a/lib/felflame/stage_manager.rb b/lib/felflame/stage_manager.rb index 50dad5f..a192b67 100644 --- a/lib/felflame/stage_manager.rb +++ b/lib/felflame/stage_manager.rb @@ -1,6 +1,8 @@ +# frozen_string_literal: true + module FelFlame module Stage - class <<self + class << self # Allows clearing of scenes and systems. # Used internally by FelFlame and shouldn't need to be ever used by developers # @!visibility private @@ -28,7 +30,7 @@ module FelFlame true end - # Executes one frame of the game. This executes all the Systems in the Scenes added to the Stage. Systems that exist in two or more different Scenes will still only get executed once. + # Executes one frame of the game. This executes all the Scenes added to the Stage in order of their priority. # @return [Boolean] +true+ def call self.scenes.each(&:call) diff --git a/lib/felflame/system_manager.rb b/lib/felflame/system_manager.rb index 480b84a..8982589 100644 --- a/lib/felflame/system_manager.rb +++ b/lib/felflame/system_manager.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module FelFlame class Systems # How early this System should be executed in a list of Systems @@ -43,7 +45,6 @@ module FelFlame @removal_triggers ||= [] end - # Stores references to systems that should be triggered when an # attribute from this manager is changed # Do not edit this hash as it is managed by FelFlame automatically. @@ -52,8 +53,7 @@ module FelFlame @attr_triggers ||= {} end - class <<self - + class << self # Stores the systems in {FelFlame::Components}. This # is needed because calling `FelFlame::Components.constants` # will not let you iterate over the value of the constants @@ -68,8 +68,8 @@ module FelFlame # Used internally by FelFlame # @!visibility private def update_const_cache - @const_cache = self.constants.map do |constant| - self.const_get constant + @const_cache = constants.map do |constant| + const_get constant end end @@ -95,7 +95,6 @@ module FelFlame super end end - end # Creates a new System which can be accessed as a constant under the namespace {FelFlame::Systems}. @@ -125,6 +124,7 @@ module FelFlame def call @block.call end + # Redefine what code is executed by this System when it is called upon. # @param block [Proc] The code you wish to be executed when the system is triggered. Can be defined by using a +do end+ block or using +{ }+ braces. def redefine(&block) @@ -155,16 +155,16 @@ module FelFlame # @param component_or_manager [Component or ComponentManager] The object to clear triggers from. Use Nil to clear triggers from all components associated with this system. # @return [Boolean] +true+ def clear_triggers(*trigger_types, component_or_manager: nil) - trigger_types = [:addition_triggers, :removal_triggers, :attr_triggers] if trigger_types.empty? + trigger_types = %i[addition_triggers removal_triggers attr_triggers] if trigger_types.empty? if trigger_types.include? :attr_triggers - if (trigger_types - [:addition_triggers, - :removal_triggers, - :attr_triggers]).empty? + if (trigger_types - %i[addition_triggers + removal_triggers + attr_triggers]).empty? if component_or_manager.nil? - #remove all attrs - self.attr_triggers.each do |cmp_or_mgr, attrs| + # remove all attrs + attr_triggers.each do |cmp_or_mgr, attrs| attrs.each do |attr| next if cmp_or_mgr.attr_triggers[attr].nil? @@ -173,49 +173,48 @@ module FelFlame self.attr_triggers = {} end else - #remove attrs relevant to comp_or_man - unless self.attr_triggers[component_or_manager].nil? - self.attr_triggers[component_or_manager].each do |attr| + # remove attrs relevant to comp_or_man + unless attr_triggers[component_or_manager].nil? + attr_triggers[component_or_manager].each do |attr| component_or_manager.attr_triggers[attr].delete self end - self.attr_triggers[component_or_manager] = [] + attr_triggers[component_or_manager] = [] end end - else + elsif component_or_manager.nil? - if component_or_manager.nil? - (trigger_types - [:addition_triggers, :removal_triggers, :attr_triggers]).each do |attr| - #remove attr - self.attr_triggers.each do |cmp_or_mgr, attrs| - cmp_or_mgr.attr_triggers[attr].delete self - end - end - self.attr_triggers.delete (trigger_types - [:addition_triggers, - :removal_triggers, - :attr_triggers]) - else - #remove attr from component_or_manager - (trigger_types - [:addition_triggers, :removal_triggers, :attr_triggers]).each do |attr| - next if component_or_manager.attr_triggers[attr].nil? - component_or_manager.attr_triggers[attr].delete self + (trigger_types - %i[addition_triggers removal_triggers attr_triggers]).each do |attr| + # remove attr + attr_triggers.each do |cmp_or_mgr, _attrs| + cmp_or_mgr.attr_triggers[attr].delete self end - self.attr_triggers[component_or_manager] -= trigger_types unless self.attr_triggers[component_or_manager].nil? end + attr_triggers.delete(trigger_types - %i[addition_triggers + removal_triggers + attr_triggers]) + else + # remove attr from component_or_manager + (trigger_types - %i[addition_triggers removal_triggers attr_triggers]).each do |attr| + next if component_or_manager.attr_triggers[attr].nil? + + component_or_manager.attr_triggers[attr].delete self + end + attr_triggers[component_or_manager] -= trigger_types unless attr_triggers[component_or_manager].nil? end end - (trigger_types & [:removal_triggers, :addition_triggers] - [:attr_triggers]).each do |trigger_type| + (trigger_types & %i[removal_triggers addition_triggers] - [:attr_triggers]).each do |trigger_type| if component_or_manager.nil? - #remove all removal triggers - self.send(trigger_type).each do |trigger| + # remove all removal triggers + send(trigger_type).each do |trigger| trigger.send(trigger_type).delete self end - self.send("#{trigger_type.to_s}=", []) + send("#{trigger_type}=", []) else - #remove removal trigger relevant to comp/man - self.send(trigger_type).delete component_or_manager + # remove removal trigger relevant to comp/man + send(trigger_type).delete component_or_manager component_or_manager.send(trigger_type).delete self end end @@ -248,10 +247,10 @@ module FelFlame else component_or_manager.attr_triggers[attr] |= [self] end - if self.attr_triggers[component_or_manager].nil? - self.attr_triggers[component_or_manager] = [attr] + if attr_triggers[component_or_manager].nil? + attr_triggers[component_or_manager] = [attr] else - self.attr_triggers[component_or_manager] |= [attr] + attr_triggers[component_or_manager] |= [attr] end true end diff --git a/lib/felflame/version.rb b/lib/felflame/version.rb index 882774f..b200c26 100644 --- a/lib/felflame/version.rb +++ b/lib/felflame/version.rb @@ -4,6 +4,6 @@ # Keeps the version of the Gem module Felflame # The version of the Gem - VERSION = "3.0.0" + VERSION = '3.0.0' end # :nocov: diff --git a/spec/component_manager_spec.rb b/spec/component_manager_spec.rb index f6f1398..9bf9b9e 100644 --- a/spec/component_manager_spec.rb +++ b/spec/component_manager_spec.rb @@ -1,10 +1,11 @@ -require_relative '../lib/felflame.rb' +# frozen_string_literal: true -describe 'Components' do +require_relative '../lib/felflame' - #let :component_manager do +describe 'Components' do + # let :component_manager do # @component_manager ||= FelFlame::Components.new('TestComponents', :param1, param2: 'def') - #end + # end before :all do @component_manager ||= FelFlame::Components.new('TestComponents', :param1, param2: 'def') @@ -43,7 +44,7 @@ describe 'Components' do expect(@component_manager.respond_to?(:[])).to be true expect(@component_manager.respond_to?(:each)).to be true @component_manager.each do |component| - expect(component.respond_to? :param1).to be true + expect(component.respond_to?(:param1)).to be true end expect(@component_manager.respond_to?(:filter)).to be true expect(@component_manager.respond_to?(:first)).to be true @@ -59,7 +60,7 @@ describe 'Components' do expect(FelFlame::Components.respond_to?(:[])).to be true expect(FelFlame::Components.respond_to?(:each)).to be true FelFlame::Components.each do |component_manager| - expect(component_manager.respond_to? :addition_triggers).to be true + expect(component_manager.respond_to?(:addition_triggers)).to be true end expect(FelFlame::Components.respond_to?(:filter)).to be true expect(FelFlame::Components.respond_to?(:first)).to be true @@ -72,13 +73,13 @@ describe 'Components' do end it 'can delete a component' do - #component_id = @cmp1.id + # component_id = @cmp1.id @ent0.add @cmp1 length = @component_manager.length expect(@cmp1.delete).to be true - expect(@component_manager.length).to eq(length-1) - #expect(@cmp1.id).to be_nil - #expect(@component_manager[component_id]).to be_nil + expect(@component_manager.length).to eq(length - 1) + # expect(@cmp1.id).to be_nil + # expect(@component_manager[component_id]).to be_nil expect(@cmp1.entities).to eq([]) end @@ -97,7 +98,6 @@ describe 'Components' do expect(@cmp3.to_h).to eq(param1: 'ok', param2: 10) end - it 'sets default params correctly' do expect(@cmp0.param1).to be_nil expect(@cmp0.param2).to eq('def') @@ -124,9 +124,9 @@ describe 'Components' do end it 'can be accessed' do - expect(@component_manager[0].respond_to? :param1).to eq(true) - expect(@component_manager[1].respond_to? :param1).to eq(true) - expect(@component_manager[2].respond_to? :param1).to eq(true) + expect(@component_manager[0].respond_to?(:param1)).to eq(true) + expect(@component_manager[1].respond_to?(:param1)).to eq(true) + expect(@component_manager[2].respond_to?(:param1)).to eq(true) end it 'cant overwrite exiting component managers' do @@ -135,7 +135,7 @@ describe 'Components' do end it 'can\'t create an attribute when its name is an existing method' do - #expect { FelFlame::Components.new('TestComponent2', :id) }.to raise_error(NameError) + # expect { FelFlame::Components.new('TestComponent2', :id) }.to raise_error(NameError) expect { FelFlame::Components.new('TestComponent2', :addition_triggers) }.to raise_error(NameError) expect { FelFlame::Components.new('TestComponent2', :removal_triggers) }.to raise_error(NameError) expect { FelFlame::Components.new('TestComponent2', :attr_triggers) }.to raise_error(NameError) diff --git a/spec/entity_manager_spec.rb b/spec/entity_manager_spec.rb index 0a18495..2068986 100644 --- a/spec/entity_manager_spec.rb +++ b/spec/entity_manager_spec.rb @@ -1,15 +1,15 @@ -require_relative '../lib/felflame.rb' +# frozen_string_literal: true -#class EntitiesTest < Minitest::Test +require_relative '../lib/felflame' -describe 'Entities' do +# class EntitiesTest < Minitest::Test +describe 'Entities' do before :all do $VERBOSE = nil @component_manager ||= FelFlame::Components.new('TestEntity', :param1, param2: 'def') end - before :each do @orig_stderr = $stderr $stderr = StringIO.new @@ -42,13 +42,11 @@ describe 'Entities' do expect { @ent0.component[@component_manager] }.to raise_error(RuntimeError) end - - it 'responds to array methods' do expect(FelFlame::Entities.respond_to?(:[])).to be true expect(FelFlame::Entities.respond_to?(:each)).to be true FelFlame::Entities.each do |entity| - expect(entity.respond_to? :components).to be true + expect(entity.respond_to?(:components)).to be true end expect(FelFlame::Entities.respond_to?(:filter)).to be true expect(FelFlame::Entities.respond_to?(:first)).to be true @@ -60,16 +58,15 @@ describe 'Entities' do expect { FelFlame::Entities.somethingwrong }.to raise_error(NoMethodError) end - it 'won\'t add duplicate entities' do @ent0.add @cmp0, @cmp0, @cmp1, @cmp1 expect(@ent0.components[@component_manager].count).to eq(2) end it 'can be accessed' do - expect(FelFlame::Entities[0].respond_to? :components).to eq(true) - expect(FelFlame::Entities[1].respond_to? :components).to eq(true) - expect(FelFlame::Entities[2].respond_to? :components).to eq(true) + expect(FelFlame::Entities[0].respond_to?(:components)).to eq(true) + expect(FelFlame::Entities[1].respond_to?(:components)).to eq(true) + expect(FelFlame::Entities[2].respond_to?(:components)).to eq(true) end it 'can have components attached' do @@ -84,7 +81,7 @@ describe 'Entities' do it 'can have components removed' do @ent0.add @cmp0 - expect(@ent0.remove @cmp0).to be true + expect(@ent0.remove(@cmp0)).to be true expect(@cmp0.entities.empty?).to be true expect(@ent0.components[@component_manager].nil?).to be true @ent0.add @cmp0 @@ -96,16 +93,16 @@ describe 'Entities' do @ent0.add @cmp0, @cmp1, @cmp2 @ent1.add @cmp0, @cmp1 @ent2.add @cmp1, @cmp2 - expect(@ent0.components).to eq({@component_manager => [@cmp0,@cmp1,@cmp2]}) - expect(@cmp0.entities).to eq([@ent0,@ent1]) - expect(@cmp1.entities).to eq([@ent0,@ent1,@ent2]) - expect(@cmp2.entities).to eq([@ent0,@ent2]) + expect(@ent0.components).to eq({ @component_manager => [@cmp0, @cmp1, @cmp2] }) + expect(@cmp0.entities).to eq([@ent0, @ent1]) + expect(@cmp1.entities).to eq([@ent0, @ent1, @ent2]) + expect(@cmp2.entities).to eq([@ent0, @ent2]) @ent1.delete expect(@cmp0.entities).to eq([@ent0]) - expect(@cmp1.entities).to eq([@ent0,@ent2]) - expect(@cmp2.entities).to eq([@ent0,@ent2]) + expect(@cmp1.entities).to eq([@ent0, @ent2]) + expect(@cmp2.entities).to eq([@ent0, @ent2]) @cmp1.delete - expect(@ent0.components).to eq({@component_manager => [@cmp0,@cmp2]}) + expect(@ent0.components).to eq({ @component_manager => [@cmp0, @cmp2] }) @component_manager.reverse_each(&:delete) expect(@component_manager.length).to eq(0) expect(@component_manager.empty?).to be true diff --git a/spec/scene_manager_spec.rb b/spec/scene_manager_spec.rb index 3f305b9..e1984dc 100644 --- a/spec/scene_manager_spec.rb +++ b/spec/scene_manager_spec.rb @@ -1,6 +1,8 @@ -require_relative '../lib/felflame.rb' +# frozen_string_literal: true -#class EntitiesTest < Minitest::Test +require_relative '../lib/felflame' + +# class EntitiesTest < Minitest::Test describe 'Scenes' do before :all do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0d826a1..797ff0f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This file was generated by the `rspec --init` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause @@ -20,15 +22,15 @@ RSpec.configure do |config| SimpleCov.start do add_filter 'spec' add_filter 'deprecated' - add_group "Ignored Code" do |src_file| + add_group 'Ignored Code' do |src_file| open(src_file.filename).grep(/:nocov:/).any? end SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new([ - SimpleCov::Formatter::Console, - SimpleCov::Formatter::HTMLFormatter, - SimpleCov::Formatter::JSONFormatter - #SimpleCovSmallBadge::Formatter - ]) + SimpleCov::Formatter::Console, + SimpleCov::Formatter::HTMLFormatter, + SimpleCov::Formatter::JSONFormatter + # SimpleCovSmallBadge::Formatter + ]) end # rspec-expectations config goes here. You can use an alternate # assertion/expectation library such as wrong or the stdlib/minitest @@ -62,55 +64,53 @@ RSpec.configure do |config| # The settings below are suggested to provide a good initial experience # with RSpec, but feel free to customize to your heart's content. -=begin - # This allows you to limit a spec run to individual examples or groups - # you care about by tagging them with `:focus` metadata. When nothing - # is tagged with `:focus`, all examples get run. RSpec also provides - # aliases for `it`, `describe`, and `context` that include `:focus` - # metadata: `fit`, `fdescribe` and `fcontext`, respectively. - config.filter_run_when_matching :focus - - # Allows RSpec to persist some state between runs in order to support - # the `--only-failures` and `--next-failure` CLI options. We recommend - # you configure your source control system to ignore this file. - config.example_status_persistence_file_path = "spec/examples.txt" - - # Limits the available syntax to the non-monkey patched syntax that is - # recommended. For more details, see: - # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ - # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ - # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode - config.disable_monkey_patching! - - # This setting enables warnings. It's recommended, but in some cases may - # be too noisy due to issues in dependencies. - config.warnings = true - - # Many RSpec users commonly either run the entire suite or an individual - # file, and it's useful to allow more verbose output when running an - # individual spec file. - if config.files_to_run.one? - # Use the documentation formatter for detailed output, - # unless a formatter has already been configured - # (e.g. via a command-line flag). - config.default_formatter = "doc" - end - - # Print the 10 slowest examples and example groups at the - # end of the spec run, to help surface which specs are running - # particularly slow. - config.profile_examples = 10 - - # Run specs in random order to surface order dependencies. If you find an - # order dependency and want to debug it, you can fix the order by providing - # the seed, which is printed after each run. - # --seed 1234 - config.order = :random - - # Seed global randomization in this process using the `--seed` CLI option. - # Setting this allows you to use `--seed` to deterministically reproduce - # test failures related to randomization by passing the same `--seed` value - # as the one that triggered the failure. - Kernel.srand config.seed -=end + # # This allows you to limit a spec run to individual examples or groups + # # you care about by tagging them with `:focus` metadata. When nothing + # # is tagged with `:focus`, all examples get run. RSpec also provides + # # aliases for `it`, `describe`, and `context` that include `:focus` + # # metadata: `fit`, `fdescribe` and `fcontext`, respectively. + # config.filter_run_when_matching :focus + # + # # Allows RSpec to persist some state between runs in order to support + # # the `--only-failures` and `--next-failure` CLI options. We recommend + # # you configure your source control system to ignore this file. + # config.example_status_persistence_file_path = "spec/examples.txt" + # + # # Limits the available syntax to the non-monkey patched syntax that is + # # recommended. For more details, see: + # # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ + # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + # # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode + # config.disable_monkey_patching! + # + # # This setting enables warnings. It's recommended, but in some cases may + # # be too noisy due to issues in dependencies. + # config.warnings = true + # + # # Many RSpec users commonly either run the entire suite or an individual + # # file, and it's useful to allow more verbose output when running an + # # individual spec file. + # if config.files_to_run.one? + # # Use the documentation formatter for detailed output, + # # unless a formatter has already been configured + # # (e.g. via a command-line flag). + # config.default_formatter = "doc" + # end + # + # # Print the 10 slowest examples and example groups at the + # # end of the spec run, to help surface which specs are running + # # particularly slow. + # config.profile_examples = 10 + # + # # Run specs in random order to surface order dependencies. If you find an + # # order dependency and want to debug it, you can fix the order by providing + # # the seed, which is printed after each run. + # # --seed 1234 + # config.order = :random + # + # # Seed global randomization in this process using the `--seed` CLI option. + # # Setting this allows you to use `--seed` to deterministically reproduce + # # test failures related to randomization by passing the same `--seed` value + # # as the one that triggered the failure. + # Kernel.srand config.seed end diff --git a/spec/stage_manager_spec.rb b/spec/stage_manager_spec.rb index b8fc70c..16f9080 100644 --- a/spec/stage_manager_spec.rb +++ b/spec/stage_manager_spec.rb @@ -1,10 +1,12 @@ -require_relative '../lib/felflame.rb' +# frozen_string_literal: true -#class EntitiesTest < Minitest::Test +require_relative '../lib/felflame' + +# class EntitiesTest < Minitest::Test describe 'Stage' do before :all do - @component_manager ||= FelFlame::Components.new('TestStage', order: Array.new) + @component_manager ||= FelFlame::Components.new('TestStage', order: []) @system2 = FelFlame::Systems.new('StageTest', priority: 1) do @component_manager.first.order.push 2 end @@ -58,7 +60,6 @@ describe 'Stage' do @scene2.add @system2 @scene3.add @system3 FelFlame::Stage.call - expect(@component_manager.first.order).to eq([1,2,3]) + expect(@component_manager.first.order).to eq([1, 2, 3]) end - end diff --git a/spec/system_manager_spec.rb b/spec/system_manager_spec.rb index f15ebaa..b7177af 100644 --- a/spec/system_manager_spec.rb +++ b/spec/system_manager_spec.rb @@ -1,7 +1,8 @@ -require_relative '../lib/felflame.rb' +# frozen_string_literal: true -describe 'Systems' do +require_relative '../lib/felflame' +describe 'Systems' do before :all do @component_manager ||= FelFlame::Components.new('TestSystems', health: 10, whatever: 'imp', mana: 10) @@testitr = 999 @@ -41,7 +42,7 @@ describe 'Systems' do expect(FelFlame::Systems.respond_to?(:[])).to be true expect(FelFlame::Systems.respond_to?(:each)).to be true FelFlame::Systems.each do |system| - expect(system.respond_to? :call).to be true + expect(system.respond_to?(:call)).to be true end expect(FelFlame::Systems.respond_to?(:filter)).to be true expect(FelFlame::Systems.respond_to?(:first)).to be true @@ -231,11 +232,11 @@ describe 'Systems' do @entity1 = FelFlame::Entities.new @system.trigger_when_is_changed @cmp0, :whatever @system.trigger_when_is_changed @cmp0, :mana - #expect(@system.attr_triggers).to eq({@cmp0 => [:name, :mana]}) - #expect(@cmp0.attr_triggers).to eq({:name => [@system], :mana => [@system]}) + # expect(@system.attr_triggers).to eq({@cmp0 => [:name, :mana]}) + # expect(@cmp0.attr_triggers).to eq({:name => [@system], :mana => [@system]}) @system.clear_triggers :attr_triggers, :whatever, component_or_manager: @cmp0 - #expect(@system.attr_triggers).to eq({@cmp0 => [:mana]}) - #expect(@cmp0.attr_triggers).to eq({:name => [], :mana => [@system]}) + # expect(@system.attr_triggers).to eq({@cmp0 => [:mana]}) + # expect(@cmp0.attr_triggers).to eq({:name => [], :mana => [@system]}) expect(@cmp0.health).to eq(10) expect(@cmp1.health).to eq(20) @cmp0.whatever = 'something' |
