1
This commit is contained in:
@@ -7,6 +7,7 @@ using BITFALL.Entities.Equipment;
|
||||
using BITKit;
|
||||
using BITKit.Entities;
|
||||
using BITKit.StateMachine;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITFALL.Guns
|
||||
@@ -16,6 +17,8 @@ namespace BITFALL.Guns
|
||||
[SerializeField] private Transform firePoint;
|
||||
[SerializeReference,SubclassSelector] private IBulletService bulletService;
|
||||
[SerializeField] private bool forceFire;
|
||||
[SerializeField] private Optional<int> customFireRate;
|
||||
[SerializeField] private Optional<IntervalUpdate> customFireInterval;
|
||||
private AssetableGun _gun=>assetableItem as AssetableGun;
|
||||
|
||||
private readonly IntervalUpdate fireInterval = new();
|
||||
@@ -24,6 +27,10 @@ namespace BITFALL.Guns
|
||||
{
|
||||
base.Entry();
|
||||
fireInterval.Interval = _gun.FireMode.FireRate is 0 ? 1 : 1f/_gun.FireMode.FireRate;
|
||||
if (customFireRate.Allow)
|
||||
{
|
||||
fireInterval.Interval =customFireRate.Value is 0 ? 1 : 1f / customFireRate.Value;
|
||||
}
|
||||
UnityEntity.AddListener<BITConstant.Command.AttackCommand>(OnAttack);
|
||||
}
|
||||
public override void Exit()
|
||||
@@ -36,7 +43,17 @@ namespace BITFALL.Guns
|
||||
{
|
||||
if (forceFire && fireInterval.AllowUpdate)
|
||||
{
|
||||
OnAttack(new BITConstant.Command.AttackCommand());
|
||||
if(customFireInterval.Allow)
|
||||
{
|
||||
if (customFireInterval.Value.AllowUpdate)
|
||||
{
|
||||
OnAttack(new BITConstant.Command.AttackCommand());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OnAttack(new BITConstant.Command.AttackCommand());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user