]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
fishops nerf real (#25148)
authordeltanedas <39013340+deltanedas@users.noreply.github.com>
Tue, 5 Mar 2024 03:13:50 +0000 (03:13 +0000)
committerGitHub <noreply@github.com>
Tue, 5 Mar 2024 03:13:50 +0000 (14:13 +1100)
* 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>
Content.Server/Forensics/Systems/ForensicsSystem.cs
Content.Server/Friends/Systems/PettableFriendSystem.cs
Content.Shared/Chemistry/Components/RehydratableComponent.cs [moved from Content.Server/Chemistry/Components/RehydratableComponent.cs with 69% similarity]
Content.Shared/Chemistry/EntitySystems/RehydratableSystem.cs [moved from Content.Server/Chemistry/EntitySystems/RehydratableSystem.cs with 51% similarity]

index 16bd2a50ee26a81d5f949fc137214abee34599b9..a081429fd3a0db5d5a4f4e280a8ed78ea509fe35 100644 (file)
@@ -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<DnaComponent, BeingGibbedEvent>(OnBeingGibbed);
             SubscribeLocalEvent<ForensicsComponent, MeleeHitEvent>(OnMeleeHit);
+            SubscribeLocalEvent<ForensicsComponent, GotRehydratedEvent>(OnRehydrated);
             SubscribeLocalEvent<CleansForensicsComponent, AfterInteractEvent>(OnAfterInteract, after: new[] { typeof(AbsorbentSystem) });
             SubscribeLocalEvent<ForensicsComponent, CleanForensicsDoAfterEvent>(OnCleanForensicsDoAfter);
             SubscribeLocalEvent<DnaComponent, TransferDnaEvent>(OnTransferDnaEvent);
@@ -71,6 +73,34 @@ namespace Content.Server.Forensics
             }
         }
 
+        private void OnRehydrated(Entity<ForensicsComponent> ent, ref GotRehydratedEvent args)
+        {
+            CopyForensicsFrom(ent.Comp, args.Target);
+        }
+
+        /// <summary>
+        /// Copy forensic information from a source entity to a destination.
+        /// Existing forensic information on the target is still kept.
+        /// </summary>
+        public void CopyForensicsFrom(ForensicsComponent src, EntityUid target)
+        {
+            var dest = EnsureComp<ForensicsComponent>(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)
index c4f65863416eea8cbd2d27924a7122afc1733c1e..8f70c843e7082bea38ae6f6f196b95cbf68ff41f 100644 (file)
@@ -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;
 
similarity index 69%
rename from Content.Server/Chemistry/Components/RehydratableComponent.cs
rename to Content.Shared/Chemistry/Components/RehydratableComponent.cs
index 636eba6ca1a684585b9ab41dc4e9e59e4cc12fb6..00599498e425d2703cca3a6b36c490a929a5e2bf 100644 (file)
@@ -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;
 
 /// <summary>
 /// Basically, monkey cubes.
@@ -16,20 +16,20 @@ public sealed partial class RehydratableComponent : Component
     /// <summary>
     /// The reagent that must be present to count as hydrated.
     /// </summary>
-    [DataField("catalyst", customTypeSerializer: typeof(PrototypeIdSerializer<ReagentPrototype>)), ViewVariables(VVAccess.ReadWrite)]
-    public string CatalystPrototype = "Water";
+    [DataField("catalyst")]
+    public ProtoId<ReagentPrototype> CatalystPrototype = "Water";
 
     /// <summary>
     /// The minimum amount of catalyst that must be present to be hydrated.
     /// </summary>
-    [DataField("catalystMinimum"), ViewVariables(VVAccess.ReadWrite)]
+    [DataField]
     public FixedPoint2 CatalystMinimum = FixedPoint2.Zero;
 
     /// <summary>
     /// The entity to create when hydrated.
     /// </summary>
-    [DataField("possibleSpawns"), ViewVariables(VVAccess.ReadWrite)]
-    public List<string> PossibleSpawns = new();
+    [DataField(required: true)]
+    public List<EntProtoId> PossibleSpawns = new();
 }
 
 /// <summary>
similarity index 51%
rename from Content.Server/Chemistry/EntitySystems/RehydratableSystem.cs
rename to Content.Shared/Chemistry/EntitySystems/RehydratableSystem.cs
index e1cdfd2066092b4176ceaa58fd3511b8870780fa..e260280ae450110f21c54931b47ab853204cb327 100644 (file)
@@ -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<RehydratableComponent, SolutionContainerChangedEvent>(OnSolutionChange);
     }
 
-    private void OnSolutionChange(Entity<RehydratableComponent> entity, ref SolutionContainerChangedEvent args)
+    private void OnSolutionChange(Entity<RehydratableComponent> 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<RehydratableComponent> entity)
+    private void Expand(Entity<RehydratableComponent> 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);