This commit is contained in:
CortexCore
2023-10-30 01:25:53 +08:00
parent add6d0cab3
commit 18f664a545
125 changed files with 3529 additions and 700 deletions

View File

@@ -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());
}
}
}