Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
gpsreceiver.c
Go to the documentation of this file.
1
class
GPSReceiver
: ItemGPS
2
{
3
4
protected
const
string
DISPLAY_TEXTURE_PATH_FORMAT
=
"dz\\gear\\navigation\\data\\GPS_%1_ca.paa"
;
5
protected
const
string
ANIM_PHASE_DISPLAY_HIDE
=
"DisplayState"
;
6
7
protected
const
int
PHASE_OFF
= 1;
8
protected
const
int
PHASE_ON
= 0;
9
10
protected
ref set<string>
m_DisplayGridSelections
;
11
protected
ref set<string>
m_DisplayAltSelections
;
12
protected
ref
map<int, string>
m_DisplayNumericSignTextureMap
;
13
15
protected
ref
array<int>
m_OrderedPositionNumbersLast
;
16
protected
ref
array<int>
m_AltitudeNumbersLast
;
17
18
protected
bool
m_InitGPS
;
19
20
void
GPSReceiver
()
21
{
22
m_OrderedPositionNumbersLast
=
new
array<int>
;
23
m_AltitudeNumbersLast
=
new
array<int>
;
24
25
int
i;
26
for
(i = 0; i <
MapNavigationBehaviour
.DISPLAY_GRID_POS_MAX_CHARS_COUNT * 2; ++i)
27
{
28
m_OrderedPositionNumbersLast
.Insert(0);
29
}
30
31
for
(i = 0; i <
MapNavigationBehaviour
.DISPLAY_ALT_MAX_CHARS_COUNT; ++i)
32
{
33
m_AltitudeNumbersLast
.Insert(0);
34
}
35
36
m_DisplayGridSelections
=
new
set<string>();
37
m_DisplayGridSelections
.Insert(
"grid_1_0"
);
38
m_DisplayGridSelections
.Insert(
"grid_1_1"
);
39
m_DisplayGridSelections
.Insert(
"grid_1_2"
);
40
m_DisplayGridSelections
.Insert(
"grid_2_0"
);
41
m_DisplayGridSelections
.Insert(
"grid_2_1"
);
42
m_DisplayGridSelections
.Insert(
"grid_2_2"
);
43
44
m_DisplayAltSelections
=
new
set<string>();
45
m_DisplayAltSelections
.Insert(
"alt_0"
);
46
m_DisplayAltSelections
.Insert(
"alt_1"
);
47
m_DisplayAltSelections
.Insert(
"alt_2"
);
48
m_DisplayAltSelections
.Insert(
"alt_3"
);
49
50
m_DisplayNumericSignTextureMap
=
new
map<int, string>
();
51
for
(i = -1; i < 11; i++)
52
{
53
54
string
texturePath =
string
.Format(
DISPLAY_TEXTURE_PATH_FORMAT
, i);
55
57
if
(i == -1)
58
{
59
texturePath =
string
.
Format
(
DISPLAY_TEXTURE_PATH_FORMAT
,
"dash"
);
60
}
61
62
m_DisplayNumericSignTextureMap
.Insert(i, texturePath);
63
}
64
}
65
66
protected
void
PositionalUpdate
()
67
{
68
UpdateDisplayPosition
();
69
UpdateDisplayElevation
();
70
71
if
(!
m_InitGPS
)
72
m_InitGPS
=
true
;
73
}
74
75
override
void
SetActions
()
76
{
77
super.SetActions();
78
79
AddAction
(
ActionTurnOnWhileInHands
);
80
AddAction
(
ActionTurnOffWhileInHands
);
81
}
82
83
override
bool
IsTurnedOn
()
84
{
85
return
GetCompEM() && GetCompEM().IsWorking();
86
}
87
88
override
void
OnWorkStart
()
89
{
90
UpdateDisplayState
(
PHASE_ON
);
91
92
if
(GetHierarchyRoot())
93
{
94
PlayerBase
pb =
PlayerBase
.Cast(GetHierarchyRoot());
95
if
(pb)
96
{
97
pb.MapNavigationItemInPossession(
this
);
98
}
99
}
100
}
101
102
override
void
OnWorkStop
()
103
{
104
UpdateDisplayState
(
PHASE_OFF
);
105
106
if
(GetHierarchyRoot())
107
{
108
PlayerBase
pb =
PlayerBase
.Cast(GetHierarchyRoot());
109
if
(pb)
110
{
111
pb.MapNavigationItemNotInPossession(
this
);
112
}
113
}
114
}
115
116
override
void
OnWork
(
float
consumed_energy)
117
{
118
PositionalUpdate
();
119
}
120
121
protected
void
UpdateDisplayState
(
int
animPhase)
122
{
123
ResetAnimationPhase(
ANIM_PHASE_DISPLAY_HIDE
,
PHASE_OFF
);
124
SetAnimationPhaseNow(
ANIM_PHASE_DISPLAY_HIDE
, animPhase);
125
}
126
127
protected
void
UpdateDisplayPosition
()
128
{
129
int
selectionIndex;
130
string
selectionName;
131
string
textureName;
132
array<int>
orderedPositionNumbers =
MapNavigationBehaviour
.OrderedPositionNumbersFromGridCoords(
this
);
133
134
bool
isArrayDifferent = orderedPositionNumbers.DifferentAtPosition(
m_OrderedPositionNumbersLast
) !=
INDEX_NOT_FOUND
;
135
if
(isArrayDifferent || !
m_InitGPS
)
136
{
137
for
(
int
i = 0; i <
m_DisplayGridSelections
.Count(); ++i)
138
{
139
selectionName =
m_DisplayGridSelections
.Get(i);
140
selectionIndex =
GetHiddenSelection
(selectionName);
141
textureName =
m_DisplayNumericSignTextureMap
.Get(orderedPositionNumbers.Get(i));
142
SetObjectTexture(selectionIndex, textureName);
143
}
144
145
m_OrderedPositionNumbersLast
= orderedPositionNumbers;
146
}
147
}
148
149
protected
void
UpdateDisplayElevation
()
150
{
151
int
selectionIndex;
152
string
selectionName;
153
array<int>
altitudeNumbers =
MapNavigationBehaviour
.OrderedAltitudeNumbersPosition(
this
);
154
155
bool
isArrayDifferent = altitudeNumbers.DifferentAtPosition(
m_AltitudeNumbersLast
) !=
INDEX_NOT_FOUND
;
156
if
(isArrayDifferent || !
m_InitGPS
)
157
{
158
for
(
int
i = 0; i <
m_DisplayAltSelections
.Count(); ++i)
159
{
160
selectionName =
m_DisplayAltSelections
.Get(i);
161
selectionIndex =
GetHiddenSelection
(selectionName);
162
SetObjectTexture(selectionIndex,
m_DisplayNumericSignTextureMap
.Get(altitudeNumbers.Get(i)));
163
}
164
165
m_AltitudeNumbersLast
= altitudeNumbers;
166
}
167
}
168
169
protected
int
GetHiddenSelection
(
string
selection)
170
{
171
int
idx = GetHiddenSelectionIndex(selection);
172
173
if
(idx !=
INDEX_NOT_FOUND
)
174
{
175
return
idx;
176
}
177
else
178
{
179
return
0;
180
}
181
}
182
183
//================================================================
184
// DEBUG
185
//================================================================
186
187
override
void
OnDebugSpawn
()
188
{
189
Battery9V
.Cast(GetInventory().CreateInInventory(
"Battery9V"
));
190
}
191
192
//================================================================
193
// DEPRECATED BELOW
194
//================================================================
195
[
Obsolete
(
"1.29: Use the overloaded function GPSReceiver::UpdateDisplayState instead"
)]
196
protected
void
UpdateDisplayState
(
bool
pIsTurnedOn)
197
{
198
if
(pIsTurnedOn)
199
{
200
UpdateDisplayState
(
PHASE_ON
);
201
}
202
else
203
{
204
UpdateDisplayState
(
PHASE_OFF
);
205
}
206
}
207
}
AddAction
void AddAction(typename actionName)
Definition
advancedcommunication.c:220
ActionTurnOffWhileInHands
Definition
actionturnoffwhileinhands.c:2
ActionTurnOnWhileInHands
Definition
actionturnonwhileinhands.c:2
Battery9V
Definition
battery9v.c:2
GPSReceiver::OnDebugSpawn
override void OnDebugSpawn()
Definition
gpsreceiver.c:187
GPSReceiver::PHASE_ON
const int PHASE_ON
Definition
gpsreceiver.c:8
GPSReceiver::m_DisplayAltSelections
ref set< string > m_DisplayAltSelections
Definition
gpsreceiver.c:11
GPSReceiver::ANIM_PHASE_DISPLAY_HIDE
const string ANIM_PHASE_DISPLAY_HIDE
Definition
gpsreceiver.c:5
GPSReceiver::PHASE_OFF
const int PHASE_OFF
Definition
gpsreceiver.c:7
GPSReceiver::OnWorkStop
override void OnWorkStop()
Definition
gpsreceiver.c:102
GPSReceiver::m_OrderedPositionNumbersLast
ref array< int > m_OrderedPositionNumbersLast
cache
Definition
gpsreceiver.c:15
GPSReceiver::m_AltitudeNumbersLast
ref array< int > m_AltitudeNumbersLast
Definition
gpsreceiver.c:16
GPSReceiver::IsTurnedOn
override bool IsTurnedOn()
Definition
gpsreceiver.c:83
GPSReceiver::OnWork
override void OnWork(float consumed_energy)
Definition
gpsreceiver.c:116
GPSReceiver::GetHiddenSelection
int GetHiddenSelection(string selection)
Definition
gpsreceiver.c:169
GPSReceiver::m_DisplayGridSelections
ref set< string > m_DisplayGridSelections
Definition
gpsreceiver.c:10
GPSReceiver::UpdateDisplayState
void UpdateDisplayState(bool pIsTurnedOn)
Definition
gpsreceiver.c:196
GPSReceiver::UpdateDisplayElevation
void UpdateDisplayElevation()
Definition
gpsreceiver.c:149
GPSReceiver::UpdateDisplayPosition
void UpdateDisplayPosition()
Definition
gpsreceiver.c:127
GPSReceiver::OnWorkStart
override void OnWorkStart()
Definition
gpsreceiver.c:88
GPSReceiver::GPSReceiver
void GPSReceiver()
Definition
gpsreceiver.c:20
GPSReceiver::m_DisplayNumericSignTextureMap
ref map< int, string > m_DisplayNumericSignTextureMap
Definition
gpsreceiver.c:12
GPSReceiver::m_InitGPS
bool m_InitGPS
Definition
gpsreceiver.c:18
GPSReceiver::PositionalUpdate
void PositionalUpdate()
Definition
gpsreceiver.c:66
GPSReceiver::UpdateDisplayState
void UpdateDisplayState(int animPhase)
Definition
gpsreceiver.c:121
GPSReceiver::SetActions
override void SetActions()
Definition
gpsreceiver.c:75
GPSReceiver::DISPLAY_TEXTURE_PATH_FORMAT
const string DISPLAY_TEXTURE_PATH_FORMAT
Definition
gpsreceiver.c:4
PlayerBase
Definition
playerbaseclient.c:2
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition
isboxcollidinggeometryproxyclasses.c:28
map
Definition
cachedequipmentstorage.c:4
INDEX_NOT_FOUND
const int INDEX_NOT_FOUND
Definition
gameplay.c:13
Obsolete
void Obsolete(string msg="")
Definition
enscript.c:371
string::Format
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
MapNavigationBehaviour
void MapNavigationBehaviour(PlayerBase pPlayer, EMapNavigationType pNavigationType=EMapNavigationType.BASIC)
Definition
mapnavigationbehaviour.c:27
Games
Dayz
scripts
4_world
entities
itembase
gear
navigation
gpsreceiver.c
Generated by
1.17.0