29 lines
740 B
C#
29 lines
740 B
C#
using Syntriax.Engine.Core;
|
|
|
|
using Syntriax.Engine.Network.Abstract;
|
|
|
|
namespace Syntriax.Engine.Network;
|
|
|
|
public class NetworkManager : NetworkBehaviour, INetworkManager
|
|
{
|
|
private BehaviourCollector<INetworkEntity> entities = null!;
|
|
|
|
private static uint networkIdIndex = 0;
|
|
|
|
protected override void OnInitialize()
|
|
{
|
|
base.OnInitialize();
|
|
|
|
NetworkId = networkIdIndex++;
|
|
|
|
entities = new(GameObject.GameManager);
|
|
foreach (var entity in entities)
|
|
entity.NetworkId = networkIdIndex++;
|
|
|
|
entities.OnCollected += OnCollected;
|
|
}
|
|
|
|
private void OnCollected(BehaviourCollector<INetworkEntity> collector, INetworkEntity entity)
|
|
=> entity.NetworkId = networkIdIndex++;
|
|
}
|