rj-action-library/Runtime/Networking/Nodes/AddNetworkingNodes.cs

47 lines
891 B
C#
Raw Normal View History

2025-01-08 18:46:17 +00:00
using Godot;
using System.Collections.Generic;
namespace Rokojori
{
[GlobalClass]
public partial class AddNetworkNodes:Action
{
[Export]
public Node[] nodes;
protected override void _OnTrigger()
{
RJLog.Log( "AddNetworkNodes" );
for ( int i = 0; i < nodes.Length; i++ )
{
AddNodeAndChildren( nodes[ i ] );
}
}
void AddNodeAndChildren( Node root )
{
var walker = new NodesWalker();
var nm = Unique<NetworkManager>.Get();
var rf = nm.references;
walker.Iterate( root,
n =>
{
var isNetworkNode = typeof( INetworkNode ).IsAssignableFrom( n.GetType() );
if ( ! isNetworkNode )
{
return;
}
var inn = (INetworkNode) n;
rf.AddMembersOf( inn );
}
);
}
}
}