BITFALL/Assets/BITKit/UnityPluginsSupport/NodeCanvas/CreateQuest.cs

31 lines
963 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using NodeCanvas.Tasks;
using NodeCanvas.Framework;
using BITKit.SubSystems;
using BITKit.SubSystems.Quest;
namespace BITKit
{
public class CreateQuest : ActionTask
{
public string questName;
public string qeustDescription;
public BBParameter<QuestSystem.Info> output;
protected override void OnExecute()
{
var quest = QuestSystem.Create(questName, qeustDescription);
if (output.isDefined)
output.SetValue(quest);
EndAction();
}
protected override void OnStop(bool interrupted)
{
base.OnStop(interrupted);
if (!interrupted) return;
if (QuestSystem.quests.TryGetValue(output.value, out var info) &&
info.State == QuestSystem.State.InProcess)
QuestSystem.Cancel(output.value);
}
}
}