File size: 2,144 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
#ifdef DIAG_DEVELOPER
class CameraToolsMenuServer
{
	ref array<Man> m_Subscribers = new array<Man>;
	void OnRPC(int rpc_type, ParamsReadContext ctx)
	{
		switch (rpc_type)
		{
			case ERPCs.DIAG_CAMERATOOLS_CAM_DATA:
			{
				Param4<vector, vector,float,float> p4 = new Param4<vector, vector,float,float>(vector.Zero, vector.Zero,0,0);
				if (ctx.Read(p4))
				{
					foreach (int index, Man p : m_Subscribers)
					{
						if (p)
						{
							GetGame().RPCSingleParam(p, ERPCs.DIAG_CAMERATOOLS_CAM_DATA, p4, true, p.GetIdentity());
						}
						else
						{
							m_Subscribers.Remove(index);
						}
					}
				}
				break;
			}
			case ERPCs.DIAG_CAMERATOOLS_CAM_SUBSCRIBE:
			{
				Param2<bool, Man> par2 = new Param2<bool, Man>(false,null);
	
				if (ctx.Read(par2))
				{
					bool enable = par2.param1;
					Man player = par2.param2;
					
					bool found = false;
					foreach (int i, Man m : m_Subscribers)
					{
						if (m == player)
						{
							if (!enable)
							{
								m_Subscribers.Remove(i);
								return;
							}
							found = true;
							m_Subscribers[i] = player;
						}
					}
					if (!found && enable)//not found in the array, insert it
					{
						m_Subscribers.Insert(player);
					}
				}
				break;
			}
		}
	}
};

class CameraToolsMenuClient
{
	Shape m_DebugShape = null;
	
	void ~CameraToolsMenuClient()
	{
		if (m_DebugShape)
		{
			m_DebugShape.Destroy();
		}
	}
	
	void DelayedDestroy()
	{
		GetGame().GetCallQueue( CALL_CATEGORY_SYSTEM ).CallLater( DestroyNow, 2000);
	}
	
	void DestroyNow()
	{
		delete this;
	}
	
	void OnRPC(ParamsReadContext ctx)
	{
		if (m_DebugShape)
		{
			m_DebugShape.Destroy();
			m_DebugShape = null;
		}
		
		Param4<vector, vector,float,float> p4 = new Param4<vector, vector,float,float>(vector.Zero, vector.Zero,0,0);
		if ( ctx.Read( p4 ) )
		{
			vector pos = p4.param1;
			vector dir = p4.param2;
			float plane = p4.param3;
			float fov = p4.param4 * Math.RAD2DEG;
			
			
			m_DebugShape = Debug.DrawFrustum(fov, 30, 0.5);
			vector mat[4];
			Math3D.DirectionAndUpMatrix(dir,vector.Up,mat);
			mat[3] = pos;
			m_DebugShape.SetMatrix(mat);

		}
	}
};
#endif