File size: 16,460 Bytes
24b81cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
class PluginItemDiagnosticEventHandler extends ScriptedWidgetEventHandler
{
	PluginItemDiagnostic m_Owner;
	override bool OnMouseEnter(Widget w, int x, int y)
	{
		if( ButtonWidget.Cast(w))
		{
			GetGame().GetMission().AddActiveInputExcludes({"menu"});
		}
		return true;

	}
	
	override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
	{
		if( ButtonWidget.Cast(w))
		{
			GetGame().GetMission().RemoveActiveInputExcludes({"menu"},true);
		}
		
		return true;
	}
	
	override bool OnClick( Widget w, int x, int y, int button )
	{
		return m_Owner.OnClick( w, x, y, button );
	}
	
	override bool OnMouseButtonDown(Widget w, int x, int y, int button)
	{
		return m_Owner.OnMouseButtonDown( w, x, y, button );
	}
	override bool OnMouseButtonUp(Widget w, int x, int y, int button)
	{
		return m_Owner.OnMouseButtonUp( w, x, y, button );
	}
}



class PluginItemDiagnostic extends PluginDeveloper
{
	Object m_Entity;

	
	ref Timer 						myTimer1;
	ref map<PlayerBase,Object> 	m_ObserversMap = new map<PlayerBase,Object>;
	ref array<string> 				m_Agents = new array<string>;
	ref map<string,float> 			m_Floats = new map<string,float>;
	ref map<string,float> 			m_VarsNumbersFinalServer = new map<string,float>;
	ref map<string,float> 			m_VarsFinalClient = new map<string,float>;
	ref array<ref Param>		m_Properties = new array<ref Param>;
	bool 									m_IsActive	= false;
	bool									m_ScriptMenuOpened;
	string									m_NoteClient;
	ref PluginItemDiagnosticEventHandler 	m_EventHandler;
	bool									m_IsDragging;
	PluginConfigDebugProfile m_ConfigDebugProfile;
	
	Widget 				m_DebugRootWidget;
	Widget 				m_FrameWidget;
	
	TextListboxWidget 	m_DebugAgentListWidget;
	TextWidget 			m_DebugOutputServer;
	TextWidget 			m_DebugOutputClient;
	TextListboxWidget 	m_DebugFloatsProperListWidget;
	TextListboxWidget 	m_DebugClientVarsWidget;
	TextWidget 			m_ClassNameWidget;
	TextWidget 			m_DistanceWidget;
	ItemPreviewWidget 	m_ItemPreviewWidget;
	
	ButtonWidget		m_DebugButtonWidget1;
	ButtonWidget		m_DebugButtonWidget2;
	ButtonWidget		m_DebugButtonWidget3;
	ButtonWidget		m_DebugButtonWidget4;
	
	ButtonWidget		m_CloseButton;

	Shape 				m_ItemLine;
	vector 				m_DraggingOffset;
	
	
	void PluginItemDiagnostic()
	{
		
		#ifndef NO_GUI
		InitializeWidgets();
		ShowWidgets(false);
		#endif
	}

	void ~PluginItemDiagnostic()
	{
		ClearProperties();
		if (m_ItemLine)
		{
			m_ItemLine.Destroy();
			m_ItemLine = null;
		}
	}
	
	override void OnInit()
	{
		m_ConfigDebugProfile = PluginConfigDebugProfile.Cast( GetPlugin(PluginConfigDebugProfile) );
		if ( m_ConfigDebugProfile )
		{
			vector pos = m_ConfigDebugProfile.GetItemDebugPos();
			if (m_DebugRootWidget && pos != vector.Zero)
			{
				float wx = pos[0];
				float wy = pos[1];
				m_DebugRootWidget.SetPos(wx, wy);
			}
		}
	}

	bool OnMouseButtonDown(Widget w, int x, int y, int button)
	{
		if (button == 0)
			SetDragging(true);
		if (button == 1)
		{
			if (m_Entity)
			{
				float xx, yy;
				m_DebugRootWidget.GetPos(xx,yy);
				ContextMenu.DisplayContextMenu(x - xx, y - yy, EntityAI.Cast(m_Entity), m_DebugRootWidget, this);
			}
		}
		return true;
	}
	
