Files
Delta-v/Content.Shared/Trigger/Systems/DnaScrambleOnTriggerSystem.cs
T
pathetic meowmeow c57721eca5 Visual nubody (humanoid appearance refactor) (#42476)
* initial visual nubody

* oops overlay

* im so pheeming rn

* conversion...

* tests

* comeback of the underwear

* oops eyes

* blabbl

* zeds

* yaml linted

* search and visible count constraints

* reordering

* preserve previously selected markings colors

* fix test

* some ui niceties

* ordering

* make DB changes backwards-compatible/downgrade-friendly

* fix things again

* fix migration

* vulpkanin markings limit increase

* wrapping

* code cleanup and more code cleanup and more code cleanup and more code cleanup and

* fix slop ports

* better sampling API

* make filter work + use the method i made for its intended purpose

* fix test fails real quick

* magic mirror cleanup, remove TODO

* don't 0-init the organ profile data

* remove deltastates

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>

# Conflicts:
#	Content.Server/Humanoid/Components/RandomHumanoidAppearanceComponent.cs
#	Content.Server/Humanoid/Systems/RandomHumanoidAppearanceSystem.cs

# Conflicts:
#	Resources/Prototypes/Species/diona.yml

# Conflicts:
#	Content.Server/Zombies/ZombieSystem.Transform.cs
2026-06-29 12:43:35 +02:00

63 lines
2.7 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 class DnaScrambleOnTriggerSystem : XOnTriggerSystem<DnaScrambleOnTriggerComponent>
{
[Dependency] private readonly MetaDataSystem _metaData = default!;
[Dependency] private readonly HumanoidProfileSystem _humanoidProfile = default!;
[Dependency] private readonly SharedVisualBodySystem _visualBody = default!;
[Dependency] private readonly IdentitySystem _identity = default!;
[Dependency] private readonly SharedForensicsSystem _forensics = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly 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
// Can't use PopupClient or PopupPredicted because the trigger might be unpredicted.
_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);