5 #ifndef DISABLE_INVENTORY
7 protected bool m_bIsSwappingItems =
false;
8 protected string m_sItemToSwapName =
"";
10 protected EquipedLoadoutStorageComponent m_LoadoutStorage;
12 protected SCR_CharacterInventoryStorageComponent m_CharacterStorage;
15 [
Attribute(
"#AR-Inventory_Equip",
desc:
"What text should be displayed when the Equip action is available." )]
16 protected string m_sEquipActionString;
17 [
Attribute(
"#AR-Inventory_Swap",
desc:
"What text should be displayed when the Swap action is available." )]
18 protected string m_sSwapActionString;
19 [
Attribute(
"#AR-Inventory_Replaces",
desc:
"What text should be displayed when the Replace action is available." )]
20 protected string m_sReplaceActionString;
23 override protected void PerformActionInternal(SCR_InventoryStorageManagerComponent manager, IEntity pOwnerEntity, IEntity pUserEntity)
25 manager.EquipCloth( pOwnerEntity );
29 override bool CanBePerformedScript(IEntity user)
31 if ( !super.CanBePerformedScript( user ) )
35 m_LoadoutStorage = EquipedLoadoutStorageComponent.Cast( user.FindComponent( EquipedLoadoutStorageComponent ) );
37 if ( !m_LoadoutCloth )
44 array<typename> blockedSlots = {};
45 m_LoadoutCloth.GetBlockedSlots(blockedSlots);
46 foreach (
typename blockedArea : blockedSlots)
50 m_sItemToSwapName =
"";
51 m_bIsSwappingItems =
false;
56 if (!m_CharacterStorage)
57 m_CharacterStorage = SCR_CharacterInventoryStorageComponent.Cast(user.FindComponent(SCR_CharacterInventoryStorageComponent));
59 if (m_CharacterStorage)
62 m_CharacterStorage.GetBlockedSlots(blockedSlots);
63 if (blockedSlots.Contains(targetArea.Type()))
65 m_sItemToSwapName =
"";
66 m_bIsSwappingItems =
false;
80 if ( !itemComp || !itemComp.GetAttributes().GetUIInfo().GetName() )
82 m_sItemToSwapName = targetArea.ToString();
83 m_bIsSwappingItems =
false;
88 m_sItemToSwapName = itemComp.GetAttributes().GetUIInfo().GetName();
89 m_bIsSwappingItems =
true;
94 m_sItemToSwapName =
"";
95 m_bIsSwappingItems =
false;
102 override bool GetActionNameScript(out
string outName)
104 if (m_bIsSwappingItems)
106 string replaceAction =
string.Format(WidgetManager.Translate(m_sReplaceActionString), WidgetManager.Translate(m_sItemToSwapName));
107 outName =
string.Format(
"%1 %2", m_sSwapActionString, replaceAction );
110 outName = m_sEquipActionString;
116 override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
118 super.Init(pOwnerEntity, pManagerComponent);
122 IEntity item =
m_Item.GetOwner();
129 Print(
"Missing BaseLoadoutClothComponent", LogLevel.ERROR);