Add technology to tech disk names (#38157)

This commit is contained in:
eoineoineoin
2025-06-11 02:15:56 +01:00
committed by GitHub
parent 1c99b8405b
commit 419b4e7916
2 changed files with 18 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
using Content.Shared.Examine; using Content.Shared.Examine;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Lathe; using Content.Shared.Lathe;
using Content.Shared.NameModifier.EntitySystems;
using Content.Shared.Popups; using Content.Shared.Popups;
using Content.Shared.Random.Helpers; using Content.Shared.Random.Helpers;
using Content.Shared.Research.Components; using Content.Shared.Research.Components;
@@ -20,6 +21,7 @@ public sealed class TechnologyDiskSystem : EntitySystem
[Dependency] private readonly SharedPopupSystem _popup = default!; [Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly SharedResearchSystem _research = default!; [Dependency] private readonly SharedResearchSystem _research = default!;
[Dependency] private readonly SharedLatheSystem _lathe = default!; [Dependency] private readonly SharedLatheSystem _lathe = default!;
[Dependency] private readonly NameModifierSystem _nameModifier = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -28,6 +30,7 @@ public sealed class TechnologyDiskSystem : EntitySystem
SubscribeLocalEvent<TechnologyDiskComponent, MapInitEvent>(OnMapInit); SubscribeLocalEvent<TechnologyDiskComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<TechnologyDiskComponent, AfterInteractEvent>(OnAfterInteract); SubscribeLocalEvent<TechnologyDiskComponent, AfterInteractEvent>(OnAfterInteract);
SubscribeLocalEvent<TechnologyDiskComponent, ExaminedEvent>(OnExamine); SubscribeLocalEvent<TechnologyDiskComponent, ExaminedEvent>(OnExamine);
SubscribeLocalEvent<TechnologyDiskComponent, RefreshNameModifiersEvent>(OnRefreshNameModifiers);
} }
private void OnMapInit(Entity<TechnologyDiskComponent> ent, ref MapInitEvent args) private void OnMapInit(Entity<TechnologyDiskComponent> ent, ref MapInitEvent args)
@@ -55,6 +58,7 @@ public sealed class TechnologyDiskSystem : EntitySystem
ent.Comp.Recipes = []; ent.Comp.Recipes = [];
ent.Comp.Recipes.Add(_random.Pick(techs)); ent.Comp.Recipes.Add(_random.Pick(techs));
Dirty(ent); Dirty(ent);
_nameModifier.RefreshNameModifiers(ent.Owner);
} }
private void OnAfterInteract(Entity<TechnologyDiskComponent> ent, ref AfterInteractEvent args) private void OnAfterInteract(Entity<TechnologyDiskComponent> ent, ref AfterInteractEvent args)
@@ -90,4 +94,16 @@ public sealed class TechnologyDiskSystem : EntitySystem
} }
args.PushMarkup(message); 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)));
}
}
}
} }

View File

@@ -2,6 +2,7 @@ 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-none = The label is blank.
tech-disk-examine = The label has a small dot matrix printed image depicting a {$result}. 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-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-name = technology disk terminal
tech-disk-ui-total-label = There are {$amount} points on the selected server tech-disk-ui-total-label = There are {$amount} points on the selected server