Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_SpawnerRequestComponent.c
Go to the documentation of this file.
4
6class SCR_SpawnerRequestComponent : ScriptComponent
7{
8 [RplProp()]
9 protected int m_iQueuedAIs;
10
11 static const float NOTIFICATION_DURATION = 2;
12
13 //------------------------------------------------------------------------------------------------
20
21 //------------------------------------------------------------------------------------------------
22 [RplRpc(RplChannel.Reliable, RplRcver.Owner)]
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
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
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}
EEntityCatalogType
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_CacheNoteComponentClass ScriptComponentClass RplProp()] protected ref array< string > m_aLines
vector position
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
void AddQueuedAI(int value)
Add (or substract) AI to quenue.
void RequestPlayerTeleport(vector position)
void RPC_DoPlayerFeedbackImpl(int msgID, int assetIndex, int catalogType)
Show notification about request result to the requester.
void RPC_DoEnableSpawning(RplId defenderSpawnerID, bool enable, int playerID)
void SendPlayerFeedback(int msgID, int assetIndex, int catalogType=-1)
void RPC_DoTeleportPlayer(vector position)
void RequestCatalogEntitySpawn(int index, notnull SCR_CatalogEntitySpawnerComponent spawnerComponent, IEntity user, SCR_EntitySpawnerSlotComponent slot)
void RPC_DoRequestCatalogSpawn(RplId rplCompId, int index, int userId, RplId slotRplId)
void EnableSpawning(notnull SCR_DefenderSpawnerComponent defenderSpawnerComp, bool enable, int playerID)
string GetMessageStringForCatalogType(EEntityCatalogType catalogType)
void Rpc(func method, void p0=NULL, void p1=NULL, void p2=NULL, void p3=NULL, void p4=NULL, void p5=NULL, void p6=NULL, void p7=NULL)
proto external Managed FindComponent(typename typeName)
Main replication API.
Definition Replication.c:14
Replication item identifier.
Definition RplId.c:14
Service providing group of defenders defined in faction. Requires SCR_EnableDefenderAction on ActionM...
void EnableSpawning(bool enable, int playerID)
Get prefab entity Data of type Ignores disabled Data s param dataType class of Data type you with to obtain return Entity Data of given type Null if not found *SCR_BaseEntityCatalogData GetEntityDataOfType(typename dataType)
Get Name of entity Prefab needs to be an editable entity return empty string if no uiinfo was found *LocalizedString GetEntityName()
Get Catalog Entry of index Can ignores disabled entries param Index of entry within list return Catalog Entry Null if entry is disabled *SCR_EntityCatalogEntry GetCatalogEntry(int index)
Get Localized overwrite name Empty if no name is overwritten return Localized overwrite name *LocalizedString GetOverwriteName()
SCR_EntityCatalog GetFactionEntityCatalogOfType(EEntityCatalogType catalogType, bool printNotFound=true)
static bool TeleportLocalPlayer(vector worldPosition, SCR_EPlayerTeleportedReason teleportReason=SCR_EPlayerTeleportedReason.DEFAULT)
Definition Functions.c:1625
static Faction GetLocalControlledEntityFaction()
Takes care of dynamic and static onscreen popups.
void PopupMsg(string text, float duration=DEFAULT_DURATION, string text2="", int prio=-1, string param1="", string param2="", string param3="", string param4="", string text2param1="", string text2param2="", string text2param3="", string text2param4="", string sound="", SCR_EPopupMsgFilter category=SCR_EPopupMsgFilter.ALL, WorldTimestamp progressStart=null, WorldTimestamp progressEnd=null)
static SCR_PopUpNotification GetInstance()
proto external PlayerController GetPlayerController()
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