Makes tools and welders ECS, add ToolQualityPrototype. (#4741)

This commit is contained in:
Vera Aguilera Puerto
2021-10-07 13:01:27 +02:00
committed by GitHub
parent f2760d0002
commit 365c7da4dc
44 changed files with 1144 additions and 863 deletions

View File

@@ -1,7 +1,12 @@
using System.Linq;
using Content.Shared.Examine;
using Content.Shared.Tool;
using Content.Shared.Tools;
using Content.Shared.Tools.Components;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Utility;
namespace Content.Shared.Construction.Steps
@@ -9,7 +14,8 @@ namespace Content.Shared.Construction.Steps
[DataDefinition]
public class ToolConstructionGraphStep : ConstructionGraphStep
{
[DataField("tool")] public ToolQuality Tool { get; } = ToolQuality.None;
[DataField("tool", required:true, customTypeSerializer:typeof(PrototypeIdSerializer<ToolQualityPrototype>))]
public string Tool { get; } = string.Empty;
[DataField("fuel")] public float Fuel { get; } = 10;
@@ -19,11 +25,15 @@ namespace Content.Shared.Construction.Steps
{
if (!string.IsNullOrEmpty(ExamineOverride))
{
examinedEvent.Message.AddMarkup(Loc.GetString(ExamineOverride));
examinedEvent.PushMarkup(Loc.GetString(ExamineOverride));
return;
}
examinedEvent.Message.AddMarkup(Loc.GetString("construction-use-tool-entity", ("toolName", Tool.GetToolName())));
if (string.IsNullOrEmpty(Tool) || !IoCManager.Resolve<IPrototypeManager>().TryIndex(Tool, out ToolQualityPrototype? quality))
return;
examinedEvent.PushMarkup(Loc.GetString("construction-use-tool-entity", ("toolName", Loc.GetString(quality.ToolName))));
}
}
}