Files
tbd-station-14/Content.Shared/Construction/ConstructionGraphNode.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

77 lines
3.0 KiB
C#

using System.Diagnostics.CodeAnalysis;
using Content.Shared.Construction.NodeEntities;
using Content.Shared.Construction.Serialization;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Shared.Construction
{
[Serializable]
[DataDefinition]
public sealed partial class ConstructionGraphNode
{
[DataField("actions", serverOnly: true)]
private IGraphAction[] _actions = Array.Empty<IGraphAction>();
[DataField("edges")]
private ConstructionGraphEdge[] _edges = Array.Empty<ConstructionGraphEdge>();
[DataField("node", required: true)]
public string Name { get; private set; } = default!;
[ViewVariables]
public IReadOnlyList<ConstructionGraphEdge> Edges => _edges;
[ViewVariables]
public IReadOnlyList<IGraphAction> Actions => _actions;
[DataField("transform")]
public IGraphTransform[] TransformLogic = Array.Empty<IGraphTransform>();
[DataField("entity", customTypeSerializer: typeof(GraphNodeEntitySerializer))]
public IGraphNodeEntity Entity { get; private set; } = new NullNodeEntity();
/// <summary>
/// Ignore requests to change the entity if the entity's current prototype inherits from specified replacement
/// </summary>
/// <remarks>
/// When this bool is true and a construction node specifies that the current entity should be replaced with a new entity, if the
/// current entity has an entity prototype which inherits from the replacement entity prototype, entity replacement will not occur.
/// E.g., if an entity with the 'AirlockCommand' prototype was to be replaced with a new entity that had the 'Airlock' prototype,
/// and 'DoNotReplaceInheritingEntities' was true, the entity would not be replaced because 'AirlockCommand' is derived from 'Airlock'
/// This will largely be used for construction graphs which have removeable upgrades, such as hacking protections for airlocks,
/// so that the upgrades can be removed and you can return to the last primary construction step without replacing the entity
/// </remarks>
[DataField("doNotReplaceInheritingEntities")]
public bool DoNotReplaceInheritingEntities = false;
public ConstructionGraphEdge? GetEdge(string target)
{
foreach (var edge in _edges)
{
if (edge.Target == target)
return edge;
}
return null;
}
public int? GetEdgeIndex(string target)
{
for (var i = 0; i < _edges.Length; i++)
{
var edge = _edges[i];
if (edge.Target == target)
return i;
}
return null;
}
public bool TryGetEdge(string target, [NotNullWhen(true)] out ConstructionGraphEdge? edge)
{
return (edge = GetEdge(target)) != null;
}
}
}