Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
tentbase.c
Go to the documentation of this file.
1 class TentBase extends ItemBase
2 {
3  const int OPENING_0 = 1;
4  const int OPENING_1 = 2;
5  const int OPENING_2 = 4;
6  const int OPENING_3 = 8;
7  const int OPENING_4 = 16;
8  const int OPENING_5 = 32;
9  const int OPENING_6 = 64;
10  const int OPENING_7 = 128;
11  const int OPENING_8 = 256;
12  const int OPENING_9 = 512;
13  const int OPENING_10 = 1024;
14  const int OPENING_11 = 2048;
15  const int OPENING_12 = 4096;
16  const int OPENING_13 = 8192;
17  const int OPENING_14 = 16384;
18  const int OPENING_15 = 32768;
19 
20  static const int PACKED = 0;
21  static const int PITCHED = 1;
22  const float MAX_PLACEMENT_HEIGHT_DIFF = 1.5;
23 
24  protected int m_State;
25  protected int m_StateLocal = -1;
26  protected bool m_IsEntrance;
27  protected bool m_IsWindow;
28  protected bool m_IsToggle;
29  protected bool m_IsBeingPacked = false;
30  protected int m_OpeningMask = 0;
31  protected int m_OpeningMaskLocal = -1;
32 
33  protected ref map< ref ToggleAnimations, bool> m_ToggleAnimations;
34  protected ref array<string> m_ShowAnimationsWhenPitched;
35  protected ref array<string> m_ShowAnimationsWhenPacked;
36  protected Object m_ClutterCutter;
37  ref protected EffectSound m_DeployLoopSound;
38  protected CamoNet m_CamoNet;
39  protected vector m_HalfExtents; // The Y value contains a heightoffset and not the halfextent !!!
40 
41  void TentBase()
42  {
43  m_ToggleAnimations = new map<ref ToggleAnimations, bool>;
44  m_ShowAnimationsWhenPitched = new array<string>;
45  m_ShowAnimationsWhenPacked = new array<string>;
46 
47  m_HalfExtents = vector.Zero;
48  RegisterNetSyncVariableInt("m_State");
49  RegisterNetSyncVariableBool("m_IsSoundSynchRemote");
50  RegisterNetSyncVariableBool("m_IsEntrance");
51  RegisterNetSyncVariableBool("m_IsWindow");
52  RegisterNetSyncVariableBool("m_IsToggle");
53  RegisterNetSyncVariableBool("m_IsDeploySound");
54  RegisterNetSyncVariableInt("m_OpeningMask");
55  RegisterNetSyncVariableBool("m_IsBeingPacked");
56 
57  ProcessInvulnerabilityCheck(GetInvulnerabilityTypeString());
58  }
59 
60  void ~TentBase()
61  {
62  if (GetGame())
63  {
64  DestroyClutterCutter();
65  }
66 
67  SEffectManager.DestroyEffect(m_DeployLoopSound);
68  }
69 
70  override string GetInvulnerabilityTypeString()
71  {
72  return "disableContainerDamage";
73  }
74 
75  override bool HasProxyParts()
76  {
77  return true;
78  }
79 
81  override bool CanProxyObstructSelf()
82  {
83  return true;
84  }
85 
86  override bool IsItemTent()
87  {
88  return true;
89  }
90 
91  override bool CanBeRepairedByCrafting()
92  {
93  return false;
94  }
95 
96  override int GetMeleeTargetType()
97  {
98  return EMeleeTargetType.NONALIGNABLE;
99  }
100 
101  override void OnStoreSave(ParamsWriteContext ctx)
102  {
103  super.OnStoreSave(ctx);
104 
105  ctx.Write(m_State);
106  ctx.Write(m_OpeningMask);
107  }
108 
109  override bool OnStoreLoad(ParamsReadContext ctx, int version)
110  {
111  if (!super.OnStoreLoad(ctx, version))
112  return false;
113 
114  ctx.Read(m_State);
115  if (version >= 110)
116  {
117  if (!ctx.Read(m_OpeningMask))
118  Print("ERROR: no opening mask found! Default openinng settings initialized.");
119  }
120 
121  if (m_State == PITCHED)
122  {
123  TryPitch(true);
124 
125  if (GetGame().IsServer())
126  {
127  if (!m_ClutterCutter && HasClutterCutter())
128  {
129  m_ClutterCutter = GetGame().CreateObjectEx(GetClutterCutter(), GetPosition(), ECE_PLACE_ON_SURFACE);
130  m_ClutterCutter.SetOrientation(GetOrientation());
131  }
132 
133  RefreshAttachements();
134  }
135  }
136  else
137  {
138  Pack(true);
139  }
140 
141  return true;
142  }
143 
144  override void RefreshPhysics()
145  {
146  super.RefreshPhysics();
147 
148  if (m_State == PITCHED)
149  {
150  TryPitch(false, true);
151  }
152  else
153  {
154  Pack(false, true);
155  }
156  }
157 
158  override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
159  {
160  super.OnItemLocationChanged(old_owner, new_owner);
161 
162  if (new_owner || old_owner)
163  {
164  if (GetInventory().CountInventory() == 1) // refuse to pack tent with anything inside
165  Pack(false);
166  }
167  }
168 
169  override void OnVariablesSynchronized()
170  {
171  super.OnVariablesSynchronized();
172 
173  if (IsDeploySound())
174  {
175  PlayDeploySound();
176  }
177  else
178  {
179  if (m_State == PITCHED)
180  {
181  if (IsManipulatedEntrance() && IsSoundSynchRemote())
182  {
183  if (m_IsToggle)
184  {
185  SoundTentOpenPlay();
186  }
187  else
188  {
189  SoundTentClosePlay();
190  }
191  }
192  else if (IsManipulatedWindow() && IsSoundSynchRemote())
193  {
194  if (m_IsToggle)
195  {
196  SoundTentOpenWindowPlay();
197  }
198  else
199  {
200  SoundTentCloseWindowPlay();
201  }
202  }
203  }
204  }
205 
207  {
209  }
210 
212  {
214  }
215 
216  if (m_State != m_StateLocal)
217  {
218  if (m_State == PACKED)
219  Pack(false);
220  else
221  TryPitch(false);
222 
223  m_StateLocal = m_State;
224  }
225 
226  if ((m_OpeningMaskLocal != m_OpeningMask)) //opening synchronization for physics recalculation
227  {
228  HandleOpeningsPhysics();
229  m_OpeningMaskLocal = m_OpeningMask;
230 
231  if (m_State == PACKED)
232  {
233  Pack(false); //intentional
234  }
235  }
236  }
237 
238  override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
239  {
240  super.EEHealthLevelChanged(oldLevel,newLevel,zone);
241 
243  return;
244 
245  if (zone == "" && GetState() == PITCHED && newLevel == GameConstants.STATE_RUINED && GetGame().IsServer())
246  MiscGameplayFunctions.DropAllItemsInInventoryInBounds(this, m_HalfExtents);
247 
248  if (zone != "Body" && zone != "Inventory" && zone != "")
249  {
250  if (newLevel == GameConstants.STATE_RUINED)
251  {
252  array<string> selections = new array<string>;
253  DamageSystem.GetComponentNamesFromDamageZone(this,zone,selections);
254  for (int j = 0; j < selections.Count(); j++)
255  {
256  if (selections.Get(j) != "")
257  {
258  RemoveProxyPhysics(selections.Get(j)); //To keep
259  //HideSelection(selections.Get(j)); //To change
260  AnimateCamonetByOpeningSelection(selections.Get(j)); //To keep
261  }
262  }
263  }
264  else if (oldLevel == GameConstants.STATE_RUINED)
265  {
266  if (GetState() == PITCHED)
267  {
268  TryPitch(true);
269  }
270  }
271  }
272  }
273 
274  void HideAllAnimationsAndProxyPhysics(bool hide_animations = true, bool hide_physics = true)
275  {
276  string cfg_path = "cfgVehicles " + GetType() + " AnimationSources";
277 
278  if (GetGame().ConfigIsExisting(cfg_path))
279  {
280  int selections = GetGame().ConfigGetChildrenCount(cfg_path);
281  string proxy_selection_name;
282 
283  for (int i = 0; i < selections; i++)
284  {
285  string selection_name;
286  GetGame().ConfigGetChildName(cfg_path, i, selection_name);
287  if (hide_animations)
288  {
289  SetAnimationPhase(selection_name, 1);
290  }
291 
292  proxy_selection_name = selection_name;
293  proxy_selection_name.ToLower();
294  if (hide_physics)
295  {
296  RemoveProxyPhysics(proxy_selection_name);
297  }
298  }
299  }
300  }
301 
302  bool ConditionIntoInventory(EntityAI player)
303  {
304  return CanBeManipulated();
305  }
306 
307  override bool CanPutIntoHands(EntityAI parent)
308  {
309  if (!super.CanPutIntoHands(parent))
310  {
311  return false;
312  }
313 
314  return CanBeManipulated();
315  }
316 
317  override bool CanPutInCargo(EntityAI parent)
318  {
319  if (!super.CanPutInCargo(parent))
320  {
321  return false;
322  }
323 
324  return CanBeManipulated();
325  }
326 
327  bool ConditionOutOfHands(EntityAI player)
328  {
329  return CanBeManipulated();
330  }
331 
332  override bool CanBeRepairedToPristine()
333  {
334  return true;
335  }
336 
337  void RefreshAttachements()
338  {
339  int slot_id_camo;
340  int slot_id_xlights;
341  EntityAI eai_xlights;
342 
343  slot_id_camo = InventorySlots.GetSlotIdFromString("CamoNet");
344  m_CamoNet = CamoNet.Cast(GetInventory().FindAttachment(slot_id_camo));
345 
346  slot_id_xlights = InventorySlots.GetSlotIdFromString("Lights");
347  eai_xlights = GetInventory().FindAttachment(slot_id_xlights);
348 
349  if (m_CamoNet)
350  {
351  HandleCamoNetAttachment(false);
352  //SetAnimationPhase("Camonet", 0);
353 
354  if (!IsKindOf("MediumTent"))
355  {
356  AddProxyPhysics("camonet");
357  }
358  }
359 
360  if (eai_xlights)
361  {
362  SetAnimationPhase("Xlights", 0);
363  SetAnimationPhase("Xlights_glass_r", 0);
364  SetAnimationPhase("Xlights_glass_g", 0);
365  SetAnimationPhase("Xlights_glass_b", 0);
366  SetAnimationPhase("Xlights_glass_y", 0);
367  }
368  }
369 
370  override void EEItemAttached(EntityAI item, string slot_name)
371  {
372  super.EEItemAttached(item, slot_name);
373 
374  if (item.IsKindOf ("CamoNet"))
375  {
376  m_CamoNet = CamoNet.Cast(item);
377  HandleCamoNetAttachment(false);
378  //SetAnimationPhase("Camonet", 0);
379 
380  if (!IsKindOf ("MediumTent"))
381  {
382  AddProxyPhysics("camonet");
383  }
384  }
385 
386  if (item.IsKindOf ("XmasLights"))
387  {
388  SetAnimationPhase("Xlights", 0);
389  SetAnimationPhase("Xlights_glass_r", 0);
390  SetAnimationPhase("Xlights_glass_g", 0);
391  SetAnimationPhase("Xlights_glass_b", 0);
392  SetAnimationPhase("Xlights_glass_y", 0);
393 
394  XmasLights xlights = XmasLights.Cast(item);
395  xlights.AttachToObject(this);
396  }
397  }
398 
399  override void EEItemDetached(EntityAI item, string slot_name)
400  {
401  super.EEItemDetached(item, slot_name);
402 
403  if (item.IsKindOf ("CamoNet"))
404  {
405  m_CamoNet = null;
406  HandleCamoNetAttachment(true);
407  //SetAnimationPhase("Camonet", 1);
408 
409  if (!IsKindOf ("MediumTent"))
410  {
411  RemoveProxyPhysics("camonet");
412  }
413  }
414 
415  if (item.IsKindOf ("XmasLights"))
416  {
417  SetAnimationPhase("Xlights", 1);
418  SetAnimationPhase("Xlights_glass_r", 1);
419  SetAnimationPhase("Xlights_glass_g", 1);
420  SetAnimationPhase("Xlights_glass_b", 1);
421  SetAnimationPhase("Xlights_glass_y", 1);
422 
423  XmasLights xlights = XmasLights.Cast(item);
424  xlights.DetachFromObject(this);
425  }
426  }
427 
428  override int GetViewIndex()
429  {
430  if (MemoryPointExists("invView2"))
431  {
433  GetInventory().GetCurrentInventoryLocation(il);
434  InventoryLocationType type = il.GetType();
435 
436  if (GetState() == PACKED)
437  {
438  switch (type)
439  {
440  case InventoryLocationType.ATTACHMENT:
441  return 1;
442  default:
443  return 0;
444  }
445  }
446  else
447  {
448  switch (type)
449  {
450  case InventoryLocationType.ATTACHMENT:
451  case InventoryLocationType.GROUND:
452  return 1;
453  default:
454  return 0;
455  }
456  }
457  }
458 
459  return 0;
460  }
461 
462  int GetState()
463  {
464  return m_State;
465  }
466 
467  int GetStateLocal()
468  {
469  return m_StateLocal;
470  }
471 
472  bool CanBePacked()
473  {
474  if (GetState() == PITCHED)
475  {
476  if (GetInventory().GetCargo().GetItemCount() == 0 && GetInventory().AttachmentCount() == 0)
477  {
478  return true;
479  }
480  }
481 
482  return false;
483  }
484 
485  bool CanBeManipulated()
486  {
487  if (GetState() == PACKED)
488  {
489  return true;
490  }
491  else
492  {
493  return false;
494  }
495  }
496 
497  bool CanAttach(ItemBase item)
498  {
499  if (item.IsKindOf ("CamoNet") && GetState() == PITCHED)
500  {
501  return true;
502  }
503 
504  return false;
505  }
506 
507  override bool IsIgnoredByConstruction()
508  {
509  return false;
510  }
511 
512  void Pack(bool update_navmesh, bool init = false)
513  {
514  HideAllAnimationsAndProxyPhysics();
515 
516  m_State = PACKED;
517  m_IsEntrance = PACKED;
518  m_IsWindow = PACKED;
519  m_IsToggle = PACKED;
520 
521  Refresh();
522 
523  GetInventory().LockInventory(HIDE_INV_FROM_SCRIPT);
524 
525  if (update_navmesh)
526  {
527  RegenerateNavmesh();
528  }
529 
530  DestroyClutterCutter();
531 
532  if (GetGame().IsServer() && !IsHologram())
533  MiscGameplayFunctions.DropAllItemsInInventoryInBounds(this, m_HalfExtents);
534 
535  SetSynchDirty();
536 
537  if ((!GetGame().IsDedicatedServer()) && !init)
538  {
539  GetOnViewIndexChanged().Invoke();
540  }
541  }
542 
543  void Pitch(bool update_navmesh, bool init = false)
544  {
545  HideAllAnimationsAndProxyPhysics();
546 
547  m_State = PITCHED;
548  m_IsEntrance = PITCHED;
549  m_IsWindow = PITCHED;
550  m_IsToggle = PITCHED;
551 
552  Refresh();
553 
554  GetInventory().UnlockInventory(HIDE_INV_FROM_SCRIPT);
555 
556  if (update_navmesh)
557  {
558  RegenerateNavmesh();
559  }
560 
561  SetSynchDirty();
562 
563  if ((!GetGame().IsDedicatedServer()) && !init)
564  {
565  GetOnViewIndexChanged().Invoke();
566  }
567  }
568 
569  protected void TryPitch(bool update_navmesh, bool init = false)
570  {
571  if (GetHierarchyRootPlayer())
572  {
573  if (GetGame().IsDedicatedServer())
574  {
575  Pack(update_navmesh,init);
576  }
577 
578  return;
579  }
580 
581  Pitch(update_navmesh,init);
582  }
583 
584  void UpdateVisuals()
585  {
586  string proxy_selection_name;
587  string animation_name;
588 
589  if (GetState() == PITCHED)
590  {
591  for (int i = 0; i < m_ShowAnimationsWhenPitched.Count(); i++)
592  {
593  animation_name = m_ShowAnimationsWhenPitched.Get(i);
594 
595  SetAnimationPhase(animation_name, 0);
596  }
597 
598  HandleOpeningsVisuals();
599  }
600  else
601  {
602  for (int j = 0; j < m_ShowAnimationsWhenPacked.Count(); j++)
603  {
604  animation_name = m_ShowAnimationsWhenPacked.Get(j);
605 
606  SetAnimationPhase(animation_name, 0);
607  }
608  }
609  }
610 
611  void UpdatePhysics()
612  {
613  string proxy_selection_name;
614  string animation_name;
615 
616  if (GetState() == PITCHED)
617  {
618  for (int i = 0; i < m_ShowAnimationsWhenPitched.Count(); i++)
619  {
620  animation_name = m_ShowAnimationsWhenPitched.Get(i);
621 
622  proxy_selection_name = animation_name;
623  proxy_selection_name.ToLower();
624  AddProxyPhysics(proxy_selection_name);
625  }
626 
627  GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Call(HandleOpeningsPhysics);
628  }
629  else
630  {
631  for (int j = 0; j < m_ShowAnimationsWhenPacked.Count(); j++)
632  {
633  animation_name = m_ShowAnimationsWhenPacked.Get(j);
634 
635  proxy_selection_name = animation_name;
636  proxy_selection_name.ToLower();
637  AddProxyPhysics(proxy_selection_name);
638  }
639  }
640  }
641 
642  //refresh visual/physics state
643  void Refresh()
644  {
645  GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).Call(UpdateVisuals);
646  UpdatePhysics();
647  }
648 
649  bool CanToggleAnimations(string selection)
650  {
651  for (int i = 0; i < m_ToggleAnimations.Count(); i++)
652  {
653  ToggleAnimations toggle = m_ToggleAnimations.GetKey(i);
654  string toggle_off = toggle.GetToggleOff();
655  toggle_off.ToLower();
656  string toggle_on = toggle.GetToggleOn();
657  toggle_on.ToLower();
658 
659  if (toggle_off == selection || toggle_on == selection)
660  {
661  string zone;
662  DamageSystem.GetDamageZoneFromComponentName(this,selection,zone);
663  return GetHealthLevel(zone) < GameConstants.STATE_RUINED;
664  }
665  }
666 
667  return false;
668  }
669 
670  void ResetToggle()
671  {
672  m_IsEntrance = false;
673  m_IsWindow = false;
674  m_IsToggle = false;
675  }
676 
677  void ManipulateEntrance()
678  {
679  m_IsEntrance = true;
680  }
681 
682  void ManipulateWindow()
683  {
684  m_IsWindow = true;
685  }
686 
687  bool IsManipulatedEntrance()
688  {
689  return m_IsEntrance;
690  }
691 
692  bool IsManipulatedWindow()
693  {
694  return m_IsWindow;
695  }
696 
697  //used by user action
698  void ToggleAnimation(string selection)
699  {
700  if (m_State == PACKED)
701  {
702  return;
703  }
704 
705  bool is_closed;
706  ResetToggle();
707 
708  for (int i = 0; i < m_ToggleAnimations.Count(); i++)
709  {
710  ToggleAnimations toggle = m_ToggleAnimations.GetKey(i);
711 
712  string toggle_off = toggle.GetToggleOff();
713  toggle_off.ToLower();
714  string toggle_on = toggle.GetToggleOn();
715  toggle_on.ToLower();
716 
717  if (toggle_off == selection || toggle_on == selection)
718  {
719  is_closed = m_OpeningMask & toggle.GetOpeningBit();
720  if (is_closed)
721  {
722  SetAnimationPhase(toggle.GetToggleOff(), 0);
723  AddProxyPhysics(toggle.GetToggleOff());
724  SetAnimationPhase(toggle.GetToggleOn(), 1);
725  RemoveProxyPhysics(toggle.GetToggleOn());
726  m_ToggleAnimations.Set(toggle, false);
727  m_IsToggle = true;
728  m_OpeningMask &= ~toggle.GetOpeningBit();
729 
730  if (selection.Contains("window"))
731  {
732  ManipulateWindow();
733  }
734 
735  if (selection.Contains("entrance") || selection.Contains("door"))
736  {
737  ManipulateEntrance();
738  }
739 
740  AnimateCamonetToggle(toggle);
741  }
742  else
743  {
744  SetAnimationPhase(toggle.GetToggleOff(), 1);
745  RemoveProxyPhysics(toggle.GetToggleOff());
746  SetAnimationPhase(toggle.GetToggleOn(), 0);
747  AddProxyPhysics(toggle.GetToggleOn());
748  m_ToggleAnimations.Set(toggle, true);
749  m_IsToggle = false;
750  m_OpeningMask |= toggle.GetOpeningBit();
751 
752  if (selection.Contains("window"))
753  {
754  ManipulateWindow();
755  }
756 
757  if (selection.Contains("entrance") || selection.Contains("door"))
758  {
759  ManipulateEntrance();
760  }
761 
762  AnimateCamonetToggle(toggle);
763  }
764  }
765  }
766  SetSynchDirty();
768  }
769 
770  void HandleCamoNetAttachment(bool hide)
771  {
772  SetAnimationPhase("CamoNet", hide);
773  }
774 
775  void AnimateCamonetToggle(ToggleAnimations toggle) {};
776 
777  void AnimateCamonetByOpeningSelection(string opening_selection) {};
778 
779  string GetSoundOpen() {};
780 
781  string GetSoundClose() {};
782 
783  string GetSoundOpenWindow() {};
784 
785  string GetSoundCloseWindow() {};
786 
787  void SoundTentOpenPlay()
788  {
789  EffectSound sound = SEffectManager.PlaySound(GetSoundOpen(), GetPosition());
790  sound.SetAutodestroy(true);
791  }
792 
793  void SoundTentClosePlay()
794  {
795  EffectSound sound = SEffectManager.PlaySound(GetSoundClose(), GetPosition());
796  sound.SetAutodestroy(true);
797  }
798 
799  void SoundTentOpenWindowPlay()
800  {
801  EffectSound sound = SEffectManager.PlaySound(GetSoundOpenWindow(), GetPosition());
802  sound.SetAutodestroy(true);
803  }
804 
805  void SoundTentCloseWindowPlay()
806  {
807  EffectSound sound = SEffectManager.PlaySound(GetSoundCloseWindow(), GetPosition());
808  sound.SetAutodestroy(true);
809  }
810 
811  void RegenerateNavmesh()
812  {
813  SetAffectPathgraph(true, false);
814 
815  GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(GetGame().UpdatePathgraphRegionByObject, 100, false, this);
816  }
817 
818  bool HasClutterCutter() {};
819  string GetClutterCutter() {};
820 
821  void DestroyClutterCutter()
822  {
823  if (GetGame().IsMultiplayer() || GetGame().IsServer())
824  {
825  if (m_ClutterCutter)
826  {
827  GetGame().ObjectDelete(m_ClutterCutter);
828  }
829  }
830  }
831 
832  //================================================================
833  // ADVANCED PLACEMENT
834  //================================================================
835 
836  override bool IsDeployable()
837  {
838  return true;
839  }
840 
841  override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
842  {
843  super.OnPlacementComplete(player, position, orientation);
844 
845  if (GetGame().IsServer())
846  {
847  TryPitch(true);
848 
849  SetIsDeploySound(true);
850  }
851  }
852 
853  void PlayDeployLoopSound()
854  {
855  if (!GetGame().IsDedicatedServer())
856  {
857  if (!m_DeployLoopSound || !m_DeployLoopSound.IsSoundPlaying())
858  {
859  m_DeployLoopSound = SEffectManager.PlaySound(GetLoopDeploySoundset(), GetPosition());
860  }
861  }
862  }
863 
864  void StopDeployLoopSound()
865  {
866  if (!GetGame().IsDedicatedServer())
867  {
868  m_DeployLoopSound.SetSoundFadeOut(0.5);
869  m_DeployLoopSound.SoundStop();
870  }
871  }
872 
873  override void SetActions()
874  {
875  super.SetActions();
876 
881  }
882 
883  void HandleOpeningsVisuals()
884  {
885  bool is_closed;
886  bool is_ruined;
887  string zone;
888  string component;
889  ToggleAnimations toggle;
890 
891  for (int i = 0; i < m_ToggleAnimations.Count(); i++)
892  {
893  toggle = m_ToggleAnimations.GetKey(i);
894  is_closed = m_OpeningMask & toggle.GetOpeningBit();
895  component = toggle.GetToggleOff(); //either one works
896  component.ToLower();
897  DamageSystem.GetDamageZoneFromComponentName(this,component,zone);
898  //is_ruined = (GetHealthLevel(zone) == GameConstants.STATE_RUINED);
899 
900  if (is_closed)
901  {
902  SetAnimationPhase(toggle.GetToggleOff(),1);
903  SetAnimationPhase(toggle.GetToggleOn(),is_ruined);
904  m_ToggleAnimations.Set(toggle, false);
905  }
906  else
907  {
908  SetAnimationPhase(toggle.GetToggleOn(),1);
909  SetAnimationPhase(toggle.GetToggleOff(),is_ruined);
910  m_ToggleAnimations.Set(toggle, true);
911  }
912  //AnimateCamonetToggle(toggle);
913  }
914  }
915 
916  void HandleOpeningsPhysics()
917  {
918  bool is_closed;
919  bool is_ruined;
920  int hplevel;
921  string zone;
922  string component;
923  ToggleAnimations toggle;
924 
925  for (int i = 0; i < m_ToggleAnimations.Count(); i++)
926  {
927  toggle = m_ToggleAnimations.GetKey(i);
928  is_closed = m_OpeningMask & toggle.GetOpeningBit();
929  component = toggle.GetToggleOff(); //either one works
930  component.ToLower();
931  DamageSystem.GetDamageZoneFromComponentName(this,component,zone);
932  is_ruined = (GetHealthLevel(zone) == GameConstants.STATE_RUINED);
933 
934  //re-adding physics to avoid proxy physics stacking
935  RemoveProxyPhysics(toggle.GetToggleOff());
936  RemoveProxyPhysics(toggle.GetToggleOn());
937 
938  if (!is_ruined && GetState() == PITCHED)
939  {
940  if (is_closed)
941  {
942  AddProxyPhysics(toggle.GetToggleOn());
943  }
944  else
945  {
946  AddProxyPhysics(toggle.GetToggleOff());
947  }
948  }
949  }
950  }
951 
952  override int GetDamageSystemVersionChange()
953  {
954  return 110;
955  }
956 
957  override bool CanReceiveItemIntoCargo(EntityAI item)
958  {
959  if (GetHealthLevel() == GameConstants.STATE_RUINED || m_IsBeingPacked)
960  return false;
961 
962  return super.CanReceiveItemIntoCargo(item);
963  }
964 
965  override bool CanLoadItemIntoCargo(EntityAI item)
966  {
967  if (!super.CanLoadItemIntoCargo(item))
968  return false;
969  if (GetHealthLevel() == GameConstants.STATE_RUINED)
970  return false;
971 
972  return true;
973  }
974 
975  override bool CanReceiveAttachment(EntityAI attachment, int slotId)
976  {
977  if (GetHealthLevel() == GameConstants.STATE_RUINED)
978  return false;
979 
980  return super.CanReceiveAttachment(attachment, slotId);
981  }
982 
983  override bool CanLoadAttachment(EntityAI attachment)
984  {
985  if (GetHealthLevel() == GameConstants.STATE_RUINED)
986  return false;
987 
988  return super.CanLoadAttachment(attachment);
989  }
990 
991  override bool CanBePlaced(Man player, vector position)
992  {
993  vector playerpos = player.GetPosition();
994  float delta1 = playerpos[1] - position[1];
995 
996  if (delta1 > MAX_PLACEMENT_HEIGHT_DIFF || delta1 < -MAX_PLACEMENT_HEIGHT_DIFF)
997  return false;
998  return true;
999  }
1000 
1001  void SetIsBeingPacked(bool isBeingPacked)
1002  {
1003  m_IsBeingPacked = isBeingPacked;
1004  SetSynchDirty();
1005  }
1006 };
ItemBase
Definition: inventoryitem.c:730
UpdatePhysics
void UpdatePhysics()
Definition: construction.c:207
GetGame
proto native CGame GetGame()
CALL_CATEGORY_SYSTEM
const int CALL_CATEGORY_SYSTEM
Definition: tools.c:8
ActionDeployObject
PlaceObjectActionReciveData ActionReciveData ActionDeployObject()
Definition: actiondeployobject.c:9
CALL_CATEGORY_GAMEPLAY
const int CALL_CATEGORY_GAMEPLAY
Definition: tools.c:10
GetState
proto native int GetState()
returns one of STATE_...
Definition: staminahandler.c:29
InventorySlots
provides access to slot configuration
Definition: inventoryslots.c:5
CanBeRepairedByCrafting
bool CanBeRepairedByCrafting()
Definition: itembase.c:923
CanReceiveItemIntoCargo
override bool CanReceiveItemIntoCargo(EntityAI item)
Definition: container_base.c:72
m_HalfExtents
Container_Base m_HalfExtents
SetIsDeploySound
void SetIsDeploySound(bool is_deploy_sound)
Definition: itembase.c:4293
Print
proto void Print(void var)
Prints content of variable to console/log.
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
OnVariablesSynchronized
override void OnVariablesSynchronized()
Definition: anniversarymusicsource.c:42
ECE_PLACE_ON_SURFACE
const int ECE_PLACE_ON_SURFACE
Definition: centraleconomy.c:37
PlayDeploySound
void PlayDeploySound()
Definition: itembase.c:4324
component
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
PlayDeployLoopSound
void PlayDeployLoopSound()
Refresh
void Refresh()
Definition: sizetochild.c:108
RefreshPhysics
void RefreshPhysics()
ActionTogglePlaceObject
Definition: actiontoggleplaceobject.c:1
IsDeploySound
bool IsDeploySound()
Definition: itembase.c:4298
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
ActionPackTent
ActionPickBerryCB ActionPackTent
GetPosition
class JsonUndergroundAreaTriggerData GetPosition
Definition: undergroundarealoader.c:9
EffectSound
Wrapper class for managing sound through SEffectManager.
Definition: effectsound.c:4
CanPutIntoHands
override bool CanPutIntoHands(EntityAI parent)
Definition: explosivesbase.c:257
map
map
Definition: controlsxboxnew.c:3
vector
Definition: enconvert.c:105
CanPutInCargo
override bool CanPutInCargo(EntityAI parent)
Definition: explosivesbase.c:247
GetDamageSystemVersionChange
override int GetDamageSystemVersionChange()
Definition: basebuildingbase.c:1146
m_ClutterCutter
protected Object m_ClutterCutter
Definition: fireplacebase.c:211
InventoryLocationType
InventoryLocationType
types of Inventory Location
Definition: inventorylocation.c:3
AddAction
void AddAction(typename actionName)
Definition: advancedcommunication.c:86
Object
Definition: objecttyped.c:1
CanBePlaced
override bool CanBePlaced(Man player, vector position)
Definition: trapbase.c:605
TentBase
Definition: cartent.c:1
UpdateVisuals
void UpdateVisuals()
Definition: construction.c:188
array< string >
m_FixDamageSystemInit
bool m_FixDamageSystemInit
Definition: itembase.c:61
m_DeployLoopSound
protected ref EffectSound m_DeployLoopSound
Definition: trapbase.c:47
init
enum MagnumStableStateID init
ToggleAnimations
Definition: toggleselections.c:1
OnStoreSave
void OnStoreSave(ParamsWriteContext ctx)
Definition: modifierbase.c:229
GetInvulnerabilityTypeString
override string GetInvulnerabilityTypeString()
Definition: basebuildingbase.c:77
EEHealthLevelChanged
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Definition: basebuildingbase.c:463
IsHologram
override bool IsHologram()
Definition: itembase.c:962
StopDeployLoopSound
void StopDeployLoopSound()
GameConstants
Definition: constants.c:612
CanPlayDeployLoopSound
bool CanPlayDeployLoopSound()
Definition: itembase.c:4360
CanLoadAttachment
override bool CanLoadAttachment(EntityAI attachment)
Definition: container_base.c:64
EEItemAttached
override void EEItemAttached(EntityAI item, string slot_name)
Definition: basebuildingbase.c:520
CanLoadItemIntoCargo
override bool CanLoadItemIntoCargo(EntityAI item)
Definition: container_base.c:80
SEffectManager
Manager class for managing Effect (EffectParticle, EffectSound)
Definition: effectmanager.c:5
CanReceiveAttachment
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Definition: basebuildingbase.c:895
EEItemDetached
override void EEItemDetached(EntityAI item, string slot_name)
Definition: basebuildingbase.c:529
OnStoreLoad
bool OnStoreLoad(ParamsReadContext ctx, int version)
Definition: modifiersmanager.c:270
EntityAI
Definition: building.c:5
GetType
override int GetType()
Definition: huddebugwincharagents.c:49
IsIgnoredByConstruction
override bool IsIgnoredByConstruction()
Definition: dayzanimal.c:65
m_State
protected float m_DrainThreshold protected bool m_State
Definition: staminahandler.c:20
ActionToggleTentOpen
Definition: actiontoggletentopen.c:1
IsSoundSynchRemote
bool IsSoundSynchRemote()
Definition: itembase.c:4273
SoundSynchRemote
void SoundSynchRemote()
Definition: itembase.c:4266
EMeleeTargetType
EMeleeTargetType
Definition: emeleetargettype.c:1
GetOrientation
vector GetOrientation()
Definition: areadamagemanager.c:306