1class PluginUniversalTemperatureSourceClient
extends PluginBase
3 const int MAX_SIMULTANEOUS_UTS = 10;
54 float fullRange = utsd.GetValue(1).ToFloat();
55 float maxRange = utsd.GetValue(2).ToFloat();
56 float temp = utsd.GetValue(3).ToFloat();
57 vector sphPos = utsd.GetValue(0).ToVector();
74 if (m_UTemperatureSourceDebugs.Count() > 0)
76 DbgUI.
Begin(
"Universal Temp Sources", 10, 300);
77 DbgUI.
Text(
string.Format(
"Lookup radius: %1m (server-side)", PluginUniversalTemperatureSourceServer.LOOKUP_RADIUS));
78 DbgUI.
Text(
string.Format(
"Count: %1", m_UTemperatureSourceDebugs.Count()));
79 DbgUI.
Text(
string.Format(
"Avg. temp: %1 °C", m_UTSAverageTemperature));
86 if (m_UTemperatureSourceDebugs.Count() == 0)
88 m_UTSAverageTemperature = 0;
107 float min = MiscGameplayFunctions.GetMinValue(utsTemperatures);
108 float max = MiscGameplayFunctions.GetMaxValue(utsTemperatures);
110 if (max > 0 && min < 0)
112 m_UTSAverageTemperature = (max + min) * 0.5;
116 m_UTSAverageTemperature = max;
124 distance =
Math.
Max(distance, 0.1);
125 float temperature = 0;
128 if (distance > utsd.GetValue(1).ToFloat())
130 float distFactor = 1 - (distance / utsd.GetValue(2).ToFloat());
131 distFactor =
Math.
Max(distFactor, 0.0);
132 temperature = utsd.GetValue(3).ToFloat() * distFactor;
136 temperature = utsd.GetValue(3).ToFloat();
155 int utsDebugCount = m_UTemperatureSourceDebugs.Count();
158 UTemperatureSourceDebug utsd = m_UTemperatureSourceDebugs[i];
159 vector pos = utsd.GetValue(0).ToVector();
162 m_RootWidget[i].SetPos(screen_pos_stats[0], screen_pos_stats[1]);
164 if (screen_pos_stats[2] > 0 && screen_pos_stats[0] > 0 && screen_pos_stats[1] > 0)
188 m_HeaderWidget[rowIndex].SetText(utsd.GetHeader());
190 int numPairs = utsd.PairsCount();
191 for (
int i = 0; i < numPairs; ++i)
208 m_UTemperatureSourceDebugs.Clear();
216 rpc.
Send(player,
ERPCs.DEV_REQUEST_UTS_DEBUG,
true, player.GetIdentity());
225 PrintString(
"-------------------------------------");
227 PrintString(
"-------------------------------------");
235 ctx.
Read(m_UTemperatureSourceDebugs);
ref TextListboxWidget m_StatListWidgets[MAX_SIMULTANIOUS_PLAYERS]
ref Widget m_RootWidget[MAX_SIMULTANIOUS_PLAYERS]
proto native vector GetScreenPos(vector world_pos)
Transforms position in world to position in screen in pixels as x, y component of vector,...
proto native WorkspaceWidget GetWorkspace()
static Shape DrawArrow(vector from, vector to, float size=0.5, int color=0xFFFFFFFF, int flags=0)
static Shape DrawCylinder(vector pos, float radius, float height=1, int color=0x1fff7f7f, ShapeFlags flags=ShapeFlags.TRANSP|ShapeFlags.NOOUTLINE)
const int MAX_SIMULTANEOUS_UTS
void EnableWidgets(bool enable)
void PluginUniversalTemperatureSourceClient()
protected PlayerBase m_Player
protected void ProcessUniversalTemperatureSources()
protected float m_UTSAverageTemperature
void OnRPC(ParamsReadContext ctx)
override void OnUpdate(float delta_time)
protected float CalcTemperatureFromTemperatureSource(notnull UTemperatureSourceDebug utsd)
void RequestUniversalTemperatureSources(PlayerBase player, int enable)
protected ref array< ref UTemperatureSourceDebug > m_UTemperatureSourceDebugs
void UpdateStatWidget(int rowIndex, UTemperatureSourceDebug utsd)
proto native void Send(Object target, int rpc_type, bool guaranteed, PlayerIdentity recipient=NULL)
Initiate remote procedure call. When called on client, RPC is evaluated on server; When called on ser...
Serialization general interface. Serializer API works with:
proto bool Write(void value_out)
proto bool Read(void value_in)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
proto native CGame GetGame()
static proto native void Begin(string windowTitle, float x=0, float y=0)
static proto native void Text(string label)
static proto native void End()
void PrintString(string s)
Helper for printing out string expression. Example: PrintString("Hello " + var);.
static proto float Max(float x, float y)
Returns bigger of two given values.
static proto float SqrFloat(float f)
Returns squared value.