summaryrefslogtreecommitdiff
path: root/scripts/entities/items
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/entities/items')
-rw-r--r--scripts/entities/items/ConsumableItem.cs8
-rw-r--r--scripts/entities/items/HealingConsumable.cs3
2 files changed, 9 insertions, 2 deletions
diff --git a/scripts/entities/items/ConsumableItem.cs b/scripts/entities/items/ConsumableItem.cs
index 8c862da..82fab49 100644
--- a/scripts/entities/items/ConsumableItem.cs
+++ b/scripts/entities/items/ConsumableItem.cs
@@ -15,7 +15,7 @@ public abstract partial class ConsumableItem : Entity
/// </summary>
/// <param name="consumer"></param>
/// <returns></returns>
- public Action GetAction(Actor consumer)
+ public Action GetAction(Player consumer)
{
return new ItemAction(consumer, this);
}
@@ -28,4 +28,10 @@ public abstract partial class ConsumableItem : Entity
/// <param name="action">Ação gerada pelo item.</param>
/// <returns>Se a ação foi realizada ou não.</returns>
public abstract bool Activate(ItemAction action);
+
+ public void ConsumedBy(Player consumer) {
+ Inventory inventory = consumer.inventory;
+ inventory.RemoveItem(this);
+ QueueFree();
+ }
} \ No newline at end of file
diff --git a/scripts/entities/items/HealingConsumable.cs b/scripts/entities/items/HealingConsumable.cs
index 3d8df51..2104693 100644
--- a/scripts/entities/items/HealingConsumable.cs
+++ b/scripts/entities/items/HealingConsumable.cs
@@ -12,7 +12,7 @@ public partial class HealingConsumable : ConsumableItem
public override bool Activate(ItemAction action)
{
- Actor consumer = action.ThisActor;
+ Player consumer = (Player) action.ThisActor;
int intendedAmount = (int)(HealingPercentage / 100 * consumer.MaxHp);
int recovered = consumer.Heal(intendedAmount);
@@ -22,6 +22,7 @@ public partial class HealingConsumable : ConsumableItem
return false;
}
MessageLogData.Instance.AddMessage($"Você consome {DisplayName} e recupera {recovered} de HP");
+ ConsumedBy(consumer);
return true;
}
} \ No newline at end of file