Files
crystall-punk-14/Content.Shared/_CP14/MagicSpell/Spells/CP14SpellSpawnInHandEntity.cs
Ed 31c9485e3b Magic rings (#378)
* flame creation spell backend

* flame creation visuals

* flame creation spell visual

* tweak

* some tweaks

* ice dagger spell

* move spells to rings

* Update ring.yml

* fix server crash
2024-08-02 00:48:36 +03:00

32 lines
967 B
C#

using Content.Shared.Hands.EntitySystems;
using Robust.Shared.Prototypes;
namespace Content.Shared._CP14.MagicSpell.Spells;
public sealed partial class CP14SpellSpawnInHandEntity : CP14SpellEffect
{
[DataField]
public List<EntProtoId> Spawns = new();
[DataField]
public bool DeleteIfCantPickup = false;
public override void Effect(EntityManager entManager, CP14SpellEffectBaseArgs args)
{
if (args.Target is null)
return;
if (!entManager.TryGetComponent<TransformComponent>(args.Target.Value, out var transformComponent))
return;
var handSystem = entManager.System<SharedHandsSystem>();
foreach (var spawn in Spawns)
{
var item = entManager.SpawnAtPosition(spawn, transformComponent.Coordinates);
if (!handSystem.TryPickupAnyHand(args.Target.Value, item) && DeleteIfCantPickup)
entManager.QueueDeleteEntity(item);
}
}
}