You can now examine Node Containers to see their "connectors" (#2881)

This commit is contained in:
Vera Aguilera Puerto
2021-01-01 14:20:23 +01:00
committed by GitHub
parent 9af508e0b5
commit 483f7f4385
7 changed files with 46 additions and 1 deletions

View File

@@ -1,7 +1,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using Content.Server.GameObjects.Components.NodeContainer.NodeGroups;
using Content.Server.GameObjects.Components.NodeContainer.Nodes; using Content.Server.GameObjects.Components.NodeContainer.Nodes;
using Content.Shared.GameObjects.EntitySystems;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.NodeContainer 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. /// Creates and maintains a set of <see cref="Node"/>s.
/// </summary> /// </summary>
[RegisterComponent] [RegisterComponent]
public class NodeContainerComponent : Component public class NodeContainerComponent : Component, IExamine
{ {
public override string Name => "NodeContainer"; public override string Name => "NodeContainer";
[ViewVariables] [ViewVariables]
public IReadOnlyList<Node> Nodes => _nodes; public IReadOnlyList<Node> Nodes => _nodes;
private List<Node> _nodes = new(); private List<Node> _nodes = new();
private bool _examinable;
public override void ExposeData(ObjectSerializer serializer) public override void ExposeData(ObjectSerializer serializer)
{ {
base.ExposeData(serializer); base.ExposeData(serializer);
serializer.DataField(ref _nodes, "nodes", new List<Node>()); serializer.DataField(ref _nodes, "nodes", new List<Node>());
serializer.DataField(ref _examinable, "examinable", false);
} }
public override void Initialize() public override void Initialize()
@@ -50,5 +56,34 @@ namespace Content.Server.GameObjects.Components.NodeContainer
} }
base.OnRemove(); 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");
}
}
} }
} }

View File

@@ -1,5 +1,6 @@
#nullable enable #nullable enable
using System; using System;
using Content.Server.GameObjects.Components.NodeContainer;
using Content.Server.GameObjects.Components.NodeContainer.NodeGroups; using Content.Server.GameObjects.Components.NodeContainer.NodeGroups;
using Content.Shared.GameObjects.Components.Power; using Content.Shared.GameObjects.Components.Power;
using Content.Shared.GameObjects.EntitySystems; using Content.Shared.GameObjects.EntitySystems;

View File

@@ -225,6 +225,7 @@
- type: PowerConsumer - type: PowerConsumer
voltage: High voltage: High
- type: NodeContainer - type: NodeContainer
examinable: true
nodes: nodes:
- !type:AdjacentNode - !type:AdjacentNode
nodeGroupID: HVPower nodeGroupID: HVPower

View File

@@ -30,6 +30,7 @@
sprite: Constructible/Power/power.rsi sprite: Constructible/Power/power.rsi
state: generator state: generator
- type: NodeContainer - type: NodeContainer
examinable: true
nodes: nodes:
- !type:AdjacentNode - !type:AdjacentNode
nodeGroupID: HVPower nodeGroupID: HVPower
@@ -80,6 +81,7 @@
maxCharge: 1000 maxCharge: 1000
startingCharge: 1000 startingCharge: 1000
- type: NodeContainer - type: NodeContainer
examinable: true
nodes: nodes:
- !type:AdjacentNode - !type:AdjacentNode
nodeGroupID: HVPower nodeGroupID: HVPower
@@ -131,6 +133,7 @@
maxCharge: 1000 maxCharge: 1000
startingCharge: 1000 startingCharge: 1000
- type: NodeContainer - type: NodeContainer
examinable: true
nodes: nodes:
- !type:AdjacentNode - !type:AdjacentNode
nodeGroupID: HVPower nodeGroupID: HVPower
@@ -177,6 +180,7 @@
maxCharge: 10000 maxCharge: 10000
startingCharge: 10000 startingCharge: 10000
- type: NodeContainer - type: NodeContainer
examinable: true
nodes: nodes:
- !type:AdjacentNode - !type:AdjacentNode
nodeGroupID: MVPower nodeGroupID: MVPower
@@ -226,6 +230,7 @@
sprite: Constructible/Power/solar_panel.rsi sprite: Constructible/Power/solar_panel.rsi
state: normal state: normal
- type: NodeContainer - type: NodeContainer
examinable: true
nodes: nodes:
- !type:AdjacentNode - !type:AdjacentNode
nodeGroupID: HVPower nodeGroupID: HVPower

View File

@@ -43,6 +43,7 @@
visuals: visuals:
- type: AMEControllerVisualizer - type: AMEControllerVisualizer
- type: NodeContainer - type: NodeContainer
examinable: true
nodes: nodes:
- !type:AdjacentNode - !type:AdjacentNode
nodeGroupID: AMEngine nodeGroupID: AMEngine

View File

@@ -38,6 +38,7 @@
- type: PowerConsumer - type: PowerConsumer
voltage: Medium voltage: Medium
- type: NodeContainer - type: NodeContainer
examinable: true
nodes: nodes:
- !type:AdjacentNode - !type:AdjacentNode
nodeGroupID: MVPower nodeGroupID: MVPower

View File

@@ -51,6 +51,7 @@
visuals: visuals:
- type: RadiationCollectorVisualizer - type: RadiationCollectorVisualizer
- type: NodeContainer - type: NodeContainer
examinable: true
nodes: nodes:
- !type:AdjacentNode - !type:AdjacentNode
nodeGroupID: HVPower nodeGroupID: HVPower