* 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>
55 lines
2.2 KiB
C#
55 lines
2.2 KiB
C#
using System.Diagnostics.CodeAnalysis;
|
|
using Content.Shared.Examine;
|
|
using Content.Shared.Stacks;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Shared.Construction.Steps
|
|
{
|
|
[DataDefinition]
|
|
public sealed partial class MaterialConstructionGraphStep : EntityInsertConstructionGraphStep
|
|
{
|
|
// TODO: Make this use the material system.
|
|
// TODO TODO: Make the material system not shit.
|
|
[DataField("material", required:true)]
|
|
public ProtoId<StackPrototype> MaterialPrototypeId { get; private set; }
|
|
|
|
[DataField] public int Amount { get; private set; } = 1;
|
|
|
|
public override void DoExamine(ExaminedEvent examinedEvent)
|
|
{
|
|
var material = IoCManager.Resolve<IPrototypeManager>().Index(MaterialPrototypeId);
|
|
var materialName = Loc.GetString(material.Name, ("amount", Amount));
|
|
|
|
examinedEvent.PushMarkup(Loc.GetString("construction-insert-material-entity", ("amount", Amount), ("materialName", materialName)));
|
|
}
|
|
|
|
public override bool EntityValid(EntityUid uid, IEntityManager entityManager, IComponentFactory compFactory)
|
|
{
|
|
return entityManager.TryGetComponent(uid, out StackComponent? stack) && stack.StackTypeId == MaterialPrototypeId && stack.Count >= Amount;
|
|
}
|
|
|
|
public bool EntityValid(EntityUid entity, [NotNullWhen(true)] out StackComponent? stack)
|
|
{
|
|
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out StackComponent? otherStack) && otherStack.StackTypeId == MaterialPrototypeId && otherStack.Count >= Amount)
|
|
stack = otherStack;
|
|
else
|
|
stack = null;
|
|
|
|
return stack != null;
|
|
}
|
|
|
|
public override ConstructionGuideEntry GenerateGuideEntry()
|
|
{
|
|
var material = IoCManager.Resolve<IPrototypeManager>().Index(MaterialPrototypeId);
|
|
var materialName = Loc.GetString(material.Name, ("amount", Amount));
|
|
|
|
return new ConstructionGuideEntry()
|
|
{
|
|
Localization = "construction-presenter-material-step",
|
|
Arguments = new (string, object)[]{("amount", Amount), ("material", materialName)},
|
|
Icon = material.Icon,
|
|
};
|
|
}
|
|
}
|
|
}
|