2020-10-08 17:41:23 +02:00
|
|
|
|
#nullable enable
|
|
|
|
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
|
|
|
using Content.Shared.GameObjects.Components;
|
2021-02-25 06:18:29 +01:00
|
|
|
|
using Content.Shared.Stacks;
|
2021-02-11 01:13:03 -08:00
|
|
|
|
using Robust.Shared.GameObjects;
|
2021-02-25 06:18:29 +01:00
|
|
|
|
using Robust.Shared.IoC;
|
2020-10-08 17:41:23 +02:00
|
|
|
|
using Robust.Shared.Localization;
|
2021-02-25 06:18:29 +01:00
|
|
|
|
using Robust.Shared.Prototypes;
|
2021-03-05 01:08:38 +01:00
|
|
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
2020-10-08 17:41:23 +02:00
|
|
|
|
using Robust.Shared.Utility;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Content.Shared.Construction
|
|
|
|
|
|
{
|
2021-03-05 01:08:38 +01:00
|
|
|
|
[DataDefinition]
|
2020-10-08 17:41:23 +02:00
|
|
|
|
public class MaterialConstructionGraphStep : EntityInsertConstructionGraphStep
|
|
|
|
|
|
{
|
|
|
|
|
|
// TODO: Make this use the material system.
|
|
|
|
|
|
// TODO TODO: Make the material system not shit.
|
2021-03-05 01:08:38 +01:00
|
|
|
|
[field: DataField("material")] public string MaterialPrototypeId { get; } = "Steel";
|
|
|
|
|
|
|
|
|
|
|
|
[field: DataField("amount")] public int Amount { get; } = 1;
|
2021-02-25 06:18:29 +01:00
|
|
|
|
|
|
|
|
|
|
public StackPrototype MaterialPrototype =>
|
|
|
|
|
|
IoCManager.Resolve<IPrototypeManager>().Index<StackPrototype>(MaterialPrototypeId);
|
|
|
|
|
|
|
2020-10-08 17:41:23 +02:00
|
|
|
|
public override void DoExamine(FormattedMessage message, bool inDetailsRange)
|
|
|
|
|
|
{
|
2021-02-25 06:18:29 +01:00
|
|
|
|
message.AddMarkup(Loc.GetString("Next, add [color=yellow]{0}x[/color] [color=cyan]{1}[/color].", Amount, MaterialPrototype.Name));
|
2020-10-08 17:41:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool EntityValid(IEntity entity)
|
|
|
|
|
|
{
|
2021-02-25 06:18:29 +01:00
|
|
|
|
return entity.TryGetComponent(out SharedStackComponent? stack) && stack.StackTypeId.Equals(MaterialPrototypeId);
|
2020-10-08 17:41:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool EntityValid(IEntity entity, [NotNullWhen(true)] out SharedStackComponent? stack)
|
|
|
|
|
|
{
|
2021-02-25 06:18:29 +01:00
|
|
|
|
if (entity.TryGetComponent(out SharedStackComponent? otherStack) && otherStack.StackTypeId.Equals(MaterialPrototypeId))
|
2020-10-08 17:41:23 +02:00
|
|
|
|
stack = otherStack;
|
|
|
|
|
|
else
|
|
|
|
|
|
stack = null;
|
|
|
|
|
|
|
|
|
|
|
|
return stack != null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|