2020-10-08 17:41:23 +02:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2021-09-15 16:36:43 +02:00
|
|
|
using Content.Shared.Examine;
|
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;
|
2021-06-21 02:13:54 +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
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Shared.Construction.Steps
|
2020-10-08 17:41:23 +02:00
|
|
|
{
|
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-05-04 15:37:16 +02:00
|
|
|
[DataField("material")] public string MaterialPrototypeId { get; } = "Steel";
|
2021-03-05 01:08:38 +01:00
|
|
|
|
2021-05-04 15:37:16 +02:00
|
|
|
[DataField("amount")] public int Amount { get; } = 1;
|
2021-02-25 06:18:29 +01:00
|
|
|
|
|
|
|
|
public StackPrototype MaterialPrototype =>
|
|
|
|
|
IoCManager.Resolve<IPrototypeManager>().Index<StackPrototype>(MaterialPrototypeId);
|
|
|
|
|
|
2021-09-15 16:36:43 +02:00
|
|
|
public override void DoExamine(ExaminedEvent examinedEvent)
|
2020-10-08 17:41:23 +02:00
|
|
|
{
|
2021-09-15 16:36:43 +02:00
|
|
|
examinedEvent.Message.AddMarkup(Loc.GetString("construction-insert-material-entity", ("amount", Amount), ("materialName", 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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|