Pow3r: stage 1 (#4208)

Co-authored-by: 20kdc <asdd2808@gmail.com>
This commit is contained in:
Pieter-Jan Briers
2021-07-04 18:11:52 +02:00
committed by GitHub
parent ea60a81fdf
commit 103bc19508
212 changed files with 8584 additions and 4426 deletions

View File

@@ -20,60 +20,18 @@ namespace Content.Server.NodeContainer
{
public override string Name => "NodeContainer";
[ViewVariables]
public IReadOnlyDictionary<string, Node> Nodes => _nodes;
[DataField("nodes")] [ViewVariables] public Dictionary<string, Node> Nodes { get; } = new();
[DataField("nodes")]
private readonly Dictionary<string, Node> _nodes = new();
[DataField("examinable")]
private bool _examinable = false;
protected override void Initialize()
{
base.Initialize();
foreach (var node in _nodes.Values)
{
node.Initialize(Owner);
}
}
protected override void Startup()
{
base.Startup();
foreach (var node in _nodes.Values)
{
node.OnContainerStartup();
}
}
protected override void Shutdown()
{
base.Shutdown();
foreach (var node in _nodes.Values)
{
node.OnContainerShutdown();
}
}
public void AnchorUpdate()
{
foreach (var node in Nodes.Values)
{
node.AnchorUpdate();
node.AnchorStateChanged();
}
}
[DataField("examinable")] private bool _examinable = false;
public T GetNode<T>(string identifier) where T : Node
{
return (T)_nodes[identifier];
return (T) Nodes[identifier];
}
public bool TryGetNode<T>(string identifier, [NotNullWhen(true)] out T? node) where T : Node
{
if (_nodes.TryGetValue(identifier, out var n) && n is T t)
if (Nodes.TryGetValue(identifier, out var n) && n is T t)
{
node = t;
return true;