Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_PlayerSpawnPointManagerComponent.c
Go to the documentation of this file.
1 [ComponentEditorProps(category: "GameScripted/GameMode", description: "")]
3 {
4 }
5 
6 class SCR_PlayerSpawnPointManagerComponent : SCR_BaseGameModeComponent
7 {
8  [Attribute(uiwidget: UIWidgets.ResourcePickerThumbnail, params: "et")]
9  protected ResourceName m_SpawnPointPrefab;
10 
11  [Attribute("1")]
13 
14  [Attribute("0", desc: "If true players are able to spawn at stationary command truck vehicles")]
16 
17  [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")]
19 
22 
23  protected ref map<int, SCR_PlayerSpawnPoint> m_SpawnPoints = new map<int, SCR_PlayerSpawnPoint>();
24 
25  //------------------------------------------------------------------------------------------------
31  void EnablePlayerSpawnPoints(bool enable, int notificationPlayerID = -1)
32  {
33  if (enable == m_bEnablePlayerSpawnPoints)
34  return;
35 
37 
39  {
40  //--- Create spawn points for all connected players
41  array<int> playerIDs = {};
42  int playerIDCount = GetGame().GetPlayerManager().GetPlayers(playerIDs);
43  for (int i; i < playerIDCount; i++)
44  {
45  AddSpawnPoint(playerIDs[i]);
46  }
47  }
48  else
49  {
50  //--- Delete all existing spawn points
51  for (int i, count = m_SpawnPoints.Count(); i < count; i++)
52  {
53  delete m_SpawnPoints.Get(i);
54  }
55  m_SpawnPoints.Clear();
56  }
57 
58  if (notificationPlayerID > 0)
59  {
60  if (enable)
61  SCR_NotificationsComponent.SendToEveryone(ENotification.EDITOR_ATTRIBUTES_ENABLE_RESPAWN_ON_PLAYER, notificationPlayerID);
62  else
63  SCR_NotificationsComponent.SendToEveryone(ENotification.EDITOR_ATTRIBUTES_DISABLE_RESPAWN_ON_PLAYER, notificationPlayerID);
64  }
65  }
66 
67  //------------------------------------------------------------------------------------------------
70  {
72  }
73 
74  //------------------------------------------------------------------------------------------------
75  protected void AddSpawnPoint(int playerID)
76  {
77  if (!m_bEnablePlayerSpawnPoints || !m_SpawnPointPrefab)
78  return;
79 
80  Resource resource = Resource.Load(m_SpawnPointPrefab);
81  if (!resource || !resource.IsValid())
82  {
83  Debug.Error(string.Format("Invalid spawn point resource: %1 in %2::AddSpawnPoint",
84  m_SpawnPointPrefab, Type().ToString()));
85 
86  return;
87  }
88 
89  SCR_PlayerSpawnPoint spawnPoint = SCR_PlayerSpawnPoint.Cast(GetGame().SpawnEntityPrefab(resource, GetOwner().GetWorld()));
90  spawnPoint.SetPlayerID(playerID);
91 
92  if (!spawnPoint) // Don't register empty entries
93  {
94  Debug.Error(string.Format("PlayerSpawnPoint for player: %1 could not be created!", playerID));
95  return;
96  }
97 
98  m_SpawnPoints.Insert(playerID, spawnPoint);
99  }
100 
101  //------------------------------------------------------------------------------------------------
102  protected void RemoveSpawnPoint(int playerID)
103  {
104  SCR_PlayerSpawnPoint spawnPoint;
105  if (m_SpawnPoints.Find(playerID, spawnPoint))
106  {
107  RplComponent.DeleteRplEntity(spawnPoint, false);
108  m_SpawnPoints.Remove(playerID);
109  }
110  }
111 
112  //------------------------------------------------------------------------------------------------
116  void EnableRadioVehicleSpawning(bool enable, int notificationPlayerID = -1)
117  {
118  if (enable == m_bRadioVehicleSpawningEnabled)
119  return;
120 
121  Rpc(RPC_EnableRadioVehicleSpawning, enable);
123 
124  if (notificationPlayerID > 0)
125  {
126  if (enable)
127  SCR_NotificationsComponent.SendToEveryone(ENotification.EDITOR_ATTRIBUTES_ENABLE_RESPAWN_ON_RADIO_VEHICLE, notificationPlayerID);
128  else
129  SCR_NotificationsComponent.SendToEveryone(ENotification.EDITOR_ATTRIBUTES_DISABLE_RESPAWN_ON_RADIO_VEHICLE, notificationPlayerID);
130  }
131  }
132 
133  //------------------------------------------------------------------------------------------------
134  [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
135  protected void RPC_EnableRadioVehicleSpawning(bool enable)
136  {
138 
141  }
142 
143  //------------------------------------------------------------------------------------------------
146  {
148  }
149 
150  //------------------------------------------------------------------------------------------------
153  {
156 
158  }
159 
160  //------------------------------------------------------------------------------------------------
164  void EnableDeployableSpawnPoints(bool enable, int notificationPlayerID = -1)
165  {
166  if (enable == m_bDeployableSpawnPointsEnabled)
167  return;
168 
169  Rpc(RPC_EnableDeployableSpawnPoints, enable);
171 
172  if (notificationPlayerID > 0)
173  {
174  if (enable)
175  SCR_NotificationsComponent.SendToEveryone(ENotification.EDITOR_ATTRIBUTES_ENABLE_DEPLOYABLE_RADIO_SPAWNPOINT, notificationPlayerID);
176  else
177  SCR_NotificationsComponent.SendToEveryone(ENotification.EDITOR_ATTRIBUTES_DISABLE_DEPLOYABLE_RADIO_SPAWNPOINT, notificationPlayerID);
178  }
179  }
180 
181  //------------------------------------------------------------------------------------------------
182  [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
183  protected void RPC_EnableDeployableSpawnPoints(bool enable)
184  {
186 
189  }
190 
191  //------------------------------------------------------------------------------------------------
194  {
196  }
197 
198  //------------------------------------------------------------------------------------------------
201  {
204 
206  }
207 
208  //------------------------------------------------------------------------------------------------
209  override void OnPlayerConnected(int playerId)
210  {
211  AddSpawnPoint(playerId);
212  }
213 
214  //------------------------------------------------------------------------------------------------
215  override void OnPlayerDisconnected(int playerId, KickCauseCode cause, int timeout)
216  {
217  RemoveSpawnPoint(playerId);
218  }
219 
220  //------------------------------------------------------------------------------------------------
221  override void OnPlayerSpawnFinalize_S(SCR_SpawnRequestComponent requestComponent, SCR_SpawnHandlerComponent handlerComponent, SCR_SpawnData data, IEntity entity)
222  {
223  int playerId = requestComponent.GetPlayerId();
224  SCR_PlayerSpawnPoint playerPoint;
225  if (m_SpawnPoints.Find(playerId, playerPoint))
226  playerPoint.EnablePoint(playerId, entity);
227  }
228 
229  //------------------------------------------------------------------------------------------------
230  override void OnPlayerKilled(int playerId, IEntity playerEntity, IEntity killerEntity, notnull Instigator killer)
231  {
232  if (!m_pGameMode.IsMaster())
233  return;
234 
235  SCR_PlayerSpawnPoint playerPoint;
236  if (m_SpawnPoints.Find(playerId, playerPoint))
237  playerPoint.DisablePoint(playerId);
238  }
239 
240  //------------------------------------------------------------------------------------------------
241  override bool RplSave(ScriptBitWriter writer)
242  {
243  writer.WriteBool(m_bRadioVehicleSpawningEnabled);
244  writer.WriteBool(m_bDeployableSpawnPointsEnabled);
245 
246  return true;
247  }
248 
249  //------------------------------------------------------------------------------------------------
250  override bool RplLoad(ScriptBitReader reader)
251  {
252  bool radioVehicleSpawningEnabled, deployableSpawnPointsEnabled;
253 
254  reader.ReadBool(radioVehicleSpawningEnabled);
255  reader.ReadBool(deployableSpawnPointsEnabled);
256 
257  RPC_EnableRadioVehicleSpawning(radioVehicleSpawningEnabled);
258  RPC_EnableDeployableSpawnPoints(deployableSpawnPointsEnabled);
259 
260  return true;
261  }
262 
263  //------------------------------------------------------------------------------------------------
264  protected override void OnDelete(IEntity owner)
265  {
266  foreach (int pointId, SCR_PlayerSpawnPoint spawnPoint : m_SpawnPoints)
267  {
268  RplComponent.DeleteRplEntity(spawnPoint, false);
269  }
270  }
271 }
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
IsPlayerSpawnPointsEnabled
bool IsPlayerSpawnPointsEnabled()
Definition: SCR_PlayerSpawnPointManagerComponent.c:69
SCR_PlayerSpawnPointManagerComponentClass
Definition: SCR_PlayerSpawnPointManagerComponent.c:2
RemoveSpawnPoint
protected void RemoveSpawnPoint(int playerID)
Definition: SCR_PlayerSpawnPointManagerComponent.c:102
RplLoad
override bool RplLoad(ScriptBitReader reader)
Definition: SCR_PlayerSpawnPointManagerComponent.c:250
IsDeployingSpawnPointsEnabled
bool IsDeployingSpawnPointsEnabled()
Definition: SCR_PlayerSpawnPointManagerComponent.c:193
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
OnPlayerConnected
override void OnPlayerConnected(int playerId)
Definition: SCR_PlayerSpawnPointManagerComponent.c:209
OnDelete
protected override void OnDelete(IEntity owner)
Definition: SCR_PlayerSpawnPointManagerComponent.c:264
m_bEnablePlayerSpawnPoints
protected bool m_bEnablePlayerSpawnPoints
Definition: SCR_PlayerSpawnPointManagerComponent.c:12
EnablePlayerSpawnPoints
void EnablePlayerSpawnPoints(bool enable, int notificationPlayerID=-1)
Definition: SCR_PlayerSpawnPointManagerComponent.c:31
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
RplRpc
SCR_AchievementsHandlerClass ScriptComponentClass RplRpc(RplChannel.Reliable, RplRcver.Owner)] void UnlockOnClient(AchievementId achievement)
Definition: SCR_AchievementsHandler.c:11
m_bRadioVehicleSpawningEnabled
protected bool m_bRadioVehicleSpawningEnabled
Definition: SCR_PlayerSpawnPointManagerComponent.c:15
KickCauseCode
KickCauseCode
Definition: KickCauseCode.c:19
Attribute
SCR_PlayerSpawnPointManagerComponentClass SCR_BaseGameModeComponentClass Attribute(uiwidget:UIWidgets.ResourcePickerThumbnail, params:"et")] protected ResourceName m_SpawnPointPrefab
Instigator
Definition: Instigator.c:6
RPC_EnableDeployableSpawnPoints
protected void RPC_EnableDeployableSpawnPoints(bool enable)
Definition: SCR_PlayerSpawnPointManagerComponent.c:183
SCR_SpawnData
Definition: SCR_SpawnData.c:9
ENotification
ENotification
Definition: ENotification.c:4
RplSave
override bool RplSave(ScriptBitWriter writer)
Definition: SCR_PlayerSpawnPointManagerComponent.c:241
m_OnSpawnPointDeployingEnabledChanged
protected ref ScriptInvokerBool m_OnSpawnPointDeployingEnabledChanged
Definition: SCR_PlayerSpawnPointManagerComponent.c:21
AddSpawnPoint
protected void AddSpawnPoint(int playerID)
Definition: SCR_PlayerSpawnPointManagerComponent.c:75
OnPlayerKilled
override void OnPlayerKilled(int playerId, IEntity playerEntity, IEntity killerEntity, notnull Instigator killer)
Definition: SCR_PlayerSpawnPointManagerComponent.c:230
ScriptInvokerBool
ScriptInvokerBase< ScriptInvokerBoolMethod > ScriptInvokerBool
Definition: SCR_ScriptInvokerHelper.c:41
m_bDeployableSpawnPointsEnabled
protected bool m_bDeployableSpawnPointsEnabled
Definition: SCR_PlayerSpawnPointManagerComponent.c:18
m_pGameMode
SCR_BaseGameModeComponentClass m_pGameMode
The game mode entity this component is attached to.
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
OnPlayerSpawnFinalize_S
override void OnPlayerSpawnFinalize_S(SCR_SpawnRequestComponent requestComponent, SCR_SpawnHandlerComponent handlerComponent, SCR_SpawnData data, IEntity entity)
Definition: SCR_PlayerSpawnPointManagerComponent.c:221
RPC_EnableRadioVehicleSpawning
protected void RPC_EnableRadioVehicleSpawning(bool enable)
Definition: SCR_PlayerSpawnPointManagerComponent.c:135
GetOnSpawnPointDeployingEnabledChanged
ScriptInvokerBool GetOnSpawnPointDeployingEnabledChanged()
Definition: SCR_PlayerSpawnPointManagerComponent.c:200
m_SpawnPoints
protected ref map< int, SCR_PlayerSpawnPoint > m_SpawnPoints
Definition: SCR_PlayerSpawnPointManagerComponent.c:23
data
Get all prefabs that have the spawner data
Definition: SCR_EntityCatalogManagerComponent.c:305
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
GetOnRadioVehicleSpawningChanged
ScriptInvokerBool GetOnRadioVehicleSpawningChanged()
Definition: SCR_PlayerSpawnPointManagerComponent.c:152
m_OnRadioVehicleSpawningChanged
protected ref ScriptInvokerBool m_OnRadioVehicleSpawningChanged
Definition: SCR_PlayerSpawnPointManagerComponent.c:20
EnableRadioVehicleSpawning
void EnableRadioVehicleSpawning(bool enable, int notificationPlayerID=-1)
Definition: SCR_PlayerSpawnPointManagerComponent.c:116
OnPlayerDisconnected
override void OnPlayerDisconnected(int playerId, KickCauseCode cause, int timeout)
Definition: SCR_PlayerSpawnPointManagerComponent.c:215
SCR_BaseGameModeComponentClass
Definition: SCR_BaseGameModeComponent.c:2
EnableDeployableSpawnPoints
void EnableDeployableSpawnPoints(bool enable, int notificationPlayerID=-1)
Definition: SCR_PlayerSpawnPointManagerComponent.c:164
IsRadioVehicleSpawningEnabled
bool IsRadioVehicleSpawningEnabled()
Definition: SCR_PlayerSpawnPointManagerComponent.c:145
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180
SCR_BaseGameModeComponent
void SCR_BaseGameModeComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_BaseGameModeComponent.c:199