Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
billboardset.c
Go to the documentation of this file.
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  GetGame().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  GetGame().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  GetGame().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 {
79 
80  void BillboardSet(string path)
81  {
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  GetGame().ConfigGetChildName(path, i, itemName);
97 
98  string typesPath = path + " " + itemName + " types";
99  string texturePath = path + " " + itemName + " texture";
100 
101  if (GetGame().ConfigIsExisting(typesPath) && GetGame().ConfigIsExisting(texturePath))
102  {
103  TStringArray types = new TStringArray();
104  string texture;
105  GetGame().ConfigGetText(texturePath, texture);
106  GetGame().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 }
GetGame
proto native CGame GetGame()
GetTextureByType
string GetTextureByType(string type)
Definition: billboardset.c:85
TStringArray
array< string > TStringArray
Definition: enscript.c:685
BillboardSet
void BillboardSet(string path)
Definition: billboardset.c:80
m_TypeTextureMapping
class BillboardSetHandler m_TypeTextureMapping
ErrorEx
enum ShapeType ErrorEx
BillboardSetHandler
Definition: billboardset.c:1
PlayerIdentity
The class that will be instanced (moddable)
Definition: gameplay.c:377
map
map
Definition: controlsxboxnew.c:3
g_Game
DayZGame g_Game
Definition: dayzgame.c:3727
LoadConfig
protected void LoadConfig(string path)
Definition: billboardset.c:90
array< ref BillboardSet >
ERPCs
ERPCs
Definition: erpcs.c:1
path
string path
Definition: optionselectormultistate.c:135