60 lines
1.7 KiB
C#
60 lines
1.7 KiB
C#
using System;
|
|
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 Net.Project.B.Inventory;
|
|
using Net.Project.B.Item;
|
|
using NodeCanvas.Framework;
|
|
using Project.B.Item;
|
|
using Project.B.Map;
|
|
using UnityEngine;
|
|
|
|
namespace Net.Project.B.NodeCanvas
|
|
{
|
|
public class GiveItemTask : ActionTask
|
|
{
|
|
public BBParameter<List<ScriptableItem>> items;
|
|
protected override async void OnExecute()
|
|
{
|
|
var entitiesService = BITApp.ServiceProvider.GetRequiredService<IEntitiesService>();
|
|
|
|
foreach (var playerInventory in entitiesService.QueryComponents<IPlayerInventory>().ToArray())
|
|
{
|
|
foreach (var scriptableItem in items.value)
|
|
{
|
|
var runtimeItem = scriptableItem.CreateRuntimeItem();
|
|
|
|
Debug.Log($"正在添加:{scriptableItem.Name}");
|
|
|
|
await UniTask.NextFrame();
|
|
|
|
try
|
|
{
|
|
if (playerInventory.Container.Add(runtimeItem) is false)
|
|
{
|
|
|
|
}
|
|
}
|
|
catch (PlayerInventoryAddItemOverridden)
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
|
|
EndAction();
|
|
}
|
|
}
|
|
} |