1
This commit is contained in:
42
Assets/Artists/Scripts/Equip/AIMeleeController.cs
Normal file
42
Assets/Artists/Scripts/Equip/AIMeleeController.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITFALL.Bullet;
|
||||
using BITFALL.Guns;
|
||||
using BITKit;
|
||||
using BITKit.Entities.Melee;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITFALL.Entities.Equipment
|
||||
{
|
||||
public class AIMeleeController : AIEquipController
|
||||
{
|
||||
[SerializeReference,SubclassSelector] private IMeleeService meleeService;
|
||||
[SerializeField] private bool forceAttack;
|
||||
|
||||
private readonly IntervalUpdate interval = new(1);
|
||||
public override void Entry()
|
||||
{
|
||||
base.Entry();
|
||||
UnityEntity.AddListener<BITConstant.Command.AttackCommand>(OnAttack);
|
||||
}
|
||||
public override void Exit()
|
||||
{
|
||||
base.Exit();
|
||||
UnityEntity.RemoveListener<BITConstant.Command.AttackCommand>(OnAttack);
|
||||
}
|
||||
|
||||
public override void OnUpdate(float deltaTime)
|
||||
{
|
||||
if (forceAttack && interval.AllowUpdate)
|
||||
{
|
||||
OnAttack(new BITConstant.Command.AttackCommand());
|
||||
}
|
||||
}
|
||||
|
||||
private void OnAttack(BITConstant.Command.AttackCommand obj)
|
||||
{
|
||||
UnityEntity.Invoke(Constant.Animation.Play, BITConstant.Player.Melee);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user