huntingoptic.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. class HuntingOptic extends ItemOptics
  2. {
  3. EntityAI m_Parent;
  4. void HuntingOptic()
  5. {
  6. HideSelection("rings_ris");
  7. HideSelection("rings_ris_pilot");
  8. }
  9. override void OnWasAttached( EntityAI parent, int slot_id )
  10. {
  11. super.OnWasAttached(parent, slot_id);
  12. m_Parent = parent;
  13. if (!ParentUsesWinchesterTypeMount())
  14. {
  15. HideSelection("rings_winchester");
  16. HideSelection("rings_winchester_pilot");
  17. ShowSelection("rings_ris");
  18. ShowSelection("rings_ris_pilot");
  19. }
  20. }
  21. override void OnWasDetached( EntityAI parent, int slot_id )
  22. {
  23. super.OnWasDetached(parent, slot_id);
  24. m_Parent = null;
  25. HideSelection("rings_ris");
  26. HideSelection("rings_ris_pilot");
  27. ShowSelection("rings_winchester");
  28. ShowSelection("rings_winchester_pilot");
  29. }
  30. override void HideSelection( string selection_name )
  31. {
  32. super.HideSelection( selection_name );
  33. if (selection_name == "hide") //hides pilotview selections in order not to obstruct view
  34. {
  35. HideSelection("rings_ris_pilot");
  36. HideSelection("rings_winchester_pilot");
  37. }
  38. }
  39. override void ShowSelection( string selection_name )
  40. {
  41. super.ShowSelection( selection_name );
  42. if (selection_name == "hide")
  43. {
  44. if (!ParentUsesWinchesterTypeMount())
  45. {
  46. HideSelection("rings_winchester");
  47. HideSelection("rings_winchester_pilot");
  48. ShowSelection("rings_ris");
  49. ShowSelection("rings_ris_pilot");
  50. }
  51. else
  52. {
  53. HideSelection("rings_ris");
  54. HideSelection("rings_ris_pilot");
  55. ShowSelection("rings_winchester");
  56. ShowSelection("rings_winchester_pilot");
  57. }
  58. }
  59. }
  60. bool ParentUsesWinchesterTypeMount()
  61. {
  62. if (m_Parent && m_Parent.ConfigIsExisting("winchesterTypeOpticsMount"))
  63. return m_Parent.ConfigGetBool("winchesterTypeOpticsMount");
  64. return false;
  65. }
  66. }