Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_OpenVehicleStorageAction.c
Go to the documentation of this file.
2 {
3 #ifndef DISABLE_INVENTORY
4  [Attribute("1")]
5  protected bool m_bShowFromOutside;
6 
7  [Attribute("1")]
8  protected bool m_bShowInside;
9 
10  [Attribute("0", desc: "If true will get Inventory from self even if parent (eg vehicle) also has an inventory.")]
11  protected bool m_bForceInventoryFromSelf;
12 
13  protected IEntity m_Vehicle;
14  protected IEntity m_InventoryOwner;
15  protected DamageManagerComponent m_DamageManager;
16  protected FactionAffiliationComponent m_VehicleAffiliation;
17 
18  //------------------------------------------------------------------------------------------------
19  override protected void PerformActionInternal(SCR_InventoryStorageManagerComponent manager, IEntity pOwnerEntity, IEntity pUserEntity)
20  {
21  manager.SetStorageToOpen(m_InventoryOwner);
22  manager.OpenInventory();
23  }
24 
25  //------------------------------------------------------------------------------------------------
26  override bool CanBeShownScript(IEntity user)
27  {
28  if (!user || !m_Vehicle || !m_InventoryOwner)
29  return false;
30 
31  if (m_DamageManager && m_DamageManager.GetState() == EDamageState.DESTROYED)
32  return false;
33 
34  ChimeraCharacter character = ChimeraCharacter.Cast(user);
35  if (character)
36  {
37  CompartmentAccessComponent compAccess = character.GetCompartmentAccessComponent();
38  if (compAccess && (compAccess.IsGettingIn() || compAccess.IsGettingOut()))
39  return false;
40 
41  if (!m_bShowFromOutside && !character.IsInVehicle())
42  return false;
43 
44  if (!m_bShowInside && character.IsInVehicle())
45  return false;
46  }
47 
48  if (!m_VehicleAffiliation)
49  return true;
50 
51  Faction vehicleFaction = m_VehicleAffiliation.GetAffiliatedFaction();
52  if (!vehicleFaction)
53  return true;
54 
55  FactionAffiliationComponent userAffiliation = FactionAffiliationComponent.Cast(user.FindComponent(FactionAffiliationComponent));
56  if (!userAffiliation)
57  return true;
58 
59  Faction userFaction = userAffiliation.GetAffiliatedFaction();
60  if (!userFaction)
61  return true;
62 
63  return !vehicleFaction.IsFactionEnemy(userFaction);
64  }
65 
66  //------------------------------------------------------------------------------------------------
67  override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
68  {
69  //~ Call one frame later as otherwise client slotted entity does not know yet who the vehicle is on init
70  GetGame().GetCallqueue().CallLater(DelayedInit, param1: pOwnerEntity, param2: pManagerComponent);
71  }
72 
73  //------------------------------------------------------------------------------------------------
74  protected void DelayedInit(IEntity pOwnerEntity, GenericComponent pManagerComponent)
75  {
76  if (!Vehicle.Cast(pOwnerEntity) && pOwnerEntity.GetParent())
77  m_Vehicle = pOwnerEntity.GetParent();
78  else
79  m_Vehicle = pOwnerEntity;
80 
81  //~ Set inventory owner the same as vehicle
82  if (!m_bForceInventoryFromSelf)
83  m_InventoryOwner = m_Vehicle;
84  //~ Set inventory owner as self
85  else
86  m_InventoryOwner = pOwnerEntity;
87 
88  if (!m_Vehicle)
89  return;
90 
92  m_VehicleAffiliation = FactionAffiliationComponent.Cast(m_Vehicle.FindComponent(FactionAffiliationComponent));
93  }
94 #endif
95 };
SCR_InventoryAction
modded version for to be used with the inventory 2.0
Definition: SCR_InventoryAction.c:3
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
EDamageState
EDamageState
Definition: EDamageState.c:12
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
Attribute
typedef Attribute
Post-process effect of scripted camera.
m_Vehicle
enum EAICompartmentType m_Vehicle
Faction
Definition: Faction.c:12
DamageManagerComponent
Definition: DamageManagerComponent.c:12
m_DamageManager
DamageManagerComponent m_DamageManager
Definition: SCR_AITargetInfo.c:19
SCR_OpenVehicleStorageAction
Definition: SCR_OpenVehicleStorageAction.c:1