File size: 2,076 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
enum eRemoteStatType
{
	NONE,
	DAMAGE_SYSTEM = 1,
	PLAYER_STATS = 2,
	OTHER = 4,
}


class RemotePlayerStatDebug
{
	PlayerBase m_Player;
	ref array<ref StatDebugObject> m_Stats = new array<ref StatDebugObject>;
	string m_Name;
	vector m_Pos;
	void RemotePlayerStatDebug(PlayerBase player)
	{
		m_Player = player;
		Init();

	}
	
	void Init()
	{
		UpdatePlayerStatsValues();
		InjectDamageSystemValues();
		m_Pos = m_Player.GetWorldPosition();
		m_Name = m_Player.GetIdentity().GetName();
	}
	
	PlayerBase GetPlayer()
	{
		return m_Player;
	}
	
	void UpdatePlayerStatsValues()
	{
		m_Player.GetPlayerStats().GetDebugInfo(m_Stats, 0);
	}
	
	void InjectDamageSystemValues()
	{
		m_Stats.Insert( new StatDebugObject("Health", m_Player.GetHealth("",""), eRemoteStatType.DAMAGE_SYSTEM) );
		m_Stats.Insert( new StatDebugObject("Blood", m_Player.GetHealth("","Blood"), eRemoteStatType.DAMAGE_SYSTEM) );
		m_Stats.Insert( new StatDebugObject("Shock", m_Player.GetHealth("","Shock"), eRemoteStatType.DAMAGE_SYSTEM) );
	}
	
	void SerializeNames(array<string> names, eRemoteDebugType type)
	{
		for(int i = 0; i < m_Stats.Count(); i++)
		{
			if( type ==  eRemoteDebugType.ALL )
			{
				names.Insert(m_Stats.Get(i).GetName());
			}
			else if( type ==  eRemoteDebugType.DAMAGE_ONLY )
			{
				StatDebugObject obj = m_Stats.Get(i);
				eRemoteStatType debug_type = obj.GetType();
				if(debug_type == eRemoteStatType.DAMAGE_SYSTEM)
				{
					names.Insert(m_Stats.Get(i).GetName());
				}
			}
		}
	}
	
	void SerializeValues(array<string> values, eRemoteDebugType type)
	{
		for(int i = 0; i < m_Stats.Count(); i++)
		{
			if( type ==  eRemoteDebugType.ALL )
			{
				values.Insert(m_Stats.Get(i).GetValue());
			}
			else if( type ==  eRemoteDebugType.DAMAGE_ONLY )
			{
				StatDebugObject obj = m_Stats.Get(i);
				eRemoteStatType debug_type = obj.GetType();
				if(debug_type == eRemoteStatType.DAMAGE_SYSTEM)
				{
					values.Insert(m_Stats.Get(i).GetValue());
				}
			}
		}
	}
	
	void Debug()
	{
		for(int i = 0; i < m_Stats.Count(); i++)
		{
			m_Stats.Get(i).Debug();
		}
	}

}