Files
tbd-station-14/Content.Shared/Construction/NodeEntities/BoardNodeEntity.cs
Ertanic 81507b9d52 Localizable craftmenu (#32339)
* Now the name of the target craft items is taken directly from the prototypes

* Deleting unnecessary fields

* Deleting unnecessary fields

* Added suffix field

* Added override via localization keys

* My favorite ItemList and TextureRect have been replaced with ListContainer and EntityPrototypeView

* Fix suffix

* Fix construction ghosts... maybe

* Remove suffix from UI

* Suffixes have been removed from prototypes

* Added a description for the secret door

* Fix search..?

* The Icon field of ConstructionPrototype has been removed

* StackPrototypes used in the construction menu have been localized

* TagConstructionGraphStep used in the construction menu have been localized

* The search bar has been localized

* Fix localization and prototypes

* Recipes are now only loaded when the crafting window is opened.

* Fix crooked merge grid of the crafting menu.

* Localization update

* Fix cyborg graph

* Revert "Recipes are now only loaded when the crafting window is opened."

This reverts commit 97749483542c2d6272bda16edf49612c69a0761a.

* Fix loc

* fix merge

* Fix upstream

* Some of the logic has been moved to Shared

* fix

* Small adjustments

* Very small change

---------

Co-authored-by: EmoGarbage404 <retron404@gmail.com>
2025-05-01 10:21:16 -04:00

40 lines
1.4 KiB
C#

using Content.Shared.Construction.Components;
using JetBrains.Annotations;
using Robust.Shared.Containers;
namespace Content.Shared.Construction.NodeEntities;
/// <summary>
/// Works for both <see cref="ComputerBoardComponent"/> and <see cref="MachineBoardComponent"/>
/// because duplicating code just for this is really stinky.
/// </summary>
[UsedImplicitly]
[DataDefinition]
public sealed partial class BoardNodeEntity : IGraphNodeEntity
{
[DataField("container")] public string Container { get; private set; } = string.Empty;
public string? GetId(EntityUid? uid, EntityUid? userUid, GraphNodeEntityArgs args)
{
if (uid == null)
return null;
var containerSystem = args.EntityManager.EntitySysManager.GetEntitySystem<SharedContainerSystem>();
if (!containerSystem.TryGetContainer(uid.Value, Container, out var container)
|| container.ContainedEntities.Count == 0)
return null;
var board = container.ContainedEntities[0];
// There should not be a case where both of these components exist on the same entity...
if (args.EntityManager.TryGetComponent(board, out MachineBoardComponent? machine))
return machine.Prototype;
if (args.EntityManager.TryGetComponent(board, out ComputerBoardComponent? computer))
return computer.Prototype;
return null;
}
}