ECS-ify Construction[Ghost]Component IExamine.

This commit is contained in:
Pieter-Jan Briers
2021-09-15 16:36:43 +02:00
parent 9733d35de7
commit ce6e37bdd8
12 changed files with 121 additions and 108 deletions

View File

@@ -1,40 +1,15 @@
using Content.Shared.Construction.Prototypes;
using Content.Shared.Examine;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
namespace Content.Client.Construction
{
[RegisterComponent]
public class ConstructionGhostComponent : Component, IExamine
public class ConstructionGhostComponent : Component
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public override string Name => "ConstructionGhost";
[ViewVariables] public ConstructionPrototype? Prototype { get; set; }
[ViewVariables] public int GhostId { get; set; }
void IExamine.Examine(FormattedMessage message, bool inDetailsRange)
{
if (Prototype == null) return;
message.AddMarkup(Loc.GetString("construction-ghost-examine-message", ("name", Prototype.Name)));
if (!_prototypeManager.TryIndex(Prototype.Graph, out ConstructionGraphPrototype? graph)) return;
var startNode = graph.Nodes[Prototype.StartNode];
if (!graph.TryPath(Prototype.StartNode, Prototype.TargetNode, out var path) ||
!startNode.TryGetEdge(path[0].Name, out var edge))
{
return;
}
edge.Steps[0].DoExamine(message, inDetailsRange);
}
}
}