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.
 
 
 
 
 
 

49 lines
1.5 KiB

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