mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 23:52:35 +00:00
Implemented event system, Implemented initial bit of scripting system, Stubbed component system. Entities can now use the scripting system to place their 'decorations'
This commit is contained in:
40
lib/component.rb
Normal file
40
lib/component.rb
Normal file
@@ -0,0 +1,40 @@
|
||||
class IMICFPS
|
||||
class Component
|
||||
COMPONENTS = {}
|
||||
|
||||
def self.get(name)
|
||||
COMPONENTS.dig(name)
|
||||
end
|
||||
|
||||
def self.inherited(subclass)
|
||||
pp subclass
|
||||
COMPONENTS["__pending"] ||= []
|
||||
COMPONENTS["__pending"] << subclass
|
||||
end
|
||||
|
||||
def self.initiate
|
||||
COMPONENTS["__pending"].each do |klass|
|
||||
component = klass.new
|
||||
COMPONENTS[component.name] = component
|
||||
end
|
||||
|
||||
COMPONENTS.delete("__pending")
|
||||
end
|
||||
|
||||
def initialize
|
||||
setup
|
||||
end
|
||||
|
||||
def name
|
||||
string = self.class.name.split("::").last
|
||||
split = string.scan(/[A-Z][a-z]*/)
|
||||
|
||||
component_name = "#{split.map { |s| s.downcase }.join("_")}".to_sym
|
||||
|
||||
return component_name
|
||||
end
|
||||
|
||||
def setup
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user