* global demi refactor * rebalance, smaller demiplanes * remove outdated connections * audio design + room coords fix * Update CP14Rooms.cs * Update wastelands.yml * hotfixes * Update CP14SpellThrowFromUser.cs * Update sky_lightning.yml
42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using System.Numerics;
|
|
using Content.Shared.Projectiles;
|
|
using Content.Shared.Throwing;
|
|
|
|
namespace Content.Shared._CP14.MagicSpell.Spells;
|
|
|
|
public sealed partial class CP14SpellThrowFromUser : CP14SpellEffect
|
|
{
|
|
[DataField]
|
|
public float ThrowPower = 10f;
|
|
|
|
[DataField]
|
|
public float Distance = 2.5f;
|
|
|
|
public override void Effect(EntityManager entManager, CP14SpellEffectBaseArgs args)
|
|
{
|
|
if (args.Target is null || args.User is null)
|
|
return;
|
|
|
|
var targetEntity = args.Target.Value;
|
|
|
|
var throwing = entManager.System<ThrowingSystem>();
|
|
var xform = entManager.System<SharedTransformSystem>();
|
|
|
|
var worldPos = xform.GetWorldPosition(args.User.Value);
|
|
var dir = xform.GetWorldPosition(args.Target.Value) - worldPos;
|
|
if (dir == Vector2.Zero)
|
|
return;
|
|
|
|
var foo = Vector2.Normalize(dir);
|
|
|
|
if (entManager.TryGetComponent<EmbeddableProjectileComponent>(targetEntity, out var embeddable))
|
|
{
|
|
var projectile = entManager.System<SharedProjectileSystem>();
|
|
|
|
projectile.EmbedDetach(targetEntity, embeddable);
|
|
}
|
|
|
|
throwing.TryThrow(targetEntity, foo * Distance, ThrowPower, args.User, doSpin: true);
|
|
}
|
|
}
|