	bool OnMouseButtonUp(Widget w, int x, int y, int button)
	{
		if (button == 0)
			SetDragging(false);
		return true;
	}
	
	void SetDragging(bool enable)
	{
		if(enable && !m_IsDragging)
			OnDraggingStart();
		else if (!enable && m_IsDragging)
			OnDraggingEnd();
		m_IsDragging = enable;
	}
	
	void OnDraggingStart()
	{
		int mx, my;
		float wx, wy;
		GetMousePos(mx,my);
		m_DebugRootWidget.GetScreenPos(wx,wy);
		m_DraggingOffset[0] = wx - mx;
		m_DraggingOffset[1] = wy - my;
	}
	
	void OnDraggingEnd()
	{
		if ( m_ConfigDebugProfile )
		{
			float wx, wy;
			m_DebugRootWidget.GetScreenPos(wx,wy);
			m_ConfigDebugProfile.SetItemDebugPos(Vector(wx,wy,0));
		}
	}
	

	
	bool OnClick( Widget w, int x, int y, int button )
	{
		SetDragging(false);
		
		if (w == m_CloseButton)
		{
			ToggleDebugWindowEvent();
			return true;
		}
		return true;
	}
	
	void RegisterDebugItem(Object item, PlayerBase player)
	{
		if(!myTimer1)
		{
			myTimer1 = new Timer();
			myTimer1.Run(1, this, "Tick", NULL, true);
		}
		
		if(m_ObserversMap.Contains(player))
		{
			m_ObserversMap.Set(player,item);
		}
		else
		{
			m_ObserversMap.Insert(player,item);
		}
		#ifdef DEVELOPER
		SetDebugDeveloper_item(item);
		#endif
	}
	
	Object GetWatchedItem(PlayerBase player)
	{
		return m_ObserversMap.Get(player);
	}
	
	
	bool IsActive()
	{
		return m_IsActive;
	}

	void OnScriptMenuOpened(bool opened/*1 - opened , 0 - closed*/)
	{
		m_ScriptMenuOpened = opened;
	}
	
	
	void ShowWidgets(bool show)
	{
		
		m_IsActive = show;
			
		if(m_DebugRootWidget) 
			m_DebugRootWidget.Show(show);
	}

	void OnSelectAction(EntityAI ent, int actionId)
	{
		PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
		player.GetActionManager().OnInstantAction(ActionDebug,new Param2<EntityAI,int>(ent,actionId));
	}

	void ReleaseFocus()
	{
		GetGame().GetInput().ResetGameFocus();
		GetGame().GetUIManager().ShowUICursor(false);
		if (GetGame().GetUIManager()) 	
		{
			if (GetGame().GetUIManager().IsDialogVisible())
			{
				GetGame().GetUIManager().CloseDialog();
				
			}
		}
	}
	
	void ToggleDebugWindowEvent()
	{
		if (m_IsActive)
		{		
			PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
			GetGame().RPCSingleParam(player, ERPCs.RPC_ITEM_DIAG_CLOSE,null, true);
			ShowWidgets(false);
			ClearWidgets();
			
			GetGame().GetCallQueue( CALL_CATEGORY_GUI ).CallLater( ReleaseFocus, 100);
			//m_IsActive = false;
			SetDragging(false);
		}
		else
		{
			ShowWidgets(true);
			//m_IsActive = true;
		}

	}

	void ClearWidgets()
	{
		m_DebugAgentListWidget.ClearItems();
		m_DebugOutputServer.SetText("");
		m_DebugOutputClient.SetText("");
		m_DebugFloatsProperListWidget.ClearItems();
		m_ItemPreviewWidget.SetItem(NULL);
		m_ClassNameWidget.SetText("");		
	}
	
	void Tick()
	{
		for(int i = 0; i < m_ObserversMap.Count();i++)
		{
			Object item = m_ObserversMap.GetElement(i);
			PlayerBase player = m_ObserversMap.GetKey(i);

			if (item && player) 
			{
				GeneratePropertiesObject(EntityAI.Cast(item));
				SendRPC(item, player);
			}
			else
			{
				Debug.LogError("PluginItemDiagnostic: dead debug record, removing record");
				m_ObserversMap.RemoveElement(i);
			}
		}
		
	}
	
	void ClearProperties()
	{
		m_Properties.Clear();
	}


