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() {}
382class 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;
431 private Widget m_widget;
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);
527 override private void OnUpdate()
539 progress =
Math.Lerp(m_alpha,0,timeDiff);
540 progress =
Math.Clamp(progress,0,1);
543 m_widget.SetAlpha(progress);
597 void Run(
float duration,
Managed obj,
string fn_name,
Param params = NULL,
bool loop =
false)
600 m_function = fn_name;
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;
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)
679 m_TargetValueOriginal = targetVal;
680 m_TargetValue = targetVal;
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)
999 if (temperature <
GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_LOWER_LIMIT)
1001 temperature = temperature - 20;
1002 temperature =
Math.Clamp( temperature, -50, 50);
1003 temperature =
Math.AbsInt(temperature);
1005 red =
Math.Clamp ( red - ((red/50 )*temperature), 0, 255);
1006 green =
Math.Clamp ( green - ((green/50 )*temperature), 0, 255);
1007 blue =
Math.Clamp ( blue+((blue/50)*temperature), 0, 255);
1009 else if (temperature >
GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_UPPER_LIMIT)
1011 temperature =
Math.Clamp(temperature, -100, 100);
1012 blue =
Math.Clamp (blue - ((blue / 100) * temperature), 0, 255);
1013 green =
Math.Clamp (green - ((green / 100) * temperature), 0, 255);
1014 red =
Math.Clamp (red + ((red / 100) * temperature), 0, 255);
1017 return ARGB(alpha, red, green, blue);
1026 if (value ==
"true" || value ==
"1")
1057 return Math.GetNumberOfSetBits(i);
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
AnimationTimer class. This timer is for animating float value. usage:
void AnimationTimer(int category=CALL_CATEGORY_SYSTEM)
override void Tick(float timeslice)
Ticks the timer, is called by timer subsystem.
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)
override bool IsRunning()
string m_FinishedFunction
float GetValue()
Returns actual animated value.
DragQueue Class provide callbacks while mouse is dragging. Callback function must have exact argument...
Super root of all classes in Enforce script.
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Simple class for fading Widgets.
void Timer(int category=CALL_CATEGORY_SYSTEM)
void Run(float duration, Managed obj, string fn_name, Param params=NULL, bool loop=false)
Starts timer.
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
proto native int GetMouseState(MouseState index)
proto void GetMousePos(out int x, out int y)
void OnInit()
Callback for user defined initialization. Called for all suites during TestHarness....
int ARGB(int a, int r, int g, int b)
void Clear(bool clearFile=false)