88 lines
2.4 KiB
C#
88 lines
2.4 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using PixelCrushers.QuestMachine;
|
|
using UnityEngine;
|
|
using SRDebugger;
|
|
using UnityEngine.SceneManagement;
|
|
using Quest = PixelCrushers.QuestMachine.Wrappers.Quest;
|
|
|
|
public class DebugQuestGatherer : MonoBehaviour
|
|
{
|
|
private int m_questIndex = 0;
|
|
private const string QUESTER_NAME = "Bascileus";
|
|
|
|
private List<QuestGiver> m_questGiversOnScene;
|
|
private DynamicOptionContainer m_container;
|
|
private QuestGiver m_currentQuestGiver;
|
|
|
|
private void OnEnable()
|
|
{
|
|
GatherAllQuestGiversOnScene();
|
|
SceneManager.sceneLoaded += OnSceneLoaded;
|
|
SceneManager.sceneUnloaded += DestroyOptionContainer;
|
|
}
|
|
|
|
|
|
private void OnDisable()
|
|
{
|
|
SceneManager.sceneLoaded -= OnSceneLoaded;
|
|
SceneManager.sceneUnloaded -= DestroyOptionContainer;
|
|
}
|
|
|
|
private void OnSceneLoaded(Scene arg0, LoadSceneMode arg1)
|
|
{
|
|
GatherAllQuestGiversOnScene();
|
|
CreatDebugButtons();
|
|
}
|
|
|
|
private void GatherAllQuestGiversOnScene()
|
|
{
|
|
m_questGiversOnScene = FindObjectsOfType<QuestGiver>(true).ToList();
|
|
}
|
|
|
|
private void DestroyOptionContainer(Scene scene)
|
|
{
|
|
if (m_container != null)
|
|
{
|
|
SRDebug.Instance.RemoveOptionContainer(m_container);
|
|
}
|
|
}
|
|
|
|
private void CreatDebugButtons()
|
|
{
|
|
m_container = new DynamicOptionContainer();
|
|
SRDebug.Instance.AddOptionContainer(m_container);
|
|
|
|
for (int i = 0; i < m_questGiversOnScene.Capacity; ++i)
|
|
{
|
|
m_currentQuestGiver = m_questGiversOnScene[i];
|
|
|
|
for (int j = 0; j < m_currentQuestGiver.questList.Count; j++)
|
|
{
|
|
PixelCrushers.QuestMachine.Quest quest = m_currentQuestGiver
|
|
.questList[j];
|
|
|
|
string questName = m_currentQuestGiver
|
|
.questList[j].title.value;
|
|
|
|
if (!quest.isTrackable)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
var index = i;
|
|
var option = OptionDefinition.FromMethod("Start Quest " + questName,
|
|
() =>
|
|
{
|
|
m_questGiversOnScene[index].GiveQuestToQuester(quest, QUESTER_NAME);
|
|
},
|
|
category:"Quests");
|
|
|
|
m_container.AddOption(option);
|
|
}
|
|
|
|
}
|
|
}
|
|
} |