862 {
863 bool hasNVGSlot;
864 for (int i = 0; i < GetInventory().GetAttachmentSlotsCount(); ++i)
865 {
866 hasNVGSlot = GetInventory().GetAttachmentSlotId(i) == InventorySlots.GetSlotIdFromString("NVG");
867 if (hasNVGSlot)
868 break;
869 }
870
871 if (player && hasNVGSlot)
872 {
873 NVGoggles nvgAttachment;
874 nvgAttachment = NVGoggles.Cast(FindAttachmentBySlotName("NVG"));
875 if (nvgAttachment)
876 {
877 if (attaching)
878 {
879 if (nvgAttachment.m_Strap && nvgAttachment.m_IsLowered)
880 {
881 nvgAttachment.SetPlayer(player);
882 player.SetNVGLowered(true);
883
884 if (player.IsControlledPlayer())
885 {
886 player.RemoveActiveNV(
NVTypes.NV_GOGGLES);
887 player.RemoveActiveNV(
NVTypes.NV_GOGGLES_2D);
888 player.RemoveActiveNV(
NVTypes.NV_GOGGLES_OFF);
889
890 player.AddActiveNV(nvgAttachment.GetCurrentNVType());
891 }
892 }
893 }
894 else if (force_disable)
895 {
896 nvgAttachment.SetPlayer(null);
897 player.SetNVGLowered(false);
898
899 if (player.IsControlledPlayer())
900 {
901 player.RemoveActiveNV(
NVTypes.NV_GOGGLES);
902 player.RemoveActiveNV(
NVTypes.NV_GOGGLES_2D);
903 player.RemoveActiveNV(
NVTypes.NV_GOGGLES_OFF);
904 }
905 }
906 else
907 {
908 if (nvgAttachment.m_Strap && nvgAttachment.m_IsLowered)
909 {
910 nvgAttachment.SetPlayer(player);
911 player.SetNVGLowered(true);
912
913 if (player.IsControlledPlayer())
914 {
915 player.RemoveActiveNV(
NVTypes.NV_GOGGLES);
916 player.RemoveActiveNV(
NVTypes.NV_GOGGLES_2D);
917 player.RemoveActiveNV(
NVTypes.NV_GOGGLES_OFF);
918
919 player.AddActiveNV(nvgAttachment.GetCurrentNVType());
920 }
921 }
922 else
923 {
924 player.SetNVGLowered(false);
925 if (player.IsControlledPlayer())
926 {
927 player.RemoveActiveNV(
NVTypes.NV_GOGGLES);
928 player.RemoveActiveNV(
NVTypes.NV_GOGGLES_2D);
929 player.RemoveActiveNV(
NVTypes.NV_GOGGLES_OFF);
930 }
931 }
932 }
933 }
934 else
935 {
936 player.SetNVGLowered(false);
937
938 if (player.IsControlledPlayer())
939 {
940 player.RemoveActiveNV(
NVTypes.NV_GOGGLES);
941 player.RemoveActiveNV(
NVTypes.NV_GOGGLES_2D);
942 player.RemoveActiveNV(
NVTypes.NV_GOGGLES_OFF);
943 }
944 }
945 }
946 }