diff options
| author | realtradam <[email protected]> | 2021-05-20 05:04:21 -0400 |
|---|---|---|
| committer | realtradam <[email protected]> | 2021-05-20 05:04:21 -0400 |
| commit | f97a9ca95e464e728bba9337b579bc380c33bc7d (patch) | |
| tree | dd45a6e615e6e873cee15cb41daaca24b3357ea6 /app/ECS/base_component.rb | |
| parent | fee80f42f0889f2d484e25f4366f14b68c65ba70 (diff) | |
| download | typemon-code-f97a9ca95e464e728bba9337b579bc380c33bc7d.tar.gz typemon-code-f97a9ca95e464e728bba9337b579bc380c33bc7d.zip | |
implemented hitboxes
Diffstat (limited to 'app/ECS/base_component.rb')
| -rw-r--r-- | app/ECS/base_component.rb | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/app/ECS/base_component.rb b/app/ECS/base_component.rb deleted file mode 100644 index f32322b..0000000 --- a/app/ECS/base_component.rb +++ /dev/null @@ -1,46 +0,0 @@ -class BaseComponent - class <<self - def id - @id ||= ID.send(ComponentHelper.underscore(ancestors[0].name.split('::').last)) - end - - def data - @data ||= {} - end - - def add(entity_id) - data[entity_id] = new - end - - def delete(entity_id) - data.delete entity_id - 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 |
