IndieGame/client/Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/Dialogue/StartDialogueTree.cs
DOBEST\zhaoyingjie f242607587 初始化工程
2024-10-11 10:12:15 +08:00

39 lines
1.3 KiB
C#

using UnityEngine;
using ParadoxNotion.Design;
using NodeCanvas.Framework;
using NodeCanvas.DialogueTrees;
namespace NodeCanvas.Tasks.Actions
{
[Category("Dialogue")]
[Description("Starts the Dialogue Tree assigned on a Dialogue Tree Controller object with specified agent used for 'Instigator'.")]
[ParadoxNotion.Design.Icon("Dialogue")]
public class StartDialogueTree : ActionTask<IDialogueActor>
{
[RequiredField]
public BBParameter<DialogueTreeController> dialogueTreeController;
public bool waitActionFinish = true;
public bool isPrefab;
private DialogueTreeController instance;
protected override string info {
get { return string.Format("Start Dialogue {0}", dialogueTreeController); }
}
protected override void OnExecute() {
instance = isPrefab ? GameObject.Instantiate(dialogueTreeController.value) : dialogueTreeController.value;
if ( waitActionFinish ) {
instance.StartDialogue(agent, (success) => { if ( isPrefab ) { Object.Destroy(instance.gameObject); } EndAction(success); });
} else {
instance.StartDialogue(agent, (success) => { if ( isPrefab ) Object.Destroy(instance.gameObject); });
EndAction();
}
}
}
}