58 lines
1.8 KiB
C#
58 lines
1.8 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Data.Common;
|
|
using System.Linq;
|
|
using System.Runtime.Remoting;
|
|
using BITKit;
|
|
using BITKit.Entities;
|
|
using BITKit.UX;
|
|
using Cysharp.Threading.Tasks;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
using Net.Project.B.Interaction;
|
|
using NodeCanvas.Framework;
|
|
using Project.B.Map;
|
|
using UnityEngine;
|
|
|
|
namespace Net.Project.B.NodeCanvas
|
|
{
|
|
public class WorldInteractionTask : ActionTask
|
|
{
|
|
public BBParameter<GameObject> worldObject;
|
|
protected override void OnExecute()
|
|
{
|
|
if (worldObject.isNull)
|
|
{
|
|
EndAction(false);
|
|
|
|
Debug.LogWarning("agent为null");
|
|
|
|
return;
|
|
}
|
|
|
|
var entitiesService = BITApp.ServiceProvider.GetRequiredService<IEntitiesService>();
|
|
|
|
if (entitiesService.TryGetEntity(worldObject.value.GetInstanceID(), out var entity) is false)
|
|
{
|
|
Debug.LogWarning("entity为null");
|
|
EndAction(false);
|
|
return;
|
|
}
|
|
|
|
if (entity.ServiceProvider.GetService<IWorldInteractable>() is not { } interactable)
|
|
{
|
|
Debug.LogWarning("interactable为null");
|
|
EndAction(false);
|
|
return;
|
|
}
|
|
|
|
var interactionService = BITApp.ServiceProvider.GetRequiredService<IWorldInteractionService>();
|
|
|
|
var player = entitiesService.QueryComponents<IEntity,LocalPlayerComponent>();
|
|
|
|
interactionService.Interaction(player.Length > 0 ? player[0].Item1:this, interactable, WorldInteractionProcess.System);
|
|
|
|
EndAction();
|
|
}
|
|
}
|
|
} |