Wizard Item Recall Spell (#34411)

This commit is contained in:
ScarKy0
2025-02-08 22:56:08 +01:00
committed by GitHub
parent 1ef6e0bd57
commit bf6fd4d581
16 changed files with 376 additions and 20 deletions

View File

@@ -67,25 +67,7 @@ public abstract partial class SharedProjectileSystem : EntitySystem
return;
}
var xform = Transform(uid);
TryComp<PhysicsComponent>(uid, out var physics);
_physics.SetBodyType(uid, BodyType.Dynamic, body: physics, xform: xform);
_transform.AttachToGridOrMap(uid, xform);
component.EmbeddedIntoUid = null;
Dirty(uid, component);
// Reset whether the projectile has damaged anything if it successfully was removed
if (TryComp<ProjectileComponent>(uid, out var projectile))
{
projectile.Shooter = null;
projectile.Weapon = null;
projectile.ProjectileSpent = false;
}
// Land it just coz uhhh yeah
var landEv = new LandEvent(args.User, true);
RaiseLocalEvent(uid, ref landEv);
_physics.WakeBody(uid, body: physics);
UnEmbed(uid, component, args.User);
// try place it in the user's hand
_hands.TryPickupAnyHand(args.User, uid);
@@ -135,6 +117,38 @@ public abstract partial class SharedProjectileSystem : EntitySystem
Dirty(uid, component);
}
public void UnEmbed(EntityUid uid, EmbeddableProjectileComponent? component, EntityUid? user = null)
{
if (!Resolve(uid, ref component))
return;
var xform = Transform(uid);
TryComp<PhysicsComponent>(uid, out var physics);
_physics.SetBodyType(uid, BodyType.Dynamic, body: physics, xform: xform);
_transform.AttachToGridOrMap(uid, xform);
component.EmbeddedIntoUid = null;
Dirty(uid, component);
// Reset whether the projectile has damaged anything if it successfully was removed
if (TryComp<ProjectileComponent>(uid, out var projectile))
{
projectile.Shooter = null;
projectile.Weapon = null;
projectile.ProjectileSpent = false;
Dirty(uid, projectile);
}
if (user != null)
{
// Land it just coz uhhh yeah
var landEv = new LandEvent(user, true);
RaiseLocalEvent(uid, ref landEv);
}
_physics.WakeBody(uid, body: physics);
}
private void PreventCollision(EntityUid uid, ProjectileComponent component, ref PreventCollideEvent args)
{
if (component.IgnoreShooter && (args.OtherEntity == component.Shooter || args.OtherEntity == component.Weapon))