Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
cameratools.c
Go to the documentation of this file.
1 #ifdef DIAG_DEVELOPER
2 class CameraToolsMenuServer
3 {
4  ref array<Man> m_Subscribers = new array<Man>;
5  void OnRPC(int rpc_type, ParamsReadContext ctx)
6  {
7  switch (rpc_type)
8  {
9  case ERPCs.DIAG_CAMERATOOLS_CAM_DATA:
10  {
11  Param4<vector, vector,float,float> p4 = new Param4<vector, vector,float,float>(vector.Zero, vector.Zero,0,0);
12  if (ctx.Read(p4))
13  {
14  foreach (int index, Man p : m_Subscribers)
15  {
16  if (p)
17  {
18  GetGame().RPCSingleParam(p, ERPCs.DIAG_CAMERATOOLS_CAM_DATA, p4, true, p.GetIdentity());
19  }
20  else
21  {
22  m_Subscribers.Remove(index);
23  }
24  }
25  }
26  break;
27  }
28  case ERPCs.DIAG_CAMERATOOLS_CAM_SUBSCRIBE:
29  {
30  Param2<bool, Man> par2 = new Param2<bool, Man>(false,null);
31 
32  if (ctx.Read(par2))
33  {
34  bool enable = par2.param1;
35  Man player = par2.param2;
36 
37  bool found = false;
38  foreach (int i, Man m : m_Subscribers)
39  {
40  if (m == player)
41  {
42  if (!enable)
43  {
44  m_Subscribers.Remove(i);
45  return;
46  }
47  found = true;
48  m_Subscribers[i] = player;
49  }
50  }
51  if (!found && enable)//not found in the array, insert it
52  {
53  m_Subscribers.Insert(player);
54  }
55  }
56  break;
57  }
58  }
59  }
60 };
61 
62 class CameraToolsMenuClient
63 {
64  Shape m_DebugShape = null;
65 
66  void ~CameraToolsMenuClient()
67  {
68  if (m_DebugShape)
69  {
70  m_DebugShape.Destroy();
71  }
72  }
73 
74  void DelayedDestroy()
75  {
76  GetGame().GetCallQueue( CALL_CATEGORY_SYSTEM ).CallLater( DestroyNow, 2000);
77  }
78 
79  void DestroyNow()
80  {
81  delete this;
82  }
83 
84  void OnRPC(ParamsReadContext ctx)
85  {
86  if (m_DebugShape)
87  {
88  m_DebugShape.Destroy();
89  m_DebugShape = null;
90  }
91 
92  Param4<vector, vector,float,float> p4 = new Param4<vector, vector,float,float>(vector.Zero, vector.Zero,0,0);
93  if ( ctx.Read( p4 ) )
94  {
95  vector pos = p4.param1;
96  vector dir = p4.param2;
97  float plane = p4.param3;
98  float fov = p4.param4 * Math.RAD2DEG;
99 
100 
101  m_DebugShape = Debug.DrawFrustum(fov, 30, 0.5);
102  vector mat[4];
103  Math3D.DirectionAndUpMatrix(dir,vector.Up,mat);
104  mat[3] = pos;
105  m_DebugShape.SetMatrix(mat);
106 
107  }
108  }
109 };
110 #endif
Param2
Definition: ppeconstants.c:66
GetGame
proto native CGame GetGame()
CALL_CATEGORY_SYSTEM
const int CALL_CATEGORY_SYSTEM
Definition: tools.c:8
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
OnRPC
void OnRPC(ParamsReadContext ctx)
Definition: displaystatus.c:216
vector
Definition: enconvert.c:105
m_DebugShape
Shape m_DebugShape
Definition: bleedingsource.c:16
array< Man >
Debug
Definition: debug.c:13
ERPCs
ERPCs
Definition: erpcs.c:1
Math
Definition: enmath.c:6
Math3D
Definition: enmath3d.c:27
Shape
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead