Compare commits
1 Commits
welcoming-
...
SpellStora
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
544a260f4b |
@@ -25,4 +25,28 @@ public sealed partial class CP14SpellStorageComponent : Component
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public bool CanUseCasterMana = true;
|
||||
|
||||
/// <summary>
|
||||
/// Maximum number of spells in storage.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public int MaxSpellsCount = 1;
|
||||
|
||||
/// <summary>
|
||||
/// allows you to getting spells from another storage.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public bool AllowSpellsGetting = false;
|
||||
|
||||
/// <summary>
|
||||
/// allows you to transfer spells to another storage. It won't work if AllowSpellsGetting is True.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public bool AllowSpellsTransfering = false;
|
||||
|
||||
/// <summary>
|
||||
/// It work if AllowSpellsTransfering is True. Delete storage entity after interact.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public bool DeleteStorageAfterInteract = false;
|
||||
}
|
||||
|
||||
@@ -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<CP14SpellStorageAccessWearingComponent, ClothingGotUnequippedEvent>(OnClothingUnequipped);
|
||||
|
||||
SubscribeLocalEvent<CP14SpellStorageRequireAttuneComponent, RemovedAttuneFromMindEvent>(OnRemovedAttune);
|
||||
SubscribeLocalEvent<CP14SpellStorageComponent, AfterInteractEvent>(OnInteract);
|
||||
}
|
||||
|
||||
private void OnSpellUsed(Entity<CP14SpellStorageUseDamageComponent> 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<CP14MagicEffectComponent>(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<CP14SpellStorageComponent> 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<CP14SpellStorageComponent>(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<CP14SpellStorageComponent>(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<CP14SpellStorageAccessHoldingComponent> ent, ref GotEquippedHandEvent args)
|
||||
{
|
||||
if (!TryComp<CP14SpellStorageComponent>(ent, out var spellStorage))
|
||||
@@ -131,6 +161,22 @@ public sealed partial class CP14SpellStorageSystem : EntitySystem
|
||||
_actions.RemoveProvidedActions(args.Wearer, ent);
|
||||
}
|
||||
|
||||
private bool TryAddNewSpellEntity(Entity<CP14SpellStorageComponent> 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<CP14MagicEffectComponent>(spellEnt.Value);
|
||||
provided.SpellStorage = mStorage;
|
||||
|
||||
mStorage.Comp.SpellEntities.Add(spellEnt.Value);
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool TryGrantAccess(Entity<CP14SpellStorageComponent> storage, EntityUid user)
|
||||
{
|
||||
if (!_mind.TryGetMind(user, out var mindId, out var mind))
|
||||
|
||||
@@ -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.
|
||||
@@ -0,0 +1,2 @@
|
||||
cp14-spells-storage-cant-transfer = Нельзя переместить заклинания из данного предмета.
|
||||
cp14-spells-storage-cant-get-spells = Этот предмет не может принять новые заклинания.
|
||||
@@ -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
|
||||
maxEnergy: 80
|
||||
|
||||
Reference in New Issue
Block a user