Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_EquipClothAction.c
Go to the documentation of this file.
1//------------------------------------------------------------------------------------------------
4{
5 #ifndef DISABLE_INVENTORY
6
7 protected bool m_bIsSwappingItems = false;
8 protected string m_sItemToSwapName = "";
9
10 protected EquipedLoadoutStorageComponent m_LoadoutStorage;
13
14
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;
21
22 //------------------------------------------------------------------------------------------------
23 override protected void PerformActionInternal(SCR_InventoryStorageManagerComponent manager, IEntity pOwnerEntity, IEntity pUserEntity)
24 {
25 manager.EquipCloth( pOwnerEntity );
26 }
27
28 //------------------------------------------------------------------------------------------------
29 override bool CanBePerformedScript(IEntity user)
30 {
31 if ( !super.CanBePerformedScript( user ) )
32 return false;
33
34 if ( !m_LoadoutStorage )
35 m_LoadoutStorage = EquipedLoadoutStorageComponent.Cast( user.FindComponent( EquipedLoadoutStorageComponent ) );
36
37 if ( !m_LoadoutCloth )
38 return false;
39
40 LoadoutAreaType targetArea = m_LoadoutCloth.GetAreaType();
41 if (!targetArea)
42 return false;
43
44 array<typename> blockedSlots = {};
45 m_LoadoutCloth.GetBlockedSlots(blockedSlots);
46 foreach (typename blockedArea : blockedSlots)
47 {
48 if (m_LoadoutStorage.GetClothFromArea(blockedArea))
49 {
51 m_bIsSwappingItems = false;
52 return false;
53 }
54 }
55
58
60 {
61 blockedSlots.Clear();
62 m_CharacterStorage.GetBlockedSlots(blockedSlots);
63 if (blockedSlots.Contains(targetArea.Type()))
64 {
66 m_bIsSwappingItems = false;
67 return false;
68 }
69 }
70
71 // Checks if the desired area is occupied. If it's occupied it will save the UI info related to the replaced item is saved.
73 {
74 IEntity itemToSwap = m_LoadoutStorage.GetClothFromArea( targetArea.Type() );
75 if (itemToSwap)
76 {
78
79 // If the component is missing configuration we can fall back on the target area name.
80 if ( !itemComp || !itemComp.GetAttributes().GetUIInfo().GetName() )
81 {
82 m_sItemToSwapName = targetArea.ToString();
83 m_bIsSwappingItems = false;
84
85 return true;
86 }
87
88 m_sItemToSwapName = itemComp.GetAttributes().GetUIInfo().GetName();
89 m_bIsSwappingItems = true;
90 }
91 else
92 {
94 m_bIsSwappingItems = false;
95 }
96 }
97 else
98 {
100 m_bIsSwappingItems = false;
101 }
102
103 return true;
104 }
105
106 //------------------------------------------------------------------------------------------------
107 override bool GetActionNameScript(out string outName)
108 {
110 {
111 string replaceAction = string.Format(WidgetManager.Translate(m_sReplaceActionString), WidgetManager.Translate(m_sItemToSwapName));
112 outName = string.Format( "%1 %2", m_sSwapActionString, replaceAction );
113 }
114 else
115 outName = m_sEquipActionString;
116
117 return true;
118 }
119
120 //------------------------------------------------------------------------------------------------
121 override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
122 {
123 super.Init(pOwnerEntity, pManagerComponent);
124
125 if (!m_Item)
126 return;
127 IEntity item = m_Item.GetOwner();
128 if (!item)
129 return;
131
132 if (!m_LoadoutCloth)
133 {
134 Print("Missing BaseLoadoutClothComponent", LogLevel.ERROR);
135 return;
136 }
137 }
138
139 #endif
140};
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external Managed FindComponent(typename typeName)
modded version for to be used with the inventory 2.0
override bool CanBePerformedScript(IEntity user)
SCR_CharacterInventoryStorageComponent m_CharacterStorage
void PerformActionInternal(SCR_InventoryStorageManagerComponent manager, IEntity pOwnerEntity, IEntity pUserEntity)
BaseLoadoutClothComponent m_LoadoutCloth
EquipedLoadoutStorageComponent m_LoadoutStorage
override bool GetActionNameScript(out string outName)
override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
modded version for to be used with the inventory 2.0
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute