Files
crystall-punk-14/Content.Shared/_CP14/MagicSpell/Spells/CP14SpellSpawnInHandEntity.cs
Red 8d984b7670 Dash (#1445)
* dash basic logic + predict spell casts

* dash

* Update kick.yml

* Update CP14SharedMagicSystem.Checks.cs
2025-06-19 00:14:58 +03:00

32 lines
976 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.PredictedSpawnAtPosition(spawn, transformComponent.Coordinates);
if (!handSystem.TryPickupAnyHand(args.Target.Value, item) && DeleteIfCantPickup)
entManager.QueueDeleteEntity(item);
}
}
}