2021-06-21 02:13:54 +02:00
|
|
|
using Content.Shared.Construction.Prototypes;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Examine;
|
2019-04-15 21:11:38 -06:00
|
|
|
using Robust.Shared.GameObjects;
|
2020-10-08 17:41:23 +02:00
|
|
|
using Robust.Shared.IoC;
|
2020-08-01 17:37:12 +02:00
|
|
|
using Robust.Shared.Localization;
|
2020-10-08 17:41:23 +02:00
|
|
|
using Robust.Shared.Prototypes;
|
2020-08-01 17:37:12 +02:00
|
|
|
using Robust.Shared.Utility;
|
2019-04-15 21:11:38 -06:00
|
|
|
using Robust.Shared.ViewVariables;
|
2018-08-02 08:29:55 +02:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Client.Construction
|
2018-08-02 08:29:55 +02:00
|
|
|
{
|
2019-07-31 15:02:36 +02:00
|
|
|
[RegisterComponent]
|
2020-08-01 17:37:12 +02:00
|
|
|
public class ConstructionGhostComponent : Component, IExamine
|
2018-08-02 08:29:55 +02:00
|
|
|
{
|
2020-10-08 17:41:23 +02:00
|
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
|
|
|
|
2018-08-02 08:29:55 +02:00
|
|
|
public override string Name => "ConstructionGhost";
|
|
|
|
|
|
2021-03-10 14:48:29 +01:00
|
|
|
[ViewVariables] public ConstructionPrototype? Prototype { get; set; }
|
|
|
|
|
[ViewVariables] public int GhostId { get; set; }
|
2020-08-01 17:37:12 +02:00
|
|
|
|
|
|
|
|
void IExamine.Examine(FormattedMessage message, bool inDetailsRange)
|
|
|
|
|
{
|
2021-03-10 14:48:29 +01:00
|
|
|
if (Prototype == null) return;
|
|
|
|
|
|
2021-06-21 02:13:54 +02:00
|
|
|
message.AddMarkup(Loc.GetString("construction-ghost-examine-message", ("name", Prototype.Name)));
|
2020-10-08 17:41:23 +02:00
|
|
|
|
2021-03-10 14:48:29 +01:00
|
|
|
if (!_prototypeManager.TryIndex(Prototype.Graph, out ConstructionGraphPrototype? graph)) return;
|
2020-10-08 17:41:23 +02:00
|
|
|
var startNode = graph.Nodes[Prototype.StartNode];
|
2021-03-15 21:55:49 +01:00
|
|
|
|
|
|
|
|
if (!graph.TryPath(Prototype.StartNode, Prototype.TargetNode, out var path) ||
|
|
|
|
|
!startNode.TryGetEdge(path[0].Name, out var edge))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-08 17:41:23 +02:00
|
|
|
edge.Steps[0].DoExamine(message, inDetailsRange);
|
2020-08-01 17:37:12 +02:00
|
|
|
}
|
2018-08-02 08:29:55 +02:00
|
|
|
}
|
|
|
|
|
}
|