mirror of
https://github.com/corvax-team/ss14-wl.git
synced 2026-09-15 14:52:26 +02:00
* IoC source gen compatibility Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter. * Missed a spot
51 lines
1.9 KiB
C#
51 lines
1.9 KiB
C#
using Content.Server.Popups;
|
|
using Content.Server.Singularity.Events;
|
|
using Content.Shared.Shuttles.Components;
|
|
using Content.Shared.Popups;
|
|
using Content.Shared.Singularity.Components;
|
|
using Content.Shared.Throwing;
|
|
using Robust.Shared.Physics.Components;
|
|
using Robust.Shared.Physics.Events;
|
|
|
|
namespace Content.Server.Singularity.EntitySystems;
|
|
|
|
public sealed partial class ContainmentFieldSystem : EntitySystem
|
|
{
|
|
[Dependency] private ThrowingSystem _throwing = default!;
|
|
[Dependency] private PopupSystem _popupSystem = default!;
|
|
[Dependency] private SharedTransformSystem _transformSystem = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<ContainmentFieldComponent, StartCollideEvent>(HandleFieldCollide);
|
|
SubscribeLocalEvent<ContainmentFieldComponent, EventHorizonAttemptConsumeEntityEvent>(HandleEventHorizon);
|
|
}
|
|
|
|
private void HandleFieldCollide(EntityUid uid, ContainmentFieldComponent component, ref StartCollideEvent args)
|
|
{
|
|
var otherBody = args.OtherEntity;
|
|
|
|
if (component.DestroyGarbage && HasComp<SpaceGarbageComponent>(otherBody))
|
|
{
|
|
_popupSystem.PopupEntity(Loc.GetString("comp-field-vaporized", ("entity", otherBody)), uid, PopupType.LargeCaution);
|
|
QueueDel(otherBody);
|
|
}
|
|
|
|
if (TryComp<PhysicsComponent>(otherBody, out var physics) && physics.Mass <= component.MaxMass && physics.Hard)
|
|
{
|
|
var fieldDir = _transformSystem.GetWorldPosition(uid);
|
|
var playerDir = _transformSystem.GetWorldPosition(otherBody);
|
|
|
|
_throwing.TryThrow(otherBody, playerDir-fieldDir, baseThrowSpeed: component.ThrowForce);
|
|
}
|
|
}
|
|
|
|
private void HandleEventHorizon(EntityUid uid, ContainmentFieldComponent component, ref EventHorizonAttemptConsumeEntityEvent args)
|
|
{
|
|
if(!args.Cancelled && !args.EventHorizon.CanBreachContainment)
|
|
args.Cancelled = true;
|
|
}
|
|
}
|