Exemple #1
0
        public void RegisterQuestSubFsm(Fsm questFsm)
        {
            if (!QuestSubFsms.ContainsKey(questFsm.Name))
            {
                QuestSubFsms.Add(questFsm.Name, questFsm);
                return;
            }
            QuestSubFsms[questFsm.Name] = questFsm;
            ActiveQuestData sessionPersistentContainer = getSessionPersistentContainer();

            sessionPersistentContainer.LoadFSMVariables(questFsm, questFsm.Name);
        }
Exemple #2
0
        private IEnumerator restoreAsync(GameObject player)
        {
            while (IsRestoringAsync)
            {
                yield return(null);
            }
            trace("Restoring quest to its last saved objective");
            IsRestoringAsync = true;
            if (questAudioInstance == null)
            {
                if (Content.TryLoadAsync(out var assetRequest, audioContentKey, Id, Id))
                {
                    yield return(assetRequest);

                    questAudioInstance = UnityEngine.Object.Instantiate(assetRequest.Asset);
                    UnityEngine.Object.DontDestroyOnLoad(questAudioInstance);
                }
                else
                {
                    Log.LogErrorFormatted(this, "Quest audio prefab not found for quest: {0}", Id);
                }
            }
            trace("attempting to load zone-specific quest prefab");
            if (PrefabInstance == null && Content.TryLoadAsync(out var prefabResult, prefabTemplateKey, Definition.name, SceneManager.GetActiveScene().name, Definition.name))
            {
                yield return(prefabResult);

                trace("Loaded quest prefab {0}", prefabResult.Asset.name);
                PrefabInstance = UnityEngine.Object.Instantiate(prefabResult.Asset);
            }
            if (playMakerFsm == null)
            {
                addPlayMakerFSM(player);
                restoreFromCompletedObjectives();
                ActiveQuestData sessionPersistentContainer = getSessionPersistentContainer();
                sessionPersistentContainer.LoadFSMVariables(playMakerFsm.Fsm, playMakerFsm.Fsm.Name);
                FsmState fsmState = playMakerFsm.Fsm.GetState(INITIALIZE_STATE_NAME);
                if (fsmState == null)
                {
                    RestartFSM();
                }
                else
                {
                    playMakerFsm.Fsm.Stop();
                    playMakerFsm.Fsm.SetState(fsmState.Name);
                    playMakerFsm.Fsm.Start();
                }
            }
            rebootScheduledEvents();
            IsRestoringAsync = false;
        }