971 {
972 #ifdef DIAG_DEVELOPER
973 if (m_StaminaDisabled)
974 return;
975 #endif
976 float val = 0.0;
977 float current_time =
m_Player.GetSimulationTimeStamp();
978 float valueProgress;
980
981
982 switch (sm.GetType())
983 {
985 if (dT == -1)
986 {
987 dT = 1;
988 }
990
991 break;
992
994 val = Math.RandomFloat(sm.GetMinValue(), sm.GetMaxValue());
996
997 break;
998
1000 if (!sm.IsInUse())
1001 {
1002 sm.SetStartTime(current_time + sm.GetStartTimeAdjustment()/dT);
1003 sm.SetRunTimeTick(dT);
1004 sm.SetInUse(true);
1005 }
1006 valueProgress = Math.Clamp((current_time - sm.GetStartTime())/sm.GetDurationAdjusted(), 0, 1 );
1007 val = Math.Lerp(sm.GetMinValue(), sm.GetMaxValue(), valueProgress);
1009
1010 break;
1011
1013 StaminaModifierExponential smex;
1014 if (!Class.CastTo(smex,sm))
1015 {
1016 ErrorEx(
"StaminaModifierExponential not found for modifier type: " + sm.GetType());
1017 break;
1018 }
1019
1020 if (!smex.IsInUse())
1021 {
1023 smex.SetRunTimeTick(dT);
1024 smex.SetInUse(true);
1025 }
1026 valueProgress = Math.Clamp((current_time - smex.GetStartTime())/smex.
GetDurationAdjusted(), 0, 1 );
1027 float exp;
1029 {
1030 exp = 1 - Math.Lerp(0, smex.
GetExponent(), valueProgress);
1032 }
1033 else
1034 {
1037 }
1038
1041
1042 break;
1043 }
1044
1048
1050 }
void StaminaModifier(int type, float min, float max, float cooldown, float startTime=0, float duration=0)
float m_StaminaDepletionMultiplier
ref StaminaModifiers m_StaminaModifiers
void SetCooldown(float time, int modifier=-1)
set cooldown timer between each consume of stamina
override float GetStartTimeAdjustment()
override float GetDurationAdjusted()