* Merge BreakOnWeightlessMove and BreakOnMove. Provide different theshold for weightless movement. * Adjust WeightlessMovementThresholds. Put a thing I forgot to put in the doafterargs. * Make DoAfterArgs only use OnMove to determine whether to check for movement and MoveThreshold to determine the threshold regardless of weightlessness. Gave DistanceThreshold a default value which will always be checked now. * Fix issue introduced by merge. * Use interaction system for determining whether a distance is within range * Fix incorrect doafter args introduced by previous merge. Forgor to commit these. * Exorcise ghost. The execution system should have been deleted when I merged previously. For a reason I cannot comprehend it came back, but only the execution system. * Exorcise ghost Pt. 2 * Allow for movement check to be overriden in zero g and adjust doafter args where needed. You can now override checking for movement in zero g with the BreakOnWeightlessMove bool. By default it will check. The following doafters were made to ignore the movement check in zero g: - Healing yourself with healing items, - Removing embedded projectiles, - Using tools like welders and crowbars * Adjust distance for cuffing/uncuffing to work. Make injections not break on weightless movement. * Fix evil incorrect and uneeded comments
115 lines
4.6 KiB
C#
115 lines
4.6 KiB
C#
using Content.Shared.Examine;
|
|
using Content.Shared.Interaction;
|
|
using Content.Shared.Inventory;
|
|
using Content.Server.Popups;
|
|
using Content.Shared.DoAfter;
|
|
using Content.Shared.Forensics;
|
|
using Content.Shared.IdentityManagement;
|
|
|
|
namespace Content.Server.Forensics
|
|
{
|
|
/// <summary>
|
|
/// Used to transfer fingerprints from entities to forensic pads.
|
|
/// </summary>
|
|
public sealed class ForensicPadSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
|
|
[Dependency] private readonly InventorySystem _inventory = default!;
|
|
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
|
[Dependency] private readonly MetaDataSystem _metaData = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<ForensicPadComponent, ExaminedEvent>(OnExamined);
|
|
SubscribeLocalEvent<ForensicPadComponent, AfterInteractEvent>(OnAfterInteract);
|
|
SubscribeLocalEvent<ForensicPadComponent, ForensicPadDoAfterEvent>(OnDoAfter);
|
|
}
|
|
|
|
private void OnExamined(EntityUid uid, ForensicPadComponent component, ExaminedEvent args)
|
|
{
|
|
if (!args.IsInDetailsRange)
|
|
return;
|
|
|
|
if (!component.Used)
|
|
{
|
|
args.PushMarkup(Loc.GetString("forensic-pad-unused"));
|
|
return;
|
|
}
|
|
|
|
args.PushMarkup(Loc.GetString("forensic-pad-sample", ("sample", component.Sample)));
|
|
}
|
|
|
|
private void OnAfterInteract(EntityUid uid, ForensicPadComponent component, AfterInteractEvent args)
|
|
{
|
|
if (!args.CanReach || args.Target == null)
|
|
return;
|
|
|
|
if (HasComp<ForensicScannerComponent>(args.Target))
|
|
return;
|
|
|
|
args.Handled = true;
|
|
|
|
if (component.Used)
|
|
{
|
|
_popupSystem.PopupEntity(Loc.GetString("forensic-pad-already-used"), args.Target.Value, args.User);
|
|
return;
|
|
}
|
|
|
|
if (_inventory.TryGetSlotEntity(args.Target.Value, "gloves", out var gloves))
|
|
{
|
|
_popupSystem.PopupEntity(Loc.GetString("forensic-pad-gloves", ("target", Identity.Entity(args.Target.Value, EntityManager))), args.Target.Value, args.User);
|
|
return;
|
|
}
|
|
|
|
if (TryComp<FingerprintComponent>(args.Target, out var fingerprint) && fingerprint.Fingerprint != null)
|
|
{
|
|
if (args.User != args.Target)
|
|
{
|
|
_popupSystem.PopupEntity(Loc.GetString("forensic-pad-start-scan-user", ("target", Identity.Entity(args.Target.Value, EntityManager))), args.Target.Value, args.User);
|
|
_popupSystem.PopupEntity(Loc.GetString("forensic-pad-start-scan-target", ("user", Identity.Entity(args.User, EntityManager))), args.Target.Value, args.Target.Value);
|
|
}
|
|
StartScan(uid, args.User, args.Target.Value, component, fingerprint.Fingerprint);
|
|
return;
|
|
}
|
|
|
|
if (TryComp<FiberComponent>(args.Target, out var fiber))
|
|
StartScan(uid, args.User, args.Target.Value, component, string.IsNullOrEmpty(fiber.FiberColor) ? Loc.GetString("forensic-fibers", ("material", fiber.FiberMaterial)) : Loc.GetString("forensic-fibers-colored", ("color", fiber.FiberColor), ("material", fiber.FiberMaterial)));
|
|
}
|
|
|
|
private void StartScan(EntityUid used, EntityUid user, EntityUid target, ForensicPadComponent pad, string sample)
|
|
{
|
|
var ev = new ForensicPadDoAfterEvent(sample);
|
|
|
|
var doAfterEventArgs = new DoAfterArgs(EntityManager, user, pad.ScanDelay, ev, used, target: target, used: used)
|
|
{
|
|
NeedHand = true,
|
|
BreakOnMove = true,
|
|
};
|
|
|
|
_doAfterSystem.TryStartDoAfter(doAfterEventArgs);
|
|
}
|
|
|
|
private void OnDoAfter(EntityUid uid, ForensicPadComponent padComponent, ForensicPadDoAfterEvent args)
|
|
{
|
|
if (args.Handled || args.Cancelled)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (args.Args.Target != null)
|
|
{
|
|
var name = HasComp<FingerprintComponent>(args.Args.Target)
|
|
? "forensic-pad-fingerprint-name"
|
|
: "forensic-pad-gloves-name";
|
|
_metaData.SetEntityName(uid, Loc.GetString(name, ("entity", args.Args.Target)));
|
|
}
|
|
|
|
padComponent.Sample = args.Sample;
|
|
padComponent.Used = true;
|
|
|
|
args.Handled = true;
|
|
}
|
|
}
|
|
}
|