Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_WristwatchComponent.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
2 [EntityEditorProps(category: "GameScripted/Gadgets", description: "Wristwatch gadget")]
4 {
5  [Attribute("0", UIWidgets.ComboBox, "Set wristwatch type", "", ParamEnumArray.FromEnum(EWristwatchType), category: "Wristwatch")]
6  int m_iWristwatchType;
7 
8  [Attribute("{6ECDF523E1035A0F}Prefabs/Items/Equipment/Watches/Watch_SandY184A_Map.et", desc: "Wristwatch prefab used for display within 2D map", category: "Wristwatch")]
9  ResourceName m_sMapResource;
10 
11  bool m_bSignalInit = false;
12  int m_iSignalHour = -1;
13  int m_iSignalMinute = -1;
14  int m_iSignalSecond = -1;
15  int m_iSignalDay = -1;
16 
17  //------------------------------------------------------------------------------------------------
19  void InitSignals(IEntity owner)
20  {
21  SignalsManagerComponent signalMgr = SignalsManagerComponent.Cast( owner.FindComponent( SignalsManagerComponent ) );
22  if (!signalMgr)
23  return;
24 
25  // cache signals
26  m_iSignalHour = signalMgr.FindSignal("Hour");
27  m_iSignalMinute = signalMgr.FindSignal("Minute");
28  m_iSignalSecond = signalMgr.FindSignal("Second");
29 
30  if (m_iWristwatchType == EWristwatchType.VOSTOK)
31  m_iSignalDay = signalMgr.FindSignal("Day");
32 
33  if (m_iSignalHour != -1 && m_iSignalMinute != -1 && m_iSignalSecond != -1)
34  m_bSignalInit = true;
35  }
36 }
37 
38 //------------------------------------------------------------------------------------------------
40 enum EWristwatchType
41 {
42  SandY184A, // US
43  VOSTOK // Soviet
44 }
45 
46 //------------------------------------------------------------------------------------------------
47 class SCR_WristwatchComponent : SCR_GadgetComponent
48 {
49  protected int m_iSeconds;
50  protected int m_iMinutes;
51  protected int m_iHours;
52  protected int m_iDay;
53 
55  protected SignalsManagerComponent m_SignalManager;
56  protected TimeAndWeatherManagerEntity m_TimeMgr;
57 
58  //------------------------------------------------------------------------------------------------
61  ResourceName GetMapPrefabResource()
62  {
63  return m_PrefabData.m_sMapResource;
64  }
65 
66  //------------------------------------------------------------------------------------------------
68  void UpdateTime()
69  {
70  if (!m_TimeMgr)
71  {
72  ChimeraWorld world = ChimeraWorld.CastFrom(GetGame().GetWorld());
73  if (world)
74  m_TimeMgr = world.GetTimeAndWeatherManager();
75 
76  return;
77  }
78 
79  m_TimeMgr.GetHoursMinutesSeconds(m_iHours, m_iMinutes, m_iSeconds);
80  if (m_iHours >= 12)
81  m_iHours -= 12;
82 
83  m_iHours *= 10;
84  m_iHours += (m_iMinutes/6);
85 
86  m_SignalManager.SetSignalValue(m_PrefabData.m_iSignalHour, m_iHours);
87  m_SignalManager.SetSignalValue(m_PrefabData.m_iSignalMinute, m_iMinutes);
88  m_SignalManager.SetSignalValue(m_PrefabData.m_iSignalSecond, m_iSeconds);
89 
90  m_iDay = m_TimeMgr.GetDay();
91 
92  m_SignalManager.SetSignalValue(m_PrefabData.m_iSignalDay, m_iDay);
93  }
94 
95  //------------------------------------------------------------------------------------------------
97  protected void UpdateWristwatchState()
98  {
99  if (System.IsConsoleApp())
100  return;
101 
102  if (m_bActivated)
104  else
106 
107  if (!m_PrefabData.m_bSignalInit)
108  m_PrefabData.InitSignals(GetOwner());
109  }
110 
111  //------------------------------------------------------------------------------------------------
113  void SetMapMode()
114  {
115  m_iMode = EGadgetMode.IN_HAND;
116  m_bActivated = true;
118 
119  ChimeraWorld world = ChimeraWorld.CastFrom(GetGame().GetWorld());
120  if (world)
121  m_TimeMgr = world.GetTimeAndWeatherManager();
122 
123  m_PrefabData.InitSignals(GetOwner());
124  }
125 
126  //------------------------------------------------------------------------------------------------
127  override void ModeSwitch(EGadgetMode mode, IEntity charOwner)
128  {
129  super.ModeSwitch(mode, charOwner);
130 
131  if (mode == EGadgetMode.IN_HAND)
132  {
133  m_bActivated = true;
135  }
136  }
137 
138  //------------------------------------------------------------------------------------------------
139  override void ModeClear(EGadgetMode mode)
140  {
141  if (mode == EGadgetMode.IN_HAND)
142  {
143  m_bActivated = false;
145  }
146 
147  super.ModeClear(mode);
148  }
149 
150  //------------------------------------------------------------------------------------------------
151  override void ActivateGadgetUpdate()
152  {
153  super.ActivateGadgetUpdate();
154 
155  InventoryItemComponent itemComponent = InventoryItemComponent.Cast(GetOwner().FindComponent(InventoryItemComponent));
156  if (itemComponent)
157  itemComponent.ActivateOwner(true); // required for the procedural animations to function
158  }
159 
160  //------------------------------------------------------------------------------------------------
161  override void DeactivateGadgetUpdate()
162  {
163  super.DeactivateGadgetUpdate();
164 
165  InventoryItemComponent itemComponent = InventoryItemComponent.Cast(GetOwner().FindComponent(InventoryItemComponent));
166  if (itemComponent)
167  itemComponent.ActivateOwner(false);
168  }
169 
170  //------------------------------------------------------------------------------------------------
171  override EGadgetType GetType()
172  {
173  return EGadgetType.WRISTWATCH;
174  }
175 
176  //------------------------------------------------------------------------------------------------
177  override bool CanBeRaised()
178  {
179  return true;
180  }
181 
182  //------------------------------------------------------------------------------------------------
183  override bool IsUsingADSControls()
184  {
185  return true;
186  }
187 
188  //------------------------------------------------------------------------------------------------
189  override void OnPostInit(IEntity owner)
190  {
191  super.OnPostInit(owner);
192 
193  m_PrefabData = SCR_WristwatchComponentClass.Cast( GetComponentData(owner) );
194  m_SignalManager = SignalsManagerComponent.Cast( owner.FindComponent( SignalsManagerComponent ) );
195 
197  }
198 
199  //------------------------------------------------------------------------------------------------
200  override void Update(float timeSlice)
201  {
202  UpdateTime();
203  }
204 }
ChimeraWorld
Definition: ChimeraWorld.c:12
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
m_iHours
protected int m_iHours
Definition: SCR_WristwatchComponent.c:51
ModeClear
override void ModeClear(EGadgetMode mode)
Definition: SCR_WristwatchComponent.c:139
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
IsUsingADSControls
override bool IsUsingADSControls()
Definition: SCR_WristwatchComponent.c:183
SCR_GadgetComponentClass
Definition: SCR_GadgetComponent.c:2
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
CanBeRaised
override bool CanBeRaised()
Definition: SCR_WristwatchComponent.c:177
m_TimeMgr
protected TimeAndWeatherManagerEntity m_TimeMgr
Definition: SCR_WristwatchComponent.c:56
DeactivateGadgetUpdate
override void DeactivateGadgetUpdate()
Definition: SCR_WristwatchComponent.c:161
m_SignalManager
protected SignalsManagerComponent m_SignalManager
Definition: SCR_WristwatchComponent.c:55
SCR_WristwatchComponentClass
Definition: SCR_WristwatchComponent.c:3
Attribute
typedef Attribute
Post-process effect of scripted camera.
ActivateGadgetUpdate
override void ActivateGadgetUpdate()
Definition: SCR_WristwatchComponent.c:151
m_iDay
protected int m_iDay
Definition: SCR_WristwatchComponent.c:52
m_iSeconds
SCR_WristwatchComponentClass m_iSeconds
OnPostInit
override void OnPostInit(IEntity owner)
Called on PostInit when all components are added.
Definition: SCR_WristwatchComponent.c:189
GetType
override EGadgetType GetType()
Definition: SCR_WristwatchComponent.c:171
UpdateTime
void UpdateTime()
Definition: SCR_WristwatchComponent.c:68
Update
override void Update(float timeSlice)
Definition: SCR_WristwatchComponent.c:200
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
SetMapMode
void SetMapMode()
Activate in a map UI mode.
Definition: SCR_WristwatchComponent.c:113
InventoryItemComponent
Definition: InventoryItemComponent.c:12
m_iMinutes
protected int m_iMinutes
Definition: SCR_WristwatchComponent.c:50
ModeSwitch
override void ModeSwitch(EGadgetMode mode, IEntity charOwner)
Definition: SCR_WristwatchComponent.c:127
UpdateWristwatchState
protected void UpdateWristwatchState()
Update state of wristwatch -> active/inactive.
Definition: SCR_WristwatchComponent.c:97
SandY184A
SCR_WristwatchComponentClass SandY184A
Wristwatch type.
GetMapPrefabResource
ResourceName GetMapPrefabResource()
Definition: SCR_WristwatchComponent.c:61
m_PrefabData
protected SCR_WristwatchComponentClass m_PrefabData
Definition: SCR_WristwatchComponent.c:54
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180