3 private bool m_IsFolded;
4 private bool m_EvaluateDeployment;
7 static vector m_LightLocalPosition;
8 static vector m_LightLocalOrientation =
"0 0 0";
11 static const string SEL_REFLECTOR_COMP_U =
"reflector";
12 static const string SEL_CORD_FOLDED_U =
"cord_folded";
13 static const string SEL_CORD_PLUGGED_U =
"cord_plugged";
14 static const string SEL_CORD_PLUGGED_F =
"spotlight_folded_cord_plugged";
15 static const string SEL_CORD_FOLDED_F =
"spotlight_folded_cord_folded";
17 static const string SEL_INVENTORY =
"inventory";
18 static const string SEL_PLACING =
"placing";
19 static const string SEL_GLASS_F =
"glass_folded";
20 static const string SEL_GLASS_U =
"glass_unfolded";
21 static const string SEL_REFLECTOR_F =
"reflector_folded";
22 static const string SEL_REFLECTOR_U =
"reflector_unfolded";
24 static const int ID_GLASS_UNFOLDED = 3;
25 static const int ID_REFLECTOR_UNFOLDED = 4;
26 static const int ID_GLASS_FOLDED = 5;
27 static const int ID_REFLECTOR_FOLDED = 6;
29 static string LIGHT_OFF_GLASS =
"dz\\gear\\camping\\Data\\spotlight_glass.rvmat";
30 static string LIGHT_OFF_REFLECTOR =
"dz\\gear\\camping\\Data\\spotlight.rvmat";
31 static string LIGHT_ON_GLASS =
"dz\\gear\\camping\\Data\\spotlight_glass_on.rvmat";
32 static string LIGHT_ON_REFLECTOR =
"dz\\gear\\camping\\Data\\spotlight_glass_on.rvmat";
35 const string SOUND_TURN_ON =
"spotlight_turn_on_SoundSet";
36 const string SOUND_TURN_OFF =
"spotlight_turn_off_SoundSet";
45 m_EvaluateDeployment =
false;
47 RegisterNetSyncVariableBool(
"m_IsSoundSynchRemote");
48 RegisterNetSyncVariableBool(
"m_IsDeploySound");
49 RegisterNetSyncVariableBool(
"m_IsFolded");
58 override bool IsElectricAppliance()
63 override void OnInitEnergy()
65 if (GetCompEM().IsPlugged())
67 if (!GetHierarchyRoot())
75 UpdateAllSelections();
82 UpdateAllSelections();
83 HideSelection(SEL_CORD_FOLDED_F);
92 override void OnSwitchOn()
99 override void OnSwitchOff()
116 m_Light.AttachOnObject(
this, m_LightLocalPosition, m_LightLocalOrientation);
119 UpdateAllSelections();
129 UpdateAllSelections();
135 super.OnItemLocationChanged(old_owner, new_owner);
140 m_EvaluateDeployment =
false;
143 m_Light.AttachOnObject(
this, m_LightLocalPosition, m_LightLocalOrientation);
153 if (player && player.GetItemInHands() ==
this)
155 Fold(GetCompEM().IsPlugged());
159 override void OnIsPlugged(
EntityAI source_device)
162 UpdateAllSelections();
165 protected void UpdateAllSelections()
167 bool isPlugged = GetCompEM().IsPlugged();
169 bool isInHands = player && player.GetItemInHands() ==
this;
172 m_LightLocalPosition = GetSelectionPositionLS(
"beamStart");
174 if (IsFolded() || isInHands)
176 HideSelection(SEL_REFLECTOR_COMP_U);
178 ShowSelection(SEL_INVENTORY);
179 ShowSelection(SEL_GLASS_F);
180 ShowSelection(SEL_REFLECTOR_F);
184 ShowSelection(SEL_CORD_PLUGGED_F);
188 ShowSelection(SEL_CORD_FOLDED_F);
193 if (GetCompEM().IsWorking())
195 SetObjectMaterial(ID_GLASS_UNFOLDED, LIGHT_ON_GLASS);
196 SetObjectMaterial(ID_REFLECTOR_UNFOLDED, LIGHT_ON_REFLECTOR);
197 SetObjectMaterial(ID_GLASS_FOLDED, LIGHT_ON_GLASS);
198 SetObjectMaterial(ID_REFLECTOR_FOLDED, LIGHT_ON_REFLECTOR);
202 SetObjectMaterial(ID_GLASS_UNFOLDED, LIGHT_OFF_GLASS);
203 SetObjectMaterial(ID_REFLECTOR_UNFOLDED, LIGHT_OFF_REFLECTOR);
204 SetObjectMaterial(ID_GLASS_FOLDED, LIGHT_OFF_GLASS);
205 SetObjectMaterial(ID_REFLECTOR_FOLDED, LIGHT_OFF_REFLECTOR);
211 ShowSelection(SEL_PLACING);
212 ShowSelection(SEL_REFLECTOR_U);
213 ShowSelection(SEL_GLASS_U);
214 ShowSelection(SEL_REFLECTOR_COMP_U);
218 ShowSelection(SEL_CORD_PLUGGED_U);
222 ShowSelection(SEL_CORD_FOLDED_U);
227 if (GetCompEM().IsWorking())
229 SetObjectMaterial(ID_GLASS_UNFOLDED, LIGHT_ON_GLASS);
230 SetObjectMaterial(ID_REFLECTOR_UNFOLDED, LIGHT_ON_REFLECTOR);
234 SetObjectMaterial(ID_GLASS_UNFOLDED, LIGHT_OFF_GLASS);
235 SetObjectMaterial(ID_REFLECTOR_UNFOLDED, LIGHT_OFF_REFLECTOR);
241 override void OnIsUnplugged(
EntityAI last_energy_source)
244 UpdateAllSelections();
249 super.OnVariablesSynchronized();
267 void Fold(
bool keep_connected =
false)
272 GetCompEM().SwitchOff();
273 GetCompEM().UnplugThis();
276 UpdateAllSelections();
283 UpdateAllSelections();
289 super.OnStoreSave(ctx);
292 ctx.Write(m_IsFolded);
297 if (!super.OnStoreLoad(ctx, version))
301 bool b_is_folded =
false;
302 if (!ctx.Read(b_is_folded))
319 if (!super.CanPutInCargo(parent))
322 return !GetCompEM().IsPlugged();
327 if (!super.CanPutIntoHands(parent))
343 protected void SoundTurnOn()
345 PlaySoundSet(m_SoundTurnOn, SOUND_TURN_ON, 0, 0);
348 protected void SoundTurnOff()
350 PlaySoundSet(m_SoundTurnOff, SOUND_TURN_OFF, 0, 0);
358 super.OnPlacementStarted(player);
366 foreach (
string selection : selections)
369 playerPB.GetHologramServer().SetSelectionToRefresh(selection);
371 playerPB.GetHologramLocal().SetSelectionToRefresh(selection);
377 super.OnPlacementComplete(player, position, orientation);
385 m_EvaluateDeployment =
true;
390 super.OnPlacementCancelled(player);
402 return "placeSpotlight_SoundSet";
407 return "spotlight_deploy_SoundSet";
421 if (!
GetGame().IsDedicatedServer())
428 override int GetViewIndex()
430 if (MemoryPointExists(
"invView2") && !m_IsFolded)