Exemplo n.º 1
0
        internal override Queue <InternalSceneRequest> BuildRequests(SceneCollection collection)
        {
            // Beforehand, we check once again that the request is valid
            // If it's not, this is a development error, warn user and return
            Queue <InternalSceneRequest> requestsUnload = _unloadStrategy.CreateRequests(collection, _forceNotSuppressible);

            if (Inspection(collection).IsSuccess == false)
            {
                Debug.LogError("Development error -- Contact developer -- Initial inspection went wrong, this request should have been denied");
                return(null);
            }
            if (requestsUnload == null)
            {
                Debug.LogError("Development error -- Contact developer -- Initial inspection went wrong, this request should have been denied");
                return(null);
            }

            // First of all, let's marshall all data input to convert them into an internal format
            // Then, from marshalled data, feeded bundle properties to scenes datas
            List <InternalSceneData> marshalledScenesToLoad = MarshallToInternalFormat(_bundle.Scenes);
            List <InternalSceneData> bundleScenesToLoad     = BundleIdentifierAttribution(collection, marshalledScenesToLoad);

            Queue <InternalSceneRequest> requests = new Queue <InternalSceneRequest>();

            requests.AddRange(requestsUnload);
            bundleScenesToLoad.ForEach(data => requests.Enqueue(new InternalSceneRequestLoad(data)));

            return(requests);
        }
Exemplo n.º 2
0
        //=============================================================================//
        //============ Internal Methods
        //=============================================================================//
        #region Internal Methods
        internal override SceneLoaderRequestResult Inspection(SceneCollection collection)
        {
            SceneLoaderRequestResult resultSceneInspection = ScenesExistsInspection(collection);

            if (resultSceneInspection.IsSuccess == false)
            {
                return(resultSceneInspection);
            }

            SceneLoaderRequestResult resultBundleInspection = BundleExistsInspection(collection);

            if (resultBundleInspection.IsSuccess == false)
            {
                return(resultBundleInspection);
            }

            SceneLoaderRequestResult resultAdditionalInspection = AdditionalInspection(collection);

            if (resultAdditionalInspection.IsSuccess == false)
            {
                return(resultAdditionalInspection);
            }

            return(SceneLoaderConstants.REQUEST_RESULTS[SceneLoaderReturnType.Accepted]);
        }
Exemplo n.º 3
0
        //=============================================================================//
        //============ Private / Protected Methods
        //=============================================================================//
        #region Private / Protected Methods

        private List <InternalSceneData> BundleIdentifierAttribution(SceneCollection collection, List <InternalSceneData> scenesData)
        {
            string bundleIdentifier = (string.IsNullOrEmpty(_bundle.BundleIdentifier)) ? (collection.GetAvailableBundleIdentifier()) : (_bundle.BundleIdentifier);
            List <InternalSceneData> scenesDataBundleAttributed = new List <InternalSceneData>(scenesData);

            scenesDataBundleAttributed.ForEach(sceneData => sceneData.FeedBundleInformation(bundleIdentifier, _bundle.BundleMainSceneNames.Contains(sceneData.SceneName)));

            return(scenesDataBundleAttributed);
        }
Exemplo n.º 4
0
        //=============================================================================//
        //============ Lifecycle Methods
        //=============================================================================//
        #region Lifecycle Methods

        /// <summary>
        /// Unity's Awake lifecycle
        /// Will initialize all member's variables and always add the scene containing SceneLoader as the first scene (this one will not be delete in any case)
        /// </summary>
        private void Awake()
        {
            _currentProcess = null;
            _collection     = new SceneCollection();

            InternalSceneData loaderScene = new InternalSceneData(UnityEngine.SceneManagement.SceneManager.GetActiveScene().name, true, false, true, "MainSceneBundle", true);

            SceneLoaderEvents.TriggerOnSceneLoadedInternal(loaderScene);
        }
Exemplo n.º 5
0
        internal override SceneLoaderRequestResult Inspection(SceneCollection collection, bool forceNotSuppressible)
        {
            InternalSceneData lastScene   = collection.GetLastScene();
            bool lastSceneNotSuppressible = lastScene != null && forceNotSuppressible == false && lastScene.IsSuppressible == false;

            return
                ((lastSceneNotSuppressible) ?
                 (SceneLoaderConstants.REQUEST_RESULTS[SceneLoaderReturnType.LoadRejectedUnloadLastSceneNotSuppressible]) :
                 (SceneLoaderConstants.REQUEST_RESULTS[SceneLoaderReturnType.Accepted]));
        }
