1
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;using BITFALL.Entities.Equipment;
|
||||
using System.Collections.Generic;
|
||||
using BITFALL.Combat;
|
||||
using BITFALL.Entities.Equipment;
|
||||
using BITKit;
|
||||
using BITKit.Entities;
|
||||
using BITKit.Entities.Melee;
|
||||
using BITKit.Sensors;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using IEntity = BITKit.Entities.IEntity;
|
||||
@@ -10,25 +15,31 @@ namespace BITFALL.Entities.Equipment
|
||||
{
|
||||
public class AIEquipController : MonoBehaviour,IEquipBase
|
||||
{
|
||||
[SerializeField] protected Optional<int> overrideDamage;
|
||||
[SerializeField] protected AssetableItem assetableItem;
|
||||
[SerializeField] protected Optional<Tag> ignoreTag;
|
||||
[SerializeReference,SubclassSelector] protected ISensor targetSensor;
|
||||
[SerializeReference, SubclassSelector] protected IMeleeService meleeService;
|
||||
protected AssetableEquip equip => assetableItem as AssetableEquip;
|
||||
protected Transform Transform { get; private set; }
|
||||
public bool IsEntered { get; set; }
|
||||
protected readonly IntervalUpdate meleeInterval = new(1);
|
||||
[Inject] public IHealth _health;
|
||||
|
||||
public virtual void Entry()
|
||||
{
|
||||
UnityEntity.AddListener<string>(Constant.Animation.OnEvent, OnAnimationEvent);
|
||||
}
|
||||
|
||||
protected virtual void OnAnimationEvent(string animationEventName)
|
||||
{
|
||||
}
|
||||
public virtual UniTask EntryAsync()
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public virtual void Entered()
|
||||
{
|
||||
UnityEntity.AddListener<string>(Constant.Animation.OnEvent, OnAnimationEvent);
|
||||
}
|
||||
public virtual void Exit()
|
||||
{
|
||||
UnityEntity.RemoveListener<string>(Constant.Animation.OnEvent, OnAnimationEvent);
|
||||
}
|
||||
|
||||
public virtual UniTask ExitAsync()
|
||||
@@ -36,8 +47,37 @@ namespace BITFALL.Entities.Equipment
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public virtual void Exited()
|
||||
{
|
||||
UnityEntity.RemoveListener<string>(Constant.Animation.OnEvent, OnAnimationEvent);
|
||||
}
|
||||
protected virtual void OnAnimationEvent(string animationEventName)
|
||||
{
|
||||
switch (animationEventName)
|
||||
{
|
||||
case BITConstant.Player.Attack:
|
||||
case BITConstant.Player.Melee:
|
||||
meleeService.Melee(new MeleeCommand()
|
||||
{
|
||||
Damage = equip.MeleeDamage,
|
||||
Force = equip.MeleeForce,
|
||||
PlayerId = Entity.Id,
|
||||
Position = transform.position,
|
||||
Range = equip.MeleeRange,
|
||||
Forward = UnityEntity.transform.forward,
|
||||
IgnoreTags = ignoreTag.Allow ?ignoreTag.Value.GetTags():Array.Empty<string>(),
|
||||
ForceHitStun = true,
|
||||
Limit = 1,
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public virtual void OnAwake()
|
||||
{
|
||||
Transform = transform;
|
||||
}
|
||||
|
||||
public virtual void OnStart()
|
||||
@@ -58,6 +98,11 @@ namespace BITFALL.Entities.Equipment
|
||||
public void PlayAudio(string name)
|
||||
{
|
||||
}
|
||||
protected void RequestMelee()
|
||||
{
|
||||
if (meleeInterval.AllowUpdate is false) return;
|
||||
UnityEntity.Invoke(Constant.Animation.Play, BITConstant.Player.Melee);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user