CatStation/Content.Shared/Trigger/Systems/DnaScrambleOnTriggerSystem.cs
Whatstone a88d2c5164
Cleanup: Resolve remaining PopupSystem warnings in Content.Shared (#44685)
* PopupClient to PopupEntity/Coordinates

* PopupPredictedX to PopupEntity/Cursor/Coordinates

* The rest of the damn owl

* nullability fixes

* Buckle cleanup

* cleanup, address PR comments

* ExecutionSystem: one popup method

* correct my filthy lies

* Apply most of ajcm's suggestions

* return user to SharedItemRecallSystem.cs

* Fix lingering Ensnarable broadcast popups

* targeted drain popups

* fix lingering untargeted Guardian popups

I read the comment on GuardianHostRecall.  Oops.

* target stethoscope popups

* fix the PDA vibration popup

* Fix target for encryption key removal popup

* anomaly scanner: args.User, not uid

* disposal unit comment, bcast pda vibration popup
2026-07-16 21:54:33 +00:00

61 lines
2.5 KiB
C#

using Content.Shared.Body;
using Content.Shared.DetailExaminable;
using Content.Shared.Forensics.Systems;
using Content.Shared.Humanoid;
using Content.Shared.IdentityManagement;
using Content.Shared.Preferences;
using Content.Shared.Popups;
using Content.Shared.Trigger.Components.Effects;
using Robust.Shared.Network;
namespace Content.Shared.Trigger.Systems;
public sealed partial class DnaScrambleOnTriggerSystem : XOnTriggerSystem<DnaScrambleOnTriggerComponent>
{
[Dependency] private MetaDataSystem _metaData = default!;
[Dependency] private HumanoidProfileSystem _humanoidProfile = default!;
[Dependency] private SharedVisualBodySystem _visualBody = default!;
[Dependency] private IdentitySystem _identity = default!;
[Dependency] private SharedForensicsSystem _forensics = default!;
[Dependency] private SharedPopupSystem _popup = default!;
[Dependency] private INetManager _net = default!;
protected override void OnTrigger(Entity<DnaScrambleOnTriggerComponent> ent, EntityUid target, ref TriggerEvent args)
{
if (!TryComp<HumanoidProfileComponent>(target, out var humanoid))
return;
args.Handled = true;
// Randomness will mispredict
// and LoadProfile causes a debug assert on the client at the moment.
if (_net.IsClient)
return;
var newProfile = HumanoidCharacterProfile.RandomWithSpecies(humanoid.Species);
_visualBody.ApplyProfileTo(target, newProfile);
_humanoidProfile.ApplyProfileTo(target, newProfile);
_metaData.SetEntityName(target, newProfile.Name, raiseEvents: false); // raising events would update ID card, station record, etc.
// If the entity has the respective components, then scramble the dna and fingerprint strings.
_forensics.RandomizeDNA(target);
_forensics.RandomizeFingerprint(target);
RemComp<DetailExaminableComponent>(target); // remove MRP+ custom description if one exists
_identity.QueueIdentityUpdate(target); // manually queue identity update since we don't raise the event
_popup.PopupEntity(Loc.GetString("scramble-on-trigger-popup"), target, target);
var ev = new DnaScrambledEvent(target);
RaiseLocalEvent(target, ref ev, true);
}
}
/// <summary>
/// Raised after an entity has been DNA Scrambled.
/// Useful for forks that need to run their own updates here.
/// </summary>
/// <param name="flag">The entity that had its DNA scrambled.</param>
[ByRefEvent]
public record struct DnaScrambledEvent(EntityUid Target);