Files
tbd-station-14/Content.Shared/Construction/MaterialConstructionGraphStep.cs
Acruid ca4fd649fe Massive Namespace Cleanup (#3120)
* Engine namespace changes.

* Automated remove redundant using statements.

* Simplified Graphics namespace.

* Apparently the container system stores full type names in the map file.😞 This updates those names.

* API Changes to LocalizationManager.LoadCulture.

* Update submodule to v0.3.2
2021-02-11 01:13:03 -08:00

47 lines
1.6 KiB
C#

#nullable enable
using System.Diagnostics.CodeAnalysis;
using Content.Shared.GameObjects.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
namespace Content.Shared.Construction
{
public class MaterialConstructionGraphStep : EntityInsertConstructionGraphStep
{
// TODO: Make this use the material system.
// TODO TODO: Make the material system not shit.
public StackType Material { get; private set; }
public int Amount { get; private set; }
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(this, x => x.Material, "material", StackType.Metal);
serializer.DataField(this, x => x.Amount, "amount", 1);
}
public override void DoExamine(FormattedMessage message, bool inDetailsRange)
{
message.AddMarkup(Loc.GetString("Next, add [color=yellow]{0}x[/color] [color=cyan]{1}[/color].", Amount, Material));
}
public override bool EntityValid(IEntity entity)
{
return entity.TryGetComponent(out SharedStackComponent? stack) && stack.StackType.Equals(Material);
}
public bool EntityValid(IEntity entity, [NotNullWhen(true)] out SharedStackComponent? stack)
{
if(entity.TryGetComponent(out SharedStackComponent? otherStack) && otherStack.StackType.Equals(Material))
stack = otherStack;
else
stack = null;
return stack != null;
}
}
}