Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_RemoveWeaponsContextAction.c
Go to the documentation of this file.
1// Un arm NPCs (Disabled)
4{
5 override bool CanBeShown(SCR_EditableEntityComponent selectedEntity, vector cursorWorldPosition, int flags)
6 {
7 //Disabled for now
8 return false;
9
10 if (selectedEntity.GetEntityType() == EEditableEntityType.CHARACTER)
11 {
12 DamageManagerComponent damageComponent = DamageManagerComponent.Cast(selectedEntity.GetOwner().FindComponent(DamageManagerComponent));
13 if (damageComponent && damageComponent.GetState() == EDamageState.DESTROYED)
14 return false;
15
16 return SCR_PossessingManagerComponent.GetPlayerIdFromMainEntity(selectedEntity.GetOwner()) <= 0;
17 }
18 return false;
19 }
20
21 //Check if character has any weapons
22 override bool CanBePerformed(SCR_EditableEntityComponent selectedEntity, vector cursorWorldPosition, int flags)
23 {
24 ChimeraCharacter character = ChimeraCharacter.Cast(selectedEntity.GetOwner());
25 if (character && character.IsInVehicle())
26 return false;
27
28 BaseWeaponManagerComponent wpnManager = BaseWeaponManagerComponent.Cast(selectedEntity.GetOwner().FindComponent(BaseWeaponManagerComponent));
29 if (!wpnManager)
30 return false;
31
32 array<IEntity> weapons = {};
33 return wpnManager.GetWeaponsList(weapons) > 0;
34 }
35
36 override void Perform(SCR_EditableEntityComponent selectedEntity, vector cursorWorldPosition)
37 {
38 //Check if anything changed while context action was active (Such as character died or got possessed)
39 if (!CanBeShown(selectedEntity, cursorWorldPosition, 0))
40 return;
41
42 ChimeraCharacter character = ChimeraCharacter.Cast(selectedEntity.GetOwner());
43 if (character && character.IsInVehicle())
44 return;
45
46 IEntity owner = selectedEntity.GetOwner();
47
48 BaseWeaponManagerComponent wpnManager = BaseWeaponManagerComponent.Cast(owner.FindComponent(BaseWeaponManagerComponent));
49 SCR_InventoryStorageManagerComponent inventory = SCR_InventoryStorageManagerComponent.Cast(owner.FindComponent(SCR_InventoryStorageManagerComponent));
50
51 if (!wpnManager || !inventory)
52 return;
53
54 array<IEntity> weapons = {};
55 wpnManager.GetWeaponsList(weapons);
56
57 foreach (IEntity weapon: weapons)
58 {
59 InventoryItemComponent pInvComp = InventoryItemComponent.Cast( weapon.FindComponent( InventoryItemComponent ) );
60 if (!pInvComp)
61 continue;
62 InventoryStorageSlot parentSlot = pInvComp.GetParentSlot();
63 if (!parentSlot)
64 continue;
65
66 inventory.TryRemoveItemFromStorage(weapon, parentSlot.GetStorage());
67 }
68 }
69};
SCR_EAIThreatSectorFlags flags
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
class SCR_ArsenalGameModeUIDataHolder SCR_BaseContainerCustomTitleUIInfo("m_UIInfo")
proto external Managed FindComponent(typename typeName)
EEditableEntityType GetEntityType(IEntity owner=null)
EEditableEntityType
Defines type of SCR_EditableEntityComponent. Assigned automatically based on IEntity inheritance.
EDamageState