separate potion and food consume delays

This commit is contained in:
thispixel
2016-02-02 11:10:44 +00:00
parent 9720574310
commit e7229e7f61
3 changed files with 12 additions and 5 deletions
+10 -3
View File
@@ -6,15 +6,22 @@ CONSUMABLES = {}
# The id of the food consumption animation.
CONSUME_ANIMATION_ID = 829
# Contains the different types of consumables
module ConsumableType
FOOD = 1
POTION = 2
end
# An item that can be consumed to produce a skill effect.
class Consumable
attr_reader :name, :id, :sound, :delay
attr_reader :name, :id, :sound, :delay, :type
def initialize(name, id, sound, delay)
def initialize(name, id, sound, delay, type)
@name = name.to_s.gsub(/_/, ' ')
@id = id
@sound = sound
@delay = delay
@type = type
end
def consume(_player)
@@ -55,7 +62,7 @@ class ConsumeAction < Action
end
def equals(other)
mob == other.mob
mob == other.mob && @consumable.type == other.consumable.type
end
end
+1 -1
View File
@@ -14,7 +14,7 @@ EAT_FOOD_SOUND = 317
class Food < Consumable
def initialize(name, id, restoration, replace, delay)
super(name, id, EAT_FOOD_SOUND, delay)
super(name, id, EAT_FOOD_SOUND, delay, ConsumableType::FOOD)
@restoration = restoration
@replace = replace
end
+1 -1
View File
@@ -21,7 +21,7 @@ end
class Potion < Consumable
def initialize(id, name, doses)
super(name, id, Constants::DRINK_POTION_SOUND, Constants::POTION_DELAY)
super(name, id, Constants::DRINK_POTION_SOUND, Constants::POTION_DELAY, ConsumableType::POTION)
@doses = doses
end