1 class TransferValues
extends Managed
3 const int TYPE_HEALTH = 1;
4 const int TYPE_BLOOD = 2;
9 const int BLOOD_THRESHOLD_LOW = 3000;
14 float m_LastBloodUpdate;
20 float m_BloodMaxValue;
25 protected bool m_InitialSyncSent;
30 m_InitialSyncSent =
false;
37 m_LastBloodUpdate = 0;
39 m_BloodMaxValue =
m_Player.GetMaxHealth(
"",
"Blood");
52 if (
GetGame().IsClient() )
return;
56 if (!m_InitialSyncSent)
93 return m_HealthClient;
98 float health_current =
m_Player.GetHealth(
"",
"Health");
101 float diff_abs =
Math.AbsFloat(difference_normalized);
105 SendValue(TYPE_HEALTH, health_normalized);
136 float blood_current =
m_Player.GetHealth(
"",
"Blood");
138 float blood_normalized =
Math.InverseLerp(BLOOD_THRESHOLD_LOW, m_BloodMaxValue, blood_current);
139 blood_normalized =
Math.Clamp(blood_normalized,0,1);
140 float difference_normalized = blood_normalized - m_LastBloodUpdate;
141 float diff_abs =
Math.AbsFloat(difference_normalized);
146 m_LastBloodUpdate = blood_normalized;
151 void SendInitValues()
153 m_InitialSyncSent =
true;
156 float health_current =
m_Player.GetHealth(
"",
"Health");
158 SendValue(TYPE_HEALTH, health_normalized);
162 float blood_current =
m_Player.GetHealth(
"",
"Blood");
163 float blood_normalized =
Math.InverseLerp(BLOOD_THRESHOLD_LOW, m_BloodMaxValue, blood_current);
164 blood_normalized =
Math.Clamp(blood_normalized,0,1);
167 m_LastBloodUpdate = blood_normalized;
170 void SendValue(
int value_type,
float value)
178 void ReceiveValue(
int value_type,
float value)
180 if ( value_type == TYPE_HEALTH )
182 m_HealthClient = value;
184 else if ( value_type == TYPE_BLOOD )
186 m_BloodClient = value;
197 ReceiveValue(value_type, value);
200 void ShowDebugValues(
bool show)
202 #ifdef DIAG_DEVELOPER
205 DbgUI.BeginCleanupScope();
206 DbgUI.Begin(
"Values", 50, 50);
208 DbgUI.Text(
"Blood: " + m_BloodClient.ToString());
209 DbgUI.Text(
"Health: " + m_HealthClient.ToString());
212 DbgUI.EndCleanupScope();
216 DbgUI.BeginCleanupScope();
217 DbgUI.Begin(
"Values", 50, 50);
219 DbgUI.EndCleanupScope();