	void GeneratePropertiesObject(EntityAI item)
	{
		ClearProperties();
		GetLocalProperties(item, m_Properties);

	}
	
	void SendRPC(Object item, PlayerBase player)
	{
		Param1<Object> p1 = new Param1<Object>(item);
		m_Properties.InsertAt(p1,0);
		GetGame().RPC(player,ERPCs.RPC_ITEM_DIAG,m_Properties,true,player.GetIdentity());
		
		if (!GetGame().IsMultiplayer())
		{
			m_Entity = item;
		}

	}
	
	void StopWatchRequest(PlayerBase player)//called from player after an RPC call
	{
		if( m_ObserversMap.Contains(player) )
		{
			m_ObserversMap.Remove(player);
		}
	}

	void OnRPC(Object entity, ParamsReadContext ctx)
	{
		
		if (!GetGame().IsMultiplayer())
		{
			entity = m_Entity;
		}
		else
		{
			m_Entity = entity;
		}
		
		ItemBase item = ItemBase.Cast(entity);
		
		
		
		#ifdef DEVELOPER
		SetDebugDeveloper_item(entity);
		#endif
		if( !IsActive() )
		{
			ShowWidgets(true);
		}

		ctx.Read(CachedObjectsParams.PARAM1_STRING);
		string debug_output_server = CachedObjectsParams.PARAM1_STRING.param1;
		array<ref Param> vars_client;
		array<ref Param> vars_server;
		if (item)
		{
			ctx.Read(CachedObjectsParams.PARAM1_INT);//hardcoded to index 1
			int agents_count 	= CachedObjectsParams.PARAM1_INT.param1;

			ctx.Read(CachedObjectsParams.PARAM1_INT);//hardcoded to index 2
			int individual_items_count 	= CachedObjectsParams.PARAM1_INT.param1;
			
			FillAgentArray(ctx, agents_count);
			
			vars_server = new array<ref Param>;
			FillServerFinalVars(individual_items_count, ctx, vars_server);

			vars_client = new array<ref Param>;
			GetLocalProperties(item, vars_client, true);
		}
		if (EntityAI.Cast(entity))
		{
			DisplayAll(EntityAI.Cast(entity), vars_server, vars_client, debug_output_server );
		}
		if (GetDayZGame().IsInventoryOpen() || GetGame().GetUIManager().FindMenu(MENU_SCRIPTCONSOLE))
			m_DebugRootWidget.SetSort(-1);
		else
			m_DebugRootWidget.SetSort(10);
		m_DebugRootWidget.Show(true);

			
	}
	
	void FillServerFinalVars(int count, ParamsReadContext ctx, array<ref Param> params )
	{
		for(int i = 0; i < count; i++)
		{
			Param2<string,float> p2 = new Param2<string,float>("",0);
			
			ctx.Read(p2);
			/*
			string name = CachedObjectsParams.PARAM2_STRING_FLOAT.param1;
			float value = CachedObjectsParams.PARAM2_STRING_FLOAT.param2;
			PrintString(name+","+value.ToString());
			*/
			params.Insert(p2);
		}
		//PrintString("----------------------------------------------------");
	}
	
	void InitializeWidgets()
	{
		m_EventHandler = new PluginItemDiagnosticEventHandler;
		m_EventHandler.m_Owner = this;
		
		if(!m_DebugRootWidget) 
			m_DebugRootWidget = GetGame().GetWorkspace().CreateWidgets("gui/layouts/debug/debug_item.layout");

		m_DebugRootWidget.SetHandler(m_EventHandler);

		m_FrameWidget = m_DebugRootWidget.FindAnyWidget("FrameWidget0");
		m_DebugAgentListWidget = TextListboxWidget.Cast(m_DebugRootWidget.FindAnyWidget("w_Agents"));
		m_DebugOutputServer = TextWidget.Cast(m_DebugRootWidget.FindAnyWidget("DebugOutputServer"));
		m_DebugOutputClient = TextWidget.Cast(m_DebugRootWidget.FindAnyWidget("DebugOutputClient"));
		m_DebugFloatsProperListWidget = TextListboxWidget.Cast(m_DebugRootWidget.FindAnyWidget("w_FloatsProper"));
		m_ItemPreviewWidget = ItemPreviewWidget.Cast(m_DebugRootWidget.FindAnyWidget("w_ItemPreview"));
		m_ClassNameWidget = TextWidget.Cast(m_DebugRootWidget.FindAnyWidget("w_ClassName"));
		m_DistanceWidget = TextWidget.Cast(m_DebugRootWidget.FindAnyWidget("w_Distance"));
		
		m_DebugButtonWidget1 = ButtonWidget.Cast(m_DebugRootWidget.FindAnyWidget("DebugButton1"));
		m_DebugButtonWidget2 = ButtonWidget.Cast(m_DebugRootWidget.FindAnyWidget("DebugButton2"));
		m_DebugButtonWidget3 = ButtonWidget.Cast(m_DebugRootWidget.FindAnyWidget("DebugButton3"));
		m_DebugButtonWidget4 = ButtonWidget.Cast(m_DebugRootWidget.FindAnyWidget("DebugButton4"));
		
		m_CloseButton = ButtonWidget.Cast(m_DebugRootWidget.FindAnyWidget("CloseButton"));
	}

