pluginplayerstatus.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. class PluginPlayerStatus extends PluginBase
  2. {
  3. ref multiMap<int, string> m_NotifiersLabel;
  4. ref multiMap<int, int> m_NotifiersIndexColor;
  5. private ref multiMap<int, string> m_NotifiersIcons;
  6. void PluginPlayerStatus()
  7. {
  8. m_NotifiersLabel = new multiMap<int, string>; // [key] label
  9. m_NotifiersIndexColor = new multiMap<int, int>; // [key] index, color
  10. m_NotifiersIcons = new multiMap<int, string>; // [key] iconName
  11. m_NotifiersIcons.Insert( NTFKEY_HUNGRY, "iconHunger" );
  12. m_NotifiersIcons.Insert( NTFKEY_THIRSTY, "iconThirsty" );
  13. m_NotifiersIcons.Insert( NTFKEY_SICK, "iconHealth" );
  14. m_NotifiersIcons.Insert( NTFKEY_BACTERIA, "iconBacteria" );
  15. m_NotifiersIcons.Insert( NTFKEY_BLEEDISH, "iconBlood" );
  16. m_NotifiersIcons.Insert( NTFKEY_FEVERISH, "iconTemperature" );
  17. m_NotifiersIcons.Insert( NTFKEY_FRACTURE, "iconFracture" );
  18. }
  19. void SetNotifier( int key, int index = 9, string label = "", int color = 0xFFFFFFFF )
  20. {
  21. if ( key )
  22. {
  23. if ( m_NotifiersLabel.HasKey( key ) )
  24. {
  25. m_NotifiersLabel.Remove( key );
  26. m_NotifiersIndexColor.Remove( key );
  27. }
  28. if ( label != "" )
  29. {
  30. m_NotifiersLabel.Insert( key, label );
  31. m_NotifiersIndexColor.Insert( key, index );
  32. m_NotifiersIndexColor.Insert( key, color );
  33. }
  34. }
  35. }
  36. void DisplayTendency( int key, int tendency, int status = 1 )
  37. {
  38. if ( key )
  39. {
  40. // display icon
  41. int icon_index = 0; // maybe we'll have several icons for different tendencies
  42. if ( m_NotifiersIcons.HasKey( key ) )
  43. {
  44. string icon_name = m_NotifiersIcons.Get( key ).Get( icon_index );
  45. Mission mission = GetGame().GetMission();
  46. if ( mission )
  47. {
  48. Hud hud = mission.GetHud();
  49. if ( hud )
  50. {
  51. hud.DisplayNotifier( key, tendency, status );
  52. }
  53. }
  54. }
  55. }
  56. }
  57. void SetBadge( int key, int value )
  58. {
  59. if ( key )
  60. {
  61. Mission mission = GetGame().GetMission();
  62. if ( mission )
  63. {
  64. Hud hud = mission.GetHud();
  65. if ( hud )
  66. {
  67. hud.DisplayBadge( key, value );
  68. }
  69. }
  70. }
  71. }
  72. void SetStamina( int value , int range )
  73. {
  74. // Log( String( "SetStamina" + itoa( value) ), LogTemplates.TEMPLATE_JANOSIK );
  75. Mission mission = GetGame().GetMission();
  76. if ( mission )
  77. {
  78. Hud hud = mission.GetHud();
  79. if ( hud )
  80. {
  81. hud.SetStamina( Math.Clamp( value, 0, range ), range );
  82. }
  83. }
  84. }
  85. void SetStance( int value )
  86. {
  87. Mission mission = GetGame().GetMission();
  88. if ( mission )
  89. {
  90. Hud hud = mission.GetHud();
  91. if ( hud )
  92. {
  93. hud.DisplayStance( value );
  94. }
  95. }
  96. }
  97. }