Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionviewbinoculars.c
Go to the documentation of this file.
2 {
3  bool m_workingRangefinder;
4 
5  override void OnActionInfoUpdate( PlayerBase player, ActionTarget target, ItemBase item )
6  {
7  Rangefinder rangefinder = Rangefinder.Cast(item);
8  if ( rangefinder )
9  {
10  m_Text = "#use_range_finder";
11  }
12  else
13  {
14  m_Text = "#Look_Through";
15  }
16  }
17 
18  override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
19  {
20  ItemOptics optic;
21  if( Class.CastTo(optic, item) && !optic.IsInOptics() && !player.IsNVGLowered() )
22  {
23  return true;
24  }
25  return false;
26  }
27 
28  override void EnterOptics(ItemOptics optic, PlayerBase player)
29  {
30  player.SetIronsights(false);
31  player.SetHandheldOpticsInUse(true);
32  player.SetOptics(true);
33  optic.EnterOptics();
34  optic.HideSelection("hide");
35  if ( NVGoggles.Cast(optic) && optic.ConfigIsExisting("simpleHiddenSelections") )
36  {
37  optic.SetSimpleHiddenSelectionState(0,false);
38  }
39 
40  if ( optic.HasEnergyManager() )
41  {
42  PoweredOptic_Base rf = PoweredOptic_Base.Cast(optic);
43  if (!rf)
44  return;
45 
46  rf.SetPlayer( player );
47  if ( GetGame().IsServer() )
48  rf.GetCompEM().SwitchOn();
49  }
50  }
51 
52  override void ExitOptics(ItemOptics optic, PlayerBase player)
53  {
54  optic.ShowSelection("hide");
55  if ( NVGoggles.Cast(optic) && optic.ConfigIsExisting("simpleHiddenSelections") )
56  {
57  optic.SetSimpleHiddenSelectionState(0,true);
58  }
59  player.SetHandheldOpticsInUse(false);
60  player.ExitSights();
61  if ( optic.HasEnergyManager() )
62  {
63  PoweredOptic_Base rf = PoweredOptic_Base.Cast(optic);
64  if (!rf)
65  return;
66 
67  rf.SetPlayer( null );
68  if ( GetGame().IsServer() )
69  rf.GetCompEM().SwitchOff();
70  }
71  }
72 }
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
PlayerBase
Definition: playerbaseclient.c:1
ActionTarget
class ActionTargets ActionTarget
ActionViewOptics
Definition: actionviewoptics.c:1
m_Text
protected string m_Text
Definition: actionbase.c:49
ItemOptics
Definition: itemoptics.c:1
PoweredOptic_Base
Definition: nvgoggles.c:1
ActionViewBinoculars
Definition: actionviewbinoculars.c:1
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10