]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Better Godmode (#37020)
authorPrincess Cheeseballs <66055347+Pronana@users.noreply.github.com>
Sat, 10 May 2025 05:06:19 +0000 (22:06 -0700)
committerGitHub <noreply@github.com>
Sat, 10 May 2025 05:06:19 +0000 (01:06 -0400)
* Commit

* Oversights oops

* breaking changes

* unbreaking changes

* Compatibility with AfterFullyEaten

* Fixed

* Update Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs

---------

Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
Content.Server/Body/Systems/BodySystem.cs
Content.Server/ImmovableRod/ImmovableRodSystem.cs
Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs
Content.Server/Nutrition/EntitySystems/FoodSystem.cs
Content.Shared/Damage/Systems/SharedGodmodeSystem.cs
Content.Shared/Destructible/SharedDestructibleSystem.cs

index d41f2d57695ce281900718b10f49ad9b4af5c3bc..fb6f8d6777d3b12abf4bf48cc5407acf101e4602 100644 (file)
@@ -12,6 +12,7 @@ using Content.Shared.Movement.Systems;
 using Robust.Shared.Audio;
 using Robust.Shared.Timing;
 using System.Numerics;
+using Content.Shared.Damage.Components;
 
 namespace Content.Server.Body.Systems;
 
@@ -110,6 +111,9 @@ public sealed class BodySystem : SharedBodySystem
             return new HashSet<EntityUid>();
         }
 
+        if (HasComp<GodmodeComponent>(bodyId))
+            return new HashSet<EntityUid>();
+
         var xform = Transform(bodyId);
         if (xform.MapUid is null)
             return new HashSet<EntityUid>();
index 0d3d69c1bcb90a9e524821df6e93097918016f5d..d881f90341f6b144bbe30ddccd8a584f0c457eaf 100644 (file)
@@ -1,4 +1,6 @@
 using Content.Server.Body.Systems;
+using Content.Server.Destructible;
+using Content.Server.Examine;
 using Content.Server.Polymorph.Components;
 using Content.Server.Popups;
 using Content.Shared.Body.Components;
@@ -24,6 +26,7 @@ public sealed class ImmovableRodSystem : EntitySystem
     [Dependency] private readonly SharedPhysicsSystem _physics = default!;
     [Dependency] private readonly SharedAudioSystem _audio = default!;
     [Dependency] private readonly DamageableSystem _damageable = default!;
+    [Dependency] private readonly DestructibleSystem _destructible = default!;
     [Dependency] private readonly SharedTransformSystem _transform = default!;
     [Dependency] private readonly SharedMapSystem _map = default!;
 
@@ -127,7 +130,7 @@ public sealed class ImmovableRodSystem : EntitySystem
             return;
         }
 
-        QueueDel(ent);
+        _destructible.DestroyEntity(ent);
     }
 
     private void OnExamined(EntityUid uid, ImmovableRodComponent component, ExaminedEvent args)
index de848b34c2c1587d5849d0ea7f5389c53dc10ff3..cd0ce8f3a60e6f08302df62ef429a28527ab23bb 100644 (file)
@@ -20,6 +20,7 @@ using Robust.Shared.Audio.Systems;
 using Robust.Shared.Containers;
 using Robust.Shared.Timing;
 using System.Linq;
+using Content.Server.Construction.Completions;
 using Content.Server.Jittering;
 using Content.Shared.Jittering;
 using Content.Shared.Power;
@@ -38,6 +39,7 @@ namespace Content.Server.Kitchen.EntitySystems
         [Dependency] private readonly SharedAudioSystem _audioSystem = default!;
         [Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
         [Dependency] private readonly SharedContainerSystem _containerSystem = default!;
+        [Dependency] private readonly SharedDestructibleSystem _destructible = default!;
         [Dependency] private readonly RandomHelperSystem _randomHelper = default!;
         [Dependency] private readonly JitteringSystem _jitter = default!;
 
@@ -123,10 +125,7 @@ namespace Content.Server.Kitchen.EntitySystems
                         if (solution.Volume > containerSolution.AvailableVolume)
                             continue;
 
-                        var dev = new DestructionEventArgs();
-                        RaiseLocalEvent(item, dev);
-
-                        QueueDel(item);
+                        _destructible.DestroyEntity(item);
                     }
 
                     _solutionContainersSystem.TryAddSolution(containerSoln.Value, solution);
