56 lines
1.5 KiB
C#
56 lines
1.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using BITKit;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Net.Project.B.Melee;
|
|
using NodeCanvas.Framework;
|
|
using UnityEngine;
|
|
|
|
namespace Net.Project.B.NodeCanvas
|
|
{
|
|
public class MeleeTask : ActionTask
|
|
{
|
|
public BBParameter<GameObject> GameObject;
|
|
public BBParameter<Transform> ViewPosition;
|
|
public BBParameter<List<string>> IgnoreTags;
|
|
public BBParameter<float> Interval;
|
|
|
|
private readonly IntervalUpdate _intervalUpdate = new(1);
|
|
|
|
private IMeleeService _meleeService;
|
|
|
|
private readonly MeleeData _meleeData = new()
|
|
{
|
|
Radius = 1,
|
|
Damage = 5,
|
|
};
|
|
|
|
protected override string OnInit()
|
|
{
|
|
_meleeService = BITApp.ServiceProvider.GetRequiredService<IMeleeService>();
|
|
if (IgnoreTags.isNoneOrNull is false)
|
|
_meleeData.IgnoreTags.AddRange(IgnoreTags.value);
|
|
return base.OnInit();
|
|
}
|
|
|
|
protected override void OnExecute()
|
|
{
|
|
base.OnExecute();
|
|
|
|
_intervalUpdate.Interval = Interval.value;
|
|
|
|
if (_intervalUpdate.AllowUpdate)
|
|
{
|
|
_meleeData.Initiator = GameObject.value.GetInstanceID();
|
|
_meleeData.StartPosition = ViewPosition.value.position;
|
|
|
|
_meleeService.Add(_meleeData);
|
|
}
|
|
|
|
EndAction();
|
|
}
|
|
|
|
}
|
|
|
|
}
|