示例#1
0
        internal static void Dispose()
        {
            if (connectionLifecycle == null)
            {
                throw new InvalidOperationException("Dispose called while not connected.");
            }

            connectionLifecycle = null;
            SignalDisconnection();

            templateProvider = null;
            Disconnecting    = false;
        }
示例#2
0
        /// <summary>
        ///     Start the bootstrap process which results in connecting to SpatialOS.
        /// </summary>
        /// <param name="gameObject">
        ///     The game object that acts as the point of initialisation for the Improbable Fabric connection
        ///     within the scene.
        /// </param>
        /// <remarks>
        ///     It is invalid to call this method before ApplyConfiguration has been called.
        ///     It is invalid to call this multiple times between matching calls to Disconnect.
        /// </remarks>
        public static void Connect(GameObject gameObject)
        {
            if (connectionLifecycle != null)
            {
                throw new InvalidOperationException("Connect called while already connected.");
            }

            if (TemplateProvider == null)
            {
                TemplateProvider = gameObject.GetComponent <IEntityTemplateProvider>() ?? gameObject.AddComponent <DefaultTemplateProvider>();
            }

            connectionLifecycle = gameObject.AddComponent <ConnectionLifecycle>();
        }