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>
This commit is contained in:
py01
2020-08-06 18:47:54 -06:00
committed by GitHub
parent 551c204a9f
commit 01b10cb687
11 changed files with 6109 additions and 10315 deletions

View File

@@ -1,8 +1,5 @@
using Content.Server.GameObjects.Components.NodeContainer.NodeGroups;
using Content.Server.GameObjects.Components.NodeContainer.Nodes;
using Content.Server.GameObjects.Components.NodeContainer.Nodes;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
using System.Collections.Generic;
@@ -21,37 +18,27 @@ namespace Content.Server.GameObjects.Components.NodeContainer
public IReadOnlyList<Node> Nodes => _nodes;
private List<Node> _nodes = new List<Node>();
#pragma warning disable 649
[Dependency] private readonly INodeFactory _nodeFactory;
#pragma warning restore 649
/// <summary>
/// A set of <see cref="NodeGroupID"/>s and <see cref="Node"/> implementation names
/// to be created and held in this container.
/// </summary>
[ViewVariables]
private Dictionary<NodeGroupID, List<string>> _nodeTypes;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _nodeTypes, "nodeTypes", new Dictionary<NodeGroupID, List<string>> { });
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 nodeType in _nodeTypes)
{
var nodeGroupID = nodeType.Key;
foreach (var nodeName in nodeType.Value)
{
_nodes.Add(MakeNewNode(nodeName, nodeGroupID, Owner));
}
}
foreach (var node in _nodes)
{
node.OnContainerInitialize();
node.OnContainerStartup();
}
}
@@ -61,13 +48,7 @@ namespace Content.Server.GameObjects.Components.NodeContainer
{
node.OnContainerRemove();
}
_nodes = null;
base.OnRemove();
}
private Node MakeNewNode(string nodeName, NodeGroupID groupID, IEntity owner)
{
return _nodeFactory.MakeNode(nodeName, groupID, owner);
}
}
}