]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
fix: properly respect AllowRepeatedMorphs (#39411)
authorPerry Fraser <perryprog@users.noreply.github.com>
Wed, 6 Aug 2025 00:02:52 +0000 (20:02 -0400)
committerGitHub <noreply@github.com>
Wed, 6 Aug 2025 00:02:52 +0000 (02:02 +0200)
* fix: properly respect AllowRepeatedMorphs

* feat: add IgnoreAllowRepeatedMorphs

Content.Server/Polymorph/Systems/PolymorphSystem.cs
Content.Shared/Polymorph/PolymorphPrototype.cs
Resources/Prototypes/Polymorphs/admin.yml

index d411eb77228b82005b0752583126a09d6d97dc22..6b6284b18e2cee9d165fedc4fdfde0cf9fd5e0d0 100644 (file)
@@ -170,15 +170,18 @@ public sealed partial class PolymorphSystem : EntitySystem
     }
 
     /// <summary>
-    /// Polymorphs the target entity into another
+    /// Polymorphs the target entity into another.
     /// </summary>
     /// <param name="uid">The entity that will be transformed</param>
-    /// <param name="configuration">Polymorph data</param>
-    /// <returns></returns>
+    /// <param name="configuration">The new polymorph configuration</param>
+    /// <returns>The new entity, or null if the polymorph failed.</returns>
     public EntityUid? PolymorphEntity(EntityUid uid, PolymorphConfiguration configuration)
     {
-        // if it's already morphed, don't allow it again with this condition active.
-        if (!configuration.AllowRepeatedMorphs && HasComp<PolymorphedEntityComponent>(uid))
+        // If they're morphed, check their current config to see if they can be
+        // morphed again
+        if (!configuration.IgnoreAllowRepeatedMorphs
+            && TryComp<PolymorphedEntityComponent>(uid, out var currentPoly)
+            && !currentPoly.Configuration.AllowRepeatedMorphs)
             return null;
 
         // If this polymorph has a cooldown, check if that amount of time has passed since the
index d731c4bfc552f61e9cb615401e8c26c4caec5284..0978d7119a3c8ec799106f20f176d4ed105b54c6 100644 (file)
@@ -112,11 +112,21 @@ public sealed partial record PolymorphConfiguration
     public bool RevertOnEat;
 
     /// <summary>
-    /// Whether or not an already polymorphed entity is able to be polymorphed again
+    /// If true, attempts to polymorph this polymorph will fail, unless
+    /// <see cref="IgnoreAllowRepeatedMorphs"/> is true on the /new/ morph.
     /// </summary>
     [DataField(serverOnly: true)]
     public bool AllowRepeatedMorphs;
 
+    /// <summary>
+    /// If true, this morph will succeed even when used on an entity
+    /// that is already polymorphed with a configuration that has
+    /// <see cref="AllowRepeatedMorphs"/> set to false. Helpful for
+    /// smite polymorphs which should always succeed.
+    /// </summary>
+    [DataField(serverOnly: true)]
+    public bool IgnoreAllowRepeatedMorphs;
+
     /// <summary>
     /// The amount of time that should pass after this polymorph has ended, before a new one
     /// can occur.
index cb274ec7d4343e5fff3076802d009b6fbcfe4217..3739175c8aa6e49ca97d9a1661154ec74a847eb7 100644 (file)
@@ -6,7 +6,7 @@
     transferName: true
     transferHumanoidAppearance: true
     inventory: Transfer
-    allowRepeatedMorphs: true
+    ignoreAllowRepeatedMorphs: true
 
 - type: polymorph
   id: AdminMonkeySmite
@@ -14,7 +14,7 @@
     entity: MobMonkey
     forced: true
     inventory: Drop
-    allowRepeatedMorphs: true
+    ignoreAllowRepeatedMorphs: true
 
 - type: polymorph
   id: AdminBreadSmite
@@ -22,7 +22,7 @@
     entity: FoodBreadPlain
     forced: true
     inventory: Drop
-    allowRepeatedMorphs: true
+    ignoreAllowRepeatedMorphs: true
 
 - type: polymorph
   id: AdminInstrumentSmite
@@ -30,7 +30,7 @@
     entity: SuperSynthesizerInstrument
     forced: true
     inventory: Drop
-    allowRepeatedMorphs: true
+    ignoreAllowRepeatedMorphs: true
 
 - type: polymorph
   id: AdminMouseSmite
@@ -38,7 +38,7 @@
     entity: MobMouse
     forced: true
     inventory: Drop
-    allowRepeatedMorphs: true
+    ignoreAllowRepeatedMorphs: true
 
 - type: polymorph
   id: AdminDisposalsSmite
@@ -46,4 +46,4 @@
     entity: DisposalUnit
     forced: true
     inventory: Drop
-    allowRepeatedMorphs: true
+    ignoreAllowRepeatedMorphs: true