Add chatty lathes (#34959)
This commit is contained in:
committed by
GitHub
parent
be5bbd4dc3
commit
5d38ae56de
@@ -8,6 +8,7 @@ using Content.Server.Materials;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Server.Radio.EntitySystems;
|
||||
using Content.Server.Stack;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
@@ -20,6 +21,7 @@ using Content.Shared.Emag.Systems;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Lathe;
|
||||
using Content.Shared.Lathe.Prototypes;
|
||||
using Content.Shared.Localizations;
|
||||
using Content.Shared.Materials;
|
||||
using Content.Shared.Power;
|
||||
using Content.Shared.ReagentSpeed;
|
||||
@@ -53,6 +55,7 @@ namespace Content.Server.Lathe
|
||||
[Dependency] private readonly SharedSolutionContainerSystem _solution = default!;
|
||||
[Dependency] private readonly StackSystem _stack = default!;
|
||||
[Dependency] private readonly TransformSystem _transform = default!;
|
||||
[Dependency] private readonly RadioSystem _radio = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Per-tick cache
|
||||
@@ -67,6 +70,7 @@ namespace Content.Server.Lathe
|
||||
SubscribeLocalEvent<LatheComponent, MapInitEvent>(OnMapInit);
|
||||
SubscribeLocalEvent<LatheComponent, PowerChangedEvent>(OnPowerChanged);
|
||||
SubscribeLocalEvent<LatheComponent, TechnologyDatabaseModifiedEvent>(OnDatabaseModified);
|
||||
SubscribeLocalEvent<LatheAnnouncingComponent, TechnologyDatabaseModifiedEvent>(OnTechnologyDatabaseModified);
|
||||
SubscribeLocalEvent<LatheComponent, ResearchRegistrationChangedEvent>(OnResearchRegistrationChanged);
|
||||
|
||||
SubscribeLocalEvent<LatheComponent, LatheQueueRecipeMessage>(OnLatheQueueRecipeMessage);
|
||||
@@ -364,6 +368,41 @@ namespace Content.Server.Lathe
|
||||
UpdateUserInterfaceState(uid, component);
|
||||
}
|
||||
|
||||
private void OnTechnologyDatabaseModified(Entity<LatheAnnouncingComponent> ent, ref TechnologyDatabaseModifiedEvent args)
|
||||
{
|
||||
if (args.NewlyUnlockedRecipes is null)
|
||||
return;
|
||||
|
||||
if (!TryGetAvailableRecipes(ent.Owner, out var potentialRecipes))
|
||||
return;
|
||||
|
||||
var recipeNames = new List<string>();
|
||||
foreach (var recipeId in args.NewlyUnlockedRecipes)
|
||||
{
|
||||
if (!potentialRecipes.Contains(new(recipeId)))
|
||||
continue;
|
||||
|
||||
if (!_proto.TryIndex(recipeId, out LatheRecipePrototype? recipe))
|
||||
continue;
|
||||
|
||||
var itemName = GetRecipeName(recipe!);
|
||||
recipeNames.Add(Loc.GetString("lathe-unlock-recipe-radio-broadcast-item", ("item", itemName)));
|
||||
}
|
||||
|
||||
if (recipeNames.Count == 0)
|
||||
return;
|
||||
|
||||
var message = Loc.GetString(
|
||||
"lathe-unlock-recipe-radio-broadcast",
|
||||
("items", ContentLocalizationManager.FormatList(recipeNames))
|
||||
);
|
||||
|
||||
foreach (var channel in ent.Comp.Channels)
|
||||
{
|
||||
_radio.SendRadioMessage(ent.Owner, message, channel, ent.Owner, escapeMarkup: false);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnResearchRegistrationChanged(EntityUid uid, LatheComponent component, ref ResearchRegistrationChangedEvent args)
|
||||
{
|
||||
UpdateUserInterfaceState(uid, component);
|
||||
|
||||
Reference in New Issue
Block a user