]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add technology to tech disk names (#38157)
authoreoineoineoin <helloworld@eoinrul.es>
Wed, 11 Jun 2025 01:15:56 +0000 (02:15 +0100)
committerGitHub <noreply@github.com>
Wed, 11 Jun 2025 01:15:56 +0000 (03:15 +0200)
Content.Shared/Research/TechnologyDisk/Systems/TechnologyDiskSystem.cs
Resources/Locale/en-US/research/components/technology-disk.ftl

index d647b3c1e6887ec2177b8ca475964bcf47ab65b2..6fe11746194390aa6f62380e1de0fca2a8f1077d 100644 (file)
@@ -1,6 +1,7 @@
 using Content.Shared.Examine;
 using Content.Shared.Interaction;
 using Content.Shared.Lathe;
+using Content.Shared.NameModifier.EntitySystems;
 using Content.Shared.Popups;
 using Content.Shared.Random.Helpers;
 using Content.Shared.Research.Components;
@@ -20,6 +21,7 @@ public sealed class TechnologyDiskSystem : EntitySystem
     [Dependency] private readonly SharedPopupSystem _popup = default!;
     [Dependency] private readonly SharedResearchSystem _research = default!;
     [Dependency] private readonly SharedLatheSystem _lathe = default!;
+    [Dependency] private readonly NameModifierSystem _nameModifier = default!;
 
     public override void Initialize()
     {
@@ -28,6 +30,7 @@ public sealed class TechnologyDiskSystem : EntitySystem
         SubscribeLocalEvent<TechnologyDiskComponent, MapInitEvent>(OnMapInit);
         SubscribeLocalEvent<TechnologyDiskComponent, AfterInteractEvent>(OnAfterInteract);
         SubscribeLocalEvent<TechnologyDiskComponent, ExaminedEvent>(OnExamine);
+        SubscribeLocalEvent<TechnologyDiskComponent, RefreshNameModifiersEvent>(OnRefreshNameModifiers);
     }
 
     private void OnMapInit(Entity<TechnologyDiskComponent> ent, ref MapInitEvent args)
@@ -55,6 +58,7 @@ public sealed class TechnologyDiskSystem : EntitySystem
         ent.Comp.Recipes = [];
         ent.Comp.Recipes.Add(_random.Pick(techs));
         Dirty(ent);
+        _nameModifier.RefreshNameModifiers(ent.Owner);
     }
 
     private void OnAfterInteract(Entity<TechnologyDiskComponent> ent, ref AfterInteractEvent args)
@@ -90,4 +94,16 @@ public sealed class TechnologyDiskSystem : EntitySystem
         }
         args.PushMarkup(message);
     }
+
+    private void OnRefreshNameModifiers(Entity<TechnologyDiskComponent> entity, ref RefreshNameModifiersEvent args)
+    {
+        if (entity.Comp.Recipes != null)
+        {
+            foreach (var recipe in entity.Comp.Recipes)
+            {
+                var proto = _protoMan.Index(recipe);
+                args.AddModifier("tech-disk-name-format", extraArgs: ("technology", _lathe.GetRecipeName(proto)));
+            }
+        }
+    }
 }
index 4f72532010eeb2cae89308df1f5df84ec6871a1e..90992f76d78c446fc1294922f1ae6786e9638b16 100644 (file)
@@ -2,8 +2,9 @@ tech-disk-inserted = You insert the disk, adding a new recipe to the server.
 tech-disk-examine-none = The label is blank.
 tech-disk-examine = The label has a small dot matrix printed image depicting a {$result}.
 tech-disk-examine-more = There are more images printed, but they're too small to discern.
+tech-disk-name-format = {$baseName} ({$technology})
 
 tech-disk-ui-name = technology disk terminal
 tech-disk-ui-total-label = There are {$amount} points on the selected server
 tech-disk-ui-cost-label = Each disk costs {$amount} points to print
-tech-disk-ui-print-button = Print Disk
\ No newline at end of file
+tech-disk-ui-print-button = Print Disk