committed by
GitHub
parent
ea60a81fdf
commit
103bc19508
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user