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