Exemplo n.º 6
0
        private SceneLoaderRequestResult ScenesExistsInspection(SceneCollection collection)
        {
            List <string> scenesName          = _bundle.Scenes.ConvertAll(scene => scene.SceneName);
            bool          atLeast1SceneExists = collection.ScenesExists(scenesName, false);

            return
                ((atLeast1SceneExists) ?
                 (SceneLoaderConstants.REQUEST_RESULTS[SceneLoaderReturnType.LoadRejectedSceneExists]) :
                 (SceneLoaderConstants.REQUEST_RESULTS[SceneLoaderReturnType.Accepted]));
        }
Exemplo n.º 7
0
        internal override SceneLoaderRequestResult Inspection(SceneCollection collection, bool forceNotSuppressible)
        {
            List <InternalSceneData> bundleScenes = collection.GetAllScenesAtBundle(_bundleIdentifier, _includeMains);
            bool scenesNotSuppressible            = bundleScenes?.Find(scene => scene.IsSuppressible == false) != null;

            return
                ((forceNotSuppressible == false && scenesNotSuppressible) ?
                 (SceneLoaderConstants.REQUEST_RESULTS[SceneLoaderReturnType.LoadRejectedUnloadBundleNotSuppressible]) :
                 (SceneLoaderConstants.REQUEST_RESULTS[SceneLoaderReturnType.Accepted]));
        }
Exemplo n.º 8
0
        internal override SceneLoaderRequestResult Inspection(SceneCollection collection, bool forceNotSuppressible)
        {
            List <InternalSceneData> allScenes = collection.GetAllScenes(false);
            bool scenesNotSuppressible         = allScenes?.Find(scene => scene.IsSuppressible == false) != null;

            return
                ((forceNotSuppressible == false && scenesNotSuppressible)
                    ? (SceneLoaderConstants.REQUEST_RESULTS[SceneLoaderReturnType.LoadRejectedUnloadAllNotSuppressible])
                    : (SceneLoaderConstants.REQUEST_RESULTS[SceneLoaderReturnType.Accepted]));
        }
Exemplo n.º 9
0
        private SceneLoaderRequestResult BundleExistsInspection(SceneCollection collection)
        {
            string bundleIdentifier       = _bundle.BundleIdentifier;
            bool   bundleIdentifierIsNull = string.IsNullOrEmpty(bundleIdentifier);
            bool   bundleIdentifierExists = bundleIdentifierIsNull == false && collection.BundleExists(bundleIdentifier);

            return
                ((bundleIdentifierExists) ?
                 (SceneLoaderConstants.REQUEST_RESULTS[SceneLoaderReturnType.LoadRejectedBundleExists]) :
                 (SceneLoaderConstants.REQUEST_RESULTS[SceneLoaderReturnType.Accepted]));
        }
Exemplo n.º 10
0
        //=============================================================================//
        //============ Internal Methods
        //=============================================================================//
        #region Internal Methods
        internal override Queue <InternalSceneRequest> CreateRequests(SceneCollection collection, bool forceNotSuppressible)
        {
            if (Inspection(collection, forceNotSuppressible).IsSuccess == false)
            {
                Debug.LogError("Development error -- Contact developer -- Initial inspection went wrong, this request should have been denied");
                return(null);
            }

            Queue <InternalSceneRequest> requests = new Queue <InternalSceneRequest>();

            requests.Enqueue(new InternalSceneRequestUnload(collection.GetLastScene()));
            return(requests);
        }
Exemplo n.º 11
0
        internal override Queue <InternalSceneRequest> BuildRequests(SceneCollection collection)
        {
            // Beforehand, we check once again that the request is valid
            // If it's not, this is a development error, warn user and return
            if (Inspection(collection).IsSuccess == false)
            {
                Debug.LogError("Development error -- Contact developer -- Initial inspection went wrong, this request should have been denied");
                return(null);
            }

            Queue <InternalSceneRequest> requests = _unloadStrategy.CreateRequests(collection, _forceNotSuppressible);

            return(requests);
        }
