Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
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")]
5
6class 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 //------------------------------------------------------------------------------------------------
45 {
46 IEntity child = entity.GetChildren();
48
49 while (child)
50 {
51 if (child.GetChildren())
53
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}
ArmaReforgerScripted GetGame()
Definition game.c:1398
void ChangeOwningFaction(notnull Faction faction)
void OnLinkedEntitiesSpawned(SCR_EditorLinkComponent link)
void FindFactionComponentsInHiearchy(IEntity entity)
SCR_ArmoryComponentClass m_aFactionAffiliationComponents
RplComponent m_RplComponent
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
proto external int SetEventMask(notnull IEntity owner, int mask)
proto external GenericComponent FindComponent(typename typeName)
proto external Managed FindComponent(typename typeName)
proto external IEntity GetChildren()
proto external IEntity GetSibling()
proto external GenericEntity GetOwner()
Get owner entity.
void EOnInit(IEntity owner)
EntityEvent
Various entity events.
Definition EntityEvent.c:14