Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ResourceContainerItemData.c
Go to the documentation of this file.
1[BaseContainerProps(configRoot: true), BaseContainerCustomCheckIntTitleField("m_bEnabled", "Resource Container Data", "DISABLED - Resource Container Data", 1)]
3{
4 [Attribute(defvalue: EResourceType.SUPPLIES.ToString(), uiwidget: UIWidgets.ComboBox, desc: "Sets the type of Resource to be used.\nOnly a transaction matching Resource types can be successfully concluded.", enums: ParamEnumArray.FromEnum(EResourceType))]
6
7 //~ Max Resource Value set by InitData()
8 protected int m_iMaxResourceValue = -1;
9
10 //--------------------------------- Get resource amount ---------------------------------\\
11
17 {
19 }
20
21 //--------------------------------- Set resource amount ---------------------------------\\
22 //~ Set the resource amount. Done on InitData() taking the info from the ResourceComponent
23 protected void SetMaxResourceValue(int maxResourceValue)
24 {
25 m_iMaxResourceValue = maxResourceValue;
26 }
27
28 //--------------------------------- Get Resource Container ---------------------------------\\
29 //~ Get container data from SCR_ResourceComponent on Prefab
30 //~ Called on InitData()
31 protected SCR_ResourceContainer GetResourceContainer(notnull SCR_EntityCatalogEntry entry, bool showError = true)
32 {
33 //~ Load Prefab
34 Resource entityPrefab = Resource.Load(entry.GetPrefab());
35 if (!entityPrefab)
36 {
37 if (showError)
38 Debug.Error2("SCR_ResourceContainerItemData", "Data '" + entry.GetPrefab() + "' (index: " + entry.GetCatalogIndex() + ") in catalog '" + typename.EnumToString(EEntityCatalogType, entry.GetCatalogParent().GetCatalogType()) + "' has an invalid prefab!");
39
40 return null;
41 }
42
43 //~ Get entity source
44 IEntitySource entitySource = SCR_BaseContainerTools.FindEntitySource(entityPrefab);
45 if (!entitySource)
46 {
47 if (showError)
48 Debug.Error2("SCR_ResourceContainerItemData", "Data '" + entry.GetPrefab() + "' (index: " + entry.GetCatalogIndex() + ") in catalog '" + typename.EnumToString(EEntityCatalogType, entry.GetCatalogParent().GetCatalogType()) + "' has an invalid prefab!");
49
50 return null;
51 }
52
53 //~ Get SCR_ResourceComponent on prefab by looping through all components
54 SCR_ResourceContainer resourceContainerTemp;
55 SCR_ResourceContainer resourceContainer;
56 int componentsCount = entitySource.GetComponentCount();
57 for (int i = 0; i < componentsCount; i++)
58 {
59 //~ Check if correct component
60 IEntityComponentSource componentSource = entitySource.GetComponent(i);
61 if (componentSource.GetClassName().ToType().IsInherited(SCR_ResourceComponent))
62 {
63 //~ Grab the resource container BaseContainer
64 BaseContainerList baseContainers = componentSource.GetObjectArray("m_aContainers");
65
66 if (!baseContainers || baseContainers.Count() == 0)
67 {
68 if (showError)
69 Debug.Error2("SCR_ResourceContainerItemData", "Data '" + entry.GetPrefab() + "' (index: " + entry.GetCatalogIndex() + ") in catalog '" + typename.EnumToString(EEntityCatalogType, entry.GetCatalogParent().GetCatalogType()) + "' has 'SCR_ResourceComponent' but no SCR_ResourceContainer is assigned! (or container variable has been renamed)");
70
71 return null;
72 }
73
74 for (int j = baseContainers.Count() - 1; j >= 0; j--)
75 {
76 resourceContainer = SCR_ResourceContainer.Cast(BaseContainerTools.CreateInstanceFromContainer(baseContainers.Get(j)));
77
78 if (resourceContainer && resourceContainer.GetResourceType() == m_eResourceType)
79 return resourceContainer;
80
81 }
82 }
83 }
84
85 if (showError)
86 Debug.Error2("SCR_ResourceContainerItemData", "Data '" + entry.GetPrefab() + "' (index: " + entry.GetCatalogIndex() + ") in catalog '" + typename.EnumToString(EEntityCatalogType, entry.GetCatalogParent().GetCatalogType()) + "' has no 'SCR_ResourceComponent'!");
87
88 return null;
89 }
90
91 //--------------------------------- Init Data ---------------------------------\\
92 //~ Set resource amount. Note: Ignored if data is disabled
93 override void InitData(notnull SCR_EntityCatalogEntry entry)
94 {
95 //~ Safty: Already has Init called or invalid
96 if (m_iMaxResourceValue != -1)
97 return;
98
99 //~ Get resource container and set max resource value
100 SCR_ResourceContainer resourceContainer = GetResourceContainer(entry);
101 if (resourceContainer)
102 SetMaxResourceValue(resourceContainer.GetMaxResourceValue());
103 }
104};
EEntityCatalogType
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
SCR_ValuableIntelArsenalRefundEffect SCR_WeightedListArsenalRefundEffect BaseContainerCustomCheckIntTitleField("m_bEnabled", "Valuable Intel - Add XP", "(Disabled) Valuable Intel - Add XP", 1)
Definition Debug.c:13
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
void SetMaxResourceValue(int maxResourceValue)
Get max resource value of container Data obtained from if no max resource value found return max Resource value *int GetMaxResourceValue()
override void InitData(notnull SCR_EntityCatalogEntry entry)
SCR_ResourceContainer GetResourceContainer(notnull SCR_EntityCatalogEntry entry, bool showError=true)
SCR_FieldOfViewSettings Attribute