35 void CallParams(
Param params)
39 GetGame().GameScript.CallFunctionParams(m_target, m_function, NULL, params);
43 GetGame().GameScript.CallFunction(m_target, m_function, NULL, 0);
68 private bool m_processing;
80 if (m_processing)
return;
108 void Call(
Class obj,
string fn_name,
Param params = NULL)
118 void RemoveCalls(
Class obj)
122 for (
int i =
Count() - 1; i >= 0; i--)
125 if (ctx.m_target == obj)
167 if (m_processing)
return;
174 bool is_holding =
false;
184 if (!is_holding || mouse_x != m_mouse_params.param1 || mouse_y != m_mouse_params.param2)
186 m_mouse_params.param1 = mouse_x;
187 m_mouse_params.param2 = mouse_y;
188 m_mouse_params.param3 = is_holding;
190 while (
Count() > last_index)
192 ctx =
Get(last_index);
199 ctx.CallParams(m_mouse_params);
211 m_processing =
false;
337 ErrorEx(
"Attempting to Init a timer when the game does not exist (GetGame() == null)");
340 protected void OnStart(
float duration,
bool loop)
349 protected void OnUpdate() {}
350 protected void OnTimer() {}
382 class TimerQueue
extends array<TimerBase>
384 private bool m_processing;
389 m_processing =
false;
397 for (
int i =
Count() - 1; i >= 0; i--)
399 Get(i).OnTimerQueueDestoryed();
407 void Tick(
float timeslice)
409 if (m_processing)
return;
415 for (
int i =
Count() - 1; i >= 0; i--)
417 Get(i).Tick(timeslice);
421 m_processing =
false;
435 void WidgetFadeTimer()
447 void FadeIn(
Widget w,
float time,
bool continue_ =
false)
449 m_alpha = w.GetAlpha();
451 if (continue_ && m_alpha > 0.95)
465 m_alpha = m_widget.GetAlpha();
466 m_widget.SetAlpha(0);
482 void FadeOut(
Widget w,
float time,
bool continue_ =
false)
484 m_alpha = w.GetAlpha();
486 if (continue_ && m_alpha < 0.05)
498 if (m_widget && !continue_)
501 m_widget.SetAlpha(m_alpha);
507 m_time = (1.0 - m_alpha) * time;
511 override private void OnTimer()
517 m_widget.SetAlpha(1);
521 m_widget.SetAlpha(0);
522 m_widget.Show(
false);
539 progress =
Math.Lerp(m_alpha,0,timeDiff);
540 progress =
Math.Clamp(progress,0,1);
543 m_widget.SetAlpha(progress);
581 protected string m_function;
582 protected ref
Param m_params;
597 void Run(
float duration,
Managed obj,
string fn_name,
Param params = NULL,
bool loop =
false)
600 m_function = fn_name;
606 override protected void OnTimer()
610 GetGame().GameScript.CallFunctionParams(m_target, m_function, NULL, m_params);
615 GetGame().GameScript.CallFunction(m_target, m_function, NULL, 0);
654 private bool m_Active;
655 private float m_TargetValue;
656 private float m_TargetValueOriginal;
657 private float m_Value;
658 protected Managed m_TargetObject;
659 protected string m_UpdateFunction;
660 protected string m_FinishedFunction;
661 protected ref
Param m_Params;
673 void Run(
float targetVal,
Managed obj,
string updateFunc,
string finishedFunc,
float startingVal = 0,
bool loop =
false,
float speed = 1.0,
Param params =
null,
int category =
CALL_CATEGORY_SYSTEM)
677 m_UpdateFunction = updateFunc;
678 m_FinishedFunction = finishedFunc;
679 m_TargetValueOriginal = targetVal;
680 m_TargetValue = targetVal;
695 override bool IsRunning()
702 override void Tick(
float timeslice)
708 float diff =
Math.AbsFloat(m_TargetValue -
m_Value);
709 float step =
m_time * timeslice;
720 if (m_TargetValue == m_TargetValueOriginal)
726 m_TargetValue = m_TargetValueOriginal;
750 private bool m_active =
false;
751 private bool m_loop =
false;
752 private float m_target_value = 0;
753 private float m_value = 0;
754 private float m_time = 0;
761 void Animate(
float val,
float speed = 1.0)
763 m_target_value = val;
773 void AnimateLoop(
float speed = 1.0)
792 float GetTargetValue() {
793 return m_target_value;
799 void SetValue(
float val) {
801 m_target_value = val;
811 void Tick(
float timeslice)
813 if ( !m_active )
return;
817 m_target_value +=
m_time *
Math.PI2 * timeslice;
818 while (m_target_value >
Math.PI2) m_target_value -=
Math.PI2;
820 m_value =
Math.Sin(m_target_value);
824 float diff =
Math.AbsFloat(m_target_value - m_value);
825 float step =
m_time * timeslice;
829 m_value = m_target_value;
834 if (m_target_value > m_value)
877 index = m_keys.Find(key);
893 index = m_keys.Find(key);
898 return m_values.Get(index);
906 return m_values.Get(index);
909 K GetKeyByIndex(
int index)
911 return m_keys.Get(index);
914 void Insert(K key, V value)
925 index = m_keys.Find(key);
931 value_array.Insert(value);
934 m_values.Insert(value_array);
939 m_values.Get(index).Insert(value);
943 void RemoveByIndex(
int index)
945 m_keys.Remove(index);
946 m_values.Remove(index);
954 index = m_keys.Find(key);
959 RemoveByIndex(index);
967 return m_keys.Count();
975 if ( m_keys && m_values)
998 if ( temperature < 20 )
1000 temperature = temperature - 20;
1001 temperature =
Math.Clamp( temperature, -50, 50);
1002 temperature =
Math.AbsInt(temperature);
1004 red =
Math.Clamp ( red - ((red/50 )*temperature), 0, 255 );
1005 green =
Math.Clamp ( green - ((green/50 )*temperature), 0, 255 );
1006 blue =
Math.Clamp ( blue+((blue/50)*temperature), 0, 255 );
1008 else if ( temperature > 20 )
1010 temperature =
Math.Clamp( temperature, -100, 100);
1011 blue =
Math.Clamp ( blue - ((blue/100 )*temperature), 0, 255 );
1012 green =
Math.Clamp ( green - ((green/100 )*temperature), 0, 255 );
1013 red =
Math.Clamp ( red+((red/100)*temperature), 0, 255 );
1016 int color =
ARGB( alpha, red, green, blue );
1026 if (value ==
"true" || value ==
"1")
1057 return Math.GetNumberOfSetBits(i);