You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.7 KiB
56 lines
1.7 KiB
1 month ago
|
using BehaviorDesigner.Runtime.Tasks;
|
||
|
using GAS.Runtime;
|
||
|
using UnityEngine;
|
||
|
using xFrame;
|
||
|
|
||
|
namespace CoreGame.Render
|
||
|
{
|
||
|
public class CheckGunAmmoEmptyCondition : Conditional
|
||
|
{
|
||
|
private enum CheckGunType
|
||
|
{
|
||
|
CurrentGun = 0,
|
||
|
MainGun = 1,
|
||
|
SupportGun = 2,
|
||
|
}
|
||
|
|
||
|
[SerializeField] private CheckGunType checkGunType;
|
||
|
public override TaskStatus OnUpdate()
|
||
|
{
|
||
|
var ownerEnt = Owner.GetEntity<CombatEntity>();
|
||
|
if (!ownerEnt.hasEquips)
|
||
|
{
|
||
|
XLog.LogWarning("CheckGunAmmoEmptyCondition: ownerEnt has no EquipsComponent");
|
||
|
return TaskStatus.Failure;
|
||
|
}
|
||
|
var equip = ownerEnt.equips;
|
||
|
CombatEntity gun = null;
|
||
|
if (checkGunType == CheckGunType.CurrentGun)
|
||
|
{
|
||
|
gun = equip.GetHoldGunEntity();
|
||
|
}
|
||
|
else if (checkGunType == CheckGunType.MainGun)
|
||
|
{
|
||
|
gun = equip.GetMainGunEntity();
|
||
|
}
|
||
|
else if (checkGunType == CheckGunType.SupportGun)
|
||
|
{
|
||
|
gun = equip.GetSupportGunEntity();
|
||
|
}
|
||
|
|
||
|
if (gun == false)
|
||
|
{
|
||
|
XLog.LogWarning("CheckGunAmmoEmptyCondition: gun is invalid");
|
||
|
return TaskStatus.Failure;
|
||
|
}
|
||
|
var prop = gun.property;
|
||
|
var currCnt = (int)prop.GetProperty(PropertyDef.Ammo);
|
||
|
var bulletInfinite = ownerEnt.TagCountContainer.HasTag(GTagLib.Buff_BulletInfinite);
|
||
|
if (currCnt < 1 && bulletInfinite == false)
|
||
|
{
|
||
|
return TaskStatus.Success;
|
||
|
}
|
||
|
return TaskStatus.Failure;
|
||
|
}
|
||
|
}
|
||
|
}
|