mirror of
https://github.com/cyberarm/i-mic-rts.git
synced 2025-12-15 15:52:34 +00:00
Extracted movement and turret into 'components' that entity get add to its self when defined
This commit is contained in:
23
lib/component.rb
Normal file
23
lib/component.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
class IMICRTS
|
||||
class Component
|
||||
@@components = {}
|
||||
|
||||
def self.get(name)
|
||||
@@components.dig(name)
|
||||
end
|
||||
|
||||
def self.inherited(klass)
|
||||
name = klass.to_s.split("::").last.downcase.to_sym
|
||||
|
||||
if get(name)
|
||||
raise "#{klass.inspect} is already defined!"
|
||||
else
|
||||
@@components[name] = klass
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Dir.glob("#{IMICRTS::GAME_ROOT_PATH}/lib/components/**/*.rb").each do |component|
|
||||
require_relative component
|
||||
end
|
||||
Reference in New Issue
Block a user