Exemplo n.º 12
0
        //=============================================================================//
        //============ Public Methods
        //=============================================================================//
        #region Public Methods
        internal override Queue <InternalSceneRequest> CreateRequests(SceneCollection collection, bool forceNotSuppressible)
        {
            if (Inspection(collection, forceNotSuppressible).IsSuccess == false)
            {
                Debug.LogError("Development error -- Contact developer -- Initial inspection went wrong, this request should have been denied");
                return(null);
            }

            Queue <InternalSceneRequest> requests = new Queue <InternalSceneRequest>();
            List <InternalSceneData>     scenes   = collection.GetAllScenesAtBundle(collection.GetLastScene()?.BundleIdentifier, true);

            scenes.ForEach(scene => requests.Enqueue(new InternalSceneRequestUnload(scene)));

            return(requests);
        }
Exemplo n.º 13
0
        internal override SceneLoaderRequestResult Inspection(SceneCollection collection, bool forceNotSuppressible)
        {
            if (_scenes == null || _scenes.Count == 0)
            {
                return(SceneLoaderConstants.REQUEST_RESULTS[SceneLoaderReturnType.UnloadRejectedSceneNotExists]);
            }

            List <string> scenesName = _scenes.ConvertAll(scene => scene.SceneName);
            bool          allExists  = collection.ScenesExists(scenesName, true);

            return
                ((allExists)
                ? (SceneLoaderConstants.REQUEST_RESULTS[SceneLoaderReturnType.Accepted])
                : (SceneLoaderConstants.REQUEST_RESULTS[SceneLoaderReturnType.UnloadRejectedSceneNotExists]));
        }
Exemplo n.º 14
0
        //=============================================================================//
        //============ Internal Methods
        //=============================================================================//
        #region Internal Methods
        internal override Queue <InternalSceneRequest> CreateRequests(SceneCollection collection, bool forceNotSuppressible)
        {
            if (Inspection(collection, forceNotSuppressible).IsSuccess == false)
            {
                Debug.LogError("Development error -- Contact developer -- Initial inspection went wrong, this request should have been denied");
                return(null);
            }

            Queue <InternalSceneRequest> requests            = new Queue <InternalSceneRequest>();
            List <InternalSceneData>     marshalledSceneData = _scenes.ConvertAll(scene => _sceneMarshaller.Marshall(scene));

            marshalledSceneData.ForEach(scene => requests.Enqueue(new InternalSceneRequestUnload(scene)));

            return(requests);
        }
Exemplo n.º 15
0
 internal abstract SceneLoaderRequestResult Inspection(SceneCollection collection, bool forceNotSuppressible);
Exemplo n.º 16
0
 //=============================================================================//
 //============ Internal Methods
 //=============================================================================//
 #region Internal Methods
 internal abstract Queue <InternalSceneRequest> CreateRequests(SceneCollection collection, bool forceNotSuppressible);
Exemplo n.º 17
0
 internal abstract Queue <InternalSceneRequest> BuildRequests(SceneCollection collection);
Exemplo n.º 18
0
 internal abstract SceneLoaderRequestResult Inspection(SceneCollection collection);
Exemplo n.º 19
0
 private SceneLoaderRequestResult AdditionalInspection(SceneCollection collection)
 {
     return(_unloadStrategy.Inspection(collection, _forceNotSuppressible));
 }
Exemplo n.º 20
0
 //=============================================================================//
 //============ Internal Methods
 //=============================================================================//
 #region Internal Methods
 internal override Queue <InternalSceneRequest> CreateRequests(SceneCollection collection, bool forceNotSuppressible)
 {
     return(new Queue <InternalSceneRequest>());
 }
Exemplo n.º 21
0
        //=============================================================================//
        //============ Internal Methods
        //=============================================================================//
        #region Internal Methods

        internal override SceneLoaderRequestResult Inspection(SceneCollection collection)
        {
            return(_unloadStrategy.Inspection(collection, _forceNotSuppressible));
        }
Exemplo n.º 22
0
 internal override SceneLoaderRequestResult Inspection(SceneCollection collection, bool forceNotSuppressible)
 {
     return(SceneLoaderConstants.REQUEST_RESULTS[SceneLoaderReturnType.Accepted]);
 }