5 bool m_reddot_displayed
6 bool m_isNVOptic =
false;
7 int m_CurrentOpticMode;
8 int m_CurrentOpticModeLocal;
11 float m_nearplane_override;
12 string m_optic_sight_texture;
13 string m_optic_sight_material;
14 string m_2D_preload_type;
27 InitCameraOverrideProperties();
28 InitOpticsDOFProperties(m_OpticsDOFProperties);
32 m_CurrentOpticModeLocal = -1;
33 RegisterNetSyncVariableInt(
"m_CurrentOpticMode", 0, 63 );
40 proto native
bool EnterOptics ();
46 proto native
bool IsInOptics ();
52 proto native
bool ExitOptics ();
58 proto native
bool HasWeaponIronsightsOverride ();
64 proto native
bool UseWeaponIronsightsOverride(
bool state);
70 proto native
bool IsUsingWeaponIronsightsOverride();
75 proto native
int GetStepFOVCount ();
81 proto native
int GetStepFOVIndex ();
88 proto native
bool SetStepFOVIndex (
int step);
94 proto native
bool StepFOVUp ();
100 proto native
bool StepFOVDown ();
105 proto native
float GetCurrentStepFOV ();
111 proto native
int GetStepZeroing ();
118 proto native
bool SetStepZeroing (
int step);
125 proto native
bool StepZeroingUp ();
132 proto native
bool StepZeroingDown ();
138 proto native
void GetCameraPoint (out
vector pos, out
vector dir);
144 proto native
float GetZoomInit();
150 proto native
float GetZoomMin();
156 proto native
float GetZoomMax();
162 proto native
float GetZeroingDistanceZoomMin();
168 proto native
float GetZeroingDistanceZoomMax();
174 proto native
void SetZeroingClampDist(
float dist);
176 override void OnWorkStart()
178 if (!
GetGame().IsDedicatedServer())
184 override void OnWorkStop()
186 if (!
GetGame().IsDedicatedServer())
194 if (GetCompEM() && GetCompEM().CanWork())
199 void UpdateOpticsReddotVisibility()
201 if (IsWorking() && !m_reddot_displayed)
205 else if (!IsWorking() && m_reddot_displayed)
211 override void OnWasAttached(
EntityAI parent,
int slot_id )
213 super.OnWasAttached(parent, slot_id);
218 if (
Class.CastTo(wep,parent))
220 SetZeroingClampDist(wep.GetZeroingClamp(wep.GetCurrentMuzzle()));
224 override void OnWasDetached(
EntityAI parent,
int slot_id )
226 super.OnWasDetached(parent, slot_id);
229 if (
PlayerBase.CastTo(player, GetHierarchyRootPlayer()))
231 player.SetReturnToOptics(
false);
237 if (
Class.CastTo(wep,parent))
239 SetZeroingClampDist(0.0);
243 override void OnInventoryExit(Man player)
245 super.OnInventoryExit(player);
250 playerPB.SetReturnToOptics(
false);
258 super.OnStoreSave(ctx);
260 ctx.Write(m_CurrentOpticMode);
265 if ( !super.OnStoreLoad(ctx,version) )
271 if ( version >= 126 )
273 if ( !ctx.Read(m_CurrentOpticMode) )
287 override void OnVariablesSynchronized()
289 super.OnVariablesSynchronized();
291 if (m_CurrentOpticModeLocal != m_CurrentOpticMode)
294 m_CurrentOpticModeLocal = m_CurrentOpticMode;
298 void InitReddotData()
300 string path =
"cfgVehicles " +
GetType() +
" OpticsInfo";
305 m_reddot_index = GetHiddenSelectionIndex(
"reddot");
306 if (
GetGame().ConfigIsExisting(
path +
" opticSightTexture"))
308 GetGame().ConfigGetText(
path +
" opticSightTexture", temp);
309 m_optic_sight_texture = temp;
312 if (
GetGame().ConfigIsExisting(
path +
" opticSightMaterial"))
314 GetGame().ConfigGetText(
path +
" opticSightMaterial", temp);
315 m_optic_sight_material = temp;
322 void ShowReddot(
bool state)
324 if (
GetGame().IsDedicatedServer())
336 if (m_reddot_index == -1)
343 if (m_optic_sight_texture !=
"")
344 SetObjectTexture(m_reddot_index, m_optic_sight_texture);
345 if (m_optic_sight_material !=
"")
346 SetObjectMaterial(m_reddot_index, m_optic_sight_material);
350 SetObjectTexture(m_reddot_index,
"");
351 SetObjectMaterial(m_reddot_index,
"");
353 m_reddot_displayed = state;
356 void InitOpticsPPInfo()
358 m_allowsDOF = InitDOFAvailability();
359 InitOpticsPP(m_mask_array, m_lens_array, m_blur_float);
361 m_isNVOptic = ConfigGetBool(
"NVOptic");
365 bool InitDOFAvailability()
368 string path =
"cfgVehicles " +
GetType() +
" OpticsInfo";
375 fov_max =
GetGame().ConfigGetFloat(
path +
" opticsZoomMax");
386 string path =
"cfgVehicles " +
GetType() +
" OpticsInfo";
387 GetGame().ConfigGetFloatArray(
path +
" PPMaskProperties", mask_array);
388 GetGame().ConfigGetFloatArray(
path +
" PPLensProperties", lens_array);
389 blur_float =
GetGame().ConfigGetFloat(
path +
" PPBlurProperties");
392 void InitCameraOverrideProperties()
394 string path =
"cfgVehicles " +
GetType() +
" OpticsInfo";
395 if (
GetGame().ConfigIsExisting(
path +
" nearPlaneDistanceOverride") )
406 bool InitOpticsDOFProperties (out
array<float> temp_array)
408 if (
GetGame().ConfigIsExisting(
"cfgVehicles " +
GetType() +
" OpticsInfo PPDOFProperties"))
410 GetGame().ConfigGetFloatArray(
"cfgVehicles " +
GetType() +
" OpticsInfo PPDOFProperties", temp_array);
413 else if (
GetGame().ConfigIsExisting(
"cfgVehicles " +
GetType() +
" OpticsInfoWeaponOverride PPDOFProperties"))
415 GetGame().ConfigGetFloatArray(
"cfgVehicles " +
GetType() +
" OpticsInfoWeaponOverride PPDOFProperties", temp_array);
432 int GetCurrentNVType()
455 void SetCurrentOpticMode(
int mode)
457 m_CurrentOpticMode = mode;
461 int GetCurrentOpticMode()
463 return m_CurrentOpticMode;
467 void OnOpticModeChange(){}
472 HideSelection(
"hide");
479 ShowSelection(
"hide");
485 return m_OpticsDOFProperties;
495 float GetOpticsPPBlur()
500 float GetNearPlaneValue()
502 return m_nearplane_override;
505 void Init2DPreloadType()
507 string path =
"cfgVehicles " +
GetType() +
" OpticsInfo preloadOpticType";
513 m_2D_preload_type = type_2d;
522 void UpdateSelectionVisibility() {}
524 override void SetActions()
531 override void OnDebugSpawn()
533 GetInventory().CreateAttachment(
"Battery9V");