13 CharacterControllerComponent m_Controller;
16 protected override void OnComplete()
23 protected override void OnFailed()
31 SCR_InventoryStorageManagerComponent
m_InvMan;
37 m_InvMan.EquipWeapon(m_pItem,
null,
false);
51 protected override void OnComplete()
55 m_pMenu.ShowStoragesList();
56 m_pMenu.ShowAllStoragesInList();
61 class SCR_CharacterInventoryStorageComponent : CharacterInventoryStorageComponent
64 [
Attribute(
"0", UIWidgets.EditBox,
"How much weight the character can carry")]
65 protected float m_fMaxWeight;
68 [
Attribute(
"0", UIWidgets.EditBox,
"How much volume the character can carry")]
71 #ifndef DISABLE_INVENTORY
74 protected ref array<IEntity>
m_aQuickSlots = {
null,
null,
null,
null,
null,
null,
null,
null,
null,
null };
79 protected static const int GADGET_OFFSET = 9999;
97 { EGadgetType.RADIO + GADGET_OFFSET },
98 { EGadgetType.BUILDING_TOOL + GADGET_OFFSET }
108 protected static const ref array<EWeaponType> WEAPON_TYPES_THROWABLE = {
EWeaponType.WT_FRAGGRENADE,
EWeaponType.WT_SMOKEGRENADE };
142 IEntity entity = slot.GetAttachedEntity();
166 void GetStorages( out notnull array<SCR_UniversalInventoryStorageComponent> storagesInInventory )
168 array<IEntity> pEntities = {};
169 int iNrOfStorages =
GetAll( pEntities );
172 foreach ( IEntity pEntity: pEntities )
176 storagesInInventory.Insert( pUniComp );
192 if ( pEntity ==
null )
208 m_LootStorage = BaseInventoryStorageComponent.Cast(pOwner.FindComponent(BaseInventoryStorageComponent));
249 if ( weaponComponent )
251 iItemType = weaponComponent.GetWeaponType();
256 SCR_GadgetComponent gadgetComponent = SCR_GadgetComponent.Cast( pItem.FindComponent( SCR_GadgetComponent ) );
257 if ( gadgetComponent )
259 EGadgetType gadgetType = gadgetComponent.GetType();
260 int consumableOffset = 0;
261 if (gadgetType == EGadgetType.CONSUMABLE)
263 SCR_ConsumableItemComponent consumable = SCR_ConsumableItemComponent.Cast(gadgetComponent);
265 consumableOffset = consumable.GetConsumableType();
267 iItemType = gadgetComponent.GetType() + GADGET_OFFSET + consumableOffset;
281 return DEFAULT_QUICK_SLOTS[iSlotIndex].Contains(iItemType);
300 foreach (
int i, ref array<int> allowedTypes: DEFAULT_QUICK_SLOTS)
302 if (allowedTypes.Contains(itemType))
334 if ( iSlotIndex == -1 )
339 parentSlot = itemComp.GetParentSlot();
341 if (parentSlot && EquipedWeaponStorageComponent.Cast(parentSlot.GetStorage()))
343 iSlotIndex = parentSlot.GetID();
347 for (
int iLoop, cnt =
m_aQuickSlots.Count(); iLoop < cnt; iLoop++)
369 if ( iSlotIndex == -1 )
375 if (turretCompartment)
380 array<IEntity> turretWeapons = {};
382 if (turretWeapons.Contains(pItem))
448 ChimeraCharacter character = ChimeraCharacter.Cast(
GetOwner());
452 CharacterControllerComponent controller = character.GetCharacterController();
456 IEntity gadget = controller.GetAttachedGadgetAtLeftHandSlot();
460 BaseWeaponManagerComponent weaponManager = controller.GetWeaponManagerComponent();
466 return weapon.GetOwner();
486 ChimeraCharacter character = ChimeraCharacter.Cast(
GetOwner());
490 CharacterControllerComponent controller = character.GetCharacterController();
494 if (controller.IsChangingItem())
497 if (controller.IsGadgetInHands())
498 controller.RemoveGadgetFromHand();
500 controller.SelectWeapon(
null);
507 ChimeraCharacter character = ChimeraCharacter.Cast(
GetOwner());
511 CharacterControllerComponent controller = character.GetCharacterController();
515 if (controller.IsChangingItem())
518 SCR_InventoryStorageManagerComponent storageManager = SCR_InventoryStorageManagerComponent.Cast(controller.GetInventoryStorageManager());
525 if (controller.IsGadgetInHands())
528 itemEnt = controller.GetAttachedGadgetAtLeftHandSlot();
529 storageManager.TryRemoveItemFromInventory(itemEnt);
533 BaseWeaponManagerComponent weaponManager = controller.GetWeaponManagerComponent();
541 SCR_EquipNextGrenadeCB
callback =
new SCR_EquipNextGrenadeCB();
544 itemEnt = currentSlot.GetWeaponEntity();
546 if (!storageManager.CanMoveItem(itemEnt))
551 if (WEAPON_TYPES_THROWABLE.Contains(
type))
552 callback.m_pItem = storageManager.FindNextWeaponOfType(
type, itemEnt,
true);
554 storageManager.SetInventoryLocked(
true);
555 controller.DropWeapon(currentSlot);
556 storageManager.SetInventoryLocked(
false);
565 super.OnAddedToSlot(item, slotID);
571 #ifdef DEBUG_INVENTORY20
581 if (!storageComponent)
588 UIInfo UIinfoItem = attr.GetUIInfo();
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);
599 super.OnRemovedFromSlot(item, slotID);
613 array<typename> blockedSlots = {};
615 loadoutComp.GetBlockedSlots(blockedSlots);
617 if (blockedSlots.IsEmpty())
622 foreach (
typename blockedSlot: blockedSlots)
629 foreach (
typename blockedSlot: blockedSlots)
656 SCR_ArmoredClothItemData armorAttr = SCR_ArmoredClothItemData.Cast(attributes.FindAttribute(SCR_ArmoredClothItemData));
658 if (armorAttr && damageMgr)
659 damageMgr.UpdateArmorDataMap(armorAttr, remove);
686 ChimeraCharacter character = ChimeraCharacter.Cast(
GetOwner());
690 CharacterControllerComponent charCtrl = character.GetCharacterController();
694 if (charCtrl.GetRightHandItem() == item || charCtrl.GetInputContext().GetLeftHandGadgetEntity() == item)
697 if (item.FindComponent(MagazineComponent))
705 if (charCtrl.IsChangingItem())
715 ChimeraCharacter character = ChimeraCharacter.Cast(
GetOwner());
719 CharacterControllerComponent controller = character.GetCharacterController();
727 else if (item.FindComponent(MagazineComponent))
731 else if (item.FindComponent(SCR_GadgetComponent))
735 switch (slotFunction)
744 if (!character.IsInVehicle())
757 SCR_ConsumableItemComponent consumableComp = SCR_ConsumableItemComponent.Cast(item.FindComponent(SCR_ConsumableItemComponent));
760 return (consumableComp
761 && consumableComp.GetConsumableEffect()
762 && consumableComp.GetConsumableEffect().CanApplyEffect(character, character));
766 SCR_GadgetComponent gadgetComp = SCR_GadgetComponent.Cast(item.FindComponent(SCR_GadgetComponent));
767 return (gadgetComp.GetMode() == EGadgetMode.IN_HAND && gadgetComp.CanBeToggled());
782 ChimeraCharacter character = ChimeraCharacter.Cast(
GetOwner());
786 CharacterControllerComponent controller = character.GetCharacterController();
793 if (item.FindComponent(MagazineComponent))
797 else if (item.FindComponent(SCR_GadgetComponent))
801 switch (slotFunction)
805 if (!character.IsInVehicle())
816 return currentWeapon && currentWeapon.GetOwner();
820 return controller.GetCanFireWeapon();
828 if (character.IsInVehicleADS())
831 return controller.CanEquipGadget(item);
845 ChimeraCharacter character = ChimeraCharacter.Cast(
GetOwner());
852 if (item.FindComponent(SCR_GadgetComponent))
856 else if (item.FindComponent(MagazineComponent))
862 switch (slotFunction)
868 SCR_MagazinePredicate predicate =
new SCR_MagazinePredicate();
869 predicate.magWellType = MagazineComponent.Cast(item.FindComponent(MagazineComponent)).GetMagazineWell().Type();
870 array<IEntity> magazines = {};
874 invMan.FindItems(magazines, predicate);
876 foreach (IEntity nextMag : magazines)
890 CharacterControllerComponent controller = character.GetCharacterController();
899 gadgetMgr.RemoveHeldGadget();
902 if (turretCompartment)
905 if (!turretController)
908 array<WeaponSlotComponent> turretWeaponSlots = {};
912 if (weaponSlot.GetWeaponEntity() == item)
913 return turretController.SelectWeapon(character, weaponSlot);
918 SCR_InventoryStorageManagerComponent inventoryManager = SCR_InventoryStorageManagerComponent.Cast(controller.GetInventoryStorageManager());
919 if (!inventoryManager)
923 BaseWeaponManagerComponent manager = controller.GetWeaponManagerComponent();
925 currentWeapon = manager.GetCurrentWeapon();
933 else if (currentWeapon && itemWeapon && currentWeapon.GetWeaponType() == itemWeapon.GetWeaponType() && WEAPON_TYPES_THROWABLE.Contains(itemWeapon.GetWeaponType()))
936 IEntity nextGrenade = inventoryManager.FindNextWeaponOfType(itemWeapon.GetWeaponType(), currentWeapon.GetOwner());
941 else if (currentWeapon && currentWeapon.GetOwner() == item && !controller.IsGadgetInHands())
944 int nextMuzzleID =
SCR_WeaponLib.GetNextMuzzleID(currentWeapon);
945 if (nextMuzzleID != -1)
946 return controller.SetMuzzle(nextMuzzleID);
969 if (character.IsInVehicleADS())
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());
981 gadgetMgr.SetGadgetMode(item, EGadgetMode.IN_HAND);
994 SCR_InventoryStorageManagerComponent storageMgr = SCR_InventoryStorageManagerComponent.Cast(character.GetCharacterController().GetInventoryStorageManager());
996 storageMgr.EquipAny(
this, item, -1, cb);
1004 SCR_InventoryStorageManagerComponent storageMgr = SCR_InventoryStorageManagerComponent.Cast(character.GetCharacterController().GetInventoryStorageManager());
1006 storageMgr.EquipAny(
this, item, -1, cb);
1015 ChimeraCharacter character = ChimeraCharacter.Cast(
GetOwner());
1019 CharacterControllerComponent controller = character.GetCharacterController();
1023 BaseWeaponManagerComponent weaponManager = controller.GetWeaponManagerComponent();
1031 if (!currentWeapon.IsReloadPossible())
1039 if (!currentMagWell)
1042 MagazineComponent magazine = MagazineComponent.Cast(item.FindComponent(MagazineComponent));
1043 if (!magazine || !magazine.GetMagazineWell())
1046 if (magazine.GetMagazineWell().Type() == currentMagWell.Type())
1058 ChimeraCharacter character = ChimeraCharacter.Cast(
GetOwner());
1062 CharacterControllerComponent controller = character.GetCharacterController();
1066 return controller.ReloadWeaponWith(item);
1072 ChimeraCharacter character = ChimeraCharacter.Cast(
GetOwner());
1076 CharacterControllerComponent controller = character.GetCharacterController();
1080 BaseWeaponManagerComponent weaponManager = controller.GetWeaponManagerComponent();
1082 weaponManager.GetWeaponsList(outWeapons);
1088 ChimeraCharacter character = ChimeraCharacter.Cast(
GetOwner());
1092 CompartmentAccessComponent compAccess = character.GetCompartmentAccessComponent();
1093 if (!compAccess || !compAccess.IsInCompartment())
1096 return compAccess.GetCompartment();
1110 BaseWeaponManagerComponent weaponManager = controller.GetWeaponManager();
1114 return weaponManager.GetCurrentWeapon();
1123 ChimeraCharacter character = ChimeraCharacter.Cast(pOwner);
1127 CharacterControllerComponent controller = character.GetCharacterController();
1131 SCR_InventoryStorageManagerComponent
pInventoryManager = SCR_InventoryStorageManagerComponent.Cast(controller.GetInventoryStorageManager());
1137 int i = DEFAULT_QUICK_SLOTS.Count();
1140 for (
int m = 0; m < i; m++ )
1149 array<IEntity> outWeapons = {};
1151 foreach ( IEntity weapon : outWeapons )
1157 array<IEntity> outItems = {};
1159 foreach ( IEntity pItem : outItems )
1175 charController.m_OnItemUseEndedInvoker.Insert(
OnItemUsed);
1205 if (!SCR_ConsumableItemComponent.Cast(item.FindComponent(SCR_ConsumableItemComponent)))
1210 if (quickSlot == -1)
1217 if (itemType > GADGET_OFFSET)
1218 t = SCR_GadgetComponent;
1220 SCR_ItemTypeSearchPredicate itemSearch =
new SCR_ItemTypeSearchPredicate(t, itemType, item);
1221 array<IEntity> items = {};
1227 invMan.FindItems(items, itemSearch);
1229 if (!items.IsEmpty())
1231 foreach (IEntity itm : items)
1248 protected void OnCompartmentEntered(IEntity targetEntity, BaseCompartmentManagerComponent manager,
int mgrID,
int slotID,
bool move)
1250 BaseCompartmentSlot compartment = manager.FindCompartment(slotID, mgrID);
1265 IEntity quickSlotEntity;
1266 SCR_InventoryStorageManagerComponent
pInventoryManager = SCR_InventoryStorageManagerComponent.Cast(
GetOwner().FindComponent( SCR_InventoryStorageManagerComponent));
1272 if (!quickSlotEntity)
1286 array<WeaponSlotComponent> turretWeaponSlots = {};
1293 IEntity weaponSlotEntity = weaponSlot.GetWeaponEntity();
1294 if (!weaponSlotEntity)
1311 protected void OnCompartmentLeft(IEntity targetEntity, BaseCompartmentManagerComponent manager,
int mgrID,
int slotID,
bool move)
1313 BaseCompartmentSlot compartment = manager.FindCompartment(slotID, mgrID);
1328 IEntity quickSlotEntity;
1329 SCR_InventoryStorageManagerComponent
pInventoryManager = SCR_InventoryStorageManagerComponent.Cast(
GetOwner().FindComponent( SCR_InventoryStorageManagerComponent));
1335 if (!quickSlotEntity)
1363 if (!turretController)
1366 BaseWeaponManagerComponent weaponManager = turretController.GetWeaponManager();
1368 return weaponManager.GetWeaponsList(weaponsList);
1377 if (!turretController)
1380 BaseWeaponManagerComponent weaponManager = turretController.GetWeaponManager();
1382 return weaponManager.GetWeaponsSlots(weaponSlots);
1412 void GetStorages( out notnull array<SCR_UniversalInventoryStorageComponent> storagesInInventory );