59 lines
1.6 KiB
C#
59 lines
1.6 KiB
C#
![]() |
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using BITKit;
|
||
|
using BITKit.Entities;
|
||
|
using Cysharp.Threading.Tasks;
|
||
|
using Net.BITKit.Chat;
|
||
|
using Net.Project.B.Dialogue;
|
||
|
using NodeCanvas.DialogueTrees;
|
||
|
using NodeCanvas.Framework;
|
||
|
using ParadoxNotion.Design;
|
||
|
using UnityEngine;
|
||
|
|
||
|
namespace Net.Project.B.NodeCanvas
|
||
|
{
|
||
|
[Category("Dialogue")]
|
||
|
[ParadoxNotion.Design.Icon("Dialogue")]
|
||
|
public class SayAndWaitReply : ActionTask<IDialogueActor>
|
||
|
{
|
||
|
[TextAreaField(4)]
|
||
|
public string Text;
|
||
|
[TextAreaField(4)]
|
||
|
public string Tips;
|
||
|
|
||
|
private IEntitiesService _entitiesService;
|
||
|
private IDialogueService _dialogueService;
|
||
|
private IChatService _chatService;
|
||
|
|
||
|
protected override string info => Text;
|
||
|
|
||
|
protected override void OnExecute()
|
||
|
{
|
||
|
BITApp.ServiceProvider.QueryComponents(out _entitiesService, out _dialogueService,out _chatService);
|
||
|
|
||
|
_dialogueService.CreateDialogue(new DialogueData()
|
||
|
{
|
||
|
ActorIdentity = agent.transform.gameObject.GetInstanceID(),
|
||
|
Text = Text,
|
||
|
MetaObject = Tips,
|
||
|
}).Forget();
|
||
|
|
||
|
_chatService.OnMessageReceived += OnMessageReceived;
|
||
|
}
|
||
|
|
||
|
private void OnMessageReceived(ChatMessage obj)
|
||
|
{
|
||
|
if(obj.FromUserId!=Environment.UserName)return;
|
||
|
|
||
|
EndAction();
|
||
|
}
|
||
|
|
||
|
protected override void OnStop(bool interrupted)
|
||
|
{
|
||
|
_chatService.OnMessageReceived -= OnMessageReceived;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|