protected override IEnumerator Connect() { yield return(base.Connect()); _manager = new NetworkEntityManager(_connection); _manager2 = new NetworkEntityManager(_connection2); }
protected override void Awake() { base.Awake(); if (UnityUtils.EntityManager == null) { #if DEBUG UnityUtils.EntityManager = NetworkEntityManager.Create(new MockConnection(true).AutoUpdate()) .RegisterUnityDefaultTypes() .SetLocalPlayer(new DefaultPlayer("DebugPlayer")); Debug.LogWarning($"{nameof(UnityUtils)}.{nameof(UnityUtils.EntityManager)} is null. " + "A mock connection has been created, so you can test your game in the editor. " + $"Create a {nameof(NetworkEntityManager)} before any network entities are active " + "if you want to connect over the network. Note that this causes an exception " + "outside the Editor in a non-debug build."); #else enabled = false; foreach (var comp in GetComponents <MonoNetworkComponent>()) { comp.enabled = false; } throw new UbernetException("The NetworkEntity could not be activated because " + $"{nameof(UnityUtils)}.{nameof(UnityUtils.EntityManager)} is null. Please connect to a provider " + " and set it to an entity manager before using entities."); #endif } var manager = UnityUtils.EntityManager; if (OwnerId == -1 && AutoRegister && !manager.IsEntityRegistered(this)) { // Register scene objects immediately manager.RegisterEntity(this); } }
public void BeforeEach() { _manager = TestUtils.CreateManagerWithMasterMockService(); _manager2 = TestUtils.CreateManagerWithSlaveMockService(); _manager.SetLocalPlayer(new DefaultPlayer()); _manager2.SetLocalPlayer(new DefaultPlayer()); }
private void Start() { _rigidbody = GetComponent <Rigidbody>(); _networkEntityManager = GameObject.FindGameObjectWithTag("NetworkManager").GetComponent <NetworkEntityManager>(); _networkEntityManager.AddEntity(this); if (entityType == Entity.Movable || entityType == Entity.Damage) { _networkEntityManager.movableEntities.Add(GetComponent <NetworkEntity>()); } }
private void Start() { Thread.CurrentThread.CurrentCulture = new CultureInfo("it"); if (GameObject.FindGameObjectsWithTag("NetworkManager").Length > 1) { Destroy(gameObject); return; } messageHandler = GetComponent <MessageHandler>(); networkPlayer = GetComponent <NetworkPlayers>(); networkMap = GetComponent <NetworkMapManager>(); networkFps = GetComponent <NetworkFPSManager>(); networkEntity = GetComponent <NetworkEntityManager>(); networkLeaderboard = GetComponent <NetworkLeaderboard>(); DontDestroyOnLoad(this); CreateServer(); }
public static NetworkEntityManager RegisterUnityDefaultTypes([NotNull] this NetworkEntityManager entityManager) { RegisterUnityDefaultTypes(entityManager.Connection.Serializer); return(entityManager); }
public static NetworkEntityManager SetAsDefaultEntityManager(this NetworkEntityManager entityManager) { EntityManager = entityManager; return(entityManager); }