* fix: spellbooks can have infinite charges * refactor: indicate infinite spellbook charges with null Not sure if I like this much better...
39 lines
1.3 KiB
C#
39 lines
1.3 KiB
C#
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Shared.Magic.Components;
|
|
|
|
/// <summary>
|
|
/// Spellbooks can grant one or more spells to the user. If marked as <see cref="LearnPermanently"/> it will teach
|
|
/// the performer the spells and wipe the book.
|
|
/// Default behavior requires the book to be held in hand
|
|
/// </summary>
|
|
[RegisterComponent, Access(typeof(SpellbookSystem))]
|
|
public sealed partial class SpellbookComponent : Component
|
|
{
|
|
/// <summary>
|
|
/// List of spells that this book has. This is a combination of the WorldSpells, EntitySpells, and InstantSpells.
|
|
/// </summary>
|
|
[ViewVariables]
|
|
public readonly List<EntityUid> Spells = new();
|
|
|
|
// The three fields below are just used for initialization.
|
|
/// <summary>
|
|
/// Dictionary of spell prototypes to charge counts.
|
|
/// If the charge count is null, it means the spell has infinite charges.
|
|
/// </summary>
|
|
[DataField]
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
|
public Dictionary<EntProtoId, int?> SpellActions = new();
|
|
|
|
[DataField]
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
|
public float LearnTime = .75f;
|
|
|
|
/// <summary>
|
|
/// If true, the spell action stays even after the book is removed
|
|
/// </summary>
|
|
[DataField]
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
|
public bool LearnPermanently;
|
|
}
|