Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
billboardset.c
Go to the documentation of this file.
1
class
BillboardSetHandler
2
{
3
protected
bool
m_BillboardSetIndex
= -1;
4
protected
ref
array<ref BillboardSet>
m_BillboardSets
;
5
protected
static
const
string
ROOT_CLASS
=
"BillboardPresets"
;
6
protected
static
int
m_SetIndexCached
= -1;
//once we resolve the name into an index, we cache it(this disallows dynamic index swapping during mission's runtime)
7
8
string
GetTextureByType
(
string
type)
9
{
10
if
(
m_BillboardSetIndex
== -1)
11
return
""
;
12
BillboardSet
bbset =
m_BillboardSets
.Get(
m_BillboardSetIndex
);
13
return
bbset.GetTextureByType(type);
14
}
15
16
void
OnRPCIndex
(
int
index)
17
{
18
if
(!
m_BillboardSets
)
19
LoadBillboardConfigs
();
20
21
if
(
m_BillboardSets
&&
m_BillboardSets
.IsValidIndex(index))
22
{
23
m_BillboardSetIndex
= index;
24
}
25
}
26
27
protected
bool
LoadBillboardConfigs
()
28
{
29
m_BillboardSets
=
new
array<ref BillboardSet>
();
30
31
int
setCount =
g_Game
.ConfigGetChildrenCount(
ROOT_CLASS
);
32
33
for
(
int
setIndex = 0; setIndex < setCount; setIndex++)
34
{
35
string
setName;
36
g_Game
.ConfigGetChildName(
ROOT_CLASS
, setIndex, setName);
37
string
path
=
ROOT_CLASS
+
" "
+ setName;
38
m_BillboardSets
.Insert(
new
BillboardSet
(
path
));
39
}
40
41
return
true
;
42
}
43
44
static
bool
ActivateBillboardSet
(
string
setClassName,
PlayerIdentity
identity)
45
{
46
if
(!
g_Game
)
47
return
false
;
48
49
if
(
m_SetIndexCached
== -1)
50
{
51
int
setCount =
g_Game
.ConfigGetChildrenCount(
ROOT_CLASS
);
52
for
(
int
setIndex = 0; setIndex < setCount; setIndex++)
53
{
54
string
setName;
55
g_Game
.ConfigGetChildName(
ROOT_CLASS
, setIndex, setName);
56
57
if
(setName == setClassName)
58
{
59
m_SetIndexCached
= setIndex;
60
break
61
}
62
}
63
}
64
65
if
(
m_SetIndexCached
!= -1)
66
{
67
auto
param =
new
Param1<int>(
m_SetIndexCached
);
68
g_Game
.RPCSingleParam( identity.
GetPlayer
(),
ERPCs
.RPC_SET_BILLBOARDS, param,
true
, identity );
69
return
true
;
70
}
71
return
false
;
72
}
73
}
74
75
76
class
BillboardSet
77
{
78
protected
ref
map<string, string>
m_TypeTextureMapping
=
new
map<string, string>
();
79
80
void
BillboardSet
(
string
path
)
81
{
82
LoadConfig
(
path
);
83
}
84
85
string
GetTextureByType
(
string
type)
86
{
87
return
m_TypeTextureMapping
.Get(type);
88
}
89
90
protected
void
LoadConfig
(
string
path
)
91
{
92
int
count =
g_Game
.ConfigGetChildrenCount(
path
);
93
for
(
int
i = 0; i < count; i++ )
94
{
95
string
itemName;
96
g_Game
.ConfigGetChildName(
path
, i, itemName);
97
98
string
typesPath =
path
+
" "
+ itemName +
" types"
;
99
string
texturePath =
path
+
" "
+ itemName +
" texture"
;
100
101
if
(
g_Game
.ConfigIsExisting(typesPath) &&
g_Game
.ConfigIsExisting(texturePath))
102
{
103
TStringArray
types =
new
TStringArray
();
104
string
texture;
105
g_Game
.ConfigGetText(texturePath, texture);
106
g_Game
.ConfigGetTextArray(typesPath, types);
107
108
foreach
(
string
s: types)
109
{
110
m_TypeTextureMapping
.Insert(s,texture);
111
}
112
}
113
else
114
{
115
ErrorEx
(
"Billboard set incorrect configuration, type or texture param missing: "
+
path
);
116
}
117
118
}
119
}
120
}
m_TypeTextureMapping
class BillboardSetHandler m_TypeTextureMapping
BillboardSet
void BillboardSet(string path)
Definition
billboardset.c:80
GetTextureByType
string GetTextureByType(string type)
Definition
billboardset.c:85
LoadConfig
void LoadConfig(string path)
Definition
billboardset.c:90
BillboardSetHandler
Definition
billboardset.c:2
BillboardSetHandler::m_BillboardSets
ref array< ref BillboardSet > m_BillboardSets
Definition
billboardset.c:4
BillboardSetHandler::ActivateBillboardSet
static bool ActivateBillboardSet(string setClassName, PlayerIdentity identity)
Definition
billboardset.c:44
BillboardSetHandler::m_BillboardSetIndex
bool m_BillboardSetIndex
Definition
billboardset.c:3
BillboardSetHandler::LoadBillboardConfigs
bool LoadBillboardConfigs()
Definition
billboardset.c:27
BillboardSetHandler::ROOT_CLASS
static const string ROOT_CLASS
Definition
billboardset.c:5
BillboardSetHandler::m_SetIndexCached
static int m_SetIndexCached
Definition
billboardset.c:6
BillboardSetHandler::OnRPCIndex
void OnRPCIndex(int index)
Definition
billboardset.c:16
BillboardSetHandler::GetTextureByType
string GetTextureByType(string type)
Definition
billboardset.c:8
PlayerIdentityBase::GetPlayer
proto Man GetPlayer()
get player
PlayerIdentity
The class that will be instanced (moddable).
Definition
gameplay.c:389
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition
isboxcollidinggeometryproxyclasses.c:28
map
Definition
cachedequipmentstorage.c:4
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
ERPCs
ERPCs
Definition
erpcs.c:2
ErrorEx
enum ShapeType ErrorEx
TStringArray
array< string > TStringArray
Definition
enscript.c:712
path
string path
Definition
optionselectormultistate.c:142
Games
Dayz
scripts
3_game
billboardset.c
Generated by
1.17.0