From 550612a37f4fd61088c994b289c833ed3d564855 Mon Sep 17 00:00:00 2001 From: deltanedas <39013340+deltanedas@users.noreply.github.com> Date: Tue, 5 Mar 2024 03:13:50 +0000 Subject: [PATCH] fishops nerf real (#25148) * refactor ops * inherit dna and fiber when fish hydrated * :trollface: * kid named finger * :trollface: * move rehydrating to shared :trollface: * nobody noticed the popup being missing all this time * method ops --------- Co-authored-by: deltanedas <@deltanedas:kde.org> --- .../Forensics/Systems/ForensicsSystem.cs | 30 +++++++++++++++++++ .../Friends/Systems/PettableFriendSystem.cs | 2 +- .../Components/RehydratableComponent.cs | 14 ++++----- .../EntitySystems/RehydratableSystem.cs | 28 ++++++++--------- 4 files changed, 51 insertions(+), 23 deletions(-) rename {Content.Server => Content.Shared}/Chemistry/Components/RehydratableComponent.cs (69%) rename {Content.Server => Content.Shared}/Chemistry/EntitySystems/RehydratableSystem.cs (51%) diff --git a/Content.Server/Forensics/Systems/ForensicsSystem.cs b/Content.Server/Forensics/Systems/ForensicsSystem.cs index 16bd2a50ee..a081429fd3 100644 --- a/Content.Server/Forensics/Systems/ForensicsSystem.cs +++ b/Content.Server/Forensics/Systems/ForensicsSystem.cs @@ -3,6 +3,7 @@ using Content.Server.DoAfter; using Content.Server.Fluids.EntitySystems; using Content.Server.Forensics.Components; using Content.Server.Popups; +using Content.Shared.Chemistry.Components; using Content.Shared.DoAfter; using Content.Shared.Forensics; using Content.Shared.Interaction; @@ -27,6 +28,7 @@ namespace Content.Server.Forensics SubscribeLocalEvent(OnBeingGibbed); SubscribeLocalEvent(OnMeleeHit); + SubscribeLocalEvent(OnRehydrated); SubscribeLocalEvent(OnAfterInteract, after: new[] { typeof(AbsorbentSystem) }); SubscribeLocalEvent(OnCleanForensicsDoAfter); SubscribeLocalEvent(OnTransferDnaEvent); @@ -71,6 +73,34 @@ namespace Content.Server.Forensics } } + private void OnRehydrated(Entity ent, ref GotRehydratedEvent args) + { + CopyForensicsFrom(ent.Comp, args.Target); + } + + /// + /// Copy forensic information from a source entity to a destination. + /// Existing forensic information on the target is still kept. + /// + public void CopyForensicsFrom(ForensicsComponent src, EntityUid target) + { + var dest = EnsureComp(target); + foreach (var dna in src.DNAs) + { + dest.DNAs.Add(dna); + } + + foreach (var fiber in src.Fibers) + { + dest.Fibers.Add(fiber); + } + + foreach (var print in src.Fingerprints) + { + dest.Fingerprints.Add(print); + } + } + private void OnAfterInteract(EntityUid uid, CleansForensicsComponent component, AfterInteractEvent args) { if (args.Handled) diff --git a/Content.Server/Friends/Systems/PettableFriendSystem.cs b/Content.Server/Friends/Systems/PettableFriendSystem.cs index c4f6586341..8f70c843e7 100644 --- a/Content.Server/Friends/Systems/PettableFriendSystem.cs +++ b/Content.Server/Friends/Systems/PettableFriendSystem.cs @@ -1,7 +1,7 @@ -using Content.Server.Chemistry.Components; using Content.Server.Friends.Components; using Content.Server.NPC.Components; using Content.Server.NPC.Systems; +using Content.Shared.Chemistry.Components; using Content.Shared.Interaction.Events; using Content.Shared.Popups; diff --git a/Content.Server/Chemistry/Components/RehydratableComponent.cs b/Content.Shared/Chemistry/Components/RehydratableComponent.cs similarity index 69% rename from Content.Server/Chemistry/Components/RehydratableComponent.cs rename to Content.Shared/Chemistry/Components/RehydratableComponent.cs index 636eba6ca1..00599498e4 100644 --- a/Content.Server/Chemistry/Components/RehydratableComponent.cs +++ b/Content.Shared/Chemistry/Components/RehydratableComponent.cs @@ -1,10 +1,10 @@ -using Content.Server.Chemistry.EntitySystems; +using Content.Shared.Chemistry.EntitySystems; using Content.Shared.Chemistry.Reagent; using Content.Shared.FixedPoint; using Robust.Shared.Prototypes; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; -namespace Content.Server.Chemistry.Components; +namespace Content.Shared.Chemistry.Components; /// /// Basically, monkey cubes. @@ -16,20 +16,20 @@ public sealed partial class RehydratableComponent : Component /// /// The reagent that must be present to count as hydrated. /// - [DataField("catalyst", customTypeSerializer: typeof(PrototypeIdSerializer)), ViewVariables(VVAccess.ReadWrite)] - public string CatalystPrototype = "Water"; + [DataField("catalyst")] + public ProtoId CatalystPrototype = "Water"; /// /// The minimum amount of catalyst that must be present to be hydrated. /// - [DataField("catalystMinimum"), ViewVariables(VVAccess.ReadWrite)] + [DataField] public FixedPoint2 CatalystMinimum = FixedPoint2.Zero; /// /// The entity to create when hydrated. /// - [DataField("possibleSpawns"), ViewVariables(VVAccess.ReadWrite)] - public List PossibleSpawns = new(); + [DataField(required: true)] + public List PossibleSpawns = new(); } /// diff --git a/Content.Server/Chemistry/EntitySystems/RehydratableSystem.cs b/Content.Shared/Chemistry/EntitySystems/RehydratableSystem.cs similarity index 51% rename from Content.Server/Chemistry/EntitySystems/RehydratableSystem.cs rename to Content.Shared/Chemistry/EntitySystems/RehydratableSystem.cs index e1cdfd2066..e260280ae4 100644 --- a/Content.Server/Chemistry/EntitySystems/RehydratableSystem.cs +++ b/Content.Shared/Chemistry/EntitySystems/RehydratableSystem.cs @@ -1,17 +1,16 @@ -using Content.Server.Chemistry.Components; -using Content.Server.Chemistry.Containers.EntitySystems; -using Content.Shared.Chemistry.EntitySystems; +using Content.Shared.Chemistry.Components; using Content.Shared.FixedPoint; using Content.Shared.Popups; using Robust.Shared.Random; -namespace Content.Server.Chemistry.EntitySystems; +namespace Content.Shared.Chemistry.EntitySystems; public sealed class RehydratableSystem : EntitySystem { - [Dependency] private readonly SharedPopupSystem _popups = default!; - [Dependency] private readonly SolutionContainerSystem _solutions = default!; [Dependency] private readonly IRobustRandom _random = default!; + [Dependency] private readonly SharedPopupSystem _popup = default!; + [Dependency] private readonly SharedSolutionContainerSystem _solutions = default!; + [Dependency] private readonly SharedTransformSystem _xform = default!; public override void Initialize() { @@ -20,27 +19,26 @@ public sealed class RehydratableSystem : EntitySystem SubscribeLocalEvent(OnSolutionChange); } - private void OnSolutionChange(Entity entity, ref SolutionContainerChangedEvent args) + private void OnSolutionChange(Entity ent, ref SolutionContainerChangedEvent args) { - var quantity = _solutions.GetTotalPrototypeQuantity(entity, entity.Comp.CatalystPrototype); - if (quantity != FixedPoint2.Zero && quantity >= entity.Comp.CatalystMinimum) + var quantity = _solutions.GetTotalPrototypeQuantity(ent, ent.Comp.CatalystPrototype); + if (quantity != FixedPoint2.Zero && quantity >= ent.Comp.CatalystMinimum) { - Expand(entity); + Expand(ent); } } // Try not to make this public if you can help it. - private void Expand(Entity entity) + private void Expand(Entity ent) { - var (uid, comp) = entity; - - _popups.PopupEntity(Loc.GetString("rehydratable-component-expands-message", ("owner", uid)), uid); + var (uid, comp) = ent; var randomMob = _random.Pick(comp.PossibleSpawns); var target = Spawn(randomMob, Transform(uid).Coordinates); + _popup.PopupEntity(Loc.GetString("rehydratable-component-expands-message", ("owner", uid)), target); - Transform(target).AttachToGridOrMap(); + _xform.AttachToGridOrMap(target); var ev = new GotRehydratedEvent(target); RaiseLocalEvent(uid, ref ev); -- 2.51.2