Exemple #1
0
 private void Fire(LoadPhase untilPhase)
 {
     if (untilPhase >= LoadPhase.Create && _phase <= LoadPhase.Create)
     {
         FireDependencies(LoadPhase.Create);
         Create();
     }
     if (untilPhase >= LoadPhase.Serialize && _phase <= LoadPhase.Serialize)
     {
         FireDependencies(LoadPhase.Serialize);
         Serialize();
     }
 }
Exemple #2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            DiagManager.Instance.LoadMsg = "Loading System";
            GraphicsManager.InitSystem(GraphicsDevice);

            CurrentPhase = LoadPhase.Content;

            Thread thread = new Thread(LoadInBackground);

            thread.IsBackground = true;
            //thread.CurrentCulture = Thread.CurrentThread.CurrentCulture;
            //thread.CurrentUICulture = Thread.CurrentThread.CurrentUICulture;
            thread.Start();

            base.Initialize();
        }
Exemple #3
0
        private void ReloadUnloadedModelsPerCondition(LoadPhase phase, Func <FileAndType, bool> condition)
        {
            if (!CanIncrementalBuild)
            {
                return;
            }
            var toLoadList = (from f in ModelLoadInfo.Keys
                              where condition(f)
                              select LoadIntermediateModel(f.File) into m
                              where m != null
                              select m).ToList();

            if (toLoadList.Count > 0)
            {
                Reload(Models.Concat(toLoadList));
                ReportModelLoadInfo(toLoadList.Select(t => t.FileAndType), phase);
            }
        }
Exemple #4
0
 private void Create()
 {
     Trace.Assert(_phase == LoadPhase.Create);
     _phase       = LoadPhase.Serialize;
     _object      = ConstructObject(_package.ResolvePackageIndex(_export.ClassIndex)?.Object?.Value as UStruct);
     _object.Name = _export.ObjectName.Text;
     if (!_export.OuterIndex.IsNull)
     {
         Trace.Assert(_export.OuterIndex.IsExport, "Outer imports are not yet supported");
         _object.Outer = _package._exportLoaders[_export.OuterIndex.Index - 1]._object;
     }
     else
     {
         _object.Outer = _package;
     }
     _object.Super    = _package.ResolvePackageIndex(_export.SuperIndex) as ResolvedExportObject;
     _object.Template = _package.ResolvePackageIndex(_export.TemplateIndex) as ResolvedExportObject;
     _object.Flags   |= (EObjectFlags)_export.ObjectFlags; // We give loaded objects the RF_WasLoaded flag in ConstructObject, so don't remove it again in here
 }
Exemple #5
0
        public async Task ApplyPatchAsync(IProgress <DirectoryPatcherProgressReport> progressCallback, CancellationToken cancellationToken, string instructionsHash)
        {
            var             actions        = new List <IFilePatchAction>();
            var             progress       = new DirectoryPatcherProgressReport();
            Action <Action> reportProgress = (phaseAction) => {
                phaseAction();
                progressCallback.Report(ObjectEx.DeepClone(progress));
            };
            var loadPhase = new LoadPhase(cancellationToken, phaseProgress => reportProgress(() => progress.Load = phaseProgress));

            await AnalyzeAsync(cancellationToken, action =>
            {
                loadPhase.StartLoading(action);
                actions.Add(action);
            }, phaseProgress => reportProgress(() => progress.Analyze = phaseProgress), instructionsHash);

            await loadPhase.AwaitAllTasksAndFinish();

            await ApplyAsync(cancellationToken, actions, phaseProgress => reportProgress(() => progress.Apply = phaseProgress));
        }
Exemple #6
0
        public async Task ApplyPatchAsync(IProgress <DirectoryPatcherProgressReport> progressCallback, CancellationToken cancellationToken, string instructions_hash)
        {
            var             actions        = new List <IFilePatchAction>();
            var             progress       = new DirectoryPatcherProgressReport();
            Action <Action> reportProgress = (phaseAction) => {
                phaseAction();
                progressCallback.Report(ObjectEx.DeepClone(progress));
            };
            var loadPhase = new LoadPhase(cancellationToken, phaseProgress => reportProgress(() => progress.Load = phaseProgress));

            // Analyze files to determine which files to download and how to download them
            await Analyze(cancellationToken, action =>
            {
                loadPhase.StartLoading(action);
                actions.Add(action);
            }, phaseProgress => reportProgress(() => progress.Analyze = phaseProgress), instructions_hash);

            // Wait for downloads to finish
            await loadPhase.AwaitAllTasksAndFinish();

            // Apply the new files
            await Apply(actions, phaseProgress => reportProgress(() => progress.Apply = phaseProgress));
        }
Exemple #7
0
        private void ReloadUnloadedModelsPerCondition(string intermediateFolder, ModelManifest lmm, LoadPhase phase, Func <FileAndType, bool> condition)
        {
            if (intermediateFolder == null)
            {
                return;
            }
            var toLoadList = (from f in _modelLoadInfo.Keys
                              where condition(f)
                              select LoadIntermediateModel(intermediateFolder, lmm, f.File) into m
                              where m != null
                              select m).ToList();

            if (toLoadList.Count > 0)
            {
                Reload(Models.Concat(toLoadList));
                ReportModelLoadInfo(toLoadList.Select(t => t.FileAndType), phase);
            }
        }
