mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-29 23:57:29 +00:00
Co-authored-by: AJCM-git <60196617+AJCM-git@users.noreply.github.com>
33 lines
983 B
C#
33 lines
983 B
C#
using Content.Server.Gatherable.Components;
|
|
using Content.Server.Projectiles;
|
|
using Content.Shared.Projectiles;
|
|
using Content.Shared.Weapons.Ranged.Systems;
|
|
using Robust.Shared.Physics.Events;
|
|
|
|
namespace Content.Server.Gatherable;
|
|
|
|
public sealed partial class GatherableSystem
|
|
{
|
|
private void InitializeProjectile()
|
|
{
|
|
SubscribeLocalEvent<GatheringProjectileComponent, StartCollideEvent>(OnProjectileCollide);
|
|
}
|
|
|
|
private void OnProjectileCollide(EntityUid uid, GatheringProjectileComponent component, ref StartCollideEvent args)
|
|
{
|
|
if (!args.OtherFixture.Hard ||
|
|
args.OurFixture.ID != SharedProjectileSystem.ProjectileFixture ||
|
|
component.Amount <= 0 ||
|
|
!TryComp<GatherableComponent>(args.OtherEntity, out var gatherable))
|
|
{
|
|
return;
|
|
}
|
|
|
|
Gather(args.OtherEntity, uid, gatherable);
|
|
component.Amount--;
|
|
|
|
if (component.Amount <= 0)
|
|
QueueDel(uid);
|
|
}
|
|
}
|