Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
pluginremoteplayerdebugclient.c
Go to the documentation of this file.
2 {
3  NONE,
5  ALL,
6 }
7 
8 class PluginRemotePlayerDebugClient extends PluginBase
9 {
10  const int MAX_SIMULTANIOUS_PLAYERS = 10;
13 
20 
21  override void OnInit()
22  {
23  #ifndef NO_GUI
24  InitWidgets();
25  #endif
26  }
27 
28  override void OnUpdate(float delta_time)
29  {
30  #ifndef NO_GUI
31  if ( m_DebugType !=0 ) UpdateWidgetsStats();
32  #endif
33  }
34 
35  void InitWidgets()
36  {
37  for (int i = 0; i < MAX_SIMULTANIOUS_PLAYERS; ++i)
38  {
39  m_RootWidget[i] = GetGame().GetWorkspace().CreateWidgets("gui/layouts/debug/day_z_debug_remoteinfo.layout");
40  m_RootWidgetDamage[i] = GetGame().GetWorkspace().CreateWidgets("gui/layouts/debug/day_z_debug_remoteinfo_damage.layout");
41  m_DamageListWidgets[i] = TextListboxWidget.Cast(m_RootWidgetDamage[i].FindAnyWidget("TextListboxWidget1"));
42  m_StatListWidgets[i] = TextListboxWidget.Cast(m_RootWidget[i].FindAnyWidget("TextListboxWidget0"));
43  m_DistanceWidget[i] = TextWidget.Cast(m_RootWidget[i].FindAnyWidget("TextWidget0"));
44  }
45  }
46 
47  void EnableWidgets(bool enable)
48  {
49  for (int i = 0; i < MAX_SIMULTANIOUS_PLAYERS; ++i)
50  {
51  m_RootWidget[i].Show(enable);
52  m_RootWidgetDamage[i].Show(enable);
53  }
54  }
55 
57  {
58  int i = 0;
59  for (; i < m_PlayerDebugStats.Count(); ++i)
60  {
62  PlayerBase player = rpd.GetPlayer();
63 
64  if (player)
65  {
66  vector pos = player.GetPosition();
67  vector screen_pos_stats = GetGame().GetScreenPos(pos + "0 0 0");
68  vector screen_pos_damage = GetGame().GetScreenPos(pos + "0 2 0");
69  m_RootWidget[i].SetPos(screen_pos_stats[0], screen_pos_stats[1]);
70  m_RootWidgetDamage[i].SetPos(screen_pos_damage[0], screen_pos_damage[1]);
71 
72  if (screen_pos_stats[2] > 0 && screen_pos_stats[0] > 0 && screen_pos_stats[1] > 0)
73  {
74  m_RootWidget[i].Show(true);
75  m_RootWidgetDamage[i].Show(true);
76  UpdateStatsWidget(i, rpd);
77  UpdateDistanceWidget(i, player);
78  UpdateDamageWidget(i, player);
79  }
80  else
81  {
82  m_RootWidget[i].Show(false);
83  m_RootWidgetDamage[i].Show(false);
84  }
85 
86  }
87  }
88  for (; i < MAX_SIMULTANIOUS_PLAYERS; ++i)
89  {
90  m_RootWidget[i].Show(false);
91  m_RootWidgetDamage[i].Show(false);
92  }
93  }
94 
95 
96  void UpdateDamageWidget(int index, PlayerBase player)
97  {
99  if (m_PlayerDebugDamage.Contains(player))
100  {
101  RemotePlayerDamageDebug value = m_PlayerDebugDamage.Get(player);
102  value.GetReversed(damage_list);
103 
104  m_DamageListWidgets[index].ClearItems();
105  if (damage_list.Count() > 0)
106  {
107  m_DamageListWidgets[index].Show(true);
108  for (int i = 0; i < damage_list.Count(); ++i)
109  {
110  DamageData data = damage_list[i];
111  float value_global = data.GetValueGlobal();
112  float value_blood = data.GetValueBlood();
113  float value_shock = data.GetValueShock();
114 
115  m_DamageListWidgets[index].AddItem( value_global.ToString(), null, 0, i );
116  m_DamageListWidgets[index].SetItem( i, value_blood.ToString(), null, 1 );
117  m_DamageListWidgets[index].SetItem( i, value_shock.ToString(), null, 2 );
118  }
119  }
120  else
121  {
122  m_DamageListWidgets[index].Show(false);
123  }
124  }
125  }
126 
127  void UpdateDistanceWidget(int index, PlayerBase other_player)
128  {
129  float distance = vector.Distance(GetGame().GetCurrentCameraPosition(), other_player.GetPosition());
130  m_DistanceWidget[index].SetText(distance.ToString() + "m");
131  }
132 
134  {
135  array<string> names = new array<string>;
136  array<string> values = new array<string>;
137  rpd.SerializeNames(names, m_DebugType);
138  rpd.SerializeValues(values,m_DebugType);
139  m_StatListWidgets[index].ClearItems();
140 
141  for (int i = 0; i < names.Count(); ++i)
142  {
143  m_StatListWidgets[index].AddItem( names.Get(i), null, 0, i );
144  m_StatListWidgets[index].SetItem( i, values.Get(i), null, 1 );
145  }
146  }
147 
148  void RequestPlayerInfo(PlayerBase player, int type)
149  {
150 #ifdef DIAG_DEVELOPER
151  if (type == 0)
152  {
153  EnableWidgets(false);
154  }
155  /*
156  else
157  {
158  EnableWidgets(true);
159  }
160  */
161  ScriptRPC rpc = new ScriptRPC();
162  m_DebugType = type;
163  rpc.Write(type);
164  rpc.Send( player, ERPCs.DEV_PLAYER_DEBUG_REQUEST, true, player.GetIdentity() );
165 #endif
166  }
167 
169  {
170  foreach (RemotePlayerDamageDebug valueDelta : delta)
171  {
172  PlayerBase playerDelta = valueDelta.GetPlayer();
173 
174  if ( m_PlayerDebugDamage.Contains(null) )
175  {
176  //cleans up garbage
177  m_PlayerDebugDamage.Remove(null);
178  }
179 
180  if ( m_PlayerDebugDamage.Contains(playerDelta) )
181  {
182  RemotePlayerDamageDebug valueLocal = m_PlayerDebugDamage.Get(playerDelta);
184  valueDelta.GetReversed(damageList);
185 
186  foreach (DamageData data : damageList)
187  {
188  valueLocal.InsertDamageObject( data );
189  }
190  }
191  else
192  {
193  m_PlayerDebugDamage.Insert(playerDelta, valueDelta);
194  }
195  }
196  }
197 
198  void DebugDamage(PlayerBase player)
199  {
200  for (int i = 0; i < m_PlayerDebugStats.Count(); i++)
201  {
202  player = m_PlayerDebugStats.Get(i).GetPlayer();
203 
204  PrintString("player:" + player.ToString() );
205  m_PlayerDebugStats.Get(i).Debug();
206  PrintString("-------------------------------------");
207  }
208 
209  for (i = 0; i < m_PlayerDebugDamage.Count(); i++)
210  {
211  PrintString("-------------------------------------");
212  if( m_PlayerDebugDamage.GetElement(i) ) m_PlayerDebugDamage.GetElement(i).Debug();
213  PrintString("-------------------------------------");
214  }
215 
216  for (i = 0; i < m_PlayerDebugDamage.Count();i++)
217  {
218  PrintString("------------Debug Damage Start--------------");
219  PlayerBase player2 = m_PlayerDebugDamage.GetKey(i);
220  RemotePlayerDamageDebug obj = m_PlayerDebugDamage.Get(player2);
221  obj.Debug();
222  PrintString("-------------Debug Damage End-------------");
223  }
224  }
225 
227  {
228  ctx.Read(m_PlayerDebugStats);
229 
231 
232  ctx.Read(player_damage);
233  PlayerBase player;
234  for (int x = 0; x < player_damage.Count(); x++)
235  {
236  RemotePlayerDamageDebug value = player_damage.Get(x);
237  if (value)
238  {
239  player = value.GetPlayer();
240  PrintString("debug damage: "+x.ToString() + "," + player.ToString());
241  value.Debug();
242 
243  int xs = 1 + 1;
244  }
245  }
246 
247  if (player_damage.Count() > 0 ) MergeDamage(player_damage);
248  }
249 }
EnableWidgets
void EnableWidgets(bool enable)
Definition: pluginremoteplayerdebugclient.c:47
GetGame
proto native CGame GetGame()
OnRPC
void OnRPC(ParamsReadContext ctx)
Definition: pluginremoteplayerdebugclient.c:226
UpdateDamageWidget
void UpdateDamageWidget(int index, PlayerBase player)
Definition: pluginremoteplayerdebugclient.c:96
m_RootWidget
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
Definition: pluginremoteplayerdebugclient.c:14
m_StatListWidgets
ref TextListboxWidget m_StatListWidgets[MAX_SIMULTANIOUS_PLAYERS]
Definition: pluginremoteplayerdebugclient.c:16
m_DistanceWidget
ref TextWidget m_DistanceWidget[MAX_SIMULTANIOUS_PLAYERS]
Definition: pluginremoteplayerdebugclient.c:18
MAX_SIMULTANIOUS_PLAYERS
enum eRemoteDebugType MAX_SIMULTANIOUS_PLAYERS
UpdateStatsWidget
void UpdateStatsWidget(int index, RemotePlayerStatDebug rpd)
Definition: pluginremoteplayerdebugclient.c:133
UpdateDistanceWidget
void UpdateDistanceWidget(int index, PlayerBase other_player)
Definition: pluginremoteplayerdebugclient.c:127
PluginBase
Definition: pluginadminlog.c:1
FindAnyWidget
proto native Widget FindAnyWidget(string pathname)
NONE
@ NONE
Definition: pluginremoteplayerdebugclient.c:3
InitWidgets
void InitWidgets()
Definition: pluginremoteplayerdebugclient.c:35
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
m_PlayerDebugDamage
ref map< PlayerBase, ref RemotePlayerDamageDebug > m_PlayerDebugDamage
Definition: pluginremoteplayerdebugclient.c:12
PlayerBase
Definition: playerbaseclient.c:1
map
map
Definition: controlsxboxnew.c:3
vector
Definition: enconvert.c:105
RemotePlayerDamageDebug
Definition: remoteplayerdamagedebug.c:1
DebugDamage
void DebugDamage(PlayerBase player)
Definition: pluginremoteplayerdebugclient.c:198
TextWidget
Definition: enwidgets.c:219
ScriptRPC
Definition: gameplay.c:104
eRemoteDebugType
eRemoteDebugType
Definition: pluginremoteplayerdebugclient.c:1
PrintString
void PrintString(string s)
Helper for printing out string expression. Example: PrintString("Hello " + var);.
Definition: enscript.c:345
m_DebugType
eRemoteDebugType m_DebugType
Definition: pluginremoteplayerdebugclient.c:19
DamageData
Definition: damagedata.c:1
RequestPlayerInfo
void RequestPlayerInfo(PlayerBase player, int type)
Definition: pluginremoteplayerdebugclient.c:148
array< ref RemotePlayerStatDebug >
MergeDamage
void MergeDamage(array< ref RemotePlayerDamageDebug > delta)
Definition: pluginremoteplayerdebugclient.c:168
UpdateWidgetsStats
void UpdateWidgetsStats()
Definition: pluginremoteplayerdebugclient.c:56
x
Icon x
DAMAGE_ONLY
@ DAMAGE_ONLY
Definition: pluginremoteplayerdebugclient.c:4
ERPCs
ERPCs
Definition: erpcs.c:1
Widget
Definition: enwidgets.c:189
RemotePlayerStatDebug
void RemotePlayerStatDebug(PlayerBase player)
Definition: remoteplayerstatdebug.c:16
m_RootWidgetDamage
ref Widget m_RootWidgetDamage[MAX_SIMULTANIOUS_PLAYERS]
Definition: pluginremoteplayerdebugclient.c:15
OnInit
override void OnInit()
Definition: pluginremoteplayerdebugclient.c:21
m_DamageListWidgets
ref TextListboxWidget m_DamageListWidgets[MAX_SIMULTANIOUS_PLAYERS]
Definition: pluginremoteplayerdebugclient.c:17
OnUpdate
override void OnUpdate(float delta_time)
Definition: pluginremoteplayerdebugclient.c:28
m_PlayerDebugStats
ref array< ref RemotePlayerStatDebug > m_PlayerDebugStats
Definition: pluginremoteplayerdebugclient.c:11
ALL
@ ALL
Definition: pluginremoteplayerdebugclient.c:5