4 protected float m_SpecialtyLevel;
5 protected float m_RoughLevel;
6 protected float m_PreciseLevel;
8 protected bool m_IsLinear;
9 protected bool m_IsActive;
10 protected bool m_IsCoolDown;
12 protected int m_UserActionsCounter;
14 static protected const int DEFAULT_EFFICIENCY = 0;
15 static protected const float PRECISE_WEIGHT_LIMIT = -1;
16 static protected const float ROUGH_WEIGHT_LIMIT = 1;
17 static protected const float COOLDOWN_TIMER = 5;
19 protected ref
Timer m_CoolDownTimer =
new Timer();
21 protected bool m_IsDebugMode;
22 protected float m_CoolDownValue;
23 protected float m_LastUAValue;
24 protected float m_ComponentBonusBefore;
25 protected float m_ComponentBonusAfter;
26 protected float m_GeneralBonusBefore;
27 protected float m_GeneralBonusAfter;
31 protected ref
Timer m_SynchTimer;
39 m_IsDebugMode =
false;
42 void InitSpecialty(
float specialty_level )
44 SetSpecialtyLevel( specialty_level );
45 SynchSpecialtyLevel();
50 delete m_CoolDownTimer;
54 float AddLinearPrecise(
float specialty_weight )
56 m_SpecialtyLevel += specialty_weight;
57 SetLastUAValue( specialty_weight );
58 m_SpecialtyLevel =
Math.Clamp( m_SpecialtyLevel, PRECISE_WEIGHT_LIMIT, ROUGH_WEIGHT_LIMIT );
60 return m_SpecialtyLevel;
64 float AddLinearRough(
float specialty_weight )
66 m_SpecialtyLevel += specialty_weight;
67 SetLastUAValue( specialty_weight );
68 m_SpecialtyLevel =
Math.Clamp( m_SpecialtyLevel, PRECISE_WEIGHT_LIMIT, ROUGH_WEIGHT_LIMIT );
70 return m_SpecialtyLevel;
74 float AddExponentialPrecise(
float specialty_weight )
76 m_UserActionsCounter -= 1;
78 if( m_UserActionsCounter == 0)
80 m_UserActionsCounter = -1;
84 float adjusted_weight = specialty_weight /
Math.Sqrt(
Math.AbsInt( m_UserActionsCounter ) );
86 SetLastUAValue( adjusted_weight );
88 m_SpecialtyLevel += adjusted_weight;
89 m_SpecialtyLevel =
Math.Clamp( m_SpecialtyLevel, PRECISE_WEIGHT_LIMIT, ROUGH_WEIGHT_LIMIT );
91 return m_SpecialtyLevel;
95 float AddExponentialRough(
float specialty_weight )
97 m_UserActionsCounter += 1;
99 if( m_UserActionsCounter == 0)
101 m_UserActionsCounter = 1;
102 m_SpecialtyLevel = 0;
105 float adjusted_weight = specialty_weight /
Math.Sqrt(
Math.AbsInt( m_UserActionsCounter ) );
107 SetLastUAValue( adjusted_weight );
109 m_SpecialtyLevel += adjusted_weight;
110 m_SpecialtyLevel =
Math.Clamp( m_SpecialtyLevel, PRECISE_WEIGHT_LIMIT, ROUGH_WEIGHT_LIMIT );
112 return m_SpecialtyLevel;
116 void AddSpecialty(
float specialty_weight )
118 if( GetSoftSkillsState() )
122 if( specialty_weight < 0 )
126 SetSpecialtyLevel( AddLinearPrecise( specialty_weight ) );
130 SetSpecialtyLevel( AddExponentialPrecise( specialty_weight ) );
133 m_Player.GetStatSpecialty().Set( m_SpecialtyLevel );
134 StartCoolDownTimer(
Math.AbsFloat( ( specialty_weight * 100 ) ) * COOLDOWN_TIMER );
135 SynchSpecialtyLevel();
137 else if( specialty_weight > 0 )
141 SetSpecialtyLevel( AddLinearRough( specialty_weight ) );
145 SetSpecialtyLevel( AddExponentialRough( specialty_weight ) );
148 m_Player.GetStatSpecialty().Set( m_SpecialtyLevel );
149 StartCoolDownTimer(
Math.AbsFloat( ( specialty_weight * 100 ) ) * COOLDOWN_TIMER );
150 SynchSpecialtyLevel();
160 StartCoolDownTimer(
Math.AbsFloat( ( specialty_weight * 100 ) ) * COOLDOWN_TIMER );
168 float AddSpecialtyBonus(
float base_value,
float specialty_weight,
bool is_cacomponent =
false,
float limit_efficiency = 2 )
170 if ( specialty_weight == 0 )
175 SetBonusBefore( is_cacomponent, base_value);
177 float adjusted_value;
179 GetPreciseRoughLevels();
181 if ( limit_efficiency != 0 )
183 if ( specialty_weight < 0 )
185 adjusted_value = base_value + ( ( base_value * m_PreciseLevel ) / limit_efficiency );
189 adjusted_value = base_value + ( ( base_value * m_RoughLevel ) / limit_efficiency );
194 if ( specialty_weight < 0 )
196 adjusted_value = base_value + ( ( base_value * m_PreciseLevel ) );
200 adjusted_value = base_value + ( ( base_value * m_RoughLevel ) );
204 SetBonusAfter( is_cacomponent, adjusted_value );
206 return adjusted_value;
212 float SubtractSpecialtyBonus(
float base_value,
float specialty_weight,
bool is_cacomponent =
false,
float limit_efficiency = 2 )
214 if ( specialty_weight == 0 )
219 SetBonusBefore( is_cacomponent, base_value);
221 float adjusted_value;
223 GetPreciseRoughLevels();
225 if ( limit_efficiency != 0 )
227 if ( specialty_weight < 0 )
229 adjusted_value = base_value - ( ( base_value * m_PreciseLevel ) / limit_efficiency );
233 adjusted_value = base_value - ( ( base_value * m_RoughLevel ) / limit_efficiency );
238 if ( specialty_weight < 0 )
240 adjusted_value = base_value - ( ( base_value * m_PreciseLevel ) );
244 adjusted_value = base_value - ( ( base_value * m_RoughLevel ) );
248 SetBonusAfter( is_cacomponent, adjusted_value );
250 return adjusted_value;
256 float AdjustCraftingTime(
float base_time,
float specialty_weight,
float limit_efficiency = 2 )
258 if ( specialty_weight == 0 )
263 SetBonusBefore(
false, base_time);
267 GetPreciseRoughLevels();
269 if ( specialty_weight < 0 )
271 adjusted_time = base_time - ( ( base_time * m_PreciseLevel ) / limit_efficiency );
275 adjusted_time = base_time - ( ( base_time * m_RoughLevel ) / limit_efficiency );
278 SetBonusAfter(
false, adjusted_time );
280 return adjusted_time;
290 void SetSpecialtyLevel(
float specialty_level )
292 m_SpecialtyLevel = specialty_level;
296 float GetSpecialtyLevel()
298 return m_SpecialtyLevel;
302 void SynchSpecialtyLevel()
305 Param1<float> specialty_level =
new Param1<float>( m_SpecialtyLevel );
311 void SetSoftSkillsState(
bool state )
317 bool GetSoftSkillsState()
323 void SetLinearState(
bool model )
335 void GetPreciseRoughLevels()
337 if ( m_SpecialtyLevel > 0)
339 m_RoughLevel = m_SpecialtyLevel;
340 m_PreciseLevel = DEFAULT_EFFICIENCY;
342 else if ( m_SpecialtyLevel < 0)
344 m_RoughLevel = DEFAULT_EFFICIENCY;
345 m_PreciseLevel =
Math.AbsFloat( m_SpecialtyLevel );
349 m_RoughLevel = DEFAULT_EFFICIENCY;
350 m_PreciseLevel = DEFAULT_EFFICIENCY;
355 void StartCoolDownTimer(
float cooldown_value )
358 SetCoolDownValue( cooldown_value );
359 m_CoolDownTimer.Run( cooldown_value,
this,
"SetCoolDown",
new Param1<bool>(
false ) );
369 void SetCoolDown(
bool cool_down )
371 m_IsCoolDown = cool_down;
377 void CreateDebugWindow(
bool create )
382 SetIsDebug( create );
387 SetIsDebug( create );
388 delete m_DebugWindow;
393 void SynchDebugStats()
397 Param5<float, float, float, float, bool> debug_stats =
new Param5<float, float, float, float, bool>( m_GeneralBonusBefore, m_GeneralBonusAfter, m_LastUAValue, m_CoolDownValue, m_IsCoolDown );
403 void SetIsDebug(
bool is_debug )
405 m_IsDebugMode = is_debug;
411 return m_IsDebugMode;
415 void SetCoolDownValue(
float cooldown_value )
417 m_CoolDownValue = cooldown_value;
421 float GetCoolDownValue()
423 return m_CoolDownValue;
427 float GetLastUAValue()
429 return m_LastUAValue;
433 void SetLastUAValue(
float last_ua_value )
435 m_LastUAValue = last_ua_value;
439 void SetBonusBefore(
bool is_cacomponent,
float base_value)
443 if ( is_cacomponent )
445 SetComponentBonusBefore(base_value);
449 SetGeneralBonusBefore(base_value);
455 void SetBonusAfter(
bool is_cacomponent,
float adjusted_value )
459 if ( is_cacomponent )
461 SetComponentBonusAfter(adjusted_value);
465 SetGeneralBonusAfter(adjusted_value);
471 float GetComponentBonusBefore()
473 return m_ComponentBonusBefore;
477 void SetComponentBonusBefore(
float component_bonus_before )
479 m_ComponentBonusBefore = component_bonus_before;
483 float GetComponentBonusAfter()
485 return m_ComponentBonusAfter;
489 void SetComponentBonusAfter(
float component_bonus_after )
491 m_ComponentBonusAfter = component_bonus_after;
495 float GetGeneralBonusBefore()
497 return m_GeneralBonusBefore;
501 void SetGeneralBonusBefore(
float general_bonus_before )
503 m_GeneralBonusBefore = general_bonus_before;
507 float GetGeneralBonusAfter()
509 return m_GeneralBonusAfter;
513 void SetGeneralBonusAfter(
float general_bonus_after )
515 m_GeneralBonusAfter = general_bonus_after;
519 void StartSynchTimer()
522 m_SynchTimer =
new Timer;
523 m_SynchTimer.Run( 2,
this,
"SynchDebugStats", NULL,
true );
527 void StopSynchTimer()
539 void ResetDebugWindow()
541 SetSpecialtyLevel( 0 );
543 SetComponentBonusBefore( 0 );
544 SetComponentBonusAfter( 0 );
545 SetGeneralBonusBefore( 0 );
546 SetGeneralBonusAfter( 0 );
547 SetCoolDownValue( 0 );
549 SynchSpecialtyLevel();
617 speciality = speciality * 100;
618 speciality =
Math.Round( speciality );
619 speciality = speciality * 0.01;
621 SpecialtyTotal.SetText(
"Specialty level: " + speciality.ToString() );