Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_PlayerSpawnPointManagerComponent.c
Go to the documentation of this file.
5
8typedef ScriptInvokerBase<SCR_DeployableSpawnPointBudgetChangedDelegate> SCR_SpawnPointBudgetInvoker;
9
11{
12 [Attribute(uiwidget: UIWidgets.ResourcePickerThumbnail, params: "et")]
14
15 [Attribute("1")]
17
18 [Attribute("0", desc: "If true players are able to spawn at stationary command truck vehicles")]
20
21 [Attribute("1", desc: "It allows players to deploy their radiobackpack and create a deployable radio spawn point. It still allows existing deployed radio spawnpoints to be deconstructed by players if this bool is false")]
23
24 [Attribute(defvalue: SCR_ESpawnPointBudgetType.SUPPLIES.ToString(), uiwidget: UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(SCR_ESpawnPointBudgetType), desc: "Budget type for respawning on deployed radios")]
26
27 [Attribute("5", desc: "Amount of spawn tickets available for deployed radios")]
29
34
36
37 //------------------------------------------------------------------------------------------------
43 void EnablePlayerSpawnPoints(bool enable, int notificationPlayerID = -1)
44 {
45 if (enable == m_bEnablePlayerSpawnPoints)
46 return;
47
49
51 {
52 //--- Create spawn points for all connected players
53 array<int> playerIDs = {};
54 int playerIDCount = GetGame().GetPlayerManager().GetPlayers(playerIDs);
55 for (int i; i < playerIDCount; i++)
56 {
57 AddSpawnPoint(playerIDs[i]);
58 }
59 }
60 else
61 {
62 //--- Delete all existing spawn points
63 for (int i, count = m_SpawnPoints.Count(); i < count; i++)
64 {
65 delete m_SpawnPoints.Get(i);
66 }
67 m_SpawnPoints.Clear();
68 }
69
70 if (notificationPlayerID > 0)
71 {
72 if (enable)
73 SCR_NotificationsComponent.SendToEveryone(ENotification.EDITOR_ATTRIBUTES_ENABLE_RESPAWN_ON_PLAYER, notificationPlayerID);
74 else
75 SCR_NotificationsComponent.SendToEveryone(ENotification.EDITOR_ATTRIBUTES_DISABLE_RESPAWN_ON_PLAYER, notificationPlayerID);
76 }
77 }
78
79 //------------------------------------------------------------------------------------------------
85
86 //------------------------------------------------------------------------------------------------
87 protected void AddSpawnPoint(int playerID)
88 {
90 return;
91
92 Resource resource = Resource.Load(m_SpawnPointPrefab);
93 if (!resource || !resource.IsValid())
94 {
95 Debug.Error(string.Format("Invalid spawn point resource: %1 in %2::AddSpawnPoint",
97
98 return;
99 }
100
101 SCR_PlayerSpawnPoint spawnPoint = SCR_PlayerSpawnPoint.Cast(GetGame().SpawnEntityPrefab(resource, GetOwner().GetWorld()));
102 spawnPoint.SetPlayerID(playerID);
103
104 if (!spawnPoint) // Don't register empty entries
105 {
106 Debug.Error(string.Format("PlayerSpawnPoint for player: %1 could not be created!", playerID));
107 return;
108 }
109
110 m_SpawnPoints.Insert(playerID, spawnPoint);
111 }
112
113 //------------------------------------------------------------------------------------------------
114 protected void RemoveSpawnPoint(int playerID)
115 {
116 SCR_PlayerSpawnPoint spawnPoint;
117 if (m_SpawnPoints.Find(playerID, spawnPoint))
118 {
119 RplComponent.DeleteRplEntity(spawnPoint, false);
120 m_SpawnPoints.Remove(playerID);
121 }
122 }
123
124 //------------------------------------------------------------------------------------------------
128 void EnableRadioVehicleSpawning(bool enable, int notificationPlayerID = -1)
129 {
130 if (enable == m_bRadioVehicleSpawningEnabled)
131 return;
132
135
136 if (notificationPlayerID > 0)
137 {
138 if (enable)
139 SCR_NotificationsComponent.SendToEveryone(ENotification.EDITOR_ATTRIBUTES_ENABLE_RESPAWN_ON_RADIO_VEHICLE, notificationPlayerID);
140 else
141 SCR_NotificationsComponent.SendToEveryone(ENotification.EDITOR_ATTRIBUTES_DISABLE_RESPAWN_ON_RADIO_VEHICLE, notificationPlayerID);
142 }
143 }
144
145 //------------------------------------------------------------------------------------------------
146 [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
154
155 //------------------------------------------------------------------------------------------------
161
162 //------------------------------------------------------------------------------------------------
171
172 //------------------------------------------------------------------------------------------------
176 void EnableDeployableSpawnPoints(bool enable, int notificationPlayerID = -1)
177 {
179 return;
180
183
184 if (notificationPlayerID > 0)
185 {
186 if (enable)
187 SCR_NotificationsComponent.SendToEveryone(ENotification.EDITOR_ATTRIBUTES_ENABLE_DEPLOYABLE_RADIO_SPAWNPOINT, notificationPlayerID);
188 else
189 SCR_NotificationsComponent.SendToEveryone(ENotification.EDITOR_ATTRIBUTES_DISABLE_DEPLOYABLE_RADIO_SPAWNPOINT, notificationPlayerID);
190 }
191 }
192
193 //------------------------------------------------------------------------------------------------
194 [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
202
203 //------------------------------------------------------------------------------------------------
209
210 //------------------------------------------------------------------------------------------------
219
220 //------------------------------------------------------------------------------------------------
224 void SetDeployableSpawnPointBudgetType(SCR_ESpawnPointBudgetType budgetType, int notificationPlayerID = -1)
225 {
226 if (budgetType == m_eDeployableSpawnPointBudgetType)
227 return;
228
231
234
235 if (notificationPlayerID <= 0)
236 return;
237
238 if (budgetType == SCR_ESpawnPointBudgetType.NONE)
239 SCR_NotificationsComponent.SendToEveryone(ENotification.EDITOR_ATTRIBUTES_CHANGED_DEPLOYABLE_RADIO_SPAWNPOINT_BUDGET_NONE, notificationPlayerID);
240 else if (budgetType == SCR_ESpawnPointBudgetType.SUPPLIES)
241 SCR_NotificationsComponent.SendToEveryone(ENotification.EDITOR_ATTRIBUTES_CHANGED_DEPLOYABLE_RADIO_SPAWNPOINT_BUDGET_SUPPLIES, notificationPlayerID);
242 else if (budgetType == SCR_ESpawnPointBudgetType.SPAWNTICKET)
243 SCR_NotificationsComponent.SendToEveryone(ENotification.EDITOR_ATTRIBUTES_CHANGED_DEPLOYABLE_RADIO_SPAWNPOINT_BUDGET_TICKETS, notificationPlayerID);
244 }
245
246 //------------------------------------------------------------------------------------------------
247 [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
255
256 //------------------------------------------------------------------------------------------------
262
263 //------------------------------------------------------------------------------------------------
272
273 //------------------------------------------------------------------------------------------------
277 void SetDeployableSpawnPointTicketAmount(int tickets, int notificationPlayerID = -1)
278 {
280 return;
281
284
285 if (notificationPlayerID > 0)
286 SCR_NotificationsComponent.SendToEveryone(ENotification.EDITOR_ATTRIBUTES_CHANGED_DEPLOYABLE_RADIO_SPAWNPOINT_TICKET_AMOUNT, notificationPlayerID, tickets);
287 }
288
289 //------------------------------------------------------------------------------------------------
290 [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
298
299 //------------------------------------------------------------------------------------------------
305
306 //------------------------------------------------------------------------------------------------
315
316 //------------------------------------------------------------------------------------------------
317 override void OnPlayerConnected(int playerId)
318 {
319 AddSpawnPoint(playerId);
320 }
321
322 //------------------------------------------------------------------------------------------------
323 override void OnPlayerDisconnected(int playerId, KickCauseCode cause, int timeout)
324 {
325 RemoveSpawnPoint(playerId);
326 }
327
328 //------------------------------------------------------------------------------------------------
329 override void OnPlayerSpawnFinalize_S(SCR_SpawnRequestComponent requestComponent, SCR_SpawnHandlerComponent handlerComponent, SCR_SpawnData data, IEntity entity)
330 {
331 int playerId = requestComponent.GetPlayerId();
332 SCR_PlayerSpawnPoint playerPoint;
333 if (m_SpawnPoints.Find(playerId, playerPoint))
334 playerPoint.EnablePoint(playerId, entity);
335 }
336
337 //------------------------------------------------------------------------------------------------
338 override void OnPlayerKilled(notnull SCR_InstigatorContextData instigatorContextData)
339 {
340 if (!m_pGameMode.IsMaster())
341 return;
342
343 SCR_PlayerSpawnPoint playerPoint;
344 if (m_SpawnPoints.Find(instigatorContextData.GetVictimPlayerID(), playerPoint))
345 playerPoint.DisablePoint(instigatorContextData.GetVictimPlayerID());
346 }
347
348 //------------------------------------------------------------------------------------------------
349 override bool RplSave(ScriptBitWriter writer)
350 {
351 writer.WriteBool(m_bRadioVehicleSpawningEnabled);
352 writer.WriteBool(m_bDeployableSpawnPointsEnabled);
353
354 return true;
355 }
356
357 //------------------------------------------------------------------------------------------------
358 override bool RplLoad(ScriptBitReader reader)
359 {
360 bool radioVehicleSpawningEnabled, deployableSpawnPointsEnabled;
361
362 reader.ReadBool(radioVehicleSpawningEnabled);
363 reader.ReadBool(deployableSpawnPointsEnabled);
364
365 RPC_EnableRadioVehicleSpawning(radioVehicleSpawningEnabled);
366 RPC_EnableDeployableSpawnPoints(deployableSpawnPointsEnabled);
367
368 return true;
369 }
370
371 //------------------------------------------------------------------------------------------------
372 protected override void OnDelete(IEntity owner)
373 {
374 foreach (int pointId, SCR_PlayerSpawnPoint spawnPoint : m_SpawnPoints)
375 {
376 RplComponent.DeleteRplEntity(spawnPoint, false);
377 }
378 }
379}
ENotification
ArmaReforgerScripted GetGame()
Definition game.c:1398
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
SCR_BaseGameModeComponentClass m_pGameMode
The game mode entity this component is attached to.
void SCR_BaseGameModeComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Get all prefabs that have the spawner data
ScriptInvokerBase< SCR_DeployableSpawnPointBudgetChangedDelegate > SCR_SpawnPointBudgetInvoker
func SCR_DeployableSpawnPointBudgetChangedDelegate
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
ScriptInvokerBase< ScriptInvokerBoolMethod > ScriptInvokerBool
ScriptInvokerBase< ScriptInvokerIntMethod > ScriptInvokerInt
int Type
Definition Debug.c:13
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
ref SCR_SpawnPointBudgetInvoker m_OnSpawnPointBudgetTypeChanged
override void OnPlayerSpawnFinalize_S(SCR_SpawnRequestComponent requestComponent, SCR_SpawnHandlerComponent handlerComponent, SCR_SpawnData data, IEntity entity)
void EnableRadioVehicleSpawning(bool enable, int notificationPlayerID=-1)
void SetDeployableSpawnPointBudgetType(SCR_ESpawnPointBudgetType budgetType, int notificationPlayerID=-1)
override void OnPlayerDisconnected(int playerId, KickCauseCode cause, int timeout)
override void OnPlayerKilled(notnull SCR_InstigatorContextData instigatorContextData)
void SetDeployableSpawnPointTicketAmount(int tickets, int notificationPlayerID=-1)
void RPC_SetDeployableSpawnPointBudgetType(SCR_ESpawnPointBudgetType budgetType)
void EnablePlayerSpawnPoints(bool enable, int notificationPlayerID=-1)
void EnableDeployableSpawnPoints(bool enable, int notificationPlayerID=-1)
Definition Types.c:486
IEntity GetOwner()
Owner entity of the fuel tank.
SCR_FieldOfViewSettings Attribute
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
Definition EnNetwork.c:95
RplRcver
Definition RplRcver.c:59
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.
Definition RplChannel.c:14
proto external string ToString()
Plain C++ pointer, no weak pointers, no memory management.