Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CharacterInventoryStorageComponent.c
Go to the documentation of this file.
2 {
3  IT_NONE = 16385
4 }
5 
6 [ComponentEditorProps(category: "GameScripted/Inventory", description: "Inventory 2.0", icon: HYBRID_COMPONENT_ICON)]
7 class SCR_CharacterInventoryStorageComponentClass: CharacterInventoryStorageComponentClass
8 {
9 }
10 
12 {
13  CharacterControllerComponent m_Controller;
14 
15  //------------------------------------------------------------------------------------------------
16  protected override void OnComplete()
17  {
18  m_Controller.TryEquipRightHandItem(m_pItem, EEquipItemType.EEquipTypeWeapon, false);
19  m_pItem = null;
20  }
21 
22  //------------------------------------------------------------------------------------------------
23  protected override void OnFailed()
24  {
25  m_pItem = null;
26  }
27 }
28 
29 class SCR_EquipNextGrenadeCB : SCR_InvCallBack
30 {
31  SCR_InventoryStorageManagerComponent m_InvMan;
32 
33  //------------------------------------------------------------------------------------------------
34  protected override void OnComplete()
35  {
36  if (m_pItem)
37  m_InvMan.EquipWeapon(m_pItem, null, false);
38 
39  m_pItem = null;
40  }
41 
42  //------------------------------------------------------------------------------------------------
43  protected override void OnFailed()
44  {
45  m_pItem = null;
46  }
47 }
48 
50 {
51  protected override void OnComplete()
52  {
53  if (m_pMenu)
54  {
55  m_pMenu.ShowStoragesList();
56  m_pMenu.ShowAllStoragesInList();
57  }
58  }
59 }
60 
61 class SCR_CharacterInventoryStorageComponent : CharacterInventoryStorageComponent
62 {
63  //TODO: define this on loadout level. This is temporary and will be removed!
64  [Attribute( "0", UIWidgets.EditBox, "How much weight the character can carry")]
65  protected float m_fMaxWeight;
66 
67  //TODO: define this on loadout level. This is temporary and will be removed!
68  [Attribute( "0", UIWidgets.EditBox, "How much volume the character can carry")]
69  protected float m_fMaxVolume;
70 
71  #ifndef DISABLE_INVENTORY
72 
73  private BaseInventoryStorageComponent m_LootStorage;
74  protected ref array<IEntity> m_aQuickSlots = { null, null, null, null, null, null, null, null, null, null };
75  protected ref map<IEntity, int> m_mSlotHistory = new map<IEntity, int>();
76  protected ref array<IEntity> m_aWeaponQuickSlotsStorage = {}; //Is used to store first four quickslots of turrets.
77  protected ref array< int > m_aQuickSlotsHistory = {}; //here we'll be remembering the items stored
78 // protected ref array<EntityComponentPrefabData> m_aPrefabsData = { null, null, null, null, null, null, null, null, null, null }; // todo: figure out the intentions
79  protected static const int GADGET_OFFSET = 9999; //EWeaponType && EGadgetType might be have the same number, offset it ( not nice (i agree) )
80 
81 // protected ref array<ref array<int>> m_aDefaultRiflemanQuickSlots = { { EWeaponType.WT_RIFLE, EWeaponType.WT_SNIPERRIFLE, EWeaponType.WT_MACHINEGUN },
82 // { EWeaponType.WT_HANDGUN, EWeaponType.WT_ROCKETLAUNCHER, EWeaponType.WT_GRENADELAUNCHER, ( EGadgetType.BINOCULARS ) + GADGET_OFFSET },
83 // { ( EGadgetType.FLASHLIGHT ) + GADGET_OFFSET },
84 // { EWeaponType.WT_FRAGGRENADE, EWeaponType.WT_SMOKEGRENADE },
85 // { ( EGadgetType.MAP ) + GADGET_OFFSET },
86 // { ( EGadgetType.COMPASS ) + GADGET_OFFSET }
87 // };
88 
89  protected static const ref array<ref array<int>> DEFAULT_QUICK_SLOTS = { { EWeaponType.WT_RIFLE, EWeaponType.WT_SNIPERRIFLE, EWeaponType.WT_MACHINEGUN },
90  { EWeaponType.WT_RIFLE, EWeaponType.WT_ROCKETLAUNCHER, EWeaponType.WT_GRENADELAUNCHER, EWeaponType.WT_SNIPERRIFLE, EWeaponType.WT_MACHINEGUN },
91  { EWeaponType.WT_HANDGUN },
92  { EWeaponType.WT_FRAGGRENADE },
93  { EWeaponType.WT_SMOKEGRENADE },
94  { EGadgetType.CONSUMABLE + GADGET_OFFSET + SCR_EConsumableType.BANDAGE },
95  { EGadgetType.CONSUMABLE + GADGET_OFFSET + SCR_EConsumableType.TOURNIQUET },
96  { EGadgetType.CONSUMABLE + GADGET_OFFSET + SCR_EConsumableType.MORPHINE, EGadgetType.CONSUMABLE + GADGET_OFFSET + SCR_EConsumableType.SALINE },
97  { EGadgetType.RADIO + GADGET_OFFSET }, // Preferably as GadgetRadio action, then it can be saline
98  { EGadgetType.BUILDING_TOOL + GADGET_OFFSET } // To be replaced with engineering tool
99  };
100 
101  protected ref array<typename> m_aBlockedSlots = {};
102  protected ref array<BaseInventoryStorageComponent> m_aStoragesInStorageList = {}; //here we remember the opened storages in the Inventory menu ( in the Storages list area )
104  protected BaseInventoryStorageComponent m_WeaponStorage;
105 
106  protected ref SCR_InvEquipCB m_Callback = new SCR_InvEquipCB();
107 
108  protected static const ref array<EWeaponType> WEAPON_TYPES_THROWABLE = { EWeaponType.WT_FRAGGRENADE, EWeaponType.WT_SMOKEGRENADE };
109 
110  //------------------------------------------------------------------------ USER METHODS ------------------------------------------------------------------------
111 
112  //------------------------------------------------------------------------------------------------
114  //TODO: define this on loadout level. This is temporary and will be removed!
115  float GetMaxLoad()
116  {
117  return m_fMaxWeight;
118  }
119 
120  //------------------------------------------------------------------------------------------------
122  BaseInventoryStorageComponent GetWeaponStorage()
123  {
124  if (!m_WeaponStorage)
125  m_WeaponStorage = BaseInventoryStorageComponent.Cast(GetOwner().FindComponent(EquipedWeaponStorageComponent));
126 
127  return m_WeaponStorage;
128  }
129 
130  //------------------------------------------------------------------------------------------------
134  {
135  // Not all attached Entities to slots are storages.
136  // For instance boots - even though attached to character storage slot by themselves represent item, not storage
137  // However if entity attached to slot it is guaranteed to have InventoryItemComponent
138  InventoryStorageSlot slot = GetSlotFromArea(eSlot.Type());
139  if (!slot)
140  return null;
141 
142  IEntity entity = slot.GetAttachedEntity();
143  if (!entity)
144  return null;
145 
146  return InventoryItemComponent.Cast(entity.FindComponent(InventoryItemComponent));
147  }
148 
149  //------------------------------------------------------------------------------------------------
152  BaseInventoryStorageComponent GetStorageFromLoadoutSlot( LoadoutAreaType eSlot )
153  {
154  return BaseInventoryStorageComponent.Cast( GetItemFromLoadoutSlot(eSlot) );
155  }
156 
157  //------------------------------------------------------------------------------------------------
158  protected bool HasStorageComponent( IEntity pEntity )
159  {
160  return GetStorageComponentFromEntity( pEntity ) != null;
161  }
162 
163  //------------------------------------------------------------------------------------------------
166  void GetStorages( out notnull array<SCR_UniversalInventoryStorageComponent> storagesInInventory )
167  {
168  array<IEntity> pEntities = {};
169  int iNrOfStorages = GetAll( pEntities );
170 
172  foreach ( IEntity pEntity: pEntities )
173  {
174  pUniComp = GetStorageComponentFromEntity(pEntity);
175  if( pUniComp )
176  storagesInInventory.Insert( pUniComp );
177  }
178  }
179 
180  //------------------------------------------------------------------------------------------------
182  void GetBlockedSlots(out notnull array<typename> blockedSlots)
183  {
184  blockedSlots.Copy(m_aBlockedSlots);
185  }
186 
187  //------------------------------------------------------------------------------------------------
191  {
192  if ( pEntity == null )
193  return null;
194 
196  }
197 
198  //------------------------------------------------------------------------------------------------
200  void SetLootStorage( IEntity pOwner )
201  {
202  if( !pOwner )
203  {
204  m_LootStorage = null;
205  return;
206  }
207 
208  m_LootStorage = BaseInventoryStorageComponent.Cast(pOwner.FindComponent(BaseInventoryStorageComponent));
209  }
210 
211  //------------------------------------------------------------------------------------------------
213  BaseInventoryStorageComponent GetLootStorage()
214  {
215  return m_LootStorage;
216  }
217 
218  //------------------------------------------------------------------------------------------------
221  bool GetIsStorageShown( notnull BaseInventoryStorageComponent pStorage )
222  {
223  return m_aStoragesInStorageList.Find( pStorage ) != -1;
224  }
225 
226  //------------------------------------------------------------------------------------------------
228  void SetStorageAsShown( notnull BaseInventoryStorageComponent pStorage )
229  {
230  if ( !GetIsStorageShown( pStorage ) )
231  m_aStoragesInStorageList.Insert( pStorage );
232  }
233 
234  //------------------------------------------------------------------------------------------------
236  void SetStorageAsHidden( notnull BaseInventoryStorageComponent pStorage )
237  {
238  m_aStoragesInStorageList.RemoveItem( pStorage );
239  }
240 
241  //------------------------------------------------------------------------------------------------
244  static int GetItemType( IEntity pItem )
245  {
246  int iItemType = -1;
247  //Weapons:
248  BaseWeaponComponent weaponComponent = BaseWeaponComponent.Cast( pItem.FindComponent( BaseWeaponComponent ) );
249  if ( weaponComponent )
250  {
251  iItemType = weaponComponent.GetWeaponType();
252  }
253  else
254  {
255  //Gadgets:
256  SCR_GadgetComponent gadgetComponent = SCR_GadgetComponent.Cast( pItem.FindComponent( SCR_GadgetComponent ) );
257  if ( gadgetComponent )
258  {
259  EGadgetType gadgetType = gadgetComponent.GetType();
260  int consumableOffset = 0;
261  if (gadgetType == EGadgetType.CONSUMABLE)
262  {
263  SCR_ConsumableItemComponent consumable = SCR_ConsumableItemComponent.Cast(gadgetComponent);
264  if (consumable)
265  consumableOffset = consumable.GetConsumableType();
266  }
267  iItemType = gadgetComponent.GetType() + GADGET_OFFSET + consumableOffset;
268  }
269  }
270 
271  return iItemType;
272  }
273 
274  //------------------------------------------------------------------------------------------------
279  bool ItemBelongsToSlot( int iItemType, int iSlotIndex )
280  {
281  return DEFAULT_QUICK_SLOTS[iSlotIndex].Contains(iItemType);
282  }
283 
284  //------------------------------------------------------------------------------------------------
287  int GetLastQuickSlotId(IEntity ent)
288  {
289  int result = m_mSlotHistory.Get(ent);
290  m_mSlotHistory.Remove(ent);
291  return result;
292  }
293 
294  //------------------------------------------------------------------------------------------------
297  int GetEntityQuickSlot(IEntity item)
298  {
299  int itemType = GetItemType(item);
300  foreach (int i, ref array<int> allowedTypes: DEFAULT_QUICK_SLOTS)
301  {
302  if (allowedTypes.Contains(itemType))
303  return i;
304  }
305 
306  return -1;
307  }
308 
309  //------------------------------------------------------------------------------------------------
312  bool IsItemAlreadyInQuickSlot(IEntity item)
313  {
314  int itemType = GetItemType(item);
315  if (itemType < 0)
316  return false;
317 
318  int slotId = GetEntityQuickSlot(item);
319  if (slotId < 0)
320  return false;
321 
322  return m_aQuickSlots[slotId] == item;
323  }
324 
325  //------------------------------------------------------------------------------------------------
331  int StoreItemToQuickSlot( notnull IEntity pItem, int iSlotIndex = -1, bool isForced = false )
332  {
333  int iItemType = GetItemType( pItem );
334  if ( iSlotIndex == -1 ) //we don't know what slot we put the item into. Check first if we remember the type of the item
335  {
336  InventoryItemComponent itemComp = InventoryItemComponent.Cast(pItem.FindComponent(InventoryItemComponent));
337  InventoryStorageSlot parentSlot;
338  if (itemComp)
339  parentSlot = itemComp.GetParentSlot();
340 
341  if (parentSlot && EquipedWeaponStorageComponent.Cast(parentSlot.GetStorage()))
342  {
343  iSlotIndex = parentSlot.GetID();
344  }
345  else
346  {
347  for (int iLoop, cnt = m_aQuickSlots.Count(); iLoop < cnt; iLoop++) //go through the all quick slots
348  {
349  if ( m_aQuickSlots[ iLoop ] ) //do it only for the empty slots
350  continue;
351  if ( iItemType == m_aQuickSlotsHistory[ iLoop ] ) // there was aready something in the slot with this index
352  {
353  iSlotIndex = iLoop;
354  break;
355  }
356  else
357  {
358  //there was nothing before, put the item into slot defined by the template ( DEFAULT_QUICK_SLOTS )
359  if ( ItemBelongsToSlot( iItemType, iLoop ) )
360  {
361  iSlotIndex = iLoop;
362  break;
363  }
364  }
365  }
366  }
367  }
368 
369  if ( iSlotIndex == -1 ) //any suitable slot not found, do not insert into quick slot
370  return -1;
371 
372  if (!isForced)
373  {
375  if (turretCompartment)
376  {
377  if (iSlotIndex < SCR_InventoryMenuUI.WEAPON_SLOTS_COUNT)
378  return -1;
379 
380  array<IEntity> turretWeapons = {};
381  GetTurretWeaponsList(turretCompartment, turretWeapons);
382  if (turretWeapons.Contains(pItem))
383  return -1;
384  }
385  }
386 
387  if ( pItem == m_aQuickSlots.Get( iSlotIndex ) ) //if there's already the item in the slot, remove it
388  {
389  m_aQuickSlots.Set( iSlotIndex, null );
390  }
391  else
392  {
393  int iOldIndex = RemoveItemFromQuickSlot( pItem );
394  if ( 0 <= iOldIndex && iOldIndex < m_aQuickSlotsHistory.Count() )
395  m_aQuickSlotsHistory[ iOldIndex ] = 0; //in case the item is already in slot and we shift the item into a different slot
396  m_aQuickSlots.Set( iSlotIndex, pItem );
397 
398  m_aQuickSlotsHistory[ iSlotIndex ] = iItemType; // remember it
399  }
400 
401  return iSlotIndex;
402  }
403 
404  //------------------------------------------------------------------------------------------------
408  int RemoveItemFromQuickSlot( IEntity pItem )
409  {
410  int iIndex = m_aQuickSlots.Find( pItem );
411  if ( iIndex != -1 )
412  m_aQuickSlots.Set( iIndex, null );
413 
414  return iIndex;
415  }
416 
417  //------------------------------------------------------------------------------------------------
421  {
422  if (iIndex >= 0 && m_aQuickSlots.Get(iIndex))
423  m_aQuickSlots.Set(iIndex, null);
424  }
425 
426  //------------------------------------------------------------------------------------------------
428  array<IEntity> GetQuickSlotItems()
429  {
430  return m_aQuickSlots;
431  }
432 
433  //------------------------------------------------------------------------------------------------
437  {
438  if (!m_aQuickSlots.IsIndexValid(index))
439  return null;
440 
441  return m_aQuickSlots[index];
442  }
443 
444  //------------------------------------------------------------------------------------------------
446  IEntity GetCurrentItem()
447  {
448  ChimeraCharacter character = ChimeraCharacter.Cast(GetOwner());
449  if (!character)
450  return null;
451 
452  CharacterControllerComponent controller = character.GetCharacterController();
453  if (!controller)
454  return null;
455 
456  IEntity gadget = controller.GetAttachedGadgetAtLeftHandSlot();
457  if (gadget)
458  return gadget;
459 
460  BaseWeaponManagerComponent weaponManager = controller.GetWeaponManagerComponent();
461  if (!weaponManager)
462  return null;
463 
464  BaseWeaponComponent weapon = weaponManager.GetCurrentWeapon();
465  if (weapon)
466  return weapon.GetOwner();
467 
468  return null;
469  }
470 
471  //------------------------------------------------------------------------------------------------
473  IEntity GetSelectedItem()
474  {
475  // Selection is in progress
476  if (m_Callback.m_pItem)
477  return m_Callback.m_pItem;
478 
479  return GetCurrentItem();
480  }
481 
482  //------------------------------------------------------------------------------------------------
485  {
486  ChimeraCharacter character = ChimeraCharacter.Cast(GetOwner());
487  if (!character)
488  return;
489 
490  CharacterControllerComponent controller = character.GetCharacterController();
491  if (!controller)
492  return;
493 
494  if (controller.IsChangingItem())
495  return;
496 
497  if (controller.IsGadgetInHands())
498  controller.RemoveGadgetFromHand();
499  else
500  controller.SelectWeapon(null);
501  }
502 
503  //------------------------------------------------------------------------------------------------
506  {
507  ChimeraCharacter character = ChimeraCharacter.Cast(GetOwner());
508  if (!character)
509  return;
510 
511  CharacterControllerComponent controller = character.GetCharacterController();
512  if (!controller)
513  return;
514 
515  if (controller.IsChangingItem())
516  return;
517 
518  SCR_InventoryStorageManagerComponent storageManager = SCR_InventoryStorageManagerComponent.Cast(controller.GetInventoryStorageManager());
519  if (!storageManager)
520  return;
521 
522  IEntity itemEnt;
523 
524  // TODO: Also drop hidden sticky gadget
525  if (controller.IsGadgetInHands())
526  {
527  // TODO: Equip another gadget or consumable of same type
528  itemEnt = controller.GetAttachedGadgetAtLeftHandSlot();
529  storageManager.TryRemoveItemFromInventory(itemEnt);
530  return;
531  }
532 
533  BaseWeaponManagerComponent weaponManager = controller.GetWeaponManagerComponent();
534  if (!weaponManager)
535  return;
536 
537  WeaponSlotComponent currentSlot = weaponManager.GetCurrentSlot();
538  if (!currentSlot)
539  return;
540 
541  SCR_EquipNextGrenadeCB callback = new SCR_EquipNextGrenadeCB();
542 
543  EWeaponType type = currentSlot.GetWeaponType();
544  itemEnt = currentSlot.GetWeaponEntity();
545 
546  if (!storageManager.CanMoveItem(itemEnt))
547  return;
548 
549  callback.m_InvMan = storageManager;
550 
551  if (WEAPON_TYPES_THROWABLE.Contains(type))
552  callback.m_pItem = storageManager.FindNextWeaponOfType(type, itemEnt, true);
553 
554  storageManager.SetInventoryLocked(true);
555  controller.DropWeapon(currentSlot);
556  storageManager.SetInventoryLocked(false);
557  }
558 
559  //------------------------------------------------------------------------------------------------
563  protected override void OnAddedToSlot(IEntity item, int slotID)
564  {
565  super.OnAddedToSlot(item, slotID);
566 
567  UpdateBlockedSlots(item, slotID, true);
568 
569  EditArmoredAttributes(item, slotID);
570 
571  #ifdef DEBUG_INVENTORY20
572  // Loadout manager is taking care of this since there are some items that shouldn't be visible when attached to slot, some have different meshes for different states.
573  // Consider glasses in first person view - they deffinitely should be disabled
574  // it is slightly more complex then this
575 
576  InventoryItemComponent itemComponent = InventoryItemComponent.Cast(item.FindComponent(InventoryItemComponent));
577  if (!itemComponent)
578  return;
579 
581  if (!storageComponent)
582  return;
583 
584  SCR_ItemAttributeCollection attr = SCR_ItemAttributeCollection.Cast(storageComponent.GetAttributes());
585  if( !attr )
586  return;
587 
588  UIInfo UIinfoItem = attr.GetUIInfo();
589  if( !UIinfoItem )
590  return;
591 
592  Print(string.Format("INV: item %1 was added. It's weight is: %2, and total weight of item/storage is: %3", UIinfoItem.GetName(), attr.GetWeight(), storageComponent.GetTotalWeight()), LogLevel.NORMAL);
593  #endif
594  }
595 
596  //------------------------------------------------------------------------------------------------
597  protected override void OnRemovedFromSlot(IEntity item, int slotID)
598  {
599  super.OnRemovedFromSlot(item, slotID);
600 
601  UpdateBlockedSlots(item, slotID, false);
602 
603  EditArmoredAttributes(item, slotID, true);
604  }
605 
606  //------------------------------------------------------------------------------------------------
607  protected void UpdateBlockedSlots(IEntity item, int slotID, bool added)
608  {
609  BaseLoadoutClothComponent loadoutComp = BaseLoadoutClothComponent.Cast(item.FindComponent(BaseLoadoutClothComponent));
610  if (!loadoutComp)
611  return;
612 
613  array<typename> blockedSlots = {};
614 
615  loadoutComp.GetBlockedSlots(blockedSlots);
616 
617  if (blockedSlots.IsEmpty())
618  return;
619 
620  if (added)
621  {
622  foreach (typename blockedSlot: blockedSlots)
623  {
624  m_aBlockedSlots.Insert(blockedSlot);
625  }
626  }
627  else
628  {
629  foreach (typename blockedSlot: blockedSlots)
630  {
631  m_aBlockedSlots.RemoveItem(blockedSlot);
632  }
633  }
634  }
635 
636  //------------------------------------------------------------------------------------------------
639  bool IsAreaBlocked(typename areaType)
640  {
641  return m_aBlockedSlots.Contains(areaType);
642  }
643 
644  //------------------------------------------------------------------------------------------------
646  protected void EditArmoredAttributes(IEntity item, int slotID, bool remove = false)
647  {
648  InventoryItemComponent itemComponent = InventoryItemComponent.Cast(item.FindComponent(InventoryItemComponent));
649  if (!itemComponent)
650  return;
651 
652  SCR_ItemAttributeCollection attributes = SCR_ItemAttributeCollection.Cast(itemComponent.GetAttributes());
653  if (!attributes)
654  return;
655 
656  SCR_ArmoredClothItemData armorAttr = SCR_ArmoredClothItemData.Cast(attributes.FindAttribute(SCR_ArmoredClothItemData));
658  if (armorAttr && damageMgr)
659  damageMgr.UpdateArmorDataMap(armorAttr, remove);
660  }
661 
662  //------------------------------------------------------------------------------------------------
666  void HandleOnItemAddedToInventory( IEntity item, BaseInventoryStorageComponent storageOwner )
667  {
668  int targetQuickSlot = StoreItemToQuickSlot(item);
669  if (targetQuickSlot > -1 && SCR_WeaponSwitchingBaseUI.s_bOpened)
670  SCR_WeaponSwitchingBaseUI.RefreshQuickSlots(targetQuickSlot);
671  }
672 
673  //------------------------------------------------------------------------------------------------
677  void HandleOnItemRemovedFromInventory( IEntity item, BaseInventoryStorageComponent storageOwner )
678  {
679  m_mSlotHistory.Set(item, m_aQuickSlots.Find(item));
680  RemoveItemFromQuickSlot( item );
681  }
682 
683  // For use from inventory menu
684  bool CanEquipItem_Inventory(notnull IEntity item)
685  {
686  ChimeraCharacter character = ChimeraCharacter.Cast(GetOwner());
687  if (!character)
688  return false;
689 
690  CharacterControllerComponent charCtrl = character.GetCharacterController();
691  if (!charCtrl)
692  return false;
693 
694  if (charCtrl.GetRightHandItem() == item || charCtrl.GetInputContext().GetLeftHandGadgetEntity() == item)
695  return false;
696 
697  if (item.FindComponent(MagazineComponent))
698  return false;
699 
700  if (item.FindComponent(BaseLoadoutClothComponent))
701  return true;
702 
703  if (item.FindComponent(BaseWeaponComponent))
704  {
705  if (charCtrl.IsChangingItem())
706  return false;
707  }
708 
709  return CanUseItem(item);
710  }
711 
712  // For use from inventory menu
713  bool CanUseItem_Inventory(notnull IEntity item, ESlotFunction slotFunction = ESlotFunction.TYPE_GENERIC)
714  {
715  ChimeraCharacter character = ChimeraCharacter.Cast(GetOwner());
716  if (!character)
717  return false;
718 
719  CharacterControllerComponent controller = character.GetCharacterController();
720  if (!controller)
721  return false;
722 
723  if (slotFunction == ESlotFunction.TYPE_GENERIC)
724  {
725  if (item.FindComponent(BaseLoadoutClothComponent))
726  slotFunction = ESlotFunction.TYPE_CLOTHES;
727  else if (item.FindComponent(MagazineComponent))
728  slotFunction = ESlotFunction.TYPE_MAGAZINE;
729  else if (item.FindComponent(BaseWeaponComponent))
730  slotFunction = ESlotFunction.TYPE_WEAPON;
731  else if (item.FindComponent(SCR_GadgetComponent))
732  slotFunction = ESlotFunction.TYPE_GADGET;
733  }
734 
735  switch (slotFunction)
736  {
737  case ESlotFunction.TYPE_CLOTHES:
738  {
739  return false;
740  } break;
741 
742  case ESlotFunction.TYPE_MAGAZINE:
743  {
744  if (!character.IsInVehicle())
745  return CanReloadCurrentWeapon(item);
746 
747  return false;
748  } break;
749 
750  case ESlotFunction.TYPE_WEAPON:
751  {
752  return false;
753  } break;
754 
755  case ESlotFunction.TYPE_GADGET:
756  {
757  SCR_ConsumableItemComponent consumableComp = SCR_ConsumableItemComponent.Cast(item.FindComponent(SCR_ConsumableItemComponent));
758  if (consumableComp)
759  {
760  return (consumableComp
761  && consumableComp.GetConsumableEffect()
762  && consumableComp.GetConsumableEffect().CanApplyEffect(character, character));
763  }
764  else
765  {
766  SCR_GadgetComponent gadgetComp = SCR_GadgetComponent.Cast(item.FindComponent(SCR_GadgetComponent));
767  return (gadgetComp.GetMode() == EGadgetMode.IN_HAND && gadgetComp.CanBeToggled());
768  }
769  } break;
770  }
771 
772  return false;
773  }
774 
775  //------------------------------------------------------------------------------------------------
780  bool CanUseItem(notnull IEntity item, ESlotFunction slotFunction = ESlotFunction.TYPE_GENERIC)
781  {
782  ChimeraCharacter character = ChimeraCharacter.Cast(GetOwner());
783  if (!character)
784  return false;
785 
786  CharacterControllerComponent controller = character.GetCharacterController();
787  if (!controller)
788  return false;
789 
790  // Autodetect slot function if not provided
791  if (slotFunction == ESlotFunction.TYPE_GENERIC)
792  {
793  if (item.FindComponent(MagazineComponent))
794  slotFunction = ESlotFunction.TYPE_MAGAZINE;
795  else if (item.FindComponent(BaseWeaponComponent))
796  slotFunction = ESlotFunction.TYPE_WEAPON;
797  else if (item.FindComponent(SCR_GadgetComponent))
798  slotFunction = ESlotFunction.TYPE_GADGET;
799  }
800 
801  switch (slotFunction)
802  {
803  case ESlotFunction.TYPE_MAGAZINE:
804  {
805  if (!character.IsInVehicle())
806  return CanReloadCurrentWeapon(item);
807 
808  return false;
809  }
810 
811  case ESlotFunction.TYPE_WEAPON:
812  {
814  {
816  return currentWeapon && currentWeapon.GetOwner(); // TODO: != item
817  }
818  else
819  {
820  return controller.GetCanFireWeapon(); // TODO: Has multiple muzzles or has next grenade type
821  }
822 
823  return false;
824  }
825 
826  case ESlotFunction.TYPE_GADGET:
827  {
828  if (character.IsInVehicleADS())
829  return false;
830 
831  return controller.CanEquipGadget(item);
832  }
833  }
834 
835  return false;
836  }
837 
838  //------------------------------------------------------------------------------------------------
843  bool UseItem(notnull IEntity item, ESlotFunction slotFunction = ESlotFunction.TYPE_GENERIC)
844  {
845  ChimeraCharacter character = ChimeraCharacter.Cast(GetOwner());
846  if (!character)
847  return false;
848 
849  // Autodetect slot function
850  if (slotFunction == ESlotFunction.TYPE_GENERIC)
851  {
852  if (item.FindComponent(SCR_GadgetComponent))
853  slotFunction = ESlotFunction.TYPE_GADGET;
854  else if (item.FindComponent(BaseLoadoutClothComponent))
855  slotFunction = ESlotFunction.TYPE_CLOTHES;
856  else if (item.FindComponent(MagazineComponent))
857  slotFunction = ESlotFunction.TYPE_MAGAZINE;
858  else if (item.FindComponent(BaseWeaponComponent))
859  slotFunction = ESlotFunction.TYPE_WEAPON;
860  }
861 
862  switch (slotFunction)
863  {
864  case ESlotFunction.TYPE_MAGAZINE:
865  {
867 
868  SCR_MagazinePredicate predicate = new SCR_MagazinePredicate();
869  predicate.magWellType = MagazineComponent.Cast(item.FindComponent(MagazineComponent)).GetMagazineWell().Type();
870  array<IEntity> magazines = {};
871 
873  if (invMan)
874  invMan.FindItems(magazines, predicate);
875 
876  foreach (IEntity nextMag : magazines)
877  {
878  if (nextMag != item)
879  {
880  StoreItemToQuickSlot(nextMag);
881  break;
882  }
883  }
884 
885  return ReloadCurrentWeapon(item);
886  }
887 
888  case ESlotFunction.TYPE_WEAPON:
889  {
890  CharacterControllerComponent controller = character.GetCharacterController();
891  if (!controller)
892  return false;
893 
894  m_Callback.m_pItem = item;
895  m_Callback.m_Controller = controller;
896 
897  SCR_GadgetManagerComponent gadgetMgr = SCR_GadgetManagerComponent.GetGadgetManager(character);
898  if (gadgetMgr)
899  gadgetMgr.RemoveHeldGadget();
900 
902  if (turretCompartment)
903  {
904  TurretControllerComponent turretController = TurretControllerComponent.Cast(turretCompartment.GetController());
905  if (!turretController)
906  return false;
907 
908  array<WeaponSlotComponent> turretWeaponSlots = {};
909  GetTurretWeaponSlots(turretCompartment, turretWeaponSlots);
910  foreach (WeaponSlotComponent weaponSlot: turretWeaponSlots)
911  {
912  if (weaponSlot.GetWeaponEntity() == item)
913  return turretController.SelectWeapon(character, weaponSlot);
914  }
915  }
916  else
917  {
918  SCR_InventoryStorageManagerComponent inventoryManager = SCR_InventoryStorageManagerComponent.Cast(controller.GetInventoryStorageManager());
919  if (!inventoryManager)
920  return false;
921 
922  BaseWeaponComponent currentWeapon;
923  BaseWeaponManagerComponent manager = controller.GetWeaponManagerComponent();
924  if (manager)
925  currentWeapon = manager.GetCurrentWeapon();
926 
927  // Swap grenade type only if reselecting the same grenade slot
928  BaseWeaponComponent itemWeapon = BaseWeaponComponent.Cast(item.FindComponent(BaseWeaponComponent));
929  if (itemWeapon && itemWeapon.CanBeEquipped(controller) != ECanBeEquippedResult.OK)
930  {
931  return false;
932  }
933  else if (currentWeapon && itemWeapon && currentWeapon.GetWeaponType() == itemWeapon.GetWeaponType() && WEAPON_TYPES_THROWABLE.Contains(itemWeapon.GetWeaponType()))
934  {
935  // Equip different type of grenade
936  IEntity nextGrenade = inventoryManager.FindNextWeaponOfType(itemWeapon.GetWeaponType(), currentWeapon.GetOwner());
937  if (nextGrenade)
938  m_Callback.m_pItem = nextGrenade;
939  }
940  // Currently selected weapon can have alternative muzzle
941  else if (currentWeapon && currentWeapon.GetOwner() == item && !controller.IsGadgetInHands())
942  {
943  // Select next muzzle of a selected weapon
944  int nextMuzzleID = SCR_WeaponLib.GetNextMuzzleID(currentWeapon);
945  if (nextMuzzleID != -1)
946  return controller.SetMuzzle(nextMuzzleID);
947 
948  return false;
949  }
950 
951  // TODO: Interrupt current equipping process now
953  {
954  controller.TryEquipRightHandItem(m_Callback.m_pItem, EEquipItemType.EEquipTypeWeapon, false);
955  m_Callback.m_pItem = null;
956  }
957  else
958  {
959  inventoryManager.EquipWeapon(m_Callback.m_pItem, m_Callback, false);
960  }
961 
962  return true;
963  }
964  break;
965  }
966 
967  case ESlotFunction.TYPE_GADGET:
968  {
969  if (character.IsInVehicleADS())
970  return false;
971 
972  // need to run through manager
973  // TODO kamil: this doesnt call setmode when switching to other item from gadget (no direct call to scripted togglefocused for example, possibly other issues?)
974  SCR_GadgetManagerComponent gadgetMgr = SCR_GadgetManagerComponent.GetGadgetManager(character);
975  if (gadgetMgr)
976  {
977  SCR_GadgetComponent gadgetComp = SCR_GadgetComponent.Cast(item.FindComponent(SCR_GadgetComponent));
978  if (gadgetComp.GetMode() == EGadgetMode.IN_HAND && gadgetComp.CanBeToggled())
979  gadgetComp.ToggleActive(!gadgetComp.IsToggledOn());
980  else
981  gadgetMgr.SetGadgetMode(item, EGadgetMode.IN_HAND);
982  }
983  else
984  return false;
985 
986  return true;
987  }
988 
989  case ESlotFunction.TYPE_CLOTHES:
990  {
991  SCR_EquipGearCB cb = new SCR_EquipGearCB();
992  cb.m_pMenu = SCR_InventoryMenuUI.GetInventoryMenu();
993 
994  SCR_InventoryStorageManagerComponent storageMgr = SCR_InventoryStorageManagerComponent.Cast(character.GetCharacterController().GetInventoryStorageManager());
995  if (storageMgr)
996  storageMgr.EquipAny(this, item, -1, cb);
997  } break;
998 
999  case ESlotFunction.TYPE_STORAGE:
1000  {
1001  SCR_EquipGearCB cb = new SCR_EquipGearCB();
1002  cb.m_pMenu = SCR_InventoryMenuUI.GetInventoryMenu();
1003 
1004  SCR_InventoryStorageManagerComponent storageMgr = SCR_InventoryStorageManagerComponent.Cast(character.GetCharacterController().GetInventoryStorageManager());
1005  if (storageMgr)
1006  storageMgr.EquipAny(this, item, -1, cb);
1007  } break;
1008  }
1009  return false;
1010  }
1011 
1012  //------------------------------------------------------------------------------------------------
1013  protected bool CanReloadCurrentWeapon(notnull IEntity item)
1014  {
1015  ChimeraCharacter character = ChimeraCharacter.Cast(GetOwner());
1016  if (!character)
1017  return false;
1018 
1019  CharacterControllerComponent controller = character.GetCharacterController();
1020  if (!controller)
1021  return false;
1022 
1023  BaseWeaponManagerComponent weaponManager = controller.GetWeaponManagerComponent();
1024  if (!weaponManager)
1025  return false;
1026 
1027  BaseWeaponComponent currentWeapon = weaponManager.GetCurrent();
1028  if (!currentWeapon)
1029  return false;
1030 
1031  if (!currentWeapon.IsReloadPossible())
1032  return false;
1033 
1034  BaseMuzzleComponent currentMuzzle = currentWeapon.GetCurrentMuzzle();
1035  if (!currentMuzzle)
1036  return false;
1037 
1038  BaseMagazineWell currentMagWell = currentMuzzle.GetMagazineWell();
1039  if (!currentMagWell)
1040  return false;
1041 
1042  MagazineComponent magazine = MagazineComponent.Cast(item.FindComponent(MagazineComponent));
1043  if (!magazine || !magazine.GetMagazineWell())
1044  return false;
1045 
1046  if (magazine.GetMagazineWell().Type() == currentMagWell.Type())
1047  return true;
1048 
1049  return false;
1050  }
1051 
1052  //------------------------------------------------------------------------------------------------
1053  protected bool ReloadCurrentWeapon(IEntity item)
1054  {
1055  if (!item)
1056  return false;
1057 
1058  ChimeraCharacter character = ChimeraCharacter.Cast(GetOwner());
1059  if (!character)
1060  return false;
1061 
1062  CharacterControllerComponent controller = character.GetCharacterController();
1063  if (!controller)
1064  return false;
1065 
1066  return controller.ReloadWeaponWith(item);
1067  }
1068 
1069  //------------------------------------------------------------------------------------------------
1070  protected void GetPlayersWeapons( notnull inout array<IEntity> outWeapons )
1071  {
1072  ChimeraCharacter character = ChimeraCharacter.Cast(GetOwner());
1073  if (!character)
1074  return;
1075 
1076  CharacterControllerComponent controller = character.GetCharacterController();
1077  if (!controller)
1078  return;
1079 
1080  BaseWeaponManagerComponent weaponManager = controller.GetWeaponManagerComponent();
1081  if (weaponManager)
1082  weaponManager.GetWeaponsList(outWeapons);
1083  }
1084 
1085  //------------------------------------------------------------------------------------------------
1086  protected BaseCompartmentSlot GetCurrentCompartment()
1087  {
1088  ChimeraCharacter character = ChimeraCharacter.Cast(GetOwner());
1089  if (!character)
1090  return null;
1091 
1092  CompartmentAccessComponent compAccess = character.GetCompartmentAccessComponent();
1093  if (!compAccess || !compAccess.IsInCompartment())
1094  return null;
1095 
1096  return compAccess.GetCompartment();
1097  }
1098 
1099  //------------------------------------------------------------------------------------------------
1101  {
1102  BaseCompartmentSlot compartment = GetCurrentCompartment();
1103  if (!compartment)
1104  return null;
1105 
1106  TurretControllerComponent controller = TurretControllerComponent.Cast(compartment.GetController());
1107  if (!controller)
1108  return null;
1109 
1110  BaseWeaponManagerComponent weaponManager = controller.GetWeaponManager();
1111  if (!weaponManager)
1112  return null;
1113 
1114  return weaponManager.GetCurrentWeapon();
1115  }
1116 
1117  //------------------------------------------------------------------------------------------------
1121  void InitAsPlayer(IEntity pOwner, bool pControlled)
1122  {
1123  ChimeraCharacter character = ChimeraCharacter.Cast(pOwner);
1124  if (!character)
1125  return;
1126 
1127  CharacterControllerComponent controller = character.GetCharacterController();
1128  if (!controller)
1129  return;
1130 
1131  SCR_InventoryStorageManagerComponent pInventoryManager = SCR_InventoryStorageManagerComponent.Cast(controller.GetInventoryStorageManager());
1132  if ( !pInventoryManager )
1133  return;
1134 
1135  if( pControlled )
1136  {
1137  int i = DEFAULT_QUICK_SLOTS.Count();
1138  if ( m_aQuickSlotsHistory.Count() < i )
1139  {
1140  for ( int m = 0; m < i; m++ )
1141  {
1142  m_aQuickSlotsHistory.Insert( 0 ); //default is none
1143  }
1144  }
1145 
1146  //Insert weapons to quick slots as first, because they can't be equipped into hands directly from different storage than EquippedWeaponStorage
1147  //TODO: optimise ( hotfix for ability to select grenades from quickslot )
1148 
1149  array<IEntity> outWeapons = {};
1150  GetPlayersWeapons( outWeapons );
1151  foreach ( IEntity weapon : outWeapons )
1152  {
1153  StoreItemToQuickSlot( weapon );
1154  }
1155 
1156  // There may be unequipped grenades among default quick item slots as well
1157  array<IEntity> outItems = {};
1158  pInventoryManager.GetItems( outItems );
1159  foreach ( IEntity pItem : outItems )
1160  {
1161  if (!pItem)
1162  continue;
1163 
1164  if (IsItemAlreadyInQuickSlot(pItem))
1165  continue;
1166 
1167  StoreItemToQuickSlot( pItem );
1168  }
1169 
1170  pInventoryManager.m_OnItemAddedInvoker.Insert( HandleOnItemAddedToInventory );
1171  pInventoryManager.m_OnItemRemovedInvoker.Insert( HandleOnItemRemovedFromInventory );
1172 
1173  SCR_CharacterControllerComponent charController = SCR_CharacterControllerComponent.Cast(controller);
1174  if (charController)
1175  charController.m_OnItemUseEndedInvoker.Insert(OnItemUsed);
1176 
1177  m_CompartmentAcessComp = SCR_CompartmentAccessComponent.Cast(character.GetCompartmentAccessComponent());
1179  return;
1180 
1182  {
1183  m_CompartmentAcessComp.GetOnCompartmentEntered().Insert(OnCompartmentEntered);
1184  m_CompartmentAcessComp.GetOnCompartmentLeft().Insert(OnCompartmentLeft);
1185  }
1186  }
1187  else
1188  {
1189  pInventoryManager.m_OnItemAddedInvoker.Remove( HandleOnItemAddedToInventory );
1190  pInventoryManager.m_OnItemRemovedInvoker.Remove( HandleOnItemRemovedFromInventory );
1191 
1193  {
1194  m_CompartmentAcessComp.GetOnCompartmentEntered().Remove(OnCompartmentEntered);
1195  m_CompartmentAcessComp.GetOnCompartmentLeft().Remove(OnCompartmentLeft);
1196  }
1197  }
1198  }
1199 
1200  //------------------------------------------------------------------------------------------------
1201  // Called when item is used by the player
1202  protected void OnItemUsed(IEntity item, bool successful, ItemUseParameters animParams)
1203  {
1204  // If the item isn't consumable, return
1205  if (!SCR_ConsumableItemComponent.Cast(item.FindComponent(SCR_ConsumableItemComponent)))
1206  return;
1207 
1208  // restock used medical item back to its quick slot
1209  int quickSlot = m_aQuickSlots.Find(item);
1210  if (quickSlot == -1)
1211  return;
1212 
1213  RemoveItemFromQuickSlotAtIndex(quickSlot);
1214  int itemType = GetItemType(item);
1215 
1216  typename t = BaseWeaponComponent;
1217  if (itemType > GADGET_OFFSET)
1218  t = SCR_GadgetComponent;
1219 
1220  SCR_ItemTypeSearchPredicate itemSearch = new SCR_ItemTypeSearchPredicate(t, itemType, item);
1221  array<IEntity> items = {};
1222 
1224  if (!invMan)
1225  return;
1226 
1227  invMan.FindItems(items, itemSearch);
1228 
1229  if (!items.IsEmpty())
1230  {
1231  foreach (IEntity itm : items)
1232  {
1233  if (itm == item)
1234  continue;
1235  StoreItemToQuickSlot(itm, quickSlot);
1236  break;
1237  }
1238  }
1239  }
1240 
1241  //------------------------------------------------------------------------------------------------
1248  protected void OnCompartmentEntered(IEntity targetEntity, BaseCompartmentManagerComponent manager, int mgrID, int slotID, bool move)
1249  {
1250  BaseCompartmentSlot compartment = manager.FindCompartment(slotID, mgrID);
1251 
1252  if (m_CompartmentAcessComp && m_CompartmentAcessComp.IsGettingIn())
1253  {
1255  for (int i, count = m_aQuickSlots.Count(); i < SCR_InventoryMenuUI.WEAPON_SLOTS_COUNT && i < count; i++)
1256  {
1258  }
1259  }
1260 
1261  if (!TurretCompartmentSlot.Cast(compartment) && !m_aWeaponQuickSlotsStorage.IsEmpty())
1262  {
1264 
1265  IEntity quickSlotEntity;
1266  SCR_InventoryStorageManagerComponent pInventoryManager = SCR_InventoryStorageManagerComponent.Cast(GetOwner().FindComponent( SCR_InventoryStorageManagerComponent));
1267 
1268  for (int i; i < m_aWeaponQuickSlotsStorage.Count(); i++)
1269  {
1270  quickSlotEntity = m_aWeaponQuickSlotsStorage[i];
1271 
1272  if (!quickSlotEntity)
1273  continue;
1274 
1275  if (!pInventoryManager.Contains(quickSlotEntity))
1276  continue;
1277 
1278  StoreItemToQuickSlot(quickSlotEntity, i, true);
1279  }
1280 
1281  SCR_WeaponSwitchingBaseUI.RefreshQuickSlots();
1282 
1283  return;
1284  }
1285 
1286  array<WeaponSlotComponent> turretWeaponSlots = {};
1287  if (GetTurretWeaponSlots(compartment, turretWeaponSlots) > 0)
1288  {
1290 
1291  foreach (int i, WeaponSlotComponent weaponSlot: turretWeaponSlots)
1292  {
1293  IEntity weaponSlotEntity = weaponSlot.GetWeaponEntity();
1294  if (!weaponSlotEntity)
1295  continue;
1296 
1297  StoreItemToQuickSlot(weaponSlotEntity, i, true);
1298  }
1299  }
1300 
1301  SCR_WeaponSwitchingBaseUI.RefreshQuickSlots();
1302  }
1303 
1304  //------------------------------------------------------------------------------------------------
1311  protected void OnCompartmentLeft(IEntity targetEntity, BaseCompartmentManagerComponent manager, int mgrID, int slotID, bool move)
1312  {
1313  BaseCompartmentSlot compartment = manager.FindCompartment(slotID, mgrID);
1314 
1315  if (!TurretCompartmentSlot.Cast(compartment))
1316  {
1318  for (int i, count = m_aQuickSlots.Count(); i < SCR_InventoryMenuUI.WEAPON_SLOTS_COUNT && i < count; i++)
1319  {
1321  }
1322  }
1323 
1324  if (m_CompartmentAcessComp && m_CompartmentAcessComp.IsGettingOut())
1325  {
1327 
1328  IEntity quickSlotEntity;
1329  SCR_InventoryStorageManagerComponent pInventoryManager = SCR_InventoryStorageManagerComponent.Cast(GetOwner().FindComponent( SCR_InventoryStorageManagerComponent));
1330 
1331  for (int i; i < m_aWeaponQuickSlotsStorage.Count(); i++)
1332  {
1333  quickSlotEntity = m_aWeaponQuickSlotsStorage[i];
1334 
1335  if (!quickSlotEntity)
1336  continue;
1337 
1338  if (!pInventoryManager.Contains(quickSlotEntity))
1339  continue;
1340 
1341  StoreItemToQuickSlot(quickSlotEntity, i, true);
1342  }
1343 
1345  }
1346 
1347  SCR_WeaponSwitchingBaseUI.RefreshQuickSlots();
1348  }
1349 
1350  //------------------------------------------------------------------------------------------------
1352  {
1353  for (int i = 0; i < SCR_InventoryMenuUI.WEAPON_SLOTS_COUNT; i++)
1354  {
1356  }
1357  }
1358 
1359  //------------------------------------------------------------------------------------------------
1360  protected int GetTurretWeaponsList(BaseCompartmentSlot compartment, out array<IEntity> weaponsList)
1361  {
1362  TurretControllerComponent turretController = TurretControllerComponent.Cast(compartment.GetController());
1363  if (!turretController)
1364  return -1;
1365 
1366  BaseWeaponManagerComponent weaponManager = turretController.GetWeaponManager();
1367  if (weaponManager)
1368  return weaponManager.GetWeaponsList(weaponsList);
1369 
1370  return -1;
1371  }
1372 
1373  //------------------------------------------------------------------------------------------------
1374  protected int GetTurretWeaponSlots(BaseCompartmentSlot compartment, out array<WeaponSlotComponent> weaponSlots)
1375  {
1376  TurretControllerComponent turretController = TurretControllerComponent.Cast(compartment.GetController());
1377  if (!turretController)
1378  return -1;
1379 
1380  BaseWeaponManagerComponent weaponManager = turretController.GetWeaponManager();
1381  if (weaponManager)
1382  return weaponManager.GetWeaponsSlots(weaponSlots);
1383 
1384  return -1;
1385  }
1386 
1387  //------------------------------------------------------------------------ COMMON METHODS ----------------------------------------------------------------------
1388 
1389  #else
1390 
1391  //------------------------------------------------------------------------------------------------
1393  float GetMaxLoad();
1394 
1395  //------------------------------------------------------------------------------------------------
1397  BaseInventoryStorageComponent GetWeaponStorage();
1398 
1399  //------------------------------------------------------------------------------------------------
1402  InventoryItemComponent GetItemFromLoadoutSlot( ELoadoutArea eSlot );
1403 
1404  //------------------------------------------------------------------------------------------------
1407  BaseInventoryStorageComponent GetStorageFromLoadoutSlot( ELoadoutArea eSlot );
1408  protected bool HasStorageComponent( IEntity pEntity );
1409 
1410  //------------------------------------------------------------------------------------------------
1412  void GetStorages( out notnull array<SCR_UniversalInventoryStorageComponent> storagesInInventory );
1413 
1414  //------------------------------------------------------------------------------------------------
1418 
1419  //------------------------------------------------------------------------------------------------
1421  void SetLootStorage( IEntity pOwner );
1422 
1423  //------------------------------------------------------------------------------------------------
1425  BaseInventoryStorageComponent GetLootStorage();
1426  //override bool CanStoreItem(IEntity item, int slotID);
1427  //override bool CanRemoveItem(IEntity item);
1428  //protected override void OnRemovedFromSlot(IEntity item, int slotID);
1429  //override InventoryStorageSlot GetEmptySlotForItem( IEntity item );
1430  //protected override void OnAddedToSlot(IEntity item, int slotID);
1431  #endif
1432 }
m_InvMan
SCR_InvEquipCB m_InvMan
pInventoryManager
protected SCR_InventoryStorageManagerComponent pInventoryManager
Definition: SCR_UniversalInventoryStorageComponent.c:25
HandleOnItemRemovedFromInventory
void HandleOnItemRemovedFromInventory(IEntity item, BaseInventoryStorageComponent storageOwner)
Definition: SCR_CharacterInventoryStorageComponent.c:677
ReloadCurrentWeapon
protected bool ReloadCurrentWeapon(IEntity item)
Definition: SCR_CharacterInventoryStorageComponent.c:1053
ItemBelongsToSlot
bool ItemBelongsToSlot(int iItemType, int iSlotIndex)
Definition: SCR_CharacterInventoryStorageComponent.c:279
SCR_EConsumableType
SCR_EConsumableType
Type of consumable gadget.
Definition: SCR_ConsumableEffectBase.c:2
SCR_WeaponSwitchingBaseUI
Definition: SCR_WeaponSwitchingBaseUI.c:4
GetMaxLoad
float GetMaxLoad()
Definition: SCR_CharacterInventoryStorageComponent.c:115
HasStorageComponent
protected bool HasStorageComponent(IEntity pEntity)
Definition: SCR_CharacterInventoryStorageComponent.c:158
GetLastQuickSlotId
int GetLastQuickSlotId(IEntity ent)
Definition: SCR_CharacterInventoryStorageComponent.c:287
IsAreaBlocked
bool IsAreaBlocked(typename areaType)
Definition: SCR_CharacterInventoryStorageComponent.c:639
m_WeaponStorage
protected BaseInventoryStorageComponent m_WeaponStorage
Definition: SCR_CharacterInventoryStorageComponent.c:104
SCR_InvCallBack
Definition: SCR_InventoryMenuUI.c:56
SCR_CompartmentAccessComponent
Definition: SCR_CompartmentAccessComponent.c:15
m_aQuickSlotsHistory
protected ref array< int > m_aQuickSlotsHistory
Definition: SCR_CharacterInventoryStorageComponent.c:77
UseItem
bool UseItem(notnull IEntity item, ESlotFunction slotFunction=ESlotFunction.TYPE_GENERIC)
Definition: SCR_CharacterInventoryStorageComponent.c:843
m_Controller
protected CompartmentControllerComponent m_Controller
Definition: SCR_VehicleDamageManagerComponent.c:197
RemoveItemFromQuickSlotAtIndex
void RemoveItemFromQuickSlotAtIndex(int iIndex)
Definition: SCR_CharacterInventoryStorageComponent.c:420
CanReloadCurrentWeapon
protected bool CanReloadCurrentWeapon(notnull IEntity item)
Definition: SCR_CharacterInventoryStorageComponent.c:1013
HandleOnItemAddedToInventory
void HandleOnItemAddedToInventory(IEntity item, BaseInventoryStorageComponent storageOwner)
Definition: SCR_CharacterInventoryStorageComponent.c:666
SCR_WeaponLib
Definition: WeaponLib.c:6
InventoryStorageSlot
Definition: InventoryStorageSlot.c:12
UpdateBlockedSlots
protected void UpdateBlockedSlots(IEntity item, int slotID, bool added)
Definition: SCR_CharacterInventoryStorageComponent.c:607
m_CompartmentAcessComp
protected SCR_CompartmentAccessComponent m_CompartmentAcessComp
Definition: SCR_CharacterInventoryStorageComponent.c:103
ComponentEditorProps
enum EItemType ComponentEditorProps(category:"GameScripted/Inventory", description:"Inventory 2.0", icon:HYBRID_COMPONENT_ICON)
Definition: SCR_CharacterInventoryStorageComponent.c:6
GetTurretWeaponSlots
protected int GetTurretWeaponSlots(BaseCompartmentSlot compartment, out array< WeaponSlotComponent > weaponSlots)
Definition: SCR_CharacterInventoryStorageComponent.c:1374
GetCurrentCompartment
protected BaseCompartmentSlot GetCurrentCompartment()
Definition: SCR_CharacterInventoryStorageComponent.c:1086
GetQuickSlotItems
array< IEntity > GetQuickSlotItems()
Definition: SCR_CharacterInventoryStorageComponent.c:428
GetWeaponStorage
BaseInventoryStorageComponent GetWeaponStorage()
Definition: SCR_CharacterInventoryStorageComponent.c:122
OnRemovedFromSlot
protected override void OnRemovedFromSlot(IEntity item, int slotID)
Definition: SCR_CharacterInventoryStorageComponent.c:597
UIInfo
UIInfo - declare object, allows to define UI elements.
Definition: UIInfo.c:13
SCR_GadgetManagerComponent
Definition: SCR_GadgetManagerComponent.c:138
GetCurrentTurretWeapon
protected BaseWeaponComponent GetCurrentTurretWeapon()
Definition: SCR_CharacterInventoryStorageComponent.c:1100
GetStorages
void GetStorages(out notnull array< SCR_UniversalInventoryStorageComponent > storagesInInventory)
Definition: SCR_CharacterInventoryStorageComponent.c:166
ItemUseParameters
Definition: ItemUseParameters.c:15
GetTurretWeaponsList
protected int GetTurretWeaponsList(BaseCompartmentSlot compartment, out array< IEntity > weaponsList)
Definition: SCR_CharacterInventoryStorageComponent.c:1360
EEquipItemType
EEquipItemType
Definition: EEquipItemType.c:12
m_LootStorage
private BaseInventoryStorageComponent m_LootStorage
Definition: SCR_CharacterInventoryStorageComponent.c:73
SCR_UniversalInventoryStorageComponent
void SCR_UniversalInventoryStorageComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_UniversalInventoryStorageComponent.c:259
ECanBeEquippedResult
ECanBeEquippedResult
Definition: ECanBeEquippedResult.c:12
m_aBlockedSlots
protected ref array< typename > m_aBlockedSlots
Definition: SCR_CharacterInventoryStorageComponent.c:101
m_mSlotHistory
protected ref map< IEntity, int > m_mSlotHistory
Definition: SCR_CharacterInventoryStorageComponent.c:75
OnComplete
protected override void OnComplete()
Definition: SCR_CharacterInventoryStorageComponent.c:34
StoreItemToQuickSlot
int StoreItemToQuickSlot(notnull IEntity pItem, int iSlotIndex=-1, bool isForced=false)
Definition: SCR_CharacterInventoryStorageComponent.c:331
WeaponSlotComponent
Definition: WeaponSlotComponent.c:12
UnequipCurrentItem
void UnequipCurrentItem()
Unequip currently held item. Not allowed while switching to another item.
Definition: SCR_CharacterInventoryStorageComponent.c:484
GetItemFromLoadoutSlot
InventoryItemComponent GetItemFromLoadoutSlot(LoadoutAreaType eSlot)
Definition: SCR_CharacterInventoryStorageComponent.c:133
OnCompartmentEntered
protected void OnCompartmentEntered(IEntity targetEntity, BaseCompartmentManagerComponent manager, int mgrID, int slotID, bool move)
Definition: SCR_CharacterInventoryStorageComponent.c:1248
InitAsPlayer
void InitAsPlayer(IEntity pOwner, bool pControlled)
Definition: SCR_CharacterInventoryStorageComponent.c:1121
SCR_CharacterControllerComponent
Definition: SCR_CharacterControllerComponent.c:35
CanUseItem
bool CanUseItem(notnull IEntity item, ESlotFunction slotFunction=ESlotFunction.TYPE_GENERIC)
Definition: SCR_CharacterInventoryStorageComponent.c:780
CharacterInventoryStorageComponentClass
Definition: CharacterInventoryStorageComponent.c:12
RemoveItemFromQuickSlot
int RemoveItemFromQuickSlot(IEntity pItem)
Definition: SCR_CharacterInventoryStorageComponent.c:408
GetLootStorage
BaseInventoryStorageComponent GetLootStorage()
Definition: SCR_CharacterInventoryStorageComponent.c:213
OnFailed
protected override void OnFailed()
Definition: SCR_CharacterInventoryStorageComponent.c:43
GetSlotFromArea
EquipedLoadoutStorageComponentClass ScriptedBaseInventoryStorageComponentClass GetSlotFromArea(typename pAreaType)
Get the first slot that satisfies the condition : "slot area type is inherited by pAreaType".
InventoryStorageManagerComponent
Definition: InventoryStorageManagerComponent.c:12
SetStorageAsShown
void SetStorageAsShown(notnull BaseInventoryStorageComponent pStorage)
Definition: SCR_CharacterInventoryStorageComponent.c:228
OnAddedToSlot
protected override void OnAddedToSlot(IEntity item, int slotID)
Definition: SCR_CharacterInventoryStorageComponent.c:563
SetStorageAsHidden
void SetStorageAsHidden(notnull BaseInventoryStorageComponent pStorage)
Definition: SCR_CharacterInventoryStorageComponent.c:236
OnItemUsed
protected void OnItemUsed(IEntity item, bool successful, ItemUseParameters animParams)
Definition: SCR_CharacterInventoryStorageComponent.c:1202
SCR_CharacterDamageManagerComponent
Definition: SCR_CharacterDamageManagerComponent.c:18
BaseMagazineWell
Definition: BaseMagazineWell.c:12
m_aQuickSlots
protected ref array< IEntity > m_aQuickSlots
Definition: SCR_CharacterInventoryStorageComponent.c:74
m_fMaxVolume
protected float m_fMaxVolume
Definition: SCR_CharacterInventoryStorageComponent.c:69
TurretCompartmentSlot
Definition: TurretCompartmentSlot.c:12
BaseWeaponComponent
Definition: BaseWeaponComponent.c:12
m_aWeaponQuickSlotsStorage
protected ref array< IEntity > m_aWeaponQuickSlotsStorage
Definition: SCR_CharacterInventoryStorageComponent.c:76
RemoveItemsFromWeaponQuickSlots
protected void RemoveItemsFromWeaponQuickSlots()
Definition: SCR_CharacterInventoryStorageComponent.c:1351
CanEquipItem_Inventory
bool CanEquipItem_Inventory(notnull IEntity item)
Definition: SCR_CharacterInventoryStorageComponent.c:684
GetAll
proto external sealed int GetAll(out notnull array< IEntity > outItems)
IsItemAlreadyInQuickSlot
bool IsItemAlreadyInQuickSlot(IEntity item)
Definition: SCR_CharacterInventoryStorageComponent.c:312
SCR_InventoryMenuUI
Definition: SCR_InventoryMenuUI.c:247
CanUseItem_Inventory
bool CanUseItem_Inventory(notnull IEntity item, ESlotFunction slotFunction=ESlotFunction.TYPE_GENERIC)
Definition: SCR_CharacterInventoryStorageComponent.c:713
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
Contains
proto external sealed bool Contains(IEntity item)
IT_NONE
IT_NONE
Definition: SCR_CharacterInventoryStorageComponent.c:2
InventoryItemComponent
Definition: InventoryItemComponent.c:12
GetBlockedSlots
void GetBlockedSlots(out notnull array< typename > blockedSlots)
Definition: SCR_CharacterInventoryStorageComponent.c:182
GetPlayersWeapons
protected void GetPlayersWeapons(notnull inout array< IEntity > outWeapons)
Definition: SCR_CharacterInventoryStorageComponent.c:1070
SCR_ItemAttributeCollection
Definition: SCR_ItemAttributeCollection.c:2
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
DropCurrentItem
void DropCurrentItem()
Drop currently held item. Not allowed while switching to another item.
Definition: SCR_CharacterInventoryStorageComponent.c:505
TurretControllerComponent
Definition: TurretControllerComponent.c:12
GetSelectedItem
IEntity GetSelectedItem()
Definition: SCR_CharacterInventoryStorageComponent.c:473
GetEntityQuickSlot
int GetEntityQuickSlot(IEntity item)
Definition: SCR_CharacterInventoryStorageComponent.c:297
EItemType
EItemType
Definition: SCR_CharacterInventoryStorageComponent.c:1
type
EDamageType type
Definition: SCR_DestructibleTreeV2.c:32
SCR_InvEquipCB
Definition: SCR_CharacterInventoryStorageComponent.c:11
EWeaponType
EWeaponType
Definition: EWeaponType.c:12
BaseLoadoutClothComponent
Definition: BaseLoadoutClothComponent.c:12
OnCompartmentLeft
protected void OnCompartmentLeft(IEntity targetEntity, BaseCompartmentManagerComponent manager, int mgrID, int slotID, bool move)
Definition: SCR_CharacterInventoryStorageComponent.c:1311
ESlotFunction
ESlotFunction
Definition: SCR_InventorySlotUI.c:12
LoadoutAreaType
Definition: LoadoutAreaType.c:12
Attribute
SCR_EquipGearCB SCR_InvCallBack Attribute("0", UIWidgets.EditBox, "How much weight the character can carry")] protected float m_fMaxWeight
GetItemType
SCR_EArsenalItemType GetItemType()
Definition: SCR_ArsenalItem.c:24
m_Callback
protected ref SCR_InvEquipCB m_Callback
Definition: SCR_CharacterInventoryStorageComponent.c:106
callback
DownloadConfigCallback callback
GetIsStorageShown
bool GetIsStorageShown(notnull BaseInventoryStorageComponent pStorage)
Definition: SCR_CharacterInventoryStorageComponent.c:221
SetLootStorage
void SetLootStorage(IEntity pOwner)
Definition: SCR_CharacterInventoryStorageComponent.c:200
GetStorageComponentFromEntity
SCR_UniversalInventoryStorageComponent GetStorageComponentFromEntity(IEntity pEntity)
Definition: SCR_CharacterInventoryStorageComponent.c:190
m_aStoragesInStorageList
protected ref array< BaseInventoryStorageComponent > m_aStoragesInStorageList
Definition: SCR_CharacterInventoryStorageComponent.c:102
BaseMuzzleComponent
Definition: BaseMuzzleComponent.c:12
GetItemFromQuickSlot
IEntity GetItemFromQuickSlot(int index)
Definition: SCR_CharacterInventoryStorageComponent.c:436
GetStorageFromLoadoutSlot
BaseInventoryStorageComponent GetStorageFromLoadoutSlot(LoadoutAreaType eSlot)
Definition: SCR_CharacterInventoryStorageComponent.c:152
GetCurrentItem
IEntity GetCurrentItem()
Definition: SCR_CharacterInventoryStorageComponent.c:446
EditArmoredAttributes
protected void EditArmoredAttributes(IEntity item, int slotID, bool remove=false)
Take the data from the armor attribute, and store them in map on damagemanager.
Definition: SCR_CharacterInventoryStorageComponent.c:646
SCR_EquipGearCB
Definition: SCR_CharacterInventoryStorageComponent.c:49
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180