Files
tbd-station-14/Content.Server/Gatherable/GatherableSystem.Projectile.cs
Ed 225a05ecdb Nuke spaceshroom ore (#28110)
nuke spaceshroom ore
2024-05-18 12:17:46 -04:00

31 lines
923 B
C#

using Content.Server.Gatherable.Components;
using Content.Shared.Projectiles;
using Robust.Shared.Physics.Events;
namespace Content.Server.Gatherable;
public sealed partial class GatherableSystem
{
private void InitializeProjectile()
{
SubscribeLocalEvent<GatheringProjectileComponent, StartCollideEvent>(OnProjectileCollide);
}
private void OnProjectileCollide(Entity<GatheringProjectileComponent> gathering, ref StartCollideEvent args)
{
if (!args.OtherFixture.Hard ||
args.OurFixtureId != SharedProjectileSystem.ProjectileFixture ||
gathering.Comp.Amount <= 0 ||
!TryComp<GatherableComponent>(args.OtherEntity, out var gatherable))
{
return;
}
Gather(args.OtherEntity, gathering, gatherable);
gathering.Comp.Amount--;
if (gathering.Comp.Amount <= 0)
QueueDel(gathering);
}
}