module AR::Game::Consumable 


  attr_accessor :on_consumed
  attr_accessor :description

  #...initialize them here
  def self.init ar_object 
    
    #add attr_serializeable properties here... 
    #if you do need them serialized on save
    #ar_object.attr_serializeable :prop1, :prop2, &block
  end

  def self.extended ar_object
    self.init ar_object

    ar_object.resolutions.push call_on_consumed_on_consumed
    
    #add to object's event subscriptions and resolutions here...

  end 

  def self.call_on_consumed_on_consumed
    AR::Events::Resolution.new event_class: AR::Events::ItemConsumed, as: "item" do |e|
      i = e.item
      c = e.consumer
      results = []
      results.push i.on_consumed.call c
      results.push (AR::Events::ObjectRemovedFromGame.new ar_object: i)
      results
    end
  end

end
