Lathe Messages (#1940)

<!--
This is a semi-strict format, you can add/remove sections as needed but
the order/format should be kept the same
Remove these comments before submitting
-->

# Description

<!--
Explain this PR in as much detail as applicable

Some example prompts to consider:
How might this affect the game? The codebase?
What might be some alternatives to this?
How/Who does this benefit/hurt [the game/codebase]?
-->

Adds lathe messages when new recipes are unlocked, ported from goob LRP

# Changelog

<!--
You can add an author after the `🆑` to change the name that appears
in the changelog (ex: `🆑 Death`)
Leaving it blank will default to your GitHub display name
This includes all available types for the changelog
-->

🆑
- add: Lathes will now notify you when they have new recipes

---------

Signed-off-by: VMSolidus <evilexecutive@gmail.com>
Signed-off-by: EctoplasmIsGood <109397347+EctoplasmIsGood@users.noreply.github.com>
Co-authored-by: BombasterDS <115770678+BombasterDS@users.noreply.github.com>
Co-authored-by: VMSolidus <evilexecutive@gmail.com>
(cherry picked from commit fd9cfbb512e5ff6130ecded09ee498224e29ed2d)
This commit is contained in:
EctoplasmIsGood
2025-03-17 12:19:30 -05:00
committed by Spatison
parent ab790f5356
commit 0059fc4d01
6 changed files with 34 additions and 2 deletions

View File

@@ -29,6 +29,8 @@ using Robust.Server.GameObjects;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Content.Server.Chat.Systems;
using Content.Shared.Chat;
namespace Content.Server.Lathe
{
@@ -50,6 +52,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 ChatSystem _chatSystem = default!; // Goobstation - New recipes message
/// <summary>
/// Per-tick cache
@@ -354,6 +357,15 @@ namespace Content.Server.Lathe
private void OnDatabaseModified(EntityUid uid, LatheComponent component, ref TechnologyDatabaseModifiedEvent args)
{
UpdateUserInterfaceState(uid, component);
// Goobstation - Lathe message on recipes update - Start
if (args.UnlockedRecipes == null || args.UnlockedRecipes.Count == 0)
return;
var recipesCount = args.UnlockedRecipes.Count(recipe => component.DynamicRecipes.Contains(recipe));
if (recipesCount > 0)
_chatSystem.TrySendInGameICMessage(uid, Loc.GetString("lathe-technology-recipes-update-message", ("count", recipesCount)), InGameICChatType.Speak, hideChat: true);
// Goobstation - Lathe message on recipes update - End
}
private void OnResearchRegistrationChanged(EntityUid uid, LatheComponent component, ref ResearchRegistrationChangedEvent args)

View File

@@ -132,7 +132,7 @@ public sealed partial class ResearchSystem
}
Dirty(uid, component);
var ev = new TechnologyDatabaseModifiedEvent();
var ev = new TechnologyDatabaseModifiedEvent(technology.RecipeUnlocks); // Goobstation - Lathe message on recipes update
RaiseLocalEvent(uid, ref ev);
}

View File

@@ -2,6 +2,7 @@ using Content.Shared.Lathe;
using Content.Shared.Research.Prototypes;
using Content.Shared.Research.Systems;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
@@ -57,4 +58,12 @@ public sealed partial class TechnologyDatabaseComponent : Component
/// server to all of it's clients.
/// </remarks>
[ByRefEvent]
public readonly record struct TechnologyDatabaseModifiedEvent;
public readonly record struct TechnologyDatabaseModifiedEvent // Goobstation - Lathe message on recipes update
{
public readonly List<ProtoId<LatheRecipePrototype>> UnlockedRecipes;
public TechnologyDatabaseModifiedEvent(List<ProtoId<LatheRecipePrototype>>? unlockedRecipes = null)
{
UnlockedRecipes = unlockedRecipes ?? new();
}
};

View File

@@ -0,0 +1 @@
lathe-technology-recipes-update-message = Lathe database has been updated with {$count} new recipes

View File

@@ -49,6 +49,8 @@
price: 800
- type: ResearchClient
- type: TechnologyDatabase
- type: Speech # Goobstation - Lathe message on recipes update
speechSounds: Lathe
# a lathe that can be sped up with space lube / slowed down with glue
- type: entity

View File

@@ -0,0 +1,8 @@
- type: speechSounds
id: Lathe
saySound:
path: /Audio/Machines/beep.ogg
askSound:
path: /Audio/Machines/beep.ogg
exclaimSound:
path: /Audio/Machines/beep.ogg