]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Move replacement chance from ReplacementAccentComponent to ReplacementAccentPrototype...
authorlzk <124214523+lzk228@users.noreply.github.com>
Fri, 17 May 2024 16:33:22 +0000 (18:33 +0200)
committerGitHub <noreply@github.com>
Fri, 17 May 2024 16:33:22 +0000 (19:33 +0300)
Move replacement chance to ReplacementAccentPrototype

Content.Server/Speech/Components/ReplacementAccentComponent.cs
Content.Server/Speech/EntitySystems/ReplacementAccentSystem.cs
Resources/Prototypes/Accents/word_replacements.yml
Resources/Prototypes/Traits/neutral.yml

index e7f57b80d04919f52b1d5ba84d5e3bf0ecfcbeef..037da720290e9598e03cac1d9d6a8ab731afdfcd 100644 (file)
@@ -22,6 +22,12 @@ namespace Content.Server.Speech.Components
         /// </summary>
         [DataField("wordReplacements")]
         public Dictionary<string, string>? WordReplacements;
+
+        /// <summary>
+        /// Allows you to substitute words, not always, but with some chance
+        /// </summary>
+        [DataField]
+        public float ReplacementChance = 1f;
     }
 
     /// <summary>
@@ -33,10 +39,5 @@ namespace Content.Server.Speech.Components
         [DataField("accent", customTypeSerializer: typeof(PrototypeIdSerializer<ReplacementAccentPrototype>), required: true)]
         public string Accent = default!;
 
-        /// <summary>
-        /// Allows you to substitute words, not always, but with some chance
-        /// </summary>
-        [DataField]
-        public float ReplacementChance = 1f;
     }
 }
index da198bcc12b4de48addbe4882caefd3d512ba079..d81d913a365c5aa8d5a85c0b71a50115d7747db1 100644 (file)
@@ -24,9 +24,6 @@ namespace Content.Server.Speech.EntitySystems
 
         private void OnAccent(EntityUid uid, ReplacementAccentComponent component, AccentGetEvent args)
         {
-            if (!_random.Prob(component.ReplacementChance))
-                return;
-
             args.Message = ApplyReplacements(args.Message, component.Accent);
         }
 
@@ -39,6 +36,9 @@ namespace Content.Server.Speech.EntitySystems
             if (!_proto.TryIndex<ReplacementAccentPrototype>(accent, out var prototype))
                 return message;
 
+            if (!_random.Prob(prototype.ReplacementChance))
+                return message;
+
             // Prioritize fully replacing if that exists--
             // ideally both aren't used at the same time (but we don't have a way to enforce that in serialization yet)
             if (prototype.FullReplacements != null)
index 30c739b8453bfb5cfb63340c674187dbb110890c..9a801d786de8eaf0515c4ebdde5e3bd8cd380e27 100644 (file)
 
 - type: accent
   id: liar
+  replacementChance: 0.15
   wordReplacements:
     liar-word-1: liar-word-replacement-1
     liar-word-2: liar-word-replacement-2
     liar-word-39: liar-word-replacement-39
     liar-word-40: liar-word-replacement-40
     liar-word-41: liar-word-replacement-41
-    liar-word-42: liar-word-replacement-42
\ No newline at end of file
+    liar-word-42: liar-word-replacement-42
index d1e0afc83c1431dd7920499d73ffc542e7a44779..78d2bba049616dca844cb777f99caca30afd2d85 100644 (file)
@@ -1,4 +1,4 @@
-- type: trait
+- type: trait
   id: PirateAccent
   name: trait-pirate-accent-name
   description: trait-pirate-accent-desc
@@ -30,5 +30,4 @@
   description: trait-liar-desc
   components:
     - type: ReplacementAccent
-      replacementChance: 0.15
       accent: liar