Files
tbd-station-14/Content.Server/GameObjects/Components/NodeContainer/NodeContainerComponent.cs
py01 01b10cb687 Node serialization change (#1497)
* NodeContainerComponent serializes a set of Nodes with ExposeData

* Fixes Nodes to work when being created by serializer

* ConduitNode

* ConduitPlacer to replace WirePlacer

* ConduitNode ConduitLayer setter

* Map update

* Comments

* Map update again

* Method ordering by privacy

* Removes conduits

* ignored component

* reorg

* map update

* readd wireplacer

Co-authored-by: py01 <pyronetics01@gmail.com>
2020-08-07 02:47:54 +02:00

55 lines
1.4 KiB
C#

using Content.Server.GameObjects.Components.NodeContainer.Nodes;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
using System.Collections.Generic;
namespace Content.Server.GameObjects.Components.NodeContainer
{
/// <summary>
/// Creates and maintains a set of <see cref="Node"/>s.
/// </summary>
[RegisterComponent]
public class NodeContainerComponent : Component
{
public override string Name => "NodeContainer";
[ViewVariables]
public IReadOnlyList<Node> Nodes => _nodes;
private List<Node> _nodes = new List<Node>();
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _nodes, "nodes", new List<Node>());
}
public override void Initialize()
{
base.Initialize();
foreach (var node in _nodes)
{
node.Initialize(Owner);
}
}
protected override void Startup()
{
base.Startup();
foreach (var node in _nodes)
{
node.OnContainerStartup();
}
}
public override void OnRemove()
{
foreach (var node in _nodes)
{
node.OnContainerRemove();
}
base.OnRemove();
}
}
}