* init * upd. * more furniture entries * furniture fully added entries * lightning.ftl * machines.ftl * Merge branch 'ConstructionLocalization' of https://github.com/Rinary1/space-sunrise into pr/179 * materials.ftl * modular.ftl * Create utilities.ftl * Create tools.ftl * Create structures.ftl * storage.ftl * upd storage.ftl * translate storage.ftl * translate modular.ftl * translate materials.ftl * translate machines.ftl * translate lighting.ftl * furniture.ftl translate * add tiles.ftl * bots, tools translate * misc add, translate * Translate some missing weapons * some translations * clothing description * fun.ftl description * Steps Translation * Revert something * New Steps translatings, Web items translate * and some new Web translatings * door staps translate * NameLocalization * ooops * Всё по новой, перевод шагов был дерьмо, теперь materials.ftl * some new reverts * фикс? * apc icon * some clears * steps fully translate * translate * Locale Search fix * пу-пу-пу * ой * Revert "apc icon" This reverts commit 65a3eab80453ab758b6a1e1c155d34938f481644. --------- Co-authored-by: Babaev <babaevyt210@gmail.com>
54 lines
2.3 KiB
C#
54 lines
2.3 KiB
C#
using System.Diagnostics.CodeAnalysis;
|
|
using Content.Shared.Examine;
|
|
using Content.Shared.Stacks;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
|
|
|
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, customTypeSerializer:typeof(PrototypeIdSerializer<StackPrototype>))]
|
|
public string MaterialPrototypeId { get; private set; } = "Steel";
|
|
|
|
[DataField("amount")] public int Amount { get; private set; } = 1;
|
|
|
|
public override void DoExamine(ExaminedEvent examinedEvent)
|
|
{
|
|
var material = IoCManager.Resolve<IPrototypeManager>().Index<StackPrototype>(MaterialPrototypeId);
|
|
|
|
examinedEvent.PushMarkup(Loc.GetString("construction-insert-material-entity", ("amount", Amount),("materialName", Loc.GetString($"ent-{material.Spawn}"))
|
|
));
|
|
}
|
|
|
|
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<StackPrototype>(MaterialPrototypeId);
|
|
|
|
return new ConstructionGuideEntry()
|
|
{
|
|
Localization = "construction-presenter-material-step",
|
|
Arguments = new (string, object)[]{("amount", Amount), ("material", Loc.GetString($"ent-{material.Spawn}"))},
|
|
Icon = material.Icon,
|
|
};
|
|
}
|
|
}
|
|
}
|