protected void AddAndSaveSubasset(QuestSubasset subasset)
 {
     if (QuestEditorWindow.selectedQuest != null)
     {
         AssetUtility.AddToAsset(subasset, QuestEditorWindow.selectedQuest);
         subasset.SetRuntimeReferences(QuestEditorWindow.selectedQuest, null);
     }
     QuestEditorWindow.UpdateSelectedQuestSerializedObject();
     QuestEditorWindow.ApplyModifiedPropertiesFromSelectedQuestSerializedObject();
     AssetDatabase.SaveAssets();
 }
        public override void CloneSubassetsInto(QuestSubasset copy)
        {
            base.CloneSubassetsInto(copy);
            var copyButton = copy as ButtonQuestContent;

            if (copyButton == null)
            {
                return;
            }
            copyButton.actionList = CloneList(actionList);
        }
Ejemplo n.º 3
0
        public override void CloneSubassetsInto(QuestSubasset copy)
        {
            base.CloneSubassetsInto(copy);
            var copyAlertQuestAction = copy as AlertQuestAction;

            if (copyAlertQuestAction == null)
            {
                return;
            }
            copyAlertQuestAction.contentList = CloneList(contentList);
        }
Ejemplo n.º 4
0
 public void DestroySubassets()
 {
     QuestSubasset.DestroyList(actionList);
     if (categorizedContentList != null)
     {
         for (int i = 0; i < categorizedContentList.Count; i++)
         {
             categorizedContentList[i].DestroySubassets();
         }
     }
 }
 public void CloneSubassetsInto(QuestConditionSet copy)
 {
     if (copy == null)
     {
         if (Debug.isDebugBuild)
         {
             Debug.LogWarning("Quest Machine: QuestConditionSet.CloneSubassetsInto() failed because copy is invalid.");
         }
         return;
     }
     copy.conditionList = QuestSubasset.CloneList(conditionList);
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Returns a new instance of the quest, including new instances of all subassets
        /// such as QuestAction, QuestCondition, and QuestContent subassets.
        /// </summary>
        public Quest Clone()
        {
            var clone = Instantiate(this);

            SetRuntimeReferences(); // Fix original's references since Instantiate calls OnEnable > SetRuntimeReferences while clone's fields still point to original.
            clone.isInstance    = true;
            clone.originalAsset = originalAsset;
            autostartConditionSet.CloneSubassetsInto(clone.autostartConditionSet);
            offerConditionSet.CloneSubassetsInto(clone.offerConditionSet);
            clone.offerConditionsUnmetContentList = QuestSubasset.CloneList(offerConditionsUnmetContentList);
            clone.offerContentList = QuestSubasset.CloneList(offerContentList);
            QuestStateInfo.CloneSubassets(stateInfoList, clone.stateInfoList);
            QuestNode.CloneSubassets(nodeList, clone.nodeList);
            tagDictionary.CopyInto(clone.tagDictionary);
            clone.SetRuntimeReferences();
            return(clone);
        }
Ejemplo n.º 7
0
 private void OnDestroy()
 {
     if (isInstance && Application.isPlaying)
     {
         QuestMachine.UnregisterQuestInstance(this);
         SetState(QuestState.Disabled);
         if (autostartConditionSet != null)
         {
             autostartConditionSet.DestroySubassets();
         }
         if (offerConditionSet != null)
         {
             offerConditionSet.DestroySubassets();
         }
         QuestSubasset.DestroyList(offerConditionsUnmetContentList);
         QuestSubasset.DestroyList(offerContentList);
         QuestStateInfo.DestroyListSubassets(stateInfoList);
         QuestNode.DestroyListSubassets(nodeList);
     }
 }
Ejemplo n.º 8
0
 public void CloneSubassetsInto(QuestStateInfo copy)
 {
     // Assumes lists are identical except subassets haven't been copied.
     if (copy == null || copy.categorizedContentList == null)
     {
         if (Debug.isDebugBuild)
         {
             Debug.LogWarning("Quest Machine: QuestStateInfo.CloneSubassetsInto() failed because the destination copy or its content list is null.");
         }
     }
     else if (m_actionList == null || m_categorizedContentList == null)
     {
         if (Debug.isDebugBuild)
         {
             Debug.LogWarning("Quest Machine: QuestStateInfo.CloneSubassetsInto() failed because the original state info's action list or content list is null.");
         }
     }
     else if (copy.categorizedContentList.Count != m_categorizedContentList.Count)
     {
         if (Debug.isDebugBuild)
         {
             Debug.LogWarning("Quest Machine: QuestStateInfo.CloneSubassetsInto() failed because the destination copy's content list is a different size than the original's.");
         }
     }
     else
     {
         copy.actionList = QuestSubasset.CloneList(m_actionList);
         for (int i = 0; i < m_categorizedContentList.Count; i++)
         {
             if (copy.categorizedContentList[i] == null)
             {
                 copy.categorizedContentList[i] = new QuestContentSet();
             }
             copy.categorizedContentList[i].contentList = QuestSubasset.CloneList(m_categorizedContentList[i].contentList);
         }
     }
 }
 public void DestroySubassets()
 {
     QuestSubasset.DestroyList(conditionList);
 }
Ejemplo n.º 10
0
 public void DestroySubassets()
 {
     QuestSubasset.DestroyList(contentList);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Allows subclasses to deep copy their own subassets by instantiating copies.
 /// </summary>
 /// <param name="copy">The copy to instantiate subasset copies into. Assumes the
 /// copy has already been instantiated and contains an accurate copy of everything
 /// except subassets.</param>
 public virtual void CloneSubassetsInto(QuestSubasset copy)
 {
 }