Helper methods for NodeContainer
Including a GetNode<T> and TryGetNode<T>
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using Content.Server.GameObjects.Components.NodeContainer.NodeGroups;
|
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 Content.Shared.GameObjects.EntitySystems;
|
||||||
@@ -64,6 +65,23 @@ namespace Content.Server.GameObjects.Components.NodeContainer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public T GetNode<T>(string identifier) where T : Node
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
node = t;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
node = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void Examine(FormattedMessage message, bool inDetailsRange)
|
public void Examine(FormattedMessage message, bool inDetailsRange)
|
||||||
{
|
{
|
||||||
if (!_examinable || !inDetailsRange) return;
|
if (!_examinable || !inDetailsRange) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user