Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ArmoryComponent.c
Go to the documentation of this file.
1 [EntityEditorProps(category: "GameScripted/ScriptWizard", description: "Component handling Armory and ammo storage compositions.", color: "0 0 255 255")]
2 class SCR_ArmoryComponentClass : ScriptComponentClass
3 {
4 }
5 
6 class SCR_ArmoryComponent : ScriptComponent
7 {
8  protected ref array <SCR_FactionAffiliationComponent> m_aFactionAffiliationComponents = {};
9  protected RplComponent m_RplComponent;
10 
11  //------------------------------------------------------------------------------------------------
13  bool IsProxy()
14  {
15  return (m_RplComponent && m_RplComponent.IsProxy());
16  }
17 
18  //------------------------------------------------------------------------------------------------
21  void ChangeOwningFaction(notnull Faction faction)
22  {
23  if (IsProxy())
24  return;
25 
26  FactionKey key = faction.GetFactionKey();
27 
29  {
30  factionComp.SetAffiliatedFactionByKey(key);
31  }
32  }
33 
34  //------------------------------------------------------------------------------------------------
35  protected void OnLinkedEntitiesSpawned(SCR_EditorLinkComponent link)
36  {
38  link.GetOnLinkedEntitiesSpawned().Remove(OnLinkedEntitiesSpawned);
39  }
40 
41  //------------------------------------------------------------------------------------------------
44  protected void FindFactionComponentsInHiearchy(IEntity entity)
45  {
46  IEntity child = entity.GetChildren();
48 
49  while (child)
50  {
51  if (child.GetChildren())
53 
54  factionComp = SCR_FactionAffiliationComponent.Cast(child.FindComponent(SCR_FactionAffiliationComponent));
55  if (factionComp)
56  m_aFactionAffiliationComponents.Insert(factionComp);
57 
58  child = child.GetSibling();
59  }
60  }
61 
62  //------------------------------------------------------------------------------------------------
63  override void EOnInit(IEntity owner)
64  {
65  if (!GetGame().InPlayMode())
66  return;
67 
68  m_RplComponent = RplComponent.Cast(GetOwner().FindComponent(RplComponent));
69  if (!m_RplComponent)
70  return;
71 
72  if (IsProxy())
73  return;
74 
75  SCR_EditorLinkComponent link = SCR_EditorLinkComponent.Cast(owner.FindComponent(SCR_EditorLinkComponent));
76  if (link)
77  link.GetOnLinkedEntitiesSpawned().Insert(OnLinkedEntitiesSpawned);
78  else
80  }
81 
82  //------------------------------------------------------------------------------------------------
83  // PostInit
84  override void OnPostInit(IEntity owner)
85  {
86  super.OnPostInit(owner);
87  SetEventMask(owner, EntityEvent.INIT);
88  }
89 }
FindFactionComponentsInHiearchy
protected void FindFactionComponentsInHiearchy(IEntity entity)
Definition: SCR_ArmoryComponent.c:44
m_aFactionAffiliationComponents
SCR_ArmoryComponentClass m_aFactionAffiliationComponents
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
OnLinkedEntitiesSpawned
protected void OnLinkedEntitiesSpawned(SCR_EditorLinkComponent link)
Definition: SCR_ArmoryComponent.c:35
ScriptComponent
SCR_SiteSlotEntityClass ScriptComponent
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
ChangeOwningFaction
void ChangeOwningFaction(notnull Faction faction)
Definition: SCR_ArmoryComponent.c:21
m_RplComponent
protected RplComponent m_RplComponent
Definition: SCR_ArmoryComponent.c:9
OnPostInit
override void OnPostInit(IEntity owner)
Called on PostInit when all components are added.
Definition: SCR_ArmoryComponent.c:84
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
IsProxy
bool IsProxy()
Definition: SCR_ArmoryComponent.c:13
SCR_ArmoryComponentClass
Definition: SCR_ArmoryComponent.c:2
EOnInit
override void EOnInit(IEntity owner)
Definition: SCR_ArmoryComponent.c:63
Faction
Definition: Faction.c:12
SCR_FactionAffiliationComponent
Definition: SCR_FactionAffiliationComponent.c:10
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180