Files
crystall-punk-14/Content.Shared/_CP14/MagicSpell/Spells/CP14SpellSpawnEntitiesOnTargetInRadius.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

35 lines
1.1 KiB
C#

using Robust.Shared.Map;
using Robust.Shared.Prototypes;
namespace Content.Shared._CP14.MagicSpell.Spells;
public sealed partial class CP14SpellSpawnEntitiesOnTargetInRadius : CP14SpellEffect
{
[DataField]
public EntProtoId Spawn = new();
public override void Effect(EntityManager entManager, CP14SpellEffectBaseArgs args)
{
EntityCoordinates? targetPoint = null;
if (args.Position is not null)
targetPoint = args.Position.Value;
if (args.Target is not null && entManager.TryGetComponent<TransformComponent>(args.Target.Value, out var transformComponent))
targetPoint = transformComponent.Coordinates;
if (targetPoint is null)
return;
// Spawn in center
entManager.SpawnAtPosition(Spawn, targetPoint.Value);
//Spawn in other directions
for (var i = 0; i < 4; i++)
{
var direction = (DirectionFlag) (1 << i);
var coords = targetPoint.Value.Offset(direction.AsDir().ToVec());
entManager.PredictedSpawnAtPosition(Spawn, coords);
}
}
}