DayZ 1.24
Loading...
Searching...
No Matches
ArrowManagerPlayer Class Reference
Inheritance diagram for ArrowManagerPlayer:
[legend]
Collaboration diagram for ArrowManagerPlayer:
[legend]

Private Member Functions

void ArrowManagerPlayer (PlayerBase player)
 
bool Save (ParamsWriteContext ctx)
 
bool Load (ParamsReadContext ctx)
 
- Private Member Functions inherited from ArrowManagerBase
void ArrowManagerBase (EntityAI owner)
 
void AddArrow (EntityAI arrow)
 
void RemoveArrow (EntityAI arrow)
 
void ClearArrows ()
 
int GetArrowsCount ()
 
void DropArrow (int index)
 
void DropFirstArrow ()
 
void DropAllArrows ()
 
EntityAI GetArrow (int index)
 
EntityAI GetFirstArrow ()
 
EntityAI AcquireFirstArrow (bool keepTransform=false)
 

Static Private Member Functions

static void InitializeHash ()
 
static void AddArrowTypeToHash (string ArrowType)
 
static GetArrowTypeFromHash (int hash)
 

Static Private Attributes

static ref map< int, typenamem_TypeHashTable
 

Additional Inherited Members

- Private Attributes inherited from ArrowManagerBase
const int VERSION = 2
 
ref array< EntityAIm_Arrows
 
EntityAI m_Owner
 

Detailed Description

Definition at line 1 of file ArrowManagerPlayer.c.

Constructor & Destructor Documentation

◆ ArrowManagerPlayer()

void ArrowManagerPlayer::ArrowManagerPlayer ( PlayerBase player)
inlineprivate

Definition at line 5 of file ArrowManagerPlayer.c.

6 {
9 }
static ref map< int, typename > m_TypeHashTable
static void InitializeHash()

References InitializeHash(), and m_TypeHashTable.

Member Function Documentation

◆ AddArrowTypeToHash()

static void ArrowManagerPlayer::AddArrowTypeToHash ( string ArrowType)
inlinestaticprivate

Definition at line 21 of file ArrowManagerPlayer.c.

22 {
23 m_TypeHashTable.Insert(ArrowType.Hash(), ArrowType.ToType());
24 }

References m_TypeHashTable.

Referenced by InitializeHash().

◆ GetArrowTypeFromHash()

static ArrowManagerPlayer::GetArrowTypeFromHash ( int hash)
inlinestaticprivate

Definition at line 26 of file ArrowManagerPlayer.c.

27 {
28 return m_TypeHashTable.Get(hash);
29 }

References m_TypeHashTable.

Referenced by Load().

◆ InitializeHash()

static void ArrowManagerPlayer::InitializeHash ( )
inlinestaticprivate

Definition at line 11 of file ArrowManagerPlayer.c.

12 {
14
15 AddArrowTypeToHash("Ammo_HuntingBolt");
16 AddArrowTypeToHash("Ammo_ImprovisedBolt_1");
17 AddArrowTypeToHash("Ammo_ImprovisedBolt_2");
18 AddArrowTypeToHash("Ammo_ImprovisedBolt_3");
19 }
static void AddArrowTypeToHash(string ArrowType)

References AddArrowTypeToHash(), and m_TypeHashTable.

Referenced by ArrowManagerPlayer().

◆ Load()

bool ArrowManagerPlayer::Load ( ParamsReadContext ctx)
inlineprivate

Definition at line 71 of file ArrowManagerPlayer.c.

72 {
73 int version;
74 if (!ctx.Read(version))
75 return false;
76
77 int count;
78 if (!ctx.Read(count))
79 return false;
80
81 for (int i = 0; i < count; i++)
82 {
83
84 if (version >= 1)
85 {
86 int hash;
87 if (!ctx.Read(hash))
88 return false;
89
90 float angleF[3];
91 float posF[3];
92 float value;
93
94 if (!ctx.Read(value))
95 return false;
96 angleF[0] = value;
97
98 if (!ctx.Read(value))
99 return false;
100 angleF[1] = value;
101
102 if (!ctx.Read(value))
103 return false;
104 angleF[2] = value;
105
106 if (!ctx.Read(value))
107 return false;
108 posF[0] = value;
109
110 if (!ctx.Read(value))
111 return false;
112 posF[1] = value;
113
114 if (!ctx.Read(value))
115 return false;
116 posF[2] = value;
117
118 vector angle = "0 0 0";
119 vector pos = "0 0 0";
120
122 pos = vector.ArrayToVec(posF);
123
124 int pivot;
125 if (!ctx.Read(pivot))
126 return false;
127
128 if (version >= 2)
129 {
130#ifdef SERVER
132#else
134#endif
135
137 EntityAI arrow = EntityAI.Cast(GetGame().CreateObjectEx(arrowType.ToString(), pos, spawnFlags));
138 if (arrow)
139 {
140 arrow.SetQuantityToMinimum();
141 arrow.SetYawPitchRoll(angle);
142 m_Owner.AddChild(arrow, pivot);
143 }
144 }
145 }
146
147 }
148
149 return true;
150 }
const int ECE_LOCAL
const int ECE_KEEPHEIGHT
const int ECE_DYNAMIC_PERSISTENCY
static GetArrowTypeFromHash(int hash)
static vector ArrayToVec(float arr[])
Convert static array of floats into a vector.
Definition EnConvert.c:503
proto native CGame GetGame()

References vector::ArrayToVec(), ECE_DYNAMIC_PERSISTENCY, ECE_KEEPHEIGHT, ECE_LOCAL, GetArrowTypeFromHash(), GetGame(), and ArrowManagerBase::m_Owner.

◆ Save()

bool ArrowManagerPlayer::Save ( ParamsWriteContext ctx)
inlineprivate

Definition at line 31 of file ArrowManagerPlayer.c.

32 {
33 ctx.Write(VERSION);
34 int count = m_Arrows.Count();
35 int i;
36 //TODO MW Delete after find why sometimes arrow missing - most likely Life span
37 for (i = count - 1; i >= 0; i--)
38 {
39 if (!m_Arrows.Get(i))
40 m_Arrows.Remove(i);
41 }
42 count = m_Arrows.Count();
43
44 ctx.Write(count);
45
46 for (i = 0; i < count; i++)
47 {
48 EntityAI arrow = m_Arrows.Get(i);
49
50 string type = arrow.GetType();
51 ctx.Write(type.Hash());
52
53 vector angle = arrow.GetLocalYawPitchRoll();
54 vector pos = arrow.GetLocalPosition();
55
56 ctx.Write(angle[0]);
57 ctx.Write(angle[1]);
58 ctx.Write(angle[2]);
59 ctx.Write(pos[0]);
60 ctx.Write(pos[1]);
61 ctx.Write(pos[2]);
62
63 int pivot = arrow.GetHierarchyPivot();
64 ctx.Write(pivot);
65 }
66
67 return true;
68 }
ref array< EntityAI > m_Arrows
proto native int Hash()
Returns hash of string.

References string::Hash(), ArrowManagerBase::m_Arrows, and ArrowManagerBase::VERSION.

Member Data Documentation

◆ m_TypeHashTable

ref map<int, typename> ArrowManagerPlayer::m_TypeHashTable
staticprivate

The documentation for this class was generated from the following file: