Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
GetPortalMat.c
Go to the documentation of this file.
1
class
GetPortalMatRequest :
JsonApiStruct
2
{
3
4
ref array<int> matHeights =
new
array<int>;
5
ref array<int> matWidths =
new
array<int>;
6
ref array<string> socketNames =
new
array<string>;
7
8
void
GetPortalMatRequest()
9
{
10
RegV(
"matHeights"
);
11
RegV(
"matWidths"
);
12
RegV(
"socketNames"
);
13
}
14
}
15
16
class
GetPortalMatResponse
:
JsonApiStruct
17
{
18
ref array<string>
matNames
=
new
array<string>;
19
20
void
GetPortalMatResponse
()
21
{
22
RegV(
"matNames"
);
23
}
24
}
25
26
class
GetPortalMat
: NetApiHandler
27
{
28
29
ref array<string> Portals =
new
array<string>();
30
31
override
JsonApiStruct
GetRequest
()
32
{
33
return
new
GetPortalMatRequest
();
34
}
35
36
override
JsonApiStruct
GetResponse(
JsonApiStruct
request)
37
{
38
GetPortalMatRequest
req =
GetPortalMatRequest
.Cast(request);
39
GetPortalMatResponse
response =
new
GetPortalMatResponse
();
40
41
// get all portal materials from assets
42
if
(Portals.Count() == 0)
43
{
44
SearchResourcesFilter
filter =
new
SearchResourcesFilter
();
45
filter.rootPath =
"$ArmaReforger:Assets"
;
46
filter.fileExtensions = {
"emat"
};
47
48
ResourceDatabase
.SearchResources(filter, Find);
49
}
50
51
for
(
int
i = 0; i < req.socketNames.Count(); i++)
52
{
53
// creating name with defined sizes
54
string
name =
"PRT_"
+ req.matWidths[i] +
"x"
+ req.matHeights[i];
55
foreach
(
string
portal : Portals)
56
{
57
// if the name with desired sizes was found add the matName + GUID to array
58
if
(
FilePath
.StripPath(portal).Contains(name))
59
{
60
ResourceManager resourceManager = Workbench.GetModule(ResourceManager);
61
MetaFile meta = resourceManager.GetMetaFile(portal);
62
string
guid = meta.GetResourceID().Substring(1, 16);
63
string
matName =
FilePath
.StripExtension(
FilePath
.StripPath(portal)) +
"_"
+ guid;
64
response.matNames.Insert(matName);
65
}
66
}
67
68
// if not add null
69
if
(i >= response.matNames.Count())
70
{
71
response.matNames.Insert(
""
);
72
}
73
}
74
return
response;
75
}
76
77
void
Find(
ResourceName
resName,
string
filePath)
78
{
79
// check if its a Portal material and if it meets naming convention so we could link the dimensions
80
Resource
resource =
Resource
.Load(resName);
81
BaseContainer
ematCont = resource.GetResource().ToBaseContainer();
82
if
(ematCont.GetClassName() ==
"MatLightPortal"
&& resName.Contains(
"PRT_"
))
83
{
84
Portals.Insert(filePath);
85
}
86
}
87
}
88
89
90
91
92
93
94
95
96
97
matNames
GetPortalMatRequest matNames
GetPortalMatResponse
void GetPortalMatResponse()
Definition
GetPortalMat.c:20
GetRequest
SCR_AICombatMoveRequestBase GetRequest()
Definition
SCR_AICombatMoveState.c:137
BaseContainer
Definition
BaseContainer.c:13
FilePath
Definition
FilePath.c:13
GetPortalMat
Definition
GetPortalMat.c:27
GetPortalMatRequest
Definition
GetPortalMat.c:2
JsonApiStruct
base classes for filtering in server browser
Definition
SCR_FeedbackDialogUI.c:3
ResourceDatabase
Definition
ResourceDatabase.c:13
Resource
Object holding reference to resource. In destructor release the resource.
Definition
Resource.c:25
ResourceName
Definition
ResourceName.c:13
SearchResourcesFilter
Object used for holding filtering params for ResourceDatabase.SearchResources() method.
Definition
System.c:9
scripts
WorkbenchGameCommon
EnfusionBlenderTools
GetPortalMat.c
Generated by
1.17.0