1 class PluginUniversalTemperatureSourceServer
extends PluginBase
3 const int INTERVAL = 1;
4 const float LOOKUP_RADIUS = 20;
6 protected float m_AccuTime;
7 protected ref set<PlayerBase> m_ClientList;
11 void PluginUniversalTemperatureSourceServer()
13 m_ClientList =
new set<PlayerBase>();
17 override void OnUpdate(
float delta_time)
19 if (m_ClientList.Count() > 0)
21 m_AccuTime += delta_time;
23 if (m_AccuTime > INTERVAL)
31 void GatherTemperatureSources(
PlayerBase player)
33 m_UTemperatureSourceDebugs.Clear();
38 vector playerPos = player.GetPosition();
41 GetGame().GetObjectsAtPosition(playerPos, LOOKUP_RADIUS, nearestObjects,
null);
43 UTemperatureSource uts;
44 UTemperatureSourceDebug utsd;
46 foreach (
Object nearestObject : nearestObjects)
49 if (ent && ent.IsUniversalTemperatureSource() && ent != player)
51 uts = ent.GetUniversalTemperatureSource();
52 utsd =
new UTemperatureSourceDebug();
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());
61 m_UTemperatureSourceDebugs.Insert(utsd);
65 if (player.GetItemInHands() && player.GetItemInHands().IsUniversalTemperatureSource())
67 uts = player.GetItemInHands().GetUniversalTemperatureSource();
68 utsd =
new UTemperatureSourceDebug();
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());
77 m_UTemperatureSourceDebugs.Insert(utsd);
83 int clientCount = m_ClientList.Count();
88 GatherTemperatureSources(player);
90 rpc.Write(m_UTemperatureSourceDebugs);
91 rpc.Send(player,
ERPCs.DEV_UTS_DEBUG_DATA,
true, player.GetIdentity());
94 m_ClientList.RemoveItem(player);
98 void OnRequestReceived(
PlayerBase player,
bool enable)
100 int index = m_ClientList.Find(player);
104 m_ClientList.Insert(player);
106 else if (index != -1 && m_ClientList.Count() > 0)
108 m_ClientList.Remove(index);
117 OnRequestReceived(player, enable);