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;
20 static const int PACKED = 0;
21 static const int PITCHED = 1;
22 const float MAX_PLACEMENT_HEIGHT_DIFF = 1.5;
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;
38 protected CamoNet m_CamoNet;
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");
64 DestroyClutterCutter();
72 return "disableContainerDamage";
75 override bool HasProxyParts()
81 override bool CanProxyObstructSelf()
86 override bool IsItemTent()
96 override int GetMeleeTargetType()
103 super.OnStoreSave(ctx);
106 ctx.Write(m_OpeningMask);
111 if (!super.OnStoreLoad(ctx, version))
117 if (!ctx.Read(m_OpeningMask))
118 Print(
"ERROR: no opening mask found! Default openinng settings initialized.");
133 RefreshAttachements();
146 super.RefreshPhysics();
150 TryPitch(
false,
true);
160 super.OnItemLocationChanged(old_owner, new_owner);
162 if (new_owner || old_owner)
164 if (GetInventory().CountInventory() == 1)
171 super.OnVariablesSynchronized();
189 SoundTentClosePlay();
196 SoundTentOpenWindowPlay();
200 SoundTentCloseWindowPlay();
226 if ((m_OpeningMaskLocal != m_OpeningMask))
228 HandleOpeningsPhysics();
229 m_OpeningMaskLocal = m_OpeningMask;
240 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
246 MiscGameplayFunctions.DropAllItemsInInventoryInBounds(
this,
m_HalfExtents);
248 if (zone !=
"Body" && zone !=
"Inventory" && zone !=
"")
253 DamageSystem.GetComponentNamesFromDamageZone(
this,zone,selections);
254 for (
int j = 0; j < selections.Count(); j++)
256 if (selections.Get(j) !=
"")
258 RemoveProxyPhysics(selections.Get(j));
260 AnimateCamonetByOpeningSelection(selections.Get(j));
274 void HideAllAnimationsAndProxyPhysics(
bool hide_animations =
true,
bool hide_physics =
true)
276 string cfg_path =
"cfgVehicles " +
GetType() +
" AnimationSources";
278 if (
GetGame().ConfigIsExisting(cfg_path))
280 int selections =
GetGame().ConfigGetChildrenCount(cfg_path);
281 string proxy_selection_name;
283 for (
int i = 0; i < selections; i++)
285 string selection_name;
286 GetGame().ConfigGetChildName(cfg_path, i, selection_name);
289 SetAnimationPhase(selection_name, 1);
292 proxy_selection_name = selection_name;
293 proxy_selection_name.ToLower();
296 RemoveProxyPhysics(proxy_selection_name);
302 bool ConditionIntoInventory(
EntityAI player)
304 return CanBeManipulated();
309 if (!super.CanPutIntoHands(parent))
314 return CanBeManipulated();
319 if (!super.CanPutInCargo(parent))
324 return CanBeManipulated();
327 bool ConditionOutOfHands(
EntityAI player)
329 return CanBeManipulated();
332 override bool CanBeRepairedToPristine()
337 void RefreshAttachements()
344 m_CamoNet = CamoNet.Cast(GetInventory().FindAttachment(slot_id_camo));
347 eai_xlights = GetInventory().FindAttachment(slot_id_xlights);
351 HandleCamoNetAttachment(
false);
354 if (!IsKindOf(
"MediumTent"))
356 AddProxyPhysics(
"camonet");
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);
372 super.EEItemAttached(item, slot_name);
374 if (item.IsKindOf (
"CamoNet"))
376 m_CamoNet = CamoNet.Cast(item);
377 HandleCamoNetAttachment(
false);
380 if (!IsKindOf (
"MediumTent"))
382 AddProxyPhysics(
"camonet");
386 if (item.IsKindOf (
"XmasLights"))
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);
394 XmasLights xlights = XmasLights.Cast(item);
395 xlights.AttachToObject(
this);
401 super.EEItemDetached(item, slot_name);
403 if (item.IsKindOf (
"CamoNet"))
406 HandleCamoNetAttachment(
true);
409 if (!IsKindOf (
"MediumTent"))
411 RemoveProxyPhysics(
"camonet");
415 if (item.IsKindOf (
"XmasLights"))
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);
423 XmasLights xlights = XmasLights.Cast(item);
424 xlights.DetachFromObject(
this);
428 override int GetViewIndex()
430 if (MemoryPointExists(
"invView2"))
433 GetInventory().GetCurrentInventoryLocation(il);
476 if (GetInventory().GetCargo().GetItemCount() == 0 && GetInventory().AttachmentCount() == 0)
485 bool CanBeManipulated()
499 if (item.IsKindOf (
"CamoNet") &&
GetState() == PITCHED)
512 void Pack(
bool update_navmesh,
bool init =
false)
514 HideAllAnimationsAndProxyPhysics();
517 m_IsEntrance = PACKED;
523 GetInventory().LockInventory(HIDE_INV_FROM_SCRIPT);
530 DestroyClutterCutter();
533 MiscGameplayFunctions.DropAllItemsInInventoryInBounds(
this,
m_HalfExtents);
539 GetOnViewIndexChanged().Invoke();
543 void Pitch(
bool update_navmesh,
bool init =
false)
545 HideAllAnimationsAndProxyPhysics();
548 m_IsEntrance = PITCHED;
549 m_IsWindow = PITCHED;
550 m_IsToggle = PITCHED;
554 GetInventory().UnlockInventory(HIDE_INV_FROM_SCRIPT);
565 GetOnViewIndexChanged().Invoke();
569 protected void TryPitch(
bool update_navmesh,
bool init =
false)
571 if (GetHierarchyRootPlayer())
573 if (
GetGame().IsDedicatedServer())
575 Pack(update_navmesh,
init);
581 Pitch(update_navmesh,
init);
586 string proxy_selection_name;
587 string animation_name;
591 for (
int i = 0; i < m_ShowAnimationsWhenPitched.Count(); i++)
593 animation_name = m_ShowAnimationsWhenPitched.Get(i);
595 SetAnimationPhase(animation_name, 0);
598 HandleOpeningsVisuals();
602 for (
int j = 0; j < m_ShowAnimationsWhenPacked.Count(); j++)
604 animation_name = m_ShowAnimationsWhenPacked.Get(j);
606 SetAnimationPhase(animation_name, 0);
613 string proxy_selection_name;
614 string animation_name;
618 for (
int i = 0; i < m_ShowAnimationsWhenPitched.Count(); i++)
620 animation_name = m_ShowAnimationsWhenPitched.Get(i);
622 proxy_selection_name = animation_name;
623 proxy_selection_name.ToLower();
624 AddProxyPhysics(proxy_selection_name);
631 for (
int j = 0; j < m_ShowAnimationsWhenPacked.Count(); j++)
633 animation_name = m_ShowAnimationsWhenPacked.Get(j);
635 proxy_selection_name = animation_name;
636 proxy_selection_name.ToLower();
637 AddProxyPhysics(proxy_selection_name);
649 bool CanToggleAnimations(
string selection)
651 for (
int i = 0; i < m_ToggleAnimations.Count(); i++)
654 string toggle_off = toggle.GetToggleOff();
655 toggle_off.ToLower();
656 string toggle_on = toggle.GetToggleOn();
659 if (toggle_off == selection || toggle_on == selection)
662 DamageSystem.GetDamageZoneFromComponentName(
this,selection,zone);
672 m_IsEntrance =
false;
677 void ManipulateEntrance()
682 void ManipulateWindow()
687 bool IsManipulatedEntrance()
692 bool IsManipulatedWindow()
698 void ToggleAnimation(
string selection)
708 for (
int i = 0; i < m_ToggleAnimations.Count(); i++)
712 string toggle_off = toggle.GetToggleOff();
713 toggle_off.ToLower();
714 string toggle_on = toggle.GetToggleOn();
717 if (toggle_off == selection || toggle_on == selection)
719 is_closed = m_OpeningMask & toggle.GetOpeningBit();
722 SetAnimationPhase(toggle.GetToggleOff(), 0);
723 AddProxyPhysics(toggle.GetToggleOff());
724 SetAnimationPhase(toggle.GetToggleOn(), 1);
725 RemoveProxyPhysics(toggle.GetToggleOn());
726 m_ToggleAnimations.Set(toggle,
false);
728 m_OpeningMask &= ~toggle.GetOpeningBit();
730 if (selection.Contains(
"window"))
735 if (selection.Contains(
"entrance") || selection.Contains(
"door"))
737 ManipulateEntrance();
740 AnimateCamonetToggle(toggle);
744 SetAnimationPhase(toggle.GetToggleOff(), 1);
745 RemoveProxyPhysics(toggle.GetToggleOff());
746 SetAnimationPhase(toggle.GetToggleOn(), 0);
747 AddProxyPhysics(toggle.GetToggleOn());
748 m_ToggleAnimations.Set(toggle,
true);
750 m_OpeningMask |= toggle.GetOpeningBit();
752 if (selection.Contains(
"window"))
757 if (selection.Contains(
"entrance") || selection.Contains(
"door"))
759 ManipulateEntrance();
762 AnimateCamonetToggle(toggle);
770 void HandleCamoNetAttachment(
bool hide)
772 SetAnimationPhase(
"CamoNet", hide);
777 void AnimateCamonetByOpeningSelection(
string opening_selection) {};
779 string GetSoundOpen() {};
781 string GetSoundClose() {};
783 string GetSoundOpenWindow() {};
785 string GetSoundCloseWindow() {};
787 void SoundTentOpenPlay()
790 sound.SetAutodestroy(
true);
793 void SoundTentClosePlay()
796 sound.SetAutodestroy(
true);
799 void SoundTentOpenWindowPlay()
802 sound.SetAutodestroy(
true);
805 void SoundTentCloseWindowPlay()
808 sound.SetAutodestroy(
true);
811 void RegenerateNavmesh()
813 SetAffectPathgraph(
true,
false);
818 bool HasClutterCutter() {};
819 string GetClutterCutter() {};
821 void DestroyClutterCutter()
836 override bool IsDeployable()
841 override void OnPlacementComplete(Man player,
vector position =
"0 0 0",
vector orientation =
"0 0 0")
843 super.OnPlacementComplete(player, position, orientation);
855 if (!
GetGame().IsDedicatedServer())
866 if (!
GetGame().IsDedicatedServer())
873 override void SetActions()
883 void HandleOpeningsVisuals()
891 for (
int i = 0; i < m_ToggleAnimations.Count(); i++)
893 toggle = m_ToggleAnimations.GetKey(i);
894 is_closed = m_OpeningMask & toggle.GetOpeningBit();
897 DamageSystem.GetDamageZoneFromComponentName(
this,
component,zone);
902 SetAnimationPhase(toggle.GetToggleOff(),1);
903 SetAnimationPhase(toggle.GetToggleOn(),is_ruined);
904 m_ToggleAnimations.Set(toggle,
false);
908 SetAnimationPhase(toggle.GetToggleOn(),1);
909 SetAnimationPhase(toggle.GetToggleOff(),is_ruined);
910 m_ToggleAnimations.Set(toggle,
true);
916 void HandleOpeningsPhysics()
925 for (
int i = 0; i < m_ToggleAnimations.Count(); i++)
927 toggle = m_ToggleAnimations.GetKey(i);
928 is_closed = m_OpeningMask & toggle.GetOpeningBit();
931 DamageSystem.GetDamageZoneFromComponentName(
this,
component,zone);
932 is_ruined = (GetHealthLevel(zone) ==
GameConstants.STATE_RUINED);
935 RemoveProxyPhysics(toggle.GetToggleOff());
936 RemoveProxyPhysics(toggle.GetToggleOn());
938 if (!is_ruined &&
GetState() == PITCHED)
942 AddProxyPhysics(toggle.GetToggleOn());
946 AddProxyPhysics(toggle.GetToggleOff());
959 if (GetHealthLevel() ==
GameConstants.STATE_RUINED || m_IsBeingPacked)
962 return super.CanReceiveItemIntoCargo(item);
967 if (!super.CanLoadItemIntoCargo(item))
980 return super.CanReceiveAttachment(attachment, slotId);
988 return super.CanLoadAttachment(attachment);
993 vector playerpos = player.GetPosition();
994 float delta1 = playerpos[1] - position[1];
996 if (delta1 > MAX_PLACEMENT_HEIGHT_DIFF || delta1 < -MAX_PLACEMENT_HEIGHT_DIFF)
1001 void SetIsBeingPacked(
bool isBeingPacked)
1003 m_IsBeingPacked = isBeingPacked;