ConstructionGL2 Part 2: Better guided steps and recipes. (#5103)

This commit is contained in:
Vera Aguilera Puerto
2021-11-02 11:24:32 +01:00
committed by GitHub
parent 5be8271907
commit 5a5006e4cf
45 changed files with 725 additions and 210 deletions

View File

@@ -6,6 +6,7 @@ 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;
namespace Content.Shared.Construction.Steps
{
@@ -14,16 +15,16 @@ namespace Content.Shared.Construction.Steps
{
// TODO: Make this use the material system.
// TODO TODO: Make the material system not shit.
[DataField("material")] public string MaterialPrototypeId { get; } = "Steel";
[DataField("material", required:true, customTypeSerializer:typeof(PrototypeIdSerializer<StackPrototype>))]
public string MaterialPrototypeId { get; } = "Steel";
[DataField("amount")] public int Amount { get; } = 1;
public StackPrototype MaterialPrototype =>
IoCManager.Resolve<IPrototypeManager>().Index<StackPrototype>(MaterialPrototypeId);
public override void DoExamine(ExaminedEvent examinedEvent)
{
examinedEvent.Message.AddMarkup(Loc.GetString("construction-insert-material-entity", ("amount", Amount), ("materialName", MaterialPrototype.Name)));
var material = IoCManager.Resolve<IPrototypeManager>().Index<StackPrototype>(MaterialPrototypeId);
examinedEvent.Message.AddMarkup(Loc.GetString("construction-insert-material-entity", ("amount", Amount), ("materialName", material.Name)));
}
public override bool EntityValid(IEntity entity)
@@ -40,5 +41,17 @@ namespace Content.Shared.Construction.Steps
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", material.Name)},
Icon = material.Icon,
};
}
}
}