Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
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 };
InventoryStorageSlot
Definition: InventoryStorageSlot.c:12
EDamageState
EDamageState
Definition: EDamageState.c:12
SCR_RemoveWeaponContextAction
Definition: SCR_RemoveWeaponsContextAction.c:3
EEditableEntityType
EEditableEntityType
Defines type of SCR_EditableEntityComponent. Assigned automatically based on IEntity inheritance.
Definition: EEditableEntityType.c:5
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
InventoryItemComponent
Definition: InventoryItemComponent.c:12
SCR_SelectedEntitiesContextAction
Definition: SCR_SelectedEntitiesContextAction.c:10
SCR_BaseContainerCustomTitleUIInfo
void SCR_BaseContainerCustomTitleUIInfo(string propertyName, string format="%1")
Definition: Attributes.c:788
DamageManagerComponent
Definition: DamageManagerComponent.c:12
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468