index e294edf15bc007bc493937afe59c9fbe62ba9363..8b7626e03104d442012f0746563fa57db101afbb 100644 (file)
@@ -52,6 +52,7 @@ public sealed class FoodSystem : EntitySystem
     [Dependency] private readonly ReactiveSystem _reaction = default!;
     [Dependency] private readonly SharedAudioSystem _audio = default!;
     [Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
+    [Dependency] private readonly SharedDestructibleSystem _destructible = default!;
     [Dependency] private readonly SharedHandsSystem _hands = default!;
     [Dependency] private readonly SharedInteractionSystem _interaction = default!;
     [Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!;
@@ -336,6 +337,11 @@ public sealed class FoodSystem : EntitySystem
         if (ev.Cancelled)
             return;
 
+        var attemptEv = new DestructionAttemptEvent();
+        RaiseLocalEvent(food, attemptEv);
+        if (attemptEv.Cancelled)
+            return;
+
         var afterEvent = new AfterFullyEatenEvent(user);
         RaiseLocalEvent(food, ref afterEvent);
 
index 4ccc56dcb8543f6e4a865578bef4b0a110ec1793..b6b487430b74327ecc2764971dbb0213391fda7c 100644 (file)
@@ -1,5 +1,6 @@
 using Content.Shared.Damage.Components;
 using Content.Shared.Damage.Events;
+using Content.Shared.Destructible;
 using Content.Shared.Rejuvenate;
 using Content.Shared.Slippery;
 using Content.Shared.StatusEffect;
@@ -18,6 +19,7 @@ public abstract class SharedGodmodeSystem : EntitySystem
         SubscribeLocalEvent<GodmodeComponent, BeforeStatusEffectAddedEvent>(OnBeforeStatusEffect);
         SubscribeLocalEvent<GodmodeComponent, BeforeStaminaDamageEvent>(OnBeforeStaminaDamage);
         SubscribeLocalEvent<GodmodeComponent, SlipAttemptEvent>(OnSlipAttempt);
+        SubscribeLocalEvent<GodmodeComponent, DestructionAttemptEvent>(OnDestruction);
     }
 
     private void OnSlipAttempt(EntityUid uid, GodmodeComponent component, SlipAttemptEvent args)
@@ -40,6 +42,11 @@ public abstract class SharedGodmodeSystem : EntitySystem
         args.Cancelled = true;
     }
 
+    private void OnDestruction(Entity<GodmodeComponent> ent, ref DestructionAttemptEvent args)
+    {
+        args.Cancel();
+    }
+
     public virtual void EnableGodmode(EntityUid uid, GodmodeComponent? godmode = null)
     {
         godmode ??= EnsureComp<GodmodeComponent>(uid);
index eb87f00b6c80d45947917c0d7f41663098d61f58..572ed9d560e06fef139fff0729a41fd424d537d0 100644 (file)
@@ -5,12 +5,18 @@ public abstract class SharedDestructibleSystem : EntitySystem
     /// <summary>
     ///     Force entity to be destroyed and deleted.
     /// </summary>
-    public void DestroyEntity(EntityUid owner)
+    public bool DestroyEntity(EntityUid owner)
     {
-        var eventArgs = new DestructionEventArgs();
+        var ev = new DestructionAttemptEvent();
+        RaiseLocalEvent(owner, ev);
+        if (ev.Cancelled)
+            return false;
 
+        var eventArgs = new DestructionEventArgs();
         RaiseLocalEvent(owner, eventArgs);
+
         QueueDel(owner);
+        return true;
     }
 
     /// <summary>
@@ -23,6 +29,14 @@ public abstract class SharedDestructibleSystem : EntitySystem
     }
 }
 
+/// <summary>
+///     Raised before an entity is about to be destroyed and deleted
+/// </summary>
+public sealed class DestructionAttemptEvent : CancellableEntityEventArgs
+{
+
+}
+
 /// <summary>
 ///     Raised when entity is destroyed and about to be deleted.
 /// </summary>