DayZ 1.24
Loading...
Searching...
No Matches
PluginUniversalTemperatureSourceServer.c
Go to the documentation of this file.
1class PluginUniversalTemperatureSourceServer extends PluginBase
2{
3 const int INTERVAL = 1;
4 const float LOOKUP_RADIUS = 20;
5
6 protected float m_AccuTime;
8
10
12 {
13 m_ClientList = new set<PlayerBase>();
14 m_UTemperatureSourceDebugs = new array<ref UTemperatureSourceDebug>();
15 }
16
17 override void OnUpdate(float delta_time)
18 {
19 if (m_ClientList.Count() > 0)
20 {
21 m_AccuTime += delta_time;
22
23 if (m_AccuTime > INTERVAL)
24 {
25 m_AccuTime = 0;
26 SendDebug();
27 }
28 }
29 }
30
32 {
33 m_UTemperatureSourceDebugs.Clear();
34
35 if (!player)
36 return;
37
38 vector playerPos = player.GetPosition();
40
41 GetGame().GetObjectsAtPosition(playerPos, LOOKUP_RADIUS, nearestObjects, null);
42
45
47 {
49 if (ent && ent.IsUniversalTemperatureSource() && ent != player)
50 {
51 uts = ent.GetUniversalTemperatureSource();
53 utsd.AddHeader(ent.GetType());
54 utsd.Add("position", uts.GetPosition().ToString(false));
55 utsd.Add("fullrange", uts.GetFullRange().ToString());
56 utsd.Add("maxrange", uts.GetMaxRange().ToString());
57 utsd.Add("temperature", uts.GetTemperature().ToString());
58 utsd.Add("temperatureraw", uts.GetTemperatureRaw().ToString());
59 utsd.Commit();
60
61 m_UTemperatureSourceDebugs.Insert(utsd);
62 }
63 }
64
65 if (player.GetItemInHands() && player.GetItemInHands().IsUniversalTemperatureSource())
66 {
67 uts = player.GetItemInHands().GetUniversalTemperatureSource();
69 utsd.AddHeader(player.GetItemInHands().GetType());
70 utsd.Add("position", uts.GetPosition().ToString(false));
71 utsd.Add("fullrange", uts.GetFullRange().ToString());
72 utsd.Add("maxrange", uts.GetMaxRange().ToString());
73 utsd.Add("temperature", uts.GetTemperature().ToString());
74 utsd.Add("temperatureraw", uts.GetTemperatureRaw().ToString());
75 utsd.Commit();
76
77 m_UTemperatureSourceDebugs.Insert(utsd);
78 }
79 }
80
81 void SendDebug()
82 {
83 int clientCount = m_ClientList.Count();
85 {
86 if (player)
87 {
89 ScriptRPC rpc = new ScriptRPC();
90 rpc.Write(m_UTemperatureSourceDebugs);
91 rpc.Send(player, ERPCs.DEV_UTS_DEBUG_DATA, true, player.GetIdentity());
92 }
93 else
94 m_ClientList.RemoveItem(player);
95 }
96 }
97
99 {
100 int index = m_ClientList.Find(player);
101
102 if (enable)
103 m_ClientList.Insert(player);
104 else if (index != -1 && m_ClientList.Count() > 0)
105 m_ClientList.Remove(index);
106 }
107
109 {
110 bool enable;
111 ctx.Read(enable);
112
114 }
115}
ERPCs
Definition ERPCs.c:2
void OnRPC(ParamsReadContext ctx, PlayerBase player)
ref array< ref UTemperatureSourceDebug > m_UTemperatureSourceDebugs
ref set< PlayerBase > m_ClientList
void OnRequestReceived(PlayerBase player, bool enable)
void GatherTemperatureSources(PlayerBase player)
override void OnUpdate(float delta_time)
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
proto native CGame GetGame()