	override void OnUpdate(float delta_time)
	{
		super.OnUpdate(delta_time);
		
		if (!m_Entity || !m_IsActive)
		{
			
			if (m_ItemLine)
			{
				m_ItemLine.Destroy();
				m_ItemLine = null;
			}
			return;
		}
		
		m_ItemPreviewWidget.Show(!m_ScriptMenuOpened);
		
		
		if (m_IsDragging)
		{
			int x,y;
			GetMousePos(x,y);
			m_DebugRootWidget.SetPos(x + m_DraggingOffset[0], y + m_DraggingOffset[1]);
		}
		vector pts[2];
		pts[0] = GetGame().GetPlayer().GetPosition();
		pts[1] = m_Entity.GetPosition();
		if (m_ItemLine)
		{
			m_ItemLine.Destroy();
			m_ItemLine = null;
			
		}
		m_ItemLine = Shape.CreateLines(COLOR_BLUE, ShapeFlags.TRANSP|ShapeFlags.NOOUTLINE|ShapeFlags.NOZBUFFER, pts, 2);
		m_DistanceWidget.SetText(vector.Distance(pts[0], pts[1]).ToString()+"m.");
	}
	
	void DisplayAll(EntityAI item, array<ref Param> vars_server, array<ref Param> vars_client, string debug_text_server)
	{
		m_ClassNameWidget.SetText( item.GetType() );
		m_ItemPreviewWidget.SetItem(item);
		UpdateAgentWidget();
		//UpdateFloatWidget();
		if (vars_server && vars_client)
			UpdateNumericalVarsWidget(vars_server, vars_client);
		m_DebugOutputServer.SetText(debug_text_server);
		m_DebugOutputClient.SetText(item.GetDebugText());
		
		/*
		string button1, button2, button3, button4;
		item.GetDebugButtonNames(button1, button2, button3, button4);
		m_DebugButtonWidget1.SetText(button1);
		m_DebugButtonWidget2.SetText(button2);
		m_DebugButtonWidget3.SetText(button3);
		m_DebugButtonWidget4.SetText(button4);
		*/
		
	
	}	

	void FillAgentArray(ParamsReadContext ctx, int agents_count)
	{
		m_Agents.Clear();
		for(int i = 0; i < agents_count; i++)
		{
			if(ctx.Read(CachedObjectsParams.PARAM1_STRING))
			{
				string agent = CachedObjectsParams.PARAM1_STRING.param1;
				m_Agents.Insert(agent);
			}
		}
	}


	void UpdateAgentWidget()
	{
		m_DebugAgentListWidget.ClearItems();
		for(int i = 0; i < m_Agents.Count(); i++)
		{
			string agent = m_Agents.Get(i);
			m_DebugAgentListWidget.AddItem(agent,NULL,0);
		}
	}	

	
	void UpdateNumericalVarsWidget(array<ref Param> vars_server, array<ref Param> vars_client)
	{
		m_DebugFloatsProperListWidget.ClearItems();
		for(int i = 0; i < vars_server.Count(); i++)
		{
			Param param_server = vars_server.Get(i);
			Param2<string,float> p2_server = Param2<string,float>.Cast(param_server);
			
			Param param_client = vars_client.Get(i);
			Param2<string,float> p2_client = Param2<string,float>.Cast(param_client);
			
			string name = p2_server.param1;
			m_DebugFloatsProperListWidget.AddItem(name,NULL,0);
			m_DebugFloatsProperListWidget.SetItem(i,p2_server.param2.ToString(),NULL,1);
			m_DebugFloatsProperListWidget.SetItem(i,p2_client.param2.ToString(),NULL,2);
		}
	}	
	
	
	void PrintOut()
	{
		Debug.LogArrayString(m_Agents,"ItemDebug");
		Debug.Log("----------------------","ItemDebug");
	}
	
	//-------------------------
	// QUERY FOR DEBUG PROPERTIES
	//-------------------------
	void GetLocalProperties(EntityAI entity, array<ref Param> properties, bool client = false)
	{
		if(!entity)
			return;
		ItemBase item = ItemBase.Cast(entity);

		if(!client)
		{
			// -------- DEBUG OUTPUT ------
			Param1<string> debug_output = new Param1<string>(entity.GetDebugText());
			properties.Insert(debug_output);
			if(!item)
				return;
			// -------- AGENTS ------------
			int num_of_agents = FillWithAgents(item, properties);
			Param1<int> agents_count = new Param1<int>(num_of_agents);
			properties.InsertAt(agents_count,1);// hard coded index 1 !!
		}
		if(!item)
			return;
		// ------ INDIVIDUAL VARS------
		int number_of_items = 0;
		Param2<string, float> quantity = new Param2<string, float>("quantity", item.GetQuantity() );
		properties.Insert(quantity);
		number_of_items++;
		//-----------------------------
		Param2<string, float> liquid_type = new Param2<string, float>("liquid_type", item.GetLiquidType() );
		properties.Insert(liquid_type);
		number_of_items++;
		//-----------------------------
		Param2<string, float> wetness = new Param2<string, float>("wetness", item.GetWet() );
		properties.Insert(wetness);
		number_of_items++;
		//-----------------------------
		Param2<string, float> temperature = new Param2<string, float>("temperature", item.GetTemperature() );
		properties.Insert(temperature);
		number_of_items++;
		//-----------------------------
		Param2<string, float> energy = new Param2<string, float>("energy", item.GetEnergy() );
		properties.Insert(energy);
		number_of_items++;
		//-----------------------------
		Param2<string, float> health;
		if(!client)
		{
			health = new Param2<string, float>("health", item.GetHealth("", "") );
		}
		else
		{
			health = new Param2<string, float>("NO SYNC",0 );
		}
		properties.Insert(health);
		number_of_items++;
		//-----------------------------
		int r,g,b,a;
		item.GetColor(r,g,b,a);
		Param2<string, float> p2r = new Param2<string, float>("R",r);
		properties.Insert(p2r);
		number_of_items++;
		Param2<string, float> p2g = new Param2<string, float>("G",g);
		properties.Insert(p2g);
		number_of_items++;
		Param2<string, float> p2b = new Param2<string, float>("B",b);
		properties.Insert(p2b);
		number_of_items++;
		Param2<string, float> p2a = new Param2<string, float>("A",a);
		properties.Insert(p2a);
		number_of_items++;
		//-----------------------------
		if(!client)
		{
			Param1<int> item_count = new Param1<int>(number_of_items);
			properties.InsertAt(item_count,2);
		}
	}

	int FillWithAgents(ItemBase item, array<ref Param> properties)
	{
		if (!item)
		{
			return 0;
		}
		int agents = item.GetAgents();
		if(agents == 0) return 0;
		int num_of_agents = 0;
		ref array<int> agents_aray = new array<int>;
		PluginTransmissionAgents.BuildAgentArray(agents, agents_aray);
		int agents_count = agents_aray.Count();
	
		for(int i = 0; i < agents_count; i++)
		{
			//PluginTransmissionAgents mta = PluginTransmissionAgents.Cast(GetPlugin(PluginTransmissionAgents));
			string agent_name = PluginTransmissionAgents.GetNameByID(agents_aray.Get(i));
			Param1<string> param1 = new Param1<string>(agent_name);
			properties.Insert(param1);
			num_of_agents++;
		}

		return num_of_agents;
	}
}