Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_SpawnerRequestComponent.c
Go to the documentation of this file.
2 {
3 }
4 
6 class SCR_SpawnerRequestComponent : ScriptComponent
7 {
8  [RplProp()]
9  protected int m_iQueuedAIs;
10 
11  static const float NOTIFICATION_DURATION = 2;
12 
13  //------------------------------------------------------------------------------------------------
17  {
19  }
20 
21  //------------------------------------------------------------------------------------------------
22  [RplRpc(RplChannel.Reliable, RplRcver.Owner)]
23  protected void RPC_DoTeleportPlayer(vector position)
24  {
25  SCR_Global.TeleportLocalPlayer(position, SCR_EPlayerTeleportedReason.BLOCKING_SPAWNER);
26  }
27 
28  //------------------------------------------------------------------------------------------------
30  void AddQueuedAI(int value)
31  {
32  m_iQueuedAIs += value;
33  if (m_iQueuedAIs <= 0)
34  m_iQueuedAIs = 0;
35 
36  Replication.BumpMe();
37  }
38 
39  //------------------------------------------------------------------------------------------------
42  {
43  return m_iQueuedAIs;
44  }
45 
46  //------------------------------------------------------------------------------------------------
51  void EnableSpawning(notnull SCR_DefenderSpawnerComponent defenderSpawnerComp, bool enable, int playerID)
52  {
53  IEntity spawnerOwnerEntity = defenderSpawnerComp.GetOwner();
54  if (!spawnerOwnerEntity)
55  return;
56 
57  RplComponent spawnerRplComp = RplComponent.Cast(spawnerOwnerEntity.FindComponent(RplComponent));
58  if (!spawnerRplComp)
59  return;
60 
61  Rpc(RPC_DoEnableSpawning, spawnerRplComp.Id(), enable, playerID);
62  }
63 
64  //------------------------------------------------------------------------------------------------
69  [RplRpc(RplChannel.Reliable, RplRcver.Server)]
70  protected void RPC_DoEnableSpawning(RplId defenderSpawnerID, bool enable, int playerID)
71  {
72  RplComponent rplComp = RplComponent.Cast(Replication.FindItem(defenderSpawnerID));
73  if (!rplComp)
74  return;
75 
76  SCR_DefenderSpawnerComponent entitySpawnerComp = SCR_DefenderSpawnerComponent.Cast(rplComp.GetEntity().FindComponent(SCR_DefenderSpawnerComponent));
77  if (!entitySpawnerComp)
78  return;
79 
80  entitySpawnerComp.EnableSpawning(enable, playerID);
81  }
82 
83  //------------------------------------------------------------------------------------------------
89  void RequestCatalogEntitySpawn(int index, notnull SCR_CatalogEntitySpawnerComponent spawnerComponent, IEntity user, SCR_EntitySpawnerSlotComponent slot)
90  {
91  int userId = GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(user);
92  if (userId == 0)
93  return;
94 
95  IEntity spawnerOwnerEntity = spawnerComponent.GetOwner();
96  if (!spawnerOwnerEntity)
97  return;
98 
99  RplComponent spawnerRplComp = RplComponent.Cast(spawnerOwnerEntity.FindComponent(RplComponent));
100  if (!spawnerRplComp)
101  return;
102 
103  RplComponent slotRplComp = RplComponent.Cast(slot.GetOwner().FindComponent(RplComponent));
104  if (!slotRplComp)
105  return;
106 
107  Rpc(RPC_DoRequestCatalogSpawn, spawnerRplComp.Id(), index, userId, slotRplComp.Id());
108  }
109 
110  //------------------------------------------------------------------------------------------------
116  [RplRpc(RplChannel.Reliable, RplRcver.Server)]
117  protected void RPC_DoRequestCatalogSpawn(RplId rplCompId, int index, int userId, RplId slotRplId)
118  {
119  RplComponent rplComp = RplComponent.Cast(Replication.FindItem(rplCompId));
120  if (!rplComp)
121  return;
122 
123  SCR_CatalogEntitySpawnerComponent entitySpawnerComp = SCR_CatalogEntitySpawnerComponent.Cast(rplComp.GetEntity().FindComponent(SCR_CatalogEntitySpawnerComponent));
124  if (!entitySpawnerComp)
125  return;
126 
127  SCR_EntityCatalogEntry entityEntry = entitySpawnerComp.GetEntryAtIndex(index);
128  if (!entityEntry)
129  return;
130 
131  RplComponent slotRplComp = RplComponent.Cast(Replication.FindItem(slotRplId));
132  if (!slotRplComp)
133  return;
134 
135  SCR_EntitySpawnerSlotComponent slotComp = SCR_EntitySpawnerSlotComponent.Cast(slotRplComp.GetEntity().FindComponent(SCR_EntitySpawnerSlotComponent));
136  if (!slotComp)
137  return;
138 
139  entitySpawnerComp.InitiateSpawn(entityEntry, userId, slotComp);
140  }
141 
142  //------------------------------------------------------------------------------------------------
147  void SendPlayerFeedback(int msgID, int assetIndex, int catalogType = -1)
148  {
149  Rpc(RPC_DoPlayerFeedbackImpl, msgID, assetIndex, catalogType);
150  }
151 
152  //------------------------------------------------------------------------------------------------
154  [RplRpc(RplChannel.Reliable, RplRcver.Owner)]
155  protected void RPC_DoPlayerFeedbackImpl(int msgID, int assetIndex, int catalogType)
156  {
157  string msg;
158  string msg2;
159 
160  if (msgID == SCR_EEntityRequestStatus.NOT_ENOUGH_SPACE)
161  {
162  msg = "#AR-Campaign_DeliveryPointObstructed-UC";
163  }
164 
166  if (!player)
167  return;
168 
169  SCR_Faction faction = SCR_Faction.Cast(player.GetLocalControlledEntityFaction());
170  if (!faction)
171  return;
172 
173  SCR_EntityCatalog factionCatalog = faction.GetFactionEntityCatalogOfType(catalogType);
174  if (!factionCatalog)
175  return;
176 
177  SCR_EntityCatalogEntry entry = factionCatalog.GetCatalogEntry(assetIndex);
178  if (!entry)
179  return;
180 
181  msg = GetMessageStringForCatalogType(catalogType);
182 
183  SCR_EntityCatalogSpawnerData spawnerData = SCR_EntityCatalogSpawnerData.Cast(entry.GetEntityDataOfType(SCR_EntityCatalogSpawnerData));
184  if (spawnerData)
185  msg2 = spawnerData.GetOverwriteName();
186 
187  if (msg2 == string.Empty)
188  msg2 = entry.GetEntityName();
189 
190  SCR_PopUpNotification.GetInstance().PopupMsg(msg, NOTIFICATION_DURATION, msg2);
191  }
192 
193  //------------------------------------------------------------------------------------------------
197  {
198  switch (catalogType)
199  {
200  case EEntityCatalogType.VEHICLE:
201  {
202  return "#AR-Campaign_VehicleReady-UC";
203  }
204  case EEntityCatalogType.CHARACTER:
205  {
206  return "#AR-Campaign_UnitReady-UC";
207  }
208  case EEntityCatalogType.GROUP:
209  {
210  return "#AR-Campaign_GroupReady-UC";
211  }
212  }
213 
214  //No specific catalogType defined
215  return "#AR-Campaign_AssetReady-UC";
216  }
217 
218  //------------------------------------------------------------------------------------------------
219  override void OnPostInit(IEntity owner)
220  {
221  if (!GetGame().InPlayMode())
222  return;
223  }
224 }
SCR_EEntityRequestStatus
SCR_EEntityRequestStatus
Definition: SCR_CatalogEntitySpawnerComponent.c:1428
SCR_EPlayerTeleportedReason
SCR_EPlayerTeleportedReason
Definition: SCR_PlayerTeleportedFeedbackComponent.c:50
SCR_PlayerController
Definition: SCR_PlayerController.c:31
RPC_DoPlayerFeedbackImpl
protected void RPC_DoPlayerFeedbackImpl(int msgID, int assetIndex, int catalogType)
Show notification about request result to the requester.
Definition: SCR_SpawnerRequestComponent.c:155
ScriptComponent
SCR_SiteSlotEntityClass ScriptComponent
SCR_DefenderSpawnerComponent
Service providing group of defenders defined in faction. Requires SCR_EnableDefenderAction on ActionM...
Definition: SCR_DefenderSpawnerComponent.c:40
RPC_DoTeleportPlayer
protected void RPC_DoTeleportPlayer(vector position)
Definition: SCR_SpawnerRequestComponent.c:23
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
ScriptGameComponentClass
Definition: ScriptGameComponent.c:12
EEntityCatalogType
EEntityCatalogType
Definition: EEntityCatalogType.c:4
RplProp
SCR_SpawnerRequestComponentClass ScriptGameComponentClass RplProp()] protected int m_iQueuedAIs
Used for handling entity spawning requests for SCR_CatalogEntitySpawnerComponent and inherited classe...
SendPlayerFeedback
void SendPlayerFeedback(int msgID, int assetIndex, int catalogType=-1)
Definition: SCR_SpawnerRequestComponent.c:147
AddQueuedAI
void AddQueuedAI(int value)
Add (or substract) AI to quenue.
Definition: SCR_SpawnerRequestComponent.c:30
RplRpc
SCR_AchievementsHandlerClass ScriptComponentClass RplRpc(RplChannel.Reliable, RplRcver.Owner)] void UnlockOnClient(AchievementId achievement)
Definition: SCR_AchievementsHandler.c:11
SCR_PopUpNotification
Takes care of dynamic and static onscreen popups.
Definition: SCR_PopupNotification.c:24
GetPlayerController
proto external PlayerController GetPlayerController()
Definition: SCR_PlayerDeployMenuHandlerComponent.c:307
GetMessageStringForCatalogType
string GetMessageStringForCatalogType(EEntityCatalogType catalogType)
Definition: SCR_SpawnerRequestComponent.c:196
SCR_SpawnerRequestComponentClass
Definition: SCR_SpawnerRequestComponent.c:1
RPC_DoRequestCatalogSpawn
protected void RPC_DoRequestCatalogSpawn(RplId rplCompId, int index, int userId, RplId slotRplId)
Definition: SCR_SpawnerRequestComponent.c:117
EnableSpawning
void EnableSpawning(notnull SCR_DefenderSpawnerComponent defenderSpawnerComp, bool enable, int playerID)
Definition: SCR_SpawnerRequestComponent.c:51
RequestPlayerTeleport
void RequestPlayerTeleport(vector position)
Definition: SCR_SpawnerRequestComponent.c:16
OnPostInit
override void OnPostInit(IEntity owner)
Called on PostInit when all components are added.
Definition: SCR_SpawnerRequestComponent.c:219
SCR_EntityCatalogSpawnerData
Definition: SCR_EntityCatalogSpawnerData.c:5
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
SCR_Global
Definition: Functions.c:6
SCR_EntityCatalog
Definition: SCR_EntityCatalog.c:181
GetQueuedAIs
int GetQueuedAIs()
Definition: SCR_SpawnerRequestComponent.c:41
RequestCatalogEntitySpawn
void RequestCatalogEntitySpawn(int index, notnull SCR_CatalogEntitySpawnerComponent spawnerComponent, IEntity user, SCR_EntitySpawnerSlotComponent slot)
Definition: SCR_SpawnerRequestComponent.c:89
position
vector position
Definition: SCR_DestructibleTreeV2.c:30
RPC_DoEnableSpawning
protected void RPC_DoEnableSpawning(RplId defenderSpawnerID, bool enable, int playerID)
Definition: SCR_SpawnerRequestComponent.c:70
SCR_Faction
Definition: SCR_Faction.c:6
SCR_EntityCatalogEntry
Definition: SCR_EntityCatalogEntry.c:5