summaryrefslogtreecommitdiff
path: root/scripts/Entities/Items/GrimoireConsumable.cs
blob: e5157a75226fc4f27d567be4a079be49f575ea5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using Godot;
using TheLegendOfGustav.Entities.Actions;
using TheLegendOfGustav.Entities.Actors;
using TheLegendOfGustav.Magic;
using TheLegendOfGustav.Map;

namespace TheLegendOfGustav.Entities.Items;

public partial class GrimoireConsumable(Vector2I initialPosition, MapData map, GrimoireConsumableDefinition definition) : ConsumableItem(initialPosition, map, definition)
{
	private SpellResource spell = definition.Spell;

	public override bool Activate(ItemAction action)
	{
		Player consumer = action.Player;

		consumer.SpellBook.LearnSpell(spell);

		ConsumedBy(consumer);
		return true;
	}
}