Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ScenarioFrameworkPluginOnInventoryChange.c
Go to the documentation of this file.
3{
4 [Attribute(UIWidgets.Auto, desc: "What to do once object inventory has changed by item addition")]
5 ref array<ref SCR_ScenarioFrameworkActionBase> m_aActionsOnItemAdded;
6
7 [Attribute(UIWidgets.Auto, desc: "What to do once object inventory has changed by item removal")]
8 ref array<ref SCR_ScenarioFrameworkActionBase> m_aActionsOnItemRemoved;
9
10 IEntity m_Asset;
11
12 //------------------------------------------------------------------------------------------------
15 override void Init(SCR_ScenarioFrameworkLayerBase object)
16 {
17 if (!object)
18 return;
19
20 super.Init(object);
21 IEntity entity = object.GetSpawnedEntity();
22 if (!entity)
23 return;
24
25 m_Asset = entity;
26
27 //Inventory system is a mess and since different entities have different storage managers that don't have this properly inherited, we need to account for that here
28 SCR_InventoryStorageManagerComponent storageManager1 = SCR_InventoryStorageManagerComponent.Cast(m_Asset.FindComponent(SCR_InventoryStorageManagerComponent));
29 if (storageManager1)
30 {
31 storageManager1.m_OnItemAddedInvoker.Insert(OnItemAdded);
32 storageManager1.m_OnItemRemovedInvoker.Insert(OnItemRemoved);
33 return;
34 }
35
36 SCR_VehicleInventoryStorageManagerComponent storageManager2 = SCR_VehicleInventoryStorageManagerComponent.Cast(m_Asset.FindComponent(SCR_VehicleInventoryStorageManagerComponent));
37 if (storageManager2)
38 {
39 storageManager2.m_OnItemAddedInvoker.Insert(OnItemAdded);
40 storageManager2.m_OnItemRemovedInvoker.Insert(OnItemRemoved);
41 return;
42 }
43
44 SCR_ArsenalInventoryStorageManagerComponent storageManager3 = SCR_ArsenalInventoryStorageManagerComponent.Cast(m_Asset.FindComponent(SCR_ArsenalInventoryStorageManagerComponent));
45 if (storageManager3)
46 {
47 storageManager3.m_OnItemAddedInvoker.Insert(OnItemAdded);
48 storageManager3.m_OnItemRemovedInvoker.Insert(OnItemRemoved);
49 return;
50 }
51 }
52
53 //------------------------------------------------------------------------------------------------
57 protected void OnItemAdded(IEntity item, BaseInventoryStorageComponent storageOwner)
58 {
59 // Here you can debug specific Plugin instance.
60 // This can be also adjusted during runtime via Debug Menu > ScenarioFramework > Plugin Inspector
61 if (m_bDebug)
62 Print("[SCR_ScenarioFrameworkPluginOnInventoryChange.OnItemAdded] debug line (" + __FILE__ + " L" + __LINE__ + ")", LogLevel.WARNING);
63
64 foreach (SCR_ScenarioFrameworkActionBase action : m_aActionsOnItemAdded)
65 {
66 action.OnActivate(m_Asset);
67 }
68 }
69
70 //------------------------------------------------------------------------------------------------
74 protected void OnItemRemoved(IEntity item, BaseInventoryStorageComponent storageOwner)
75 {
76 // Here you can debug specific Plugin instance.
77 // This can be also adjusted during runtime via Debug Menu > ScenarioFramework > Plugin Inspector
78 if (m_bDebug)
79 Print("[SCR_ScenarioFrameworkPluginOnInventoryChange.OnItemRemoved] debug line (" + __FILE__ + " L" + __LINE__ + ")", LogLevel.WARNING);
80
81 foreach (SCR_ScenarioFrameworkActionBase action : m_aActionsOnItemRemoved)
82 {
83 action.OnActivate(m_Asset);
84 }
85 }
86
87 //------------------------------------------------------------------------------------------------
88 override array<ref SCR_ScenarioFrameworkActionBase> GetActions()
89 {
90 array<ref SCR_ScenarioFrameworkActionBase> combinedActions = {};
91
92 foreach (SCR_ScenarioFrameworkActionBase action : m_aActionsOnItemAdded)
93 {
94 combinedActions.Insert(action);
95 }
96
97 foreach (SCR_ScenarioFrameworkActionBase action : m_aActionsOnItemRemoved)
98 {
99 combinedActions.Insert(action);
100 }
101
102 return combinedActions;
103 }
104}
override void Init()
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
void SCR_ScenarioFrameworkLayerBase(IEntityComponentSource src, IEntity ent, IEntity parent)
void OnItemRemoved(IEntity item, BaseInventoryStorageComponent storageOwner)
override array< ref SCR_ScenarioFrameworkActionBase > GetActions()
void OnItemAdded(IEntity item, BaseInventoryStorageComponent storageOwner)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute