Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_DetachMagazineUserAction.c
Go to the documentation of this file.
2{
3 protected SCR_InventoryStorageManagerComponent m_InventoryManager;
4
5 override bool CanBeShownScript(IEntity user)
6 {
7 if (!super.CanBeShownScript(user))
8 return false;
9
11 {
13 if(!character)
14 return false;
15
16 m_InventoryManager = SCR_InventoryStorageManagerComponent.Cast(character.FindComponent(SCR_InventoryStorageManagerComponent));
17 }
18
19 if(!m_InventoryManager || !m_WeaponComponent.GetCurrentMagazine())
20 return false;
21
22 BaseMuzzleComponent muzzleComp = m_WeaponComponent.GetCurrentMuzzle();
23 if (GetOwner() != muzzleComp.GetOwner())
24 return false;
25
26 IEntity currentMag = m_WeaponComponent.GetCurrentMagazine().GetOwner();
28 BaseInventoryStorageComponent magStorage = magInventory.GetParentSlot().GetStorage();
29 WeaponAttachmentsStorageComponent wasc = WeaponAttachmentsStorageComponent.Cast(magStorage);
30 if (!wasc)
31 return false; // Must be a WeaponAttachmentsStorageComponent
32
33 return m_InventoryManager.CanRemoveItemFromStorage(currentMag, magStorage);
34 }
35
36 override protected void PerformActionInternal(SCR_InventoryStorageManagerComponent manager, IEntity pOwnerEntity, IEntity pUserEntity)
37 {
38 IEntity currentMag = m_WeaponComponent.GetCurrentMagazine().GetOwner();
40 BaseInventoryStorageComponent magStorage = magInventory.GetParentSlot().GetStorage();
41
42 WeaponAttachmentsStorageComponent wasc = WeaponAttachmentsStorageComponent.Cast(magStorage);
43 if (!wasc)
44 {
45 Print("ERROR: Magazine is no longer in the weapon", LogLevel.ERROR);
46 return; // Must be a WeaponAttachmentsStorageComponent
47 }
48
49 auto charCtrl = CharacterControllerComponent.Cast(m_InventoryManager.GetOwner().FindComponent(CharacterControllerComponent));
50 charCtrl.DetachCurrentMagazine();
51
52 m_InventoryManager.PlayItemSound(pOwnerEntity, "SOUND_UNEQUIP");
53 }
54
55 override bool GetActionNameScript(out string outName)
56 {
58 return false;
59
60 if (!m_WeaponComponent.GetCurrentMagazine())
61 return false;
62
63 IEntity currentMag = m_WeaponComponent.GetCurrentMagazine().GetOwner();
64 if (!currentMag)
65 return false;
66
68 if (!magItem)
69 return false;
70
71 UIInfo actionInfo = GetUIInfo();
72 UIInfo itemInfo = magItem.GetUIInfo();
73 if (actionInfo && itemInfo)
74 {
75 outName = string.Format("%1%2", actionInfo.GetName(), itemInfo.GetName());
76 return true;
77 }
78 else
79 {
80 return false;
81 }
82 }
83};
proto external Managed FindComponent(typename typeName)
override bool GetActionNameScript(out string outName)
void PerformActionInternal(SCR_InventoryStorageManagerComponent manager, IEntity pOwnerEntity, IEntity pUserEntity)
SCR_InventoryStorageManagerComponent m_InventoryManager
override bool CanBeShownScript(IEntity user)
BaseWeaponComponent m_WeaponComponent
static IEntity GetLocalControlledEntity()
UIInfo - allows to define UI elements.
Definition UIInfo.c:14
IEntity GetOwner()
Owner entity of the fuel tank.
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