3 const string PRIMARY_WEAPON_TYPE =
"primary";
4 const string SECONDARY_WEAPON_TYPE =
"secondary";
5 const string GRENADE_WEAPON_TYPE =
"grenade";
7 protected bool m_bIsSwappingWeapons =
false;
8 protected string m_sWeaponToSwapName =
"";
10 protected ref array<WeaponSlotComponent> m_aWeaponSlots = {};
11 protected string m_sWeaponOnGroundType =
"";
12 protected int m_iSameTypeSlotsCount = 0;
16 bool CanEquipOrReplaceWeapon( IEntity userEntity )
18 ChimeraCharacter user = ChimeraCharacter.Cast( userEntity );
22 BaseWeaponManagerComponent weaponManager = user.GetCharacterController().GetWeaponManagerComponent();
26 m_iSameTypeSlotsCount = 0;
27 m_bIsSwappingWeapons =
false;
28 m_sWeaponToSwapName =
"";
31 if ( m_sWeaponOnGroundType == GRENADE_WEAPON_TYPE )
34 m_aWeaponSlots.Clear();
35 weaponManager.GetWeaponsSlots( m_aWeaponSlots );
37 string weaponSlotType;
42 weaponSlotType = weaponSlot.GetWeaponSlotType();
44 if ( weaponSlotType != m_sWeaponOnGroundType && !CharacterHandWeaponSlotComponent.Cast(weaponSlot) )
47 m_iSameTypeSlotsCount++;
49 if ( !weaponSlot.GetWeaponEntity() )
58 m_bIsSwappingWeapons =
true;
60 UIInfo weaponToSwapUIInfo = weaponToSwap.GetUIInfo();
63 if ( weaponToSwapUIInfo )
65 string weaponToSwapName = weaponToSwapUIInfo.GetName();
67 if ( !weaponToSwapName.IsEmpty() )
68 m_sWeaponToSwapName = weaponToSwapName;
71 m_sWeaponToSwapName = m_sWeaponOnGroundType;
78 override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
80 super.Init(pOwnerEntity, pManagerComponent);
84 Print(
"Pick up/equip UserAction is attached to an object which is not an item" , LogLevel.WARNING );
90 if ( !m_pWeaponOnGroundComponent )
92 m_sWeaponOnGroundType = m_pWeaponOnGroundComponent.GetWeaponSlotType();
105 if ( currentWeapon.GetWeaponSlotType() == m_sWeaponOnGroundType )
106 return currentWeapon;
110 string weaponSlotType;
115 weaponSlotType = weaponSlot.GetWeaponSlotType();
117 if ( weaponSlotType == m_sWeaponOnGroundType )