using Syntriax.Engine.Core; using Syntriax.Engine.Network.Abstract; namespace Syntriax.Engine.Network; public class NetworkBehaviour : BehaviourOverride, INetworkBehaviour, INetworkEntity { public int NetworkId { get; private set; } = 0; public bool LocalAssigned { get; private set; } = false; public bool IsServer { get; private set; } = false; public bool IsClient { get; private set; } = false; public INetworkCommunicator NetworkCommunicator { get; private set; } = null!; protected override void OnInitialize() { NetworkCommunicator = BehaviourController.GetBehaviourInParent() ?? GameObject.GameManager.FindBehaviour() ?? throw new System.Exception($"Could not find an {nameof(INetworkCommunicator)}."); if (NetworkCommunicator is INetworkClient client) { IsClient = true; return; } IsServer = true; LocalAssigned = true; // TODO Set and send Network Id } int INetworkEntity.NetworkId { get => NetworkId; set => NetworkId = value; } void INetworkEntity.SetNetworkId(int id) => NetworkId = id; }