58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Data.Common;
|
|
using System.Linq;
|
|
using BITKit;
|
|
using BITKit.Entities;
|
|
using BITKit.UX;
|
|
using Cysharp.Threading.Tasks;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
using NodeCanvas.Framework;
|
|
using Project.B.Map;
|
|
using UnityEngine;
|
|
|
|
namespace Net.Project.B.NodeCanvas
|
|
{
|
|
public class WaitItemNode : ActionTask
|
|
{
|
|
[SerializeField] public BBParameter<List<int>> RequiredItemIds;
|
|
[SerializeField] public BBParameter<GameObject> worldContainer;
|
|
protected override void OnExecute()
|
|
{
|
|
|
|
var entitiesService = BITApp.ServiceProvider.GetRequiredService<IEntitiesService>();
|
|
|
|
if (entitiesService.TryGetEntity(worldContainer.value.GetInstanceID(), out var entity) is false)
|
|
{
|
|
EndAction(false);
|
|
|
|
return;
|
|
}
|
|
|
|
if (entity.ServiceProvider.GetService<IRuntimeItemContainer>() is not { } container)
|
|
{
|
|
EndAction(false);
|
|
return;
|
|
}
|
|
|
|
container.OnRelease += OnRelease;
|
|
|
|
return;
|
|
void OnRelease(bool obj)
|
|
{
|
|
if(obj is false)return;
|
|
|
|
var items = container.GetItems().Select(x => x.ScriptableId).ToArray();
|
|
|
|
foreach (var requiredId in RequiredItemIds.value)
|
|
{
|
|
if(items.Contains(requiredId) is false)return;
|
|
}
|
|
|
|
EndAction();
|
|
}
|
|
}
|
|
|
|
}
|
|
} |