internal DispatchEventHandler(MonoBehaviour hostBehaviour, SpatialCommunicator spatialCommunicator) { entityInterestedComponentsUpdater = new EntityComponentInterestOverridesUpdater(hostBehaviour, SpatialOS.WorkerComponentInterestModifier); entityInterestedComponentsUpdater.AddUpdateReceiver(this); this.spatialCommunicator = spatialCommunicator; authorityChangedNotifier = new AuthorityChangedNotifier(LocalEntities.Instance); authorityChangedNotifier.RegisterAuthorityChangedReceiver(this); }
private void Start() { PrintClientInfo(); parameters = CreateWorkerConnectionParameters(SpatialOS.Configuration); View = new View(); View.OnDisconnect(SpatialOS.Disconnected); deferredActionDispatcher = new DeferredActionDispatcher(); spatialCommunicator = new SpatialCommunicator(null, View, deferredActionDispatcher); eventHandler = new DispatchEventHandler(this, spatialCommunicator); InitializeEntityPipeline(); // The current MonoBehaviour could be destroyed in response to aborted connection attempts, // causing leaks of unmanaged resources due to in-progress coroutines not running to completion. // Create a new host MonoBehaviour and run on it instead. var starter = gameObject.GetComponent <ConnectionCoroutineHost>() ?? gameObject.AddComponent <ConnectionCoroutineHost>(); starter.StartCoroutine(Connect()); }