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); }
//=============================================================================// //============ 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]); }
//=============================================================================// //============ 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); }
//=============================================================================// //============ 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); }
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])); }
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])); }
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])); }
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])); }
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])); }
//=============================================================================// //============ 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); }
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); }
//=============================================================================// //============ 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); }
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])); }
//=============================================================================// //============ 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); }
internal abstract SceneLoaderRequestResult Inspection(SceneCollection collection, bool forceNotSuppressible);
//=============================================================================// //============ Internal Methods //=============================================================================// #region Internal Methods internal abstract Queue <InternalSceneRequest> CreateRequests(SceneCollection collection, bool forceNotSuppressible);
internal abstract Queue <InternalSceneRequest> BuildRequests(SceneCollection collection);
internal abstract SceneLoaderRequestResult Inspection(SceneCollection collection);
private SceneLoaderRequestResult AdditionalInspection(SceneCollection collection) { return(_unloadStrategy.Inspection(collection, _forceNotSuppressible)); }
//=============================================================================// //============ Internal Methods //=============================================================================// #region Internal Methods internal override Queue <InternalSceneRequest> CreateRequests(SceneCollection collection, bool forceNotSuppressible) { return(new Queue <InternalSceneRequest>()); }
//=============================================================================// //============ Internal Methods //=============================================================================// #region Internal Methods internal override SceneLoaderRequestResult Inspection(SceneCollection collection) { return(_unloadStrategy.Inspection(collection, _forceNotSuppressible)); }
internal override SceneLoaderRequestResult Inspection(SceneCollection collection, bool forceNotSuppressible) { return(SceneLoaderConstants.REQUEST_RESULTS[SceneLoaderReturnType.Accepted]); }