Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
shelter.c
Go to the documentation of this file.
1 class ShelterBase extends TentBase
2 {
3  static const string SITE_OBJECT_TYPE = "ShelterSite";
4 
5  void ShelterBase()
6  {
7  m_ShowAnimationsWhenPitched.Insert("Body");
8  m_ShowAnimationsWhenPacked.Insert("Body");
9 
10  m_HalfExtents = Vector(0.8, 0.15, 1.3);
11  }
12 
13  override void SetActions()
14  {
15  super.SetActions();
16 
21 
23  }
24 
25  override void EEInit()
26  {
27  super.EEInit();
28 
29  TryPitch(true, true);
30  }
31 
32  void Deconstruct()
33  {
34  StaticConstructionMethods.SpawnConstructionMaterialPiles(this, null, GetMaterialPath(), GetShelterVariant());
35  SpawnKit();
36  Delete();
37  }
38 
39  string GetMaterialPath()
40  {
41  return string.Format("%1 %2 Construction site %3 Materials", CFG_VEHICLESPATH, SITE_OBJECT_TYPE, GetShelterVariant());
42  }
43 
44  string GetShelterVariant()
45  {
46  return "";
47  }
48 
49  void SpawnKit()
50  {
51  ItemBase constructionKit = ItemBase.Cast(GetGame().CreateObjectEx("ShelterKit", GetPosition(), ECE_PLACE_ON_SURFACE));
52  constructionKit.SetHealth01("", "", GetHealth01());
53  }
54 
55  override bool IsPlayerInside(PlayerBase player, string selection)
56  {
57  vector player_pos = player.GetPosition();
58  vector shelter_pos = GetPosition();
59  vector ref_dir = GetDirection();
60  ref_dir[1] = 0;
61  ref_dir.Normalize();
62 
63  vector x[2];
64  vector b1,b2;
65  GetCollisionBox(x);
66  b1 = x[0];
67  b2 = x[1];
68 
69  vector dir_to_shelter = shelter_pos - player_pos;
70  dir_to_shelter[1] = 0;
71  float len = dir_to_shelter.Length();
72 
73  dir_to_shelter.Normalize();
74 
75  vector ref_dir_angle = ref_dir.VectorToAngles();
76  vector dir_to_shelter_angle = dir_to_shelter.VectorToAngles();
77  vector test_angles = dir_to_shelter_angle - ref_dir_angle;
78 
79  vector test_position = test_angles.AnglesToVector() * len;
80 
81  if (test_position[0] < b1[0] || test_position[0] > b2[0] || test_position[2] < 0.2 || test_position[2] > 2.2 )
82  {
83  return false;
84  }
85  else
86  {
87  return true;
88  }
89  }
90 }
91 
92 class ShelterFabric extends ShelterBase
93 {
94  override string GetShelterVariant()
95  {
96  return "fabric";
97  }
98 }
99 
100 class ShelterLeather extends ShelterBase
101 {
102  override string GetShelterVariant()
103  {
104  return "leather";
105  }
106 }
107 
108 class ShelterStick extends ShelterBase
109 {
110  override string GetShelterVariant()
111  {
112  return "stick";
113  }
114 }
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
SetActions
override void SetActions()
Definition: shelter.c:12
ShelterBase
void ShelterBase()
Definition: shelter.c:4
ActionDeployObject
PlaceObjectActionReciveData ActionReciveData ActionDeployObject()
Definition: actiondeployobject.c:9
ActionDeconstructShelter
Definition: actionpackshelter.c:1
EEInit
override void EEInit()
Definition: shelter.c:24
StaticConstructionMethods
Definition: construction.c:1220
m_HalfExtents
Container_Base m_HalfExtents
RemoveAction
void RemoveAction(typename actionName)
Definition: advancedcommunication.c:118
SpawnKit
void SpawnKit()
Definition: shelter.c:48
ECE_PLACE_ON_SURFACE
const int ECE_PLACE_ON_SURFACE
Definition: centraleconomy.c:37
ActionTogglePlaceObject
Definition: actiontoggleplaceobject.c:1
ActionPackTent
ActionPickBerryCB ActionPackTent
GetPosition
class JsonUndergroundAreaTriggerData GetPosition
Definition: undergroundarealoader.c:9
PlayerBase
Definition: playerbaseclient.c:1
vector
Definition: enconvert.c:105
ShelterBase
Definition: shelter.c:100
CFG_VEHICLESPATH
const string CFG_VEHICLESPATH
Definition: constants.c:209
AddAction
void AddAction(typename actionName)
Definition: advancedcommunication.c:86
TentBase
Definition: cartent.c:1
IsPlayerInside
override bool IsPlayerInside(PlayerBase player, string selection)
Definition: shelter.c:54
x
Icon x
GetShelterVariant
class ShelterBase extends TentBase GetShelterVariant()
Definition: shelter.c:94
GetMaterialPath
string GetMaterialPath()
Definition: shelter.c:38
Vector
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
ActionToggleTentOpen
Definition: actiontoggletentopen.c:1
Deconstruct
void Deconstruct()
Definition: shelter.c:31