Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_BIKIMagazineHelper.c
Go to the documentation of this file.
2{
3 //------------------------------------------------------------------------------------------------
6 static ResourceName GetFirstBullet(notnull BaseContainer magazineContainer)
7 {
8 IEntityComponentSource magazineComponentSource = SCR_BaseContainerTools.FindComponentSource(magazineContainer, MagazineComponent);
9 if (!magazineComponentSource)
10 return ResourceName.Empty;
11
12 ResourceName config;
13 if (!magazineComponentSource.Get("AmmoConfig", config) || !config)
14 return ResourceName.Empty;
15
16 Resource resource = Resource.Load(config);
17 if (!resource.IsValid())
18 return ResourceName.Empty;
19
20 array<int> indices;
21 if (!magazineComponentSource.Get("AmmoMapping", indices) || indices.IsEmpty())
22 return ResourceName.Empty;
23
24 BaseContainer configContainer = resource.GetResource().ToBaseContainer();
25 array<ResourceName> ammoResourceNames;
26 if (!configContainer.Get("AmmoResourceArray", ammoResourceNames))
27 return ResourceName.Empty;
28
29 int index = indices[0];
30 if (!ammoResourceNames.IsIndexValid(index))
31 return ResourceName.Empty;
32
33 return ammoResourceNames[index];
34 }
35
36 //------------------------------------------------------------------------------------------------
39 static map<typename, ref array<ResourceName>> GetMagazineWells(notnull array<ResourceName> magazines)
40 {
41 if (magazines.IsEmpty())
43
45
46 Resource resource;
47 BaseContainer baseContainer;
48 IEntityComponentSource magazineComponentSource;
49 foreach (ResourceName magazine : magazines)
50 {
51 resource = Resource.Load(magazine);
52 if (!resource.IsValid())
53 continue;
54
55 //baseContainer = resource.GetResource().ToBaseContainer();
56 magazineComponentSource = SCR_BaseContainerTools.FindComponentSource(resource, MagazineComponent);
57 if (!magazineComponentSource)
58 continue;
59
60 baseContainer = magazineComponentSource.GetObject("MagazineWell");
61 if (!baseContainer)
62 continue;
63
64 typename typeName = baseContainer.GetClassName().ToType();
65 if (!typeName)
66 continue;
67
68 if (result.Contains(typeName))
69 result.Get(typeName).Insert(magazine);
70 else
71 result.Insert(typeName, { magazine });
72 }
73
74 return result;
75 }
76}
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
Definition Types.c:486