Files
crystall-punk-14/Content.Server/Singularity/EntitySystems/ContainmentFieldSystem.cs

51 lines
2.0 KiB
C#
Raw Normal View History

using Content.Server.Popups;
using Content.Server.Singularity.Events;
Cargo Mail System (#35429) * shitcode init * biocoding, SpawnTableOnUse, Moving shit to shared * server :( * fixes * ok works * Discard changes to Content.Shared/Interaction/Events/GettingUsedAttemptEvent.cs * Discard changes to Content.Shared/Forensics/Components/FingerprintMaskComponent.cs * Discard changes to Content.Shared/Forensics/Components/FingerprintComponent.cs * Discard changes to Content.Server/Forensics/Systems/ForensicsSystem.cs * Discard changes to Content.Server/StationRecords/Systems/StationRecordsSystem.cs * Discard changes to Content.Server/Storage/EntitySystems/SpawnItemsOnUseSystem.cs * Discard changes to Content.Shared/Interaction/Events/GettingUsedAttemptEvent.cs * big stuff * preperation * temperory spawning thing for testing * Update CargoDeliveryDataComponent.cs * kinda proper spawning idk god save me * cleanup (kinda) * preparation 2.0 * stuff i think * entity table work * renames * spawn ratio based on players * comment * letter tables * more spam * package tables * comment * biocodedn't * builds correctly * cleaning * Update deliveries_tables.yml * labels * package sprites * mail teleporter * revert testing value * fix test * fix other test * i love tests * mail teleporter enabled by default * random cooldowns * fixtures * Discard changes to Content.Shared/FingerprintReader/FingerprintReaderComponent.cs * Discard changes to Content.Shared/FingerprintReader/FingerprintReaderSystem.cs * Discard changes to Content.Shared/Interaction/Events/GettingUsedAttemptEvent.cs * Discard changes to Resources/Locale/en-US/fingerprint-reader/fingerprint-reader.ftl * clean * fuck paper scrap * oops * fuck SpawnTableOnUse * mail teleporter board in QM locker + addressed review * oops * clean * sound on delivery spawn * address review * partial review address * partial review addressing * addressing partial review * pratarial revivew address * misprediction hell * stuff * more stuff * unrelated * TODO * link * partial review * DirtyField --------- Co-authored-by: Milon <milonpl.git@proton.me>
2025-03-07 14:51:08 +01:00
using Content.Shared.Shuttles.Components;
2022-08-05 00:22:37 -04:00
using Content.Shared.Popups;
using Content.Shared.Singularity.Components;
2022-08-05 00:22:37 -04:00
using Content.Shared.Throwing;
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!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
2022-08-05 00:22:37 -04:00
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ContainmentFieldComponent, StartCollideEvent>(HandleFieldCollide);
SubscribeLocalEvent<ContainmentFieldComponent, EventHorizonAttemptConsumeEntityEvent>(HandleEventHorizon);
2022-08-05 00:22:37 -04:00
}
private void HandleFieldCollide(EntityUid uid, ContainmentFieldComponent component, ref StartCollideEvent args)
2022-08-05 00:22:37 -04:00
{
var otherBody = args.OtherEntity;
2022-08-05 00:22:37 -04:00
if (component.DestroyGarbage && HasComp<SpaceGarbageComponent>(otherBody))
2022-08-05 00:22:37 -04: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)
{
var fieldDir = _transformSystem.GetWorldPosition(uid);
var playerDir = _transformSystem.GetWorldPosition(otherBody);
2022-08-05 00:22:37 -04:00
_throwing.TryThrow(otherBody, playerDir-fieldDir, baseThrowSpeed: component.ThrowForce);
2022-08-05 00:22:37 -04:00
}
}
private void HandleEventHorizon(EntityUid uid, ContainmentFieldComponent component, ref EventHorizonAttemptConsumeEntityEvent args)
{
if(!args.Cancelled && !args.EventHorizon.CanBreachContainment)
args.Cancelled = true;
}
2022-08-05 00:22:37 -04:00
}