10 string m_MainPartName;
11 string m_MainPartNameNoTool;
26 int m_AttachmentsIndex;
35 m_AttachmentsIndex = 0;
40 m_ActionVariantManager.GetOnUpdateInvoker().Clear();
41 m_ActionVariantManager.GetOnUpdateInvoker().Insert(OnUpdateActions);
44 m_ActionNoToolVariantManager.GetOnUpdateInvoker().Clear();
45 m_ActionNoToolVariantManager.GetOnUpdateInvoker().Insert(OnUpdateActionsNoTool);
52 string GetMainPartName()
54 return m_MainPartName;
57 string GetMainPartNameNoTool()
59 return m_MainPartNameNoTool;
62 void SetTarget(
Object target )
74 m_TargetPart = target_part;
82 void SetSlotId(
int slot_id )
92 void SetActionInitiator(
PlayerBase action_initiator )
94 m_ActionInitiator = action_initiator;
99 return m_ActionInitiator;
108 void RefreshPartsToBuild(
string main_part_name,
ItemBase tool,
bool use_tool =
true )
113 void OnUpdateActions(
Object item,
Object target,
int component_index )
119 if ( base_building_object )
121 string main_part_name = target.GetActionComponentName( component_index );
122 base_building_object.GetConstruction().GetConstructionPartsToBuild( main_part_name, m_BuildParts, tool, m_MainPartName,
true );
123 m_ActionVariantManager.SetActionVariantCount(m_BuildParts.Count());
127 m_BuildParts.Clear();
128 m_ActionVariantManager.Clear();
134 m_BuildParts.Clear();
135 m_ActionVariantManager.Clear();
141 void OnUpdateActionsNoTool(
Object item,
Object target,
int component_index )
144 if ( base_building_object )
146 string main_part_name = target.GetActionComponentName( component_index );
147 base_building_object.GetConstruction().GetConstructionPartsToBuild( main_part_name, m_BuildPartsNoTool,
null, m_MainPartNameNoTool,
false );
148 m_ActionNoToolVariantManager.SetActionVariantCount(m_BuildPartsNoTool.Count());
152 m_BuildPartsNoTool.Clear();
153 m_ActionNoToolVariantManager.Clear();
157 int GetConstructionPartsCount()
159 return m_BuildParts.Count();
170 if( m_BuildParts.Count() > idx )
172 return m_BuildParts.Get( idx );
179 if( m_BuildPartsNoTool.Count() > idx )
181 return m_BuildPartsNoTool.Get( idx );
191 return m_CombinationLock;
199 string GetDialNumberText()
203 if ( m_CombinationLock )
205 string combination_text = m_CombinationLock.GetCombination().ToString();
208 int length_diff = m_CombinationLock.GetLockDigits() - combination_text.Length();
209 for (
int i = 0; i < length_diff; ++i )
211 combination_text =
"0" + combination_text;
215 for (
int j = 0; j < m_CombinationLock.GetLockDigits(); ++j )
217 if ( j == m_CombinationLock.GetDialIndex() )
219 dial_text +=
string.Format(
"[%1]", combination_text.Get( j ) );
223 dial_text +=
string.Format(
" %1 ", combination_text.Get( j ) );
236 string cfg_path =
"cfgVehicles" +
" " + target.GetType() +
" "+
"GUIInventoryAttachmentsProps";
238 if (
GetGame().ConfigIsExisting( cfg_path ) )
240 int child_count =
GetGame().ConfigGetChildrenCount( cfg_path );
242 for (
int i = 0; i < child_count; i++ )
245 GetGame().ConfigGetChildName( cfg_path, i, child_name );
247 string child_selection;
248 GetGame().ConfigGetText( cfg_path +
" " + child_name +
" " +
"selection", child_selection );
250 if ( selection == child_selection )
253 GetGame().ConfigGetTextArray( cfg_path +
" " + child_name +
" " +
"attachmentSlots", attachment_slots );
255 for (
int j = 0; j < attachment_slots.Count(); ++j )
257 int target_slot_id =
InventorySlots.GetSlotIdFromString( attachment_slots.Get( j ) );
258 int item_slot_count = item_to_attach.GetInventory().GetSlotIdCount();
260 for (
int k = 0; k < item_slot_count; ++k )
262 int item_slot_id = item_to_attach.GetInventory().GetSlotId( k );
263 ItemBase attachment_item =
ItemBase.Cast( target.GetInventory().FindAttachment( item_slot_id ) );
265 if ( target_slot_id == item_slot_id )
267 if ( target.GetInventory().CanAddAttachmentEx( item_to_attach, item_slot_id ) && target.CanReceiveAttachment( item_to_attach, item_slot_id ) || attachment_item && attachment_item.CanBeCombined( item_to_attach ) )
269 if(target.CanDisplayAttachmentSlot(target_slot_id))
288 string cfg_path =
"cfgVehicles" +
" " + target.GetType() +
" "+
"GUIInventoryAttachmentsProps";
289 if (
GetGame().ConfigIsExisting( cfg_path ) )
291 int child_count =
GetGame().ConfigGetChildrenCount( cfg_path );
293 for (
int i = 0; i < child_count; i++ )
296 GetGame().ConfigGetChildName( cfg_path, i, child_name );
298 string child_selection;
299 GetGame().ConfigGetText( cfg_path +
" " + child_name +
" " +
"selection", child_selection );
301 if ( selection == child_selection )
304 GetGame().ConfigGetTextArray( cfg_path +
" " + child_name +
" " +
"attachmentSlots", attachment_slots );
306 for (
int j = 0; j < attachment_slots.Count(); ++j )
308 int target_slot_id =
InventorySlots.GetSlotIdFromString( attachment_slots.Get( j ) );
311 EntityAI attachment = target.GetInventory().FindAttachment( target_slot_id );
312 if ( attachment && target.GetInventory().CanRemoveAttachmentEx( attachment, target_slot_id ) && !target.GetInventory().GetSlotLock( target_slot_id ) )
314 attachments.Insert( attachment );
324 if ( target.ConfigGetBool(
"canBeSplit" ) && item && !target.IsFullQuantity() )
326 int quantity_used = target.ComputeQuantityUsed( item,
true );
327 if( quantity_used != 0 )
329 target.AddQuantity( quantity_used );
330 item.AddQuantity( -quantity_used );
335 void RefreshAttachmentsToDetach(
EntityAI target,
string main_part_name )
337 GetAttachmentsFromSelection( target, main_part_name, m_Attachments );
340 void SetNextAttachmentIndex()
342 if ( GetAttachmentsToDetachCount() > 1 )
344 if ( m_AttachmentsIndex <= GetAttachmentsToDetachCount() - 2 )
346 m_AttachmentsIndex++;
348 else if ( m_AttachmentsIndex >= GetAttachmentsToDetachCount() > - 1 )
350 m_AttachmentsIndex = 0;
355 m_AttachmentsIndex = 0;
359 int GetAttachmentsToDetachCount()
361 return m_Attachments.Count();
364 EntityAI GetActualAttachmentToDetach()
366 if ( GetAttachmentsToDetachCount() > 0 )
368 m_AttachmentsIndex =
Math.Clamp( m_AttachmentsIndex, 0, GetAttachmentsToDetachCount() - 1 );
370 if ( m_Attachments && GetAttachmentsToDetachCount() > ( m_AttachmentsIndex ) )
372 return m_Attachments.Get( m_AttachmentsIndex );
382 void ResetActionIndexes()
385 m_AttachmentsIndex = 0;