1class 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;
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);
112 float blood_current =
m_Player.GetHealth(
"",
"Blood");
114 float blood_normalized =
Math.InverseLerp(BLOOD_THRESHOLD_LOW, m_BloodMaxValue, blood_current);
115 blood_normalized =
Math.Clamp(blood_normalized,0,1);
116 float difference_normalized = blood_normalized - m_LastBloodUpdate;
117 float diff_abs =
Math.AbsFloat(difference_normalized);
122 m_LastBloodUpdate = blood_normalized;
129 m_InitialSyncSent =
true;
132 float health_current =
m_Player.GetHealth(
"",
"Health");
134 SendValue(TYPE_HEALTH, health_normalized);
138 float blood_current =
m_Player.GetHealth(
"",
"Blood");
139 float blood_normalized =
Math.InverseLerp(BLOOD_THRESHOLD_LOW, m_BloodMaxValue, blood_current);
140 blood_normalized =
Math.Clamp(blood_normalized,0,1);
142 m_LastBloodUpdate = blood_normalized;
155 if ( value_type == TYPE_HEALTH )
157 m_HealthClient = value;
159 else if ( value_type == TYPE_BLOOD )
161 m_BloodClient = value;
177 #ifdef DIAG_DEVELOPER
180 DbgUI.BeginCleanupScope();
181 DbgUI.Begin(
"Values", 50, 50);
183 DbgUI.Text(
"Blood: " + m_BloodClient.ToString());
184 DbgUI.Text(
"Health: " + m_HealthClient.ToString());
187 DbgUI.EndCleanupScope();
191 DbgUI.BeginCleanupScope();
192 DbgUI.Begin(
"Values", 50, 50);
194 DbgUI.EndCleanupScope();
void OnRPC(ParamsReadContext ctx)
void ShowDebugValues(bool show)
void ReceiveValue(int value_type, float value)
void SendValue(int value_type, float value)
void OnScheduledTick(float deltatime)
void SendInitValues()
Sends values on object creation.
void TransferValues(PlayerBase player)
Serialization general interface. Serializer API works with:
proto native CGame GetGame()
eInjuryHandlerLevels m_LastHealthUpdate
const float SENSITIVTY_PERCENTAGE
enum eInjuryHandlerLevels VALUE_CHECK_INTERVAL
float m_TimeSinceLastTick