optics.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. class Crossbow_RedpointOptic : ItemOptics {};
  2. class LongrangeOptic : ItemOptics {};
  3. class SportingOptic : ItemOptics {};
  4. class PistolOptic : ItemOptics {};
  5. class GrozaOptic : ItemOptics {};
  6. class ACOGOptic : ItemOptics {};
  7. class ACOGOptic_6x : ItemOptics {};
  8. class KashtanOptic : ItemOptics {};
  9. class M68Optic : ItemOptics
  10. {
  11. override bool IsSightOnly()
  12. {
  13. return true;
  14. }
  15. }
  16. class M4_T3NRDSOptic : ItemOptics
  17. {
  18. override bool IsSightOnly()
  19. {
  20. return true;
  21. }
  22. }
  23. class FNP45_MRDSOptic : ItemOptics
  24. {
  25. override bool IsSightOnly()
  26. {
  27. return true;
  28. }
  29. }
  30. class ReflexOptic : ItemOptics
  31. {
  32. override bool IsSightOnly()
  33. {
  34. return true;
  35. }
  36. }
  37. class KobraOptic : ItemOptics
  38. {
  39. override bool IsSightOnly()
  40. {
  41. return true;
  42. }
  43. }
  44. class KazuarOptic: ItemOptics
  45. {
  46. override void InitOpticMode() //TODO - decide whether to randomize on spawn and how to determine it (attachment etc.)
  47. {
  48. super.InitOpticMode();
  49. SetCurrentOpticMode(GameConstants.OPTICS_STATE_NIGHTVISION);
  50. }
  51. override int GetCurrentNVType()
  52. {
  53. if (IsWorking())
  54. {
  55. switch (m_CurrentOpticMode)
  56. {
  57. case GameConstants.OPTICS_STATE_DAY:
  58. return NVTypes.NV_OPTICS_KAZUAR_DAY;
  59. case GameConstants.OPTICS_STATE_NIGHTVISION:
  60. return NVTypes.NV_OPTICS_KAZUAR_NIGHT;
  61. }
  62. Error("Undefined optic mode of " + this);
  63. return NVTypes.NONE;
  64. }
  65. else
  66. {
  67. return NVTypes.NV_OPTICS_OFF;
  68. }
  69. }
  70. override void OnOpticModeChange()
  71. {
  72. super.OnOpticModeChange();
  73. UpdateSelectionVisibility();
  74. }
  75. override void OnOpticEnter()
  76. {
  77. super.OnOpticEnter();
  78. HideSelection("hide_cover_pilot");
  79. }
  80. override void UpdateSelectionVisibility()
  81. {
  82. super.UpdateSelectionVisibility();
  83. switch (GetCurrentOpticMode())
  84. {
  85. case GameConstants.OPTICS_STATE_NIGHTVISION:
  86. HideSelection("hide_cover");
  87. HideSelection("hide_cover_pilot");
  88. break;
  89. case GameConstants.OPTICS_STATE_DAY:
  90. ShowSelection("hide_cover");
  91. if ( !GetGame().IsDedicatedServer() && !IsInOptics() ) //quick sanity check, just in case
  92. {
  93. ShowSelection("hide_cover_pilot");
  94. }
  95. break;
  96. }
  97. }
  98. override void SetActions()
  99. {
  100. super.SetActions();
  101. AddAction(ActionToggleNVMode);
  102. }
  103. };
  104. class StarlightOptic: ItemOptics
  105. {
  106. override void InitOpticMode() //TODO - decide whether to randomize on spawn and how to determine it (attachment etc.)
  107. {
  108. super.InitOpticMode();
  109. SetCurrentOpticMode(GameConstants.OPTICS_STATE_NIGHTVISION);
  110. }
  111. override int GetCurrentNVType()
  112. {
  113. if (IsWorking())
  114. {
  115. switch (m_CurrentOpticMode)
  116. {
  117. case GameConstants.OPTICS_STATE_DAY:
  118. return NVTypes.NV_OPTICS_STARLIGHT_DAY;
  119. case GameConstants.OPTICS_STATE_NIGHTVISION:
  120. return NVTypes.NV_OPTICS_STARLIGHT_NIGHT;
  121. }
  122. Error("Undefined optic mode of " + this);
  123. return NVTypes.NONE;
  124. }
  125. else
  126. {
  127. return NVTypes.NV_OPTICS_OFF;
  128. }
  129. }
  130. override void OnOpticModeChange()
  131. {
  132. super.OnOpticModeChange();
  133. UpdateSelectionVisibility();
  134. }
  135. override void OnOpticEnter()
  136. {
  137. super.OnOpticEnter();
  138. HideSelection("hide_cover_pilot");
  139. }
  140. override void UpdateSelectionVisibility()
  141. {
  142. super.UpdateSelectionVisibility();
  143. switch (GetCurrentOpticMode())
  144. {
  145. case GameConstants.OPTICS_STATE_NIGHTVISION:
  146. HideSelection("hide_cover");
  147. HideSelection("hide_cover_pilot");
  148. break;
  149. case GameConstants.OPTICS_STATE_DAY:
  150. ShowSelection("hide_cover");
  151. if ( !GetGame().IsDedicatedServer() && !IsInOptics() ) //quick sanity check, just in case
  152. {
  153. ShowSelection("hide_cover_pilot");
  154. }
  155. break;
  156. }
  157. }
  158. override void SetActions()
  159. {
  160. super.SetActions();
  161. AddAction(ActionToggleNVMode);
  162. }
  163. }
  164. class MK4Optic_ColorBase : ItemOptics {};
  165. class MK4Optic_Tan : MK4Optic_ColorBase {};
  166. class MK4Optic_Black : MK4Optic_ColorBase {};
  167. class MK4Optic_Green : MK4Optic_ColorBase {};