Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_CampaignSuppliesComponent.c
Go to the documentation of this file.
1[EntityEditorProps(category: "GameScripted/Campaign", description: "Makes a vehicle able to carry Conflict resources.", color: "0 0 255 255")]
5
8{
9 // Member variables
13 protected bool m_bAwardUnloadXP = true;
14 protected bool m_bIsPlayerInRange;
15
16 protected static const float SUPPLY_TRUCK_UNLOAD_RADIUS = 25;
17
18 [RplProp()]
19 protected ref array<int> m_aLoadingPlayerIDs = {};
20
21 [RplProp()]
22 protected ref array<int> m_aUnloadingPlayerIDs = {};
23
24 // Script Invoker
27
28 // Synced variables
29 [Attribute("0", desc: "How many supplies this component holds when it is created."), RplProp(onRplName: "OnSuppliesChanged")]
30 protected int m_iSupplies;
31
32 // Synced variables
33 [Attribute("0", desc: "Maximum supplies this component can hold."), RplProp(onRplName: "OnSuppliesChanged")]
34 protected int m_iSuppliesMax;
35
36 [Attribute("0", desc: "Maximum distance from a supply depot a player can still (un)load their truck")]
37 protected float m_fOperationalRadius;
38
39 [Attribute("0", UIWidgets.CheckBox, "This component belongs to a supply depot without a parent base.", "")]
41
42 //------------------------------------------------------------------------------------------------
45 [Obsolete("Use SCR_ResourceComponent operations instead")]
46 int GetLoadingPlayer(bool unloading = false)
47 {
48 array<int> loadingArray;
49 //Switch between loading and unloading players
50 if(!unloading)
51 loadingArray = m_aLoadingPlayerIDs;
52 else
53 loadingArray = m_aUnloadingPlayerIDs;
54
55 //return id of first player (if there is any)
56 if(!loadingArray.IsEmpty())
57 return loadingArray[0];
58 else
59 return 0;
60 }
61 //------------------------------------------------------------------------------------------------
64 [Obsolete("Use SCR_ResourceComponent operations instead")]
65 void SetSupplyLoadingPlayer(int playerID)
66 {
67 if(!m_aLoadingPlayerIDs.Contains(playerID))
68 {
69 m_aLoadingPlayerIDs.Insert(playerID);
70 Replication.BumpMe();
71 }
72 }
73
74 //------------------------------------------------------------------------------------------------
77 // Deletes from loading players array
78 [Obsolete("Use SCR_ResourceComponent operations instead")]
79 void DeleteSupplyLoadingPlayer(int playerID)
80 {
81 if(m_aLoadingPlayerIDs.Contains(playerID))
82 {
83 m_aLoadingPlayerIDs.RemoveItemOrdered(playerID);
84 Replication.BumpMe();
85 }
86 }
87
88 //------------------------------------------------------------------------------------------------
89 //~ Called on player killed
90 protected void OnPlayerKilled(notnull SCR_InstigatorContextData instigatorContextData)
91 {
92 /*DeleteSupplyLoadingPlayer(playerId);
93 DeleteSupplyUnloadingPlayer(playerId);*/
94 }
95
96 //------------------------------------------------------------------------------------------------
99 [Obsolete("Use SCR_ResourceComponent operations instead")]
100 void SetSupplyUnloadingPlayer(int playerID)
101 {
102 if(!m_aUnloadingPlayerIDs.Contains(playerID))
103 {
104 m_aUnloadingPlayerIDs.Insert(playerID);
105 Replication.BumpMe();
106 }
107 }
108
109 //------------------------------------------------------------------------------------------------
112 [Obsolete("Use SCR_ResourceComponent operations instead")]
114 {
115 if(m_aUnloadingPlayerIDs.Contains(playerID))
116 {
117 m_aUnloadingPlayerIDs.RemoveItemOrdered(playerID);
118 Replication.BumpMe();
119 }
120 }
121
122 //------------------------------------------------------------------------------------------------
123 [Obsolete("Use SCR_ResourceComponent operations instead")]
125 {
126 // script invoker executed when ammout of supplies in vehicle changed. m_iSupplies is ammout of currently loaded supplies.
128 }
129
130 //------------------------------------------------------------------------------------------------
132 [Obsolete("Use SCR_ResourceComponent operations instead")]
134 {
135 return m_iSupplies;
136 }
137
138 //------------------------------------------------------------------------------------------------
140 [Obsolete("Use SCR_ResourceComponent operations instead")]
142 {
143 return m_iSuppliesMax;
144 }
145
146 //------------------------------------------------------------------------------------------------
148 [Obsolete("Use SCR_ResourceComponent operations instead")]
149 void SetSuppliesMax(int suppliesMax)
150 {
151 m_iSuppliesMax = suppliesMax;
152 if (m_iSupplies > suppliesMax)
154
155 Replication.BumpMe();
157 }
158
159 //------------------------------------------------------------------------------------------------
162 [Obsolete("Use SCR_ResourceComponent operations instead")]
164 {
165 if (m_fOperationalRadius != 0)
167
168 return SUPPLY_TRUCK_UNLOAD_RADIUS;
169 }
170
171 //------------------------------------------------------------------------------------------------
173 [Obsolete("Use SCR_ResourceComponent operations instead")]
174 void SetIsPlayerInRange(bool status)
175 {
176 m_bIsPlayerInRange = status;
177 }
178
179 //------------------------------------------------------------------------------------------------
181 [Obsolete("Use SCR_ResourceComponent operations instead")]
183 {
184 return m_bIsPlayerInRange;
185 }
186
187 //------------------------------------------------------------------------------------------------
189 [Obsolete("Use SCR_ResourceComponent operations instead")]
199
200 //------------------------------------------------------------------------------------------------
202 [Obsolete("Use SCR_ResourceComponent operations instead")]
212
213 //------------------------------------------------------------------------------------------------
216 [Obsolete("Use SCR_ResourceComponent operations instead")]
217 bool AwardXP()
218 {
219 return m_bAwardUnloadXP;
220 }
221
222 //------------------------------------------------------------------------------------------------
226 [Obsolete("Use SCR_ResourceComponent operations instead")]
227 void AddSupplies(int supplies, bool replicate = true)
228 {
229 int oldSupplies = m_iSupplies;
230 m_iSupplies += supplies;
231
234
235 if (m_iSupplies < 0)
236 m_iSupplies = 0;
237
238 if (replicate && m_iSupplies != oldSupplies)
239 Replication.BumpMe();
240
242 }
243
244 //------------------------------------------------------------------------------------------------
246 [Obsolete("Use SCR_ResourceComponent operations instead")]
248 {
250 }
251
252 //------------------------------------------------------------------------------------------------
253 override void EOnInit(IEntity owner)
254 {
256 if (!gamemode)
257 return;
258
261 gamemode.GetOnPlayerKilled().Insert(OnPlayerKilled);
262
263 if (m_bIsStandaloneDepot && GetGame().InPlayMode())
264 {
265 SCR_GameModeCampaign campaign = SCR_GameModeCampaign.GetInstance();
266 if (campaign)
267 campaign.GetBaseManager().RegisterRemnantSupplyDepot(this);
268 }
269 }
270
271 //------------------------------------------------------------------------------------------------
272 override void OnPostInit(IEntity owner)
273 {
274 super.OnPostInit(owner);
275 SetEventMask(owner, EntityEvent.INIT);
276
278 {
279 string err = string.Format("SCR_CampaignSuppliesComponent on %1 carries more supplies (%2) than its maximum (%3)!", owner, m_iSupplies, m_iSuppliesMax);
280 Print(err, LogLevel.ERROR);
281 }
282 }
283
284 //------------------------------------------------------------------------------------------------
288 {
289 SCR_CampaignSuppliesComponent suppliesComponent;
290
291 suppliesComponent = SCR_CampaignSuppliesComponent.Cast(ent.FindComponent(SCR_CampaignSuppliesComponent));
292 if (suppliesComponent)
293 return suppliesComponent;
294
295 SlotManagerComponent slotManager = SlotManagerComponent.Cast(ent.FindComponent(SlotManagerComponent));
296 if (!slotManager)
297 return null;
298
299 array<EntitySlotInfo> slots = {};
300 slotManager.GetSlotInfos(slots);
301 IEntity truckBed;
302
303 foreach (EntitySlotInfo slot: slots)
304 {
305 if (!slot)
306 continue;
307
308 truckBed = slot.GetAttachedEntity();
309
310 if (!truckBed)
311 continue;
312
314 if (suppliesComponent)
315 return suppliesComponent;
316 }
317
318 return null;
319 }
320
321 //------------------------------------------------------------------------------------------------
322 // constructor
329
330 //------------------------------------------------------------------------------------------------
331 // destructor
333 {
336
338 if (!gamemode)
339 return;
340
343 gamemode.GetOnPlayerKilled().Remove(OnPlayerKilled);
344 }
345}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_BaseGameMode GetGameMode()
SCR_CacheNoteComponentClass ScriptComponentClass RplProp()] protected ref array< string > m_aLines
SCR_CampaignSuppliesComponent GetSuppliesComponent()
void OnPlayerKilled(notnull SCR_InstigatorContextData instigatorContextData)
SCR_CampaignSuppliesComponentClass m_LastLoadedAt
Makes a vehicle able to carry Conflict resources.
int GetLoadingPlayer(bool unloading=false)
ref array< int > m_aLoadingPlayerIDs
void AddSupplies(int supplies, bool replicate=true)
SCR_CampaignMilitaryBaseComponent m_LastXPAwardedAt
void SetSupplyLoadingPlayer(int playerID)
void SetSupplyUnloadingPlayer(int playerID)
bool GetIsPlayerInRange()
void SetLastLoadedAt(SCR_CampaignMilitaryBaseComponent base)
float GetOperationalRadius()
bool m_bIsStandaloneDepot
float m_fOperationalRadius
void ~SCR_CampaignSuppliesComponent()
void SCR_CampaignSuppliesComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
ref array< int > m_aUnloadingPlayerIDs
void OnSuppliesChanged()
ref ScriptInvoker m_OnSuppliesChanged
void DeleteSupplyLoadingPlayer(int playerID)
void DeleteSupplyUnloadingPlayer(int playerID)
SCR_CampaignMilitaryBaseComponent m_LastUnloadedAt
ref ScriptInvoker m_OnSuppliesTruckDeleted
bool GetIsStandaloneDepot()
void SetLastUnloadedAt(SCR_CampaignMilitaryBaseComponent base)
void SetSuppliesMax(int suppliesMax)
void SetIsPlayerInRange(bool status)
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
void SCR_GameModeCampaign(IEntitySource src, IEntity parent)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
enum EVehicleType IEntity
proto external int SetEventMask(notnull IEntity owner, int mask)
proto external Managed FindComponent(typename typeName)
Main replication API.
Definition Replication.c:14
ScriptInvokerBase< SCR_BaseGameMode_OnPlayerDisconnected > GetOnPlayerDisconnected()
ScriptInvokerBase< SCR_BaseGameMode_OnControllableDestroyed > GetOnPlayerKilled()
void EOnInit(IEntity owner)
IEntity GetOwner()
Owner entity of the fuel tank.
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
Definition EntityEvent.c:14
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134