Exemple #8
0
 public void ReloadUnloadedModels(string intermediateFolder, ModelManifest lmm, LoadPhase phase)
 {
     ReloadUnloadedModelsPerCondition(intermediateFolder, lmm, phase, f => _modelLoadInfo[f] == LoadPhase.None);
 }
Exemple #9
0
 public void ReloadModelsPerIncrementalChanges(IEnumerable <string> changes, string intermediateFolder, ModelManifest lmm, LoadPhase phase)
 {
     if (changes == null)
     {
         return;
     }
     ReloadUnloadedModelsPerCondition(
         intermediateFolder,
         lmm,
         phase,
         f =>
     {
         var key = ((RelativePath)f.File).GetPathFromWorkingFolder().ToString();
         return(changes.Contains(key));
     });
 }
Exemple #10
0
 public void ReportModelLoadInfo(FileAndType file, LoadPhase phase)
 {
     _modelLoadInfo[file] = phase;
 }
 public OnDataLoadEventArgs(LoadPhase phase, bool isPrimaryLoading = false)
 {
     Phase            = phase;
     IsPrimaryLoading = isPrimaryLoading;
 }
Exemple #12
0
 public void ReloadUnloadedModels(LoadPhase phase)
 {
     ReloadUnloadedModelsPerCondition(phase, f => ModelLoadInfo[f] == LoadPhase.None);
 }
Exemple #13
0
 public LoadDependency(LoadPhase fromPhase, LoadPhase toPhase, ExportLoader?target)
 {
     FromPhase = fromPhase;
     ToPhase   = toPhase;
     Target    = target;
 }
Exemple #14
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            //Updating completely ignores delta time and updates by-frames
            //It also waits until drawing ends (which is locked at 60FPS) to ensure that updating does not take *shorter* than 1/60 of a second
            //This is because the following needs to be achieved:
            //Perfect simulation whether the updates were fast or slow
            //And for the game to not frame skip if the updates were too slow (deltatime too high), even if it meant slowing down the game itself.
            if (!drawTurn)
            {
                if (!firstUpdate && CurrentPhase > LoadPhase.System)
                {
                    splashFrames++;
                    if (backgroundLoaded)
                    {
                        if (DiagManager.Instance.DevMode)
                        {
                            DiagManager.Instance.DevEditor.Load();
                            while (!DiagManager.Instance.DevEditor.Loaded)
                            {
                                Thread.Sleep(10);
                            }

                            CurrentPhase = LoadPhase.Ready;
                        }
                        else if (fadeFrames == 0)
                        {
                            if (Keyboard.GetState().GetPressedKeys().Length > 0 || GamePad.GetState(PlayerIndex.One).Buttons != new GamePadButtons())
                            {
                                fadeFrames++;
                            }
                        }
                        else
                        {
                            if (fadeFrames < SPLASH_FADE_FRAMES)
                            {
                                fadeFrames++;
                            }
                            else
                            {
                                CurrentPhase = LoadPhase.Ready;
                            }
                        }
                    }
                }

                if (CurrentPhase == LoadPhase.Ready)
                {
                    try
                    {
                        SoundManager.NewFrame();
                        GraphicsManager.Update();

                        FrameInput input = new FrameInput();
                        if (DiagManager.Instance.ActiveDebugReplay != null && DiagManager.Instance.DebugReplayIndex < DiagManager.Instance.ActiveDebugReplay.Count)
                        {
                            input = DiagManager.Instance.ActiveDebugReplay[DiagManager.Instance.DebugReplayIndex];
                            DiagManager.Instance.DebugReplayIndex++;
                            if (IsActive)
                            {
                                input.ReadDevInput(Keyboard.GetState(), Mouse.GetState());
                            }
                        }
                        else if (IsActive) //set this frame's input
                        {
                            input = new FrameInput(GamePad.GetState(PlayerIndex.One), Keyboard.GetState(), Mouse.GetState());
                        }

                        if (DiagManager.Instance.ActiveDebugReplay == null)
                        {
                            DiagManager.Instance.LogInput(input);
                        }
                        GameManager.Instance.SetMetaInput(input);
                        GameManager.Instance.UpdateMeta();
                        GameManager.Instance.SetFrameInput(input);
                        GameManager.Instance.Update();
                        LuaEngine.Instance.Update(gameTime);
                    }
                    catch (Exception ex)
                    {
                        DiagManager.Instance.LogError(ex);
                    }

                    firstUpdate = true;//allow drawing now
                }
                else if (CurrentPhase == LoadPhase.Unload)
                {
                    Exit();
                }
                drawTurn = true;
            }
            base.Update(gameTime);
        }
 private void SecondPhaseComplete()
 {
     _loadPhase = LoadPhase.Complete;
     loadProgress.fillAmount = 1f;
 }