Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_SpawnPointRequestUIComponent.c
Go to the documentation of this file.
1
class
SCR_SpawnPointRequestUIComponent
:
SCR_DeployRequestUIBaseComponent
2
{
3
[
Attribute
(
"Selector"
)]
4
protected
string
m_sSpawnPointSelector
;
5
protected
Widget
m_wSpawnPointSelector
;
6
7
protected
RplId
m_SelectedSpawnPointId
=
RplId
.Invalid();
8
protected
SCR_SpawnPointSpinBox
m_SpawnPointSelector
;
9
10
protected
ref
ScriptInvoker<RplId>
m_OnSpawnPointSelected
;
11
static
ref
ScriptInvoker<RplId>
s_OnSpawnPointSelected
;
12
13
//------------------------------------------------------------------------------------------------
14
override
void
HandlerAttached
(
Widget
w)
15
{
16
m_wSpawnPointSelector
= w.FindAnyWidget(
m_sSpawnPointSelector
);
17
if
(
m_wSpawnPointSelector
)
18
m_SpawnPointSelector
=
SCR_SpawnPointSpinBox
.Cast(
m_wSpawnPointSelector
.FindHandler(
SCR_SpawnPointSpinBox
));
19
20
if
(!
m_SpawnPointSelector
)
21
return
;
22
23
m_SpawnPointSelector
.m_OnChanged.Insert(
SelectSpawnPoint
);
24
SCR_SpawnPoint
.Event_SpawnPointFactionAssigned.Insert(
OnSpawnPointFactionChange
);
25
SCR_SpawnPoint
.Event_SpawnPointAdded.Insert(
OnSpawnPointAdded
);
26
SCR_SpawnPoint
.Event_SpawnPointRemoved.Insert(
RemoveSpawnPoint
);
27
SCR_SpawnPoint
.
OnSpawnPointNameChanged
.Insert(
UpdateSpawnPointName
);
28
}
29
30
override
void
HandlerDeattached
(
Widget
w)
31
{
32
if
(
m_SpawnPointSelector
)
33
m_SpawnPointSelector
.m_OnChanged.Remove(
SelectSpawnPoint
);
34
35
SCR_SpawnPoint
.Event_SpawnPointFactionAssigned.Remove(
OnSpawnPointFactionChange
);
36
SCR_SpawnPoint
.Event_SpawnPointAdded.Remove(
OnSpawnPointAdded
);
37
SCR_SpawnPoint
.Event_SpawnPointRemoved.Remove(
RemoveSpawnPoint
);
38
SCR_SpawnPoint
.
OnSpawnPointNameChanged
.Remove(
UpdateSpawnPointName
);
39
}
40
41
protected
void
SelectSpawnPoint
(
SCR_SpawnPointSpinBox
spinbox,
int
itemId)
42
{
43
if
(spinbox.
IsEmpty
())
44
return
;
45
46
if
(spinbox.
GetSpawnPointId
(itemId) !=
m_SelectedSpawnPointId
)
47
{
48
m_SelectedSpawnPointId
= spinbox.
GetSpawnPointId
(itemId);
49
GetOnSpawnPointSelected
().Invoke(
m_SelectedSpawnPointId
);
50
SGetOnSpawnPointSelected
().Invoke(
m_SelectedSpawnPointId
);
51
}
52
}
53
54
protected
void
SetSpawnPoint
(
RplId
spawnPointId)
55
{
56
m_SelectedSpawnPointId
= spawnPointId;
57
GetOnSpawnPointSelected
().Invoke(spawnPointId);
58
}
59
60
void
CycleSpawnPoints
(
bool
next =
true
)
// false for previous spawn
61
{
62
int
currentIndex =
m_SpawnPointSelector
.GetCurrentIndex();
63
int
nextIndex = currentIndex + 1;
64
if
(!next)
65
nextIndex = currentIndex - 1;
66
67
int
itemCount =
m_SpawnPointSelector
.m_aElementNames.Count();
68
if
(nextIndex >= itemCount)
69
nextIndex = 0;
70
else
if
(nextIndex < 0)
71
nextIndex = itemCount - 1;
72
73
m_SpawnPointSelector
.SetCurrentItem(nextIndex);
74
}
75
76
protected
void
AddSpawnPoint
(
SCR_SpawnPoint
spawnPoint)
77
{
78
if
(spawnPoint && spawnPoint.
IsSpawnPointVisibleForPlayer
(
SCR_PlayerController
.
GetLocalPlayerId
()))
79
{
80
RplId
currentSpawnPointId =
m_SelectedSpawnPointId
;
81
string
name = spawnPoint.GetSpawnPointName();
82
m_SpawnPointSelector
.AddItem(name, spawnPoint.
GetRplId
());
83
84
if
(spawnPoint.
GetRplId
() != currentSpawnPointId)
85
{
86
int
itemId =
m_SpawnPointSelector
.GetItemId(currentSpawnPointId);
87
if
(itemId > -1)
88
m_SpawnPointSelector
.SetCurrentItem(itemId);
// make sure currently selected spawn point stays selected after new point is added
89
}
90
}
91
}
92
93
protected
void
RemoveSpawnPoint
(
SCR_SpawnPoint
spawnPoint)
94
{
95
RplId
currentSpawnPointId =
m_SelectedSpawnPointId
;
96
int
itemId =
m_SpawnPointSelector
.GetItemId(spawnPoint.
GetRplId
());
97
if
(itemId == -1)
98
return
;
99
100
m_SpawnPointSelector
.RemoveItem(itemId);
101
102
if
(spawnPoint.
GetRplId
() != currentSpawnPointId)
103
{
104
itemId =
m_SpawnPointSelector
.GetItemId(currentSpawnPointId);
105
m_SpawnPointSelector
.SetCurrentItem(itemId);
106
m_SelectedSpawnPointId
=
GetCurrentRplId
();
107
}
108
}
109
110
protected
void
UpdateSpawnPointName
(
RplId
id
,
string
name)
111
{
112
int
itemId =
m_SpawnPointSelector
.GetItemId(
id
);
113
m_SpawnPointSelector
.SetItemName(itemId, name);
114
}
115
116
protected
void
OnSpawnPointAdded
(
SCR_SpawnPoint
spawnPoint)
117
{
118
Faction
playerFaction =
SCR_FactionManager
.SGetLocalPlayerFaction();
119
if
(playerFaction && playerFaction.GetFactionKey() == spawnPoint.
GetFactionKey
())
120
AddSpawnPoint
(spawnPoint);
121
}
122
123
protected
void
OnSpawnPointFactionChange
(
SCR_SpawnPoint
spawnPoint)
124
{
125
Faction
playerFaction =
SCR_FactionManager
.SGetLocalPlayerFaction();
126
if
(playerFaction && playerFaction.GetFactionKey() == spawnPoint.
GetFactionKey
())
127
AddSpawnPoint
(spawnPoint);
128
else
129
RemoveSpawnPoint
(spawnPoint);
130
}
131
132
protected
void
ClearSpawnPoints
()
133
{
134
m_SpawnPointSelector
.ClearAll();
135
// todo@lk: show warning
136
}
137
138
void
ShowAvailableSpawnPoints
(
Faction
faction)
139
{
140
if
(!faction)
141
return
;
142
143
ClearSpawnPoints
();
144
145
array<SCR_SpawnPoint> infos =
SCR_SpawnPoint
.GetSpawnPointsForFaction(faction.GetFactionKey());
146
if
(infos.IsEmpty())
147
{
148
SetSpawnPoint
(
RplId
.Invalid());
149
return
;
150
}
151
152
infos.Sort(
true
);
153
154
int
pid =
SCR_PlayerController
.
GetLocalPlayerId
();
155
foreach
(
SCR_SpawnPoint
info : infos)
156
{
157
if
(info.IsSpawnPointVisibleForPlayer(pid))
158
AddSpawnPoint
(info);
159
}
160
161
SetLastUsedSpawnPointSelected
();
162
SetRallyPointSpawnSelected
();
163
}
164
165
//------------------------------------------------------------------------------------------------
168
protected
void
SetLastUsedSpawnPointSelected
()
169
{
170
PlayerController pc =
GetGame
().GetPlayerController();
171
if
(!pc)
172
return
;
173
174
SCR_PlayerDeployMenuHandlerComponent menuHandler = SCR_PlayerDeployMenuHandlerComponent.Cast(pc.FindComponent(SCR_PlayerDeployMenuHandlerComponent));
175
if
(!menuHandler)
176
return
;
177
178
int
lastUsedSpawnPointRplId = menuHandler.GetLastUsedSpawnPointId();
179
180
if
(!
SCR_SpawnPoint
.
GetSpawnPointByRplId
(lastUsedSpawnPointRplId))
181
return
;
182
183
int
lastUsedSpawnPointId =
m_SpawnPointSelector
.GetItemId(lastUsedSpawnPointRplId);
184
if
(lastUsedSpawnPointId <= 0)
185
return
;
186
187
m_SpawnPointSelector
.SetCurrentItem(lastUsedSpawnPointId);
188
}
189
190
//------------------------------------------------------------------------------------------------
192
protected
void
SetRallyPointSpawnSelected
()
193
{
194
PlayerController pc =
GetGame
().GetPlayerController();
195
if
(!pc)
196
return
;
197
198
SCR_PlayerControllerGroupComponent playerControllerGroupComponent = SCR_PlayerControllerGroupComponent.GetPlayerControllerComponent(pc.GetPlayerId());
199
if
(!playerControllerGroupComponent)
200
return
;
201
202
int
playerGroupId = playerControllerGroupComponent.GetGroupID();
203
SCR_AIGroup
playerGroup =
SCR_GroupsManagerComponent
.GetInstance().FindGroup(playerGroupId);
204
if
(!playerGroup)
205
return
;
206
207
int
rallyPointBaseCallsignId = playerGroup.
GetRallyPointId
();
208
if
(rallyPointBaseCallsignId < 0)
209
return
;
210
211
array<SCR_SpawnPoint> spawnPoints =
m_SpawnPointSelector
.GetSpawnPointsInList();
212
IEntity
parentEntity;
213
SCR_MilitaryBaseComponent baseComponent;
214
foreach
(
SCR_SpawnPoint
spawnPoint : spawnPoints)
215
{
216
parentEntity = spawnPoint.
GetRootParent
();
217
if
(!parentEntity)
218
continue
;
219
220
baseComponent = SCR_MilitaryBaseComponent.Cast(parentEntity.
FindComponent
(SCR_MilitaryBaseComponent));
221
if
(!baseComponent)
222
continue
;
223
224
if
(baseComponent.GetCallsign() != rallyPointBaseCallsignId)
225
continue
;
226
227
int
rallyPointSpawnPointId =
m_SpawnPointSelector
.GetItemId(spawnPoint.GetRplId());
228
m_SpawnPointSelector
.SetCurrentItem(rallyPointSpawnPointId);
229
230
return
;
231
}
232
}
233
234
void
UpdateRelevantSpawnPoints
()
235
{
236
array<SCR_SpawnPoint> spawnPoints =
m_SpawnPointSelector
.GetSpawnPointsInList();
237
PlayerController pc =
GetGame
().GetPlayerController();
238
SCR_PlayerFactionAffiliationComponent
plyFactionComp =
SCR_PlayerFactionAffiliationComponent
.Cast(pc.FindComponent(
SCR_PlayerFactionAffiliationComponent
));
239
array<SCR_SpawnPoint> playerSpawnPoints =
SCR_SpawnPoint
.GetSpawnPointsForFaction(plyFactionComp.GetAffiliatedFaction().GetFactionKey());
240
241
foreach
(
SCR_SpawnPoint
sp : spawnPoints)
242
{
243
if
(!sp.IsSpawnPointVisibleForPlayer(pc.GetPlayerId()))
244
RemoveSpawnPoint
(sp);
245
}
246
247
foreach
(
SCR_SpawnPoint
sp : playerSpawnPoints)
248
{
249
if
(spawnPoints.Contains(sp))
250
continue
;
251
252
if
(sp.IsSpawnPointVisibleForPlayer(pc.GetPlayerId()))
253
AddSpawnPoint
(sp);
254
}
255
}
256
257
void
SelectSpawnPointExt
(
RplId
id
)
258
{
259
int
itemId =
m_SpawnPointSelector
.GetItemId(
id
);
260
if
(itemId > -1)
261
m_SpawnPointSelector
.SetCurrentItem(itemId);
262
}
263
264
ScriptInvoker
GetOnSpawnPointSelected
()
265
{
266
if
(!
m_OnSpawnPointSelected
)
267
m_OnSpawnPointSelected
=
new
ScriptInvoker
();
268
269
return
m_OnSpawnPointSelected
;
270
}
271
272
static
ScriptInvoker
SGetOnSpawnPointSelected
()
273
{
274
if
(!
s_OnSpawnPointSelected
)
275
s_OnSpawnPointSelected
=
new
ScriptInvoker
();
276
277
return
s_OnSpawnPointSelected
;
278
}
279
280
RplId
GetCurrentRplId
()
281
{
282
return
m_SpawnPointSelector
.GetSpawnPointId(
m_SpawnPointSelector
.GetCurrentIndex());
283
}
284
285
bool
IsSelectorFocused
()
286
{
287
return
m_SpawnPointSelector
&&
m_SpawnPointSelector
.IsFocused();
288
}
289
};
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
SCR_FactionManager
void SCR_FactionManager(IEntitySource src, IEntity parent)
Definition
SCR_FactionManager.c:498
SCR_GroupsManagerComponent
void SCR_GroupsManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition
SCR_GroupsManagerComponent.c:1747
Faction
Definition
Faction.c:13
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
IEntity::GetRootParent
proto external IEntity GetRootParent()
RplId
Replication item identifier.
Definition
RplId.c:14
SCR_AIGroup
Definition
SCR_AIGroup.c:75
SCR_AIGroup::GetRallyPointId
int GetRallyPointId()
Definition
SCR_AIGroup.c:250
SCR_DeployRequestUIBaseComponent
Definition
SCR_DeployRequestUIBaseComponent.c:3
SCR_PlayerController
Definition
SCR_PlayerController.c:31
SCR_PlayerController::GetLocalPlayerId
static int GetLocalPlayerId()
Returns either a valid ID of local player or 0.
Definition
SCR_PlayerController.c:481
SCR_PlayerFactionAffiliationComponent
Definition
SCR_PlayerFactionAffiliationComponent.c:21
SCR_SpawnPoint
Spawn point entity defines positions on which players can possibly spawn.
Definition
SCR_SpawnPoint.c:28
SCR_SpawnPoint::IsSpawnPointVisibleForPlayer
bool IsSpawnPointVisibleForPlayer(int pid)
Definition
SCR_SpawnPoint.c:105
SCR_SpawnPoint::OnSpawnPointNameChanged
static ref SCR_SpawnPointNameChanged_Invoker OnSpawnPointNameChanged
Definition
SCR_SpawnPoint.c:88
SCR_SpawnPoint::GetSpawnPointByRplId
static SCR_SpawnPoint GetSpawnPointByRplId(RplId id)
Definition
SCR_SpawnPoint.c:311
SCR_SpawnPoint::GetRplId
RplId GetRplId()
Definition
SCR_SpawnPoint.c:302
SCR_SpawnPoint::GetFactionKey
string GetFactionKey()
Definition
SCR_SpawnPoint.c:503
SCR_SpawnPointRequestUIComponent
Definition
SCR_SpawnPointRequestUIComponent.c:2
SCR_SpawnPointRequestUIComponent::IsSelectorFocused
bool IsSelectorFocused()
Definition
SCR_SpawnPointRequestUIComponent.c:285
SCR_SpawnPointRequestUIComponent::SelectSpawnPoint
void SelectSpawnPoint(SCR_SpawnPointSpinBox spinbox, int itemId)
Definition
SCR_SpawnPointRequestUIComponent.c:41
SCR_SpawnPointRequestUIComponent::HandlerDeattached
override void HandlerDeattached(Widget w)
Definition
SCR_SpawnPointRequestUIComponent.c:30
SCR_SpawnPointRequestUIComponent::m_sSpawnPointSelector
string m_sSpawnPointSelector
Definition
SCR_SpawnPointRequestUIComponent.c:4
SCR_SpawnPointRequestUIComponent::s_OnSpawnPointSelected
static ref ScriptInvoker< RplId > s_OnSpawnPointSelected
Definition
SCR_SpawnPointRequestUIComponent.c:11
SCR_SpawnPointRequestUIComponent::UpdateRelevantSpawnPoints
void UpdateRelevantSpawnPoints()
Definition
SCR_SpawnPointRequestUIComponent.c:234
SCR_SpawnPointRequestUIComponent::OnSpawnPointFactionChange
void OnSpawnPointFactionChange(SCR_SpawnPoint spawnPoint)
Definition
SCR_SpawnPointRequestUIComponent.c:123
SCR_SpawnPointRequestUIComponent::m_SpawnPointSelector
SCR_SpawnPointSpinBox m_SpawnPointSelector
Definition
SCR_SpawnPointRequestUIComponent.c:8
SCR_SpawnPointRequestUIComponent::OnSpawnPointAdded
void OnSpawnPointAdded(SCR_SpawnPoint spawnPoint)
Definition
SCR_SpawnPointRequestUIComponent.c:116
SCR_SpawnPointRequestUIComponent::m_wSpawnPointSelector
Widget m_wSpawnPointSelector
Definition
SCR_SpawnPointRequestUIComponent.c:5
SCR_SpawnPointRequestUIComponent::UpdateSpawnPointName
void UpdateSpawnPointName(RplId id, string name)
Definition
SCR_SpawnPointRequestUIComponent.c:110
SCR_SpawnPointRequestUIComponent::AddSpawnPoint
void AddSpawnPoint(SCR_SpawnPoint spawnPoint)
Definition
SCR_SpawnPointRequestUIComponent.c:76
SCR_SpawnPointRequestUIComponent::GetCurrentRplId
RplId GetCurrentRplId()
Definition
SCR_SpawnPointRequestUIComponent.c:280
SCR_SpawnPointRequestUIComponent::CycleSpawnPoints
void CycleSpawnPoints(bool next=true)
Definition
SCR_SpawnPointRequestUIComponent.c:60
SCR_SpawnPointRequestUIComponent::SetLastUsedSpawnPointSelected
void SetLastUsedSpawnPointSelected()
Definition
SCR_SpawnPointRequestUIComponent.c:168
SCR_SpawnPointRequestUIComponent::HandlerAttached
override void HandlerAttached(Widget w)
Definition
SCR_SpawnPointRequestUIComponent.c:14
SCR_SpawnPointRequestUIComponent::SetSpawnPoint
void SetSpawnPoint(RplId spawnPointId)
Definition
SCR_SpawnPointRequestUIComponent.c:54
SCR_SpawnPointRequestUIComponent::ClearSpawnPoints
void ClearSpawnPoints()
Definition
SCR_SpawnPointRequestUIComponent.c:132
SCR_SpawnPointRequestUIComponent::m_OnSpawnPointSelected
ref ScriptInvoker< RplId > m_OnSpawnPointSelected
Definition
SCR_SpawnPointRequestUIComponent.c:10
SCR_SpawnPointRequestUIComponent::SetRallyPointSpawnSelected
void SetRallyPointSpawnSelected()
Sets the player group Rally Point as default selected option in spawn selector.
Definition
SCR_SpawnPointRequestUIComponent.c:192
SCR_SpawnPointRequestUIComponent::SelectSpawnPointExt
void SelectSpawnPointExt(RplId id)
Definition
SCR_SpawnPointRequestUIComponent.c:257
SCR_SpawnPointRequestUIComponent::ShowAvailableSpawnPoints
void ShowAvailableSpawnPoints(Faction faction)
Definition
SCR_SpawnPointRequestUIComponent.c:138
SCR_SpawnPointRequestUIComponent::GetOnSpawnPointSelected
ScriptInvoker GetOnSpawnPointSelected()
Definition
SCR_SpawnPointRequestUIComponent.c:264
SCR_SpawnPointRequestUIComponent::m_SelectedSpawnPointId
RplId m_SelectedSpawnPointId
Definition
SCR_SpawnPointRequestUIComponent.c:7
SCR_SpawnPointRequestUIComponent::RemoveSpawnPoint
void RemoveSpawnPoint(SCR_SpawnPoint spawnPoint)
Definition
SCR_SpawnPointRequestUIComponent.c:93
SCR_SpawnPointRequestUIComponent::SGetOnSpawnPointSelected
static ScriptInvoker SGetOnSpawnPointSelected()
Definition
SCR_SpawnPointRequestUIComponent.c:272
SCR_SpawnPointSpinBox
Definition
SCR_SpawnPointSpinBox.c:2
SCR_SpawnPointSpinBox::GetSpawnPointId
RplId GetSpawnPointId(int itemId)
Definition
SCR_SpawnPointSpinBox.c:47
SCR_SpawnPointSpinBox::IsEmpty
bool IsEmpty()
Definition
SCR_SpawnPointSpinBox.c:59
Widget
Definition
Widget.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
ScriptInvoker
ScriptInvokerBase< func > ScriptInvoker
Definition
tools.c:134
scripts
Game
UI
Menu
DeployMenu
SCR_SpawnPointRequestUIComponent.c
Generated by
1.17.0