You can now examine Node Containers to see their "connectors" (#2881)
This commit is contained in:
committed by
GitHub
parent
9af508e0b5
commit
483f7f4385
@@ -1,7 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.GameObjects.Components.NodeContainer.NodeGroups;
|
||||
using Content.Server.GameObjects.Components.NodeContainer.Nodes;
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.NodeContainer
|
||||
@@ -10,18 +14,20 @@ namespace Content.Server.GameObjects.Components.NodeContainer
|
||||
/// Creates and maintains a set of <see cref="Node"/>s.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public class NodeContainerComponent : Component
|
||||
public class NodeContainerComponent : Component, IExamine
|
||||
{
|
||||
public override string Name => "NodeContainer";
|
||||
|
||||
[ViewVariables]
|
||||
public IReadOnlyList<Node> Nodes => _nodes;
|
||||
private List<Node> _nodes = new();
|
||||
private bool _examinable;
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
serializer.DataField(ref _nodes, "nodes", new List<Node>());
|
||||
serializer.DataField(ref _examinable, "examinable", false);
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
@@ -50,5 +56,34 @@ namespace Content.Server.GameObjects.Components.NodeContainer
|
||||
}
|
||||
base.OnRemove();
|
||||
}
|
||||
|
||||
public void Examine(FormattedMessage message, bool inDetailsRange)
|
||||
{
|
||||
if (!_examinable || !inDetailsRange) return;
|
||||
|
||||
for (var i = 0; i < Nodes.Count; i++)
|
||||
{
|
||||
var node = Nodes[i];
|
||||
if (node == null) continue;
|
||||
switch (node.NodeGroupID)
|
||||
{
|
||||
case NodeGroupID.HVPower:
|
||||
message.AddMarkup(
|
||||
Loc.GetString("It has a connector for [color=orange]HV cables[/color]."));
|
||||
break;
|
||||
case NodeGroupID.MVPower:
|
||||
message.AddMarkup(
|
||||
Loc.GetString("It has a connector for [color=yellow]MV cables[/color]."));
|
||||
break;
|
||||
case NodeGroupID.Apc:
|
||||
message.AddMarkup(
|
||||
Loc.GetString("It has a connector for [color=green]LV cables[/color]."));
|
||||
break;
|
||||
}
|
||||
|
||||
if(i != Nodes.Count - 1)
|
||||
message.AddMarkup("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user