]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
predict egg cracking + refactor (#25028)
authordeltanedas <39013340+deltanedas@users.noreply.github.com>
Thu, 8 Feb 2024 06:24:24 +0000 (06:24 +0000)
committerGitHub <noreply@github.com>
Thu, 8 Feb 2024 06:24:24 +0000 (17:24 +1100)
* move stuff to server and some refactoring

* update spikables to not use triggering

* add Delete bool just incase

* a new egg

* mom can we have webedit. no, we have webedit at home

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
Content.Shared/Chemistry/Components/SolutionSpikerComponent.cs [moved from Content.Server/Chemistry/Components/SolutionSpikerComponent.cs with 51% similarity]
Content.Shared/Chemistry/EntitySystems/SolutionSpikerSystem.cs [moved from Content.Server/Chemistry/EntitySystems/SolutionSpikableSystem.cs with 61% similarity]
Resources/Prototypes/Entities/Objects/Consumable/Food/egg.yml
Resources/Prototypes/Entities/Objects/Specific/Medical/morgue.yml
Resources/Prototypes/Entities/Objects/Specific/chemistry.yml

similarity index 51%
rename from Content.Server/Chemistry/Components/SolutionSpikerComponent.cs
rename to Content.Shared/Chemistry/Components/SolutionSpikerComponent.cs
index 1fad6c9a3e81124e236472fe33815ff1f6995f6e..e6cf9e02054a8a58903de39b424b3548222c67d9 100644 (file)
@@ -1,30 +1,40 @@
-namespace Content.Server.Chemistry.Components;
+using Content.Shared.Chemistry.EntitySystems;
+using Robust.Shared.GameStates;
 
-[RegisterComponent]
+namespace Content.Shared.Chemistry.Components;
+
+[RegisterComponent, NetworkedComponent, Access(typeof(SolutionSpikerSystem))]
 public sealed partial class SolutionSpikerComponent : Component
 {
     /// <summary>
     ///     The source solution to take the reagents from in order
     ///     to spike the other solution container.
     /// </summary>
-    [DataField]
-    public string SourceSolution { get; private set; } = string.Empty;
+    [DataField(required: true)]
+    public string SourceSolution = string.Empty;
 
     /// <summary>
     ///     If spiking with this entity should ignore empty containers or not.
     /// </summary>
     [DataField]
-    public bool IgnoreEmpty { get; private set; }
+    public bool IgnoreEmpty;
+
+    /// <summary>
+    /// If true, the entity is deleted after spiking.
+    /// This is almost certainly what you want.
+    /// </summary>
+    [DataField]
+    public bool Delete = true;
 
     /// <summary>
     ///     What should pop up when spiking with this entity.
     /// </summary>
     [DataField]
-    public LocId Popup { get; private set; } = "spike-solution-generic";
+    public LocId Popup = "spike-solution-generic";
 
     /// <summary>
     ///     What should pop up when spiking fails because the container was empty.
     /// </summary>
     [DataField]
-    public LocId PopupEmpty { get; private set; } = "spike-solution-empty-generic";
+    public LocId PopupEmpty = "spike-solution-empty-generic";
 }
similarity index 61%
rename from Content.Server/Chemistry/EntitySystems/SolutionSpikableSystem.cs
rename to Content.Shared/Chemistry/EntitySystems/SolutionSpikerSystem.cs
index 7518b45a8bcd7207b5667f86871c2f5d68e8622d..f179580604c9a98faefbafe21596cd8740bf2019 100644 (file)
@@ -1,12 +1,9 @@
-using Content.Server.Chemistry.Components;
-using Content.Server.Chemistry.Containers.EntitySystems;
-using Content.Server.Explosion.EntitySystems;
-using Content.Server.Popups;
+using Content.Shared.Popups;
 using Content.Shared.Chemistry.Components;
 using Content.Shared.Chemistry.Components.SolutionManager;
 using Content.Shared.Interaction;
 
-namespace Content.Server.Chemistry.EntitySystems;
+namespace Content.Shared.Chemistry.EntitySystems;
 
 /// <summary>
 ///     Entity system used to handle when solution containers are 'spiked'
@@ -17,11 +14,10 @@ namespace Content.Server.Chemistry.EntitySystems;
 ///     Examples of spikable entity interactions include pills being dropped into glasses,
 ///     eggs being cracked into bowls, and so on.
 /// </summary>
-public sealed class SolutionSpikableSystem : EntitySystem
+public sealed class SolutionSpikerSystem : EntitySystem
 {
-    [Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!;
-    [Dependency] private readonly TriggerSystem _triggerSystem = default!;
-    [Dependency] private readonly PopupSystem _popupSystem = default!;
+    [Dependency] private readonly SharedPopupSystem _popup = default!;
+    [Dependency] private readonly SharedSolutionContainerSystem _solution = default!;
 
     public override void Initialize()
     {
@@ -47,23 +43,24 @@ public sealed class SolutionSpikableSystem : EntitySystem
     {
         if (!Resolve(source, ref spikableSource, ref managerSource, false)
             || !Resolve(target, ref spikableTarget, ref managerTarget, false)
-            || !_solutionContainerSystem.TryGetRefillableSolution((target, spikableTarget, managerTarget), out var targetSoln, out var targetSolution)
-            || !_solutionContainerSystem.TryGetSolution((source, managerSource), spikableSource.SourceSolution, out _, out var sourceSolution))
+            || !_solution.TryGetRefillableSolution((target, spikableTarget, managerTarget), out var targetSoln, out var targetSolution)
+            || !_solution.TryGetSolution((source, managerSource), spikableSource.SourceSolution, out _, out var sourceSolution))
         {
             return;
         }
 
         if (targetSolution.Volume == 0 && !spikableSource.IgnoreEmpty)
         {
-            _popupSystem.PopupEntity(Loc.GetString(spikableSource.PopupEmpty, ("spiked-entity", target), ("spike-entity", source)), user, user);
+            _popup.PopupClient(Loc.GetString(spikableSource.PopupEmpty, ("spiked-entity", target), ("spike-entity", source)), user, user);
             return;
         }
 
-        if (!_solutionContainerSystem.ForceAddSolution(targetSoln.Value, sourceSolution))
+        if (!_solution.ForceAddSolution(targetSoln.Value, sourceSolution))
             return;
 
-        _popupSystem.PopupEntity(Loc.GetString(spikableSource.Popup, ("spiked-entity", target), ("spike-entity", source)), user, user);
+        _popup.PopupClient(Loc.GetString(spikableSource.Popup, ("spiked-entity", target), ("spike-entity", source)), user, user);
         sourceSolution.RemoveAllSolution();
-        _triggerSystem.Trigger(source, user);
+        if (spikableSource.Delete)
+            QueueDel(source);
     }
 }
index 449b996dac4323cf39758d6cd32a5a4db9007bca..8cd2fa70ee55942a9f18429191dd8c263fe198cc 100644 (file)
@@ -30,7 +30,6 @@
     sourceSolution: food
     ignoreEmpty: true
     popup: spike-solution-egg
-  - type: DeleteOnTrigger
   # egg fragile
   - type: DamageOnHighSpeedImpact
     minimumSpeed: 0.1
index c34ca70c4575b53db89e343cd2ffd2786ee3ddf9..7f59949a37b01b0a1e2bb125bc797af5c9758b6f 100644 (file)
   - type: SolutionSpiker
     sourceSolution: food
     ignoreEmpty: true
-  - type: DeleteOnTrigger
   - type: Extractable
     grindableSolutionName: food
 
index a8acc5ff9c4d4bca1d15d1aa5aee570632d27ba5..ab65940fabc73afaa5588eb3418251450c85ef0c 100644 (file)
         maxVol: 20
   - type: SolutionSpiker
     sourceSolution: food
-  - type: DeleteOnTrigger
   - type: Extractable
     grindableSolutionName: food
   - type: StaticPrice