2022-08-05 00:22:37 -04:00
|
|
|
|
using Content.Server.Popups;
|
|
|
|
|
|
using Content.Server.Shuttles.Components;
|
2022-12-19 18:47:15 -08:00
|
|
|
|
using Content.Server.Singularity.Events;
|
2022-08-05 00:22:37 -04:00
|
|
|
|
using Content.Shared.Popups;
|
2022-12-23 23:55:31 -05:00
|
|
|
|
using Content.Shared.Singularity.Components;
|
2022-08-05 00:22:37 -04:00
|
|
|
|
using Content.Shared.Throwing;
|
2022-09-14 17:26:26 +10:00
|
|
|
|
using Robust.Shared.Physics.Components;
|
|
|
|
|
|
using Robust.Shared.Physics.Events;
|
2022-08-05 00:22:37 -04:00
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Singularity.EntitySystems;
|
|
|
|
|
|
|
|
|
|
|
|
public sealed class ContainmentFieldSystem : EntitySystem
|
|
|
|
|
|
{
|
|
|
|
|
|
[Dependency] private readonly ThrowingSystem _throwing = default!;
|
|
|
|
|
|
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
|
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<ContainmentFieldComponent, StartCollideEvent>(HandleFieldCollide);
|
2022-12-19 18:47:15 -08:00
|
|
|
|
SubscribeLocalEvent<ContainmentFieldComponent, EventHorizonAttemptConsumeEntityEvent>(HandleEventHorizon);
|
2022-08-05 00:22:37 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-14 17:26:26 +10:00
|
|
|
|
private void HandleFieldCollide(EntityUid uid, ContainmentFieldComponent component, ref StartCollideEvent args)
|
2022-08-05 00:22:37 -04:00
|
|
|
|
{
|
2023-05-09 19:21:26 +12:00
|
|
|
|
var otherBody = args.OtherEntity;
|
2022-08-05 00:22:37 -04:00
|
|
|
|
|
2023-10-19 12:34:31 -07:00
|
|
|
|
if (HasComp<SpaceGarbageComponent>(otherBody))
|
2022-08-05 00:22:37 -04:00
|
|
|
|
{
|
2023-10-19 12:34:31 -07:00
|
|
|
|
_popupSystem.PopupEntity(Loc.GetString("comp-field-vaporized", ("entity", otherBody)), uid, PopupType.LargeCaution);
|
|
|
|
|
|
QueueDel(otherBody);
|
2022-08-05 00:22:37 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (TryComp<PhysicsComponent>(otherBody, out var physics) && physics.Mass <= component.MaxMass && physics.Hard)
|
|
|
|
|
|
{
|
2024-02-28 00:51:20 +11:00
|
|
|
|
var fieldDir = Transform(uid).WorldPosition;
|
|
|
|
|
|
var playerDir = Transform(otherBody).WorldPosition;
|
2022-08-05 00:22:37 -04:00
|
|
|
|
|
|
|
|
|
|
_throwing.TryThrow(otherBody, playerDir-fieldDir, strength: component.ThrowForce);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-12-19 18:47:15 -08:00
|
|
|
|
|
2023-07-19 01:01:27 -07:00
|
|
|
|
private void HandleEventHorizon(EntityUid uid, ContainmentFieldComponent component, ref EventHorizonAttemptConsumeEntityEvent args)
|
2022-12-19 18:47:15 -08:00
|
|
|
|
{
|
|
|
|
|
|
if(!args.Cancelled && !args.EventHorizon.CanBreachContainment)
|
2023-07-19 01:01:27 -07:00
|
|
|
|
args.Cancelled = true;
|
2022-12-19 18:47:15 -08:00
|
|
|
|
}
|
2022-08-05 00:22:37 -04:00
|
|
|
|
}
|