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:
37
lib/event_handler.rb
Normal file
37
lib/event_handler.rb
Normal file
@@ -0,0 +1,37 @@
|
||||
class IMICFPS
|
||||
class EventHandler
|
||||
@@handlers = {}
|
||||
|
||||
def self.inherited(subclass)
|
||||
@@handlers["__pending"] ||= []
|
||||
|
||||
@@handlers["__pending"] << subclass
|
||||
end
|
||||
|
||||
def self.initiate
|
||||
@@handlers["__pending"].each do |handler|
|
||||
instance = handler.new
|
||||
instance.handles.each do |event|
|
||||
@@handlers[event] = instance
|
||||
end
|
||||
end
|
||||
|
||||
@@handlers.delete("__pending")
|
||||
end
|
||||
|
||||
def self.get(event)
|
||||
@@handlers.dig(event)
|
||||
end
|
||||
|
||||
def initialize
|
||||
end
|
||||
|
||||
def handlers
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
def handle(subscriber, context, *args)
|
||||
raise NotImplementedError
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user