using BehaviorDesigner.Runtime.Tasks; using UnityEngine; using xFrame; namespace CoreGame.Render { public class TrySwitchGunAction : Action { private enum TrySwitchGunType { NextGun = 0, MainGun = 1, SupportGun = 2, } [SerializeField] private TrySwitchGunType trySwitchGunType; public override TaskStatus OnUpdate() { var ownerEnt = Owner.GetEntity(); if (!ownerEnt.hasEquips) { XLog.LogWarning("TrySwitchGunAction: ownerEnt has no EquipsComponent"); return TaskStatus.Failure; } var equip = ownerEnt.equips; EquipData slotData = default; if (trySwitchGunType == TrySwitchGunType.NextGun) { slotData = equip.GetNextSlotData(); } else if (trySwitchGunType == TrySwitchGunType.MainGun) { slotData = equip.GetMainSlotData(); } else if (trySwitchGunType == TrySwitchGunType.SupportGun) { slotData = equip.GetSupportSlotData(); } if (slotData.equipEid == 0) { XLog.LogWarning("TrySwitchGunAction: slotData.equipEid is 0"); return TaskStatus.Failure; } return GunSrv.SwitchGun(ownerEnt, slotData.slotId) ? TaskStatus.Success : TaskStatus.Failure; } } }