diff --git a/Content.Shared/_CP14/MagicSpellStorage/CP14SpellStorageComponent.cs b/Content.Shared/_CP14/MagicSpellStorage/CP14SpellStorageComponent.cs
index 971f50b4c8..05ac58c7a1 100644
--- a/Content.Shared/_CP14/MagicSpellStorage/CP14SpellStorageComponent.cs
+++ b/Content.Shared/_CP14/MagicSpellStorage/CP14SpellStorageComponent.cs
@@ -25,4 +25,28 @@ public sealed partial class CP14SpellStorageComponent : Component
///
[DataField]
public bool CanUseCasterMana = true;
+
+ ///
+ /// Maximum number of spells in storage.
+ ///
+ [DataField]
+ public int MaxSpellsCount = 1;
+
+ ///
+ /// allows you to getting spells from another storage.
+ ///
+ [DataField]
+ public bool AllowSpellsGetting = false;
+
+ ///
+ /// allows you to transfer spells to another storage. It won't work if AllowSpellsGetting is True.
+ ///
+ [DataField]
+ public bool AllowSpellsTransfering = false;
+
+ ///
+ /// It work if AllowSpellsTransfering is True. Delete storage entity after interact.
+ ///
+ [DataField]
+ public bool DeleteStorageAfterInteract = false;
}
diff --git a/Content.Shared/_CP14/MagicSpellStorage/CP14SpellStorageSystem.cs b/Content.Shared/_CP14/MagicSpellStorage/CP14SpellStorageSystem.cs
index dcf728ce37..0a3aac1cfd 100644
--- a/Content.Shared/_CP14/MagicSpellStorage/CP14SpellStorageSystem.cs
+++ b/Content.Shared/_CP14/MagicSpellStorage/CP14SpellStorageSystem.cs
@@ -5,9 +5,12 @@ using Content.Shared.Actions;
using Content.Shared.Clothing;
using Content.Shared.Clothing.Components;
using Content.Shared.Damage;
+using Content.Shared.Interaction;
+using Content.Shared.Popups;
using Content.Shared.Hands;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Mind;
+using Robust.Shared.Prototypes;
using Robust.Shared.Network;
namespace Content.Shared._CP14.MagicSpellStorage;
@@ -21,6 +24,7 @@ public sealed partial class CP14SpellStorageSystem : EntitySystem
[Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly SharedMindSystem _mind = default!;
[Dependency] private readonly CP14SharedMagicAttuningSystem _attuning = default!;
+ [Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly SharedHandsSystem _hands = default!;
[Dependency] private readonly INetManager _net = default!;
[Dependency] private readonly DamageableSystem _damageable = default!;
@@ -40,6 +44,7 @@ public sealed partial class CP14SpellStorageSystem : EntitySystem
SubscribeLocalEvent(OnClothingUnequipped);
SubscribeLocalEvent(OnRemovedAttune);
+ SubscribeLocalEvent(OnInteract);
}
private void OnSpellUsed(Entity ent, ref CP14SpellFromSpellStorageUsedEvent args)
@@ -57,14 +62,7 @@ public sealed partial class CP14SpellStorageSystem : EntitySystem
foreach (var spell in mStorage.Comp.Spells)
{
- var spellEnt = _actionContainer.AddAction(mStorage, spell);
- if (spellEnt is null)
- continue;
-
- var provided = EntityManager.EnsureComponent(spellEnt.Value);
- provided.SpellStorage = mStorage;
-
- mStorage.Comp.SpellEntities.Add(spellEnt.Value);
+ TryAddNewSpellEntity(mStorage, spell);
}
}
@@ -79,6 +77,38 @@ public sealed partial class CP14SpellStorageSystem : EntitySystem
}
}
+ private void OnInteract(Entity storage, ref AfterInteractEvent args)
+ {
+ if (_net.IsClient || args.Target is null)
+ return;
+
+ if (!storage.Comp.AllowSpellsTransfering || storage.Comp.AllowSpellsGetting)
+ {
+ _popup.PopupPredicted(Loc.GetString("cp14-spells-storage-cant-transfer"), args.Used, args.Used);
+ return;
+ }
+
+ if (!TryComp(args.Target, out var targetStorage))
+ return;
+
+ if (!targetStorage.AllowSpellsGetting)
+ {
+ _popup.PopupPredicted(Loc.GetString("cp14-spells-storage-cant-get-spells"), args.Target.Value, args.Used);
+ return;
+ }
+
+ var targetEnt = new Entity(args.Target.Value, targetStorage);
+
+ foreach (var spell in storage.Comp.Spells)
+ {
+ targetStorage.Spells.Add(spell);
+ TryAddNewSpellEntity(targetEnt, spell);
+ }
+
+ if (storage.Comp.DeleteStorageAfterInteract)
+ QueueDel(args.Used);
+ }
+
private void OnEquippedHand(Entity ent, ref GotEquippedHandEvent args)
{
if (!TryComp(ent, out var spellStorage))
@@ -131,6 +161,22 @@ public sealed partial class CP14SpellStorageSystem : EntitySystem
_actions.RemoveProvidedActions(args.Wearer, ent);
}
+ private bool TryAddNewSpellEntity(Entity mStorage, EntProtoId spell)
+ {
+ if (mStorage.Comp.SpellEntities.Count == mStorage.Comp.MaxSpellsCount)
+ return false;
+
+ var spellEnt = _actionContainer.AddAction(mStorage, spell);
+ if (spellEnt is null)
+ return false;
+
+ var provided = EntityManager.EnsureComponent(spellEnt.Value);
+ provided.SpellStorage = mStorage;
+
+ mStorage.Comp.SpellEntities.Add(spellEnt.Value);
+ return true;
+ }
+
private bool TryGrantAccess(Entity storage, EntityUid user)
{
if (!_mind.TryGetMind(user, out var mindId, out var mind))
diff --git a/Resources/Locale/en-US/_CP14/spells-storage/spells-storage.ftl b/Resources/Locale/en-US/_CP14/spells-storage/spells-storage.ftl
new file mode 100644
index 0000000000..d8da38ccd1
--- /dev/null
+++ b/Resources/Locale/en-US/_CP14/spells-storage/spells-storage.ftl
@@ -0,0 +1,2 @@
+cp14-spells-storage-cant-transfer = You can't transfer spells from this item.
+cp14-spells-storage-cant-get-spells = This item cannot get new spells.
diff --git a/Resources/Locale/ru-RU/_CP14/spells-storage/spells-storage.ftl b/Resources/Locale/ru-RU/_CP14/spells-storage/spells-storage.ftl
new file mode 100644
index 0000000000..0e0c772cc8
--- /dev/null
+++ b/Resources/Locale/ru-RU/_CP14/spells-storage/spells-storage.ftl
@@ -0,0 +1,2 @@
+cp14-spells-storage-cant-transfer = Нельзя переместить заклинания из данного предмета.
+cp14-spells-storage-cant-get-spells = Этот предмет не может принять новые заклинания.
diff --git a/Resources/Prototypes/_CP14/Entities/Objects/Weapons/Magic/twoHandedStaffs.yml b/Resources/Prototypes/_CP14/Entities/Objects/Weapons/Magic/twoHandedStaffs.yml
index 854406613b..561d95b2d3 100644
--- a/Resources/Prototypes/_CP14/Entities/Objects/Weapons/Magic/twoHandedStaffs.yml
+++ b/Resources/Prototypes/_CP14/Entities/Objects/Weapons/Magic/twoHandedStaffs.yml
@@ -23,7 +23,7 @@
- type: Wieldable
- type: IncreaseDamageOnWield
damage:
- types:
+ types:
Blunt: 6
- type: MeleeWeapon
angle: 100
@@ -42,6 +42,7 @@
- type: CP14MagicAttuningItem
- type: CP14SpellStorageAccessHolding
- type: CP14SpellStorage
+ maxSpellsCount: 4
spells:
- CP14ActionSpellCureWounds
- CP14ActionSpellCureBurn
@@ -53,4 +54,4 @@
- type: CP14MagicEnergyExaminable
- type: CP14MagicEnergyContainer
energy: 80
- maxEnergy: 80
\ No newline at end of file
+ maxEnergy: 80