Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_BaseSupportStationComponent.c
Go to the documentation of this file.
1 [ComponentEditorProps(category: "GameScripted/SupportStation", description: "")]
2 class SCR_BaseSupportStationComponentClass : ScriptComponentClass
3 {
4  [Attribute("0", desc: "If false then the object has no physics to move itself. If true it means the entity is a vehicle (or part of a vehicle) and it can be moved via physics which means it checks the rigid body if it has a velocity and does not allow to be used if it has", category: "General Settings")]
5  protected bool m_bIsVehicle;
6 
7  [Attribute("1", desc: "If true it will send out a notification if the user uses it. The Inherented class does need to support notifications for it to be send", category: "Specific Settings")]
8  protected bool m_bSendNotificationOnUse;
9 
10  [Attribute("0", desc: "If true it allows the support station to get the 'FactionAffiliationComponent' from parent. This is only done when no 'FactionAffiliationComponent' is found on self and main use case is for vehicle compartments. Only used if 'FactionUsageCheck' is set", category: "Faction Settings")]
11  protected bool m_bAllowGetFactionFromParent;
12 
13  [Attribute("{9DD9C6279F4489B4}Sounds/Editor/SupportStations/SupportStations_Vehicles.acp", desc: "File that contains the sound effect", params: "acp", category: "On use Audio")]
14  protected ResourceName m_sOnUseSoundEffectFile;
15 
16  [Attribute(desc: "Sound effect played when executing is done. Broadcast to players. Leave empty if no sfx", category: "On use Audio")]
17  protected string m_sOnUseSoundEffectEventName;
18 
19  [Attribute(desc: "Sound played from from user on successfully action. (Some support station might play action on action owner instead of user). Leave empty to not play any voice effects", category: "On use Audio")]
20  protected string m_sCharacterVoiceEventOnUse;
21 
22  [Attribute("40", desc: "Priority of voice played on use", params: "0 inf 1", category: "On use Audio")]
23  protected int m_iCharacterVoicePriority;
24 
25  protected ref SCR_AudioSourceConfiguration m_OnUseAudioSourceConfiguration;
26 
27  //------------------------------------------------------------------------------------------------
30  bool GetSendNotificationOnUse()
31  {
33  }
34 
35  //------------------------------------------------------------------------------------------------
38  bool CanMoveWithPhysics()
39  {
40  return m_bIsVehicle;
41  }
42 
43  //------------------------------------------------------------------------------------------------
47  bool AllowGetFactionFromParent()
48  {
50  }
51 
52  //------------------------------------------------------------------------------------------------
56  SCR_AudioSourceConfiguration GetOnUseAudioConfig()
57  {
58  //~ Create Audio source if it does not yet exist
59  if (!m_OnUseAudioSourceConfiguration)
60  {
61  if (SCR_StringHelper.IsEmptyOrWhiteSpace(m_sOnUseSoundEffectFile) || SCR_StringHelper.IsEmptyOrWhiteSpace(m_sOnUseSoundEffectEventName))
62  return null;
63 
64  m_OnUseAudioSourceConfiguration = new SCR_AudioSourceConfiguration();
67 
68  if (!CanMoveWithPhysics())
70  else
72  }
73 
75  }
76 
77  //------------------------------------------------------------------------------------------------
81  void GetCharacterVoiceSoundEventVariables(out string characterVoiceEventOnUse, out int characterVoicePriority)
82  {
83  characterVoiceEventOnUse = m_sCharacterVoiceEventOnUse;
84  characterVoicePriority = m_iCharacterVoicePriority;
85  }
86 }
87 
88 class SCR_BaseSupportStationComponent : ScriptComponent
89 {
90  [Attribute("0", desc: "Priority dictates the array order when trying to get the first availible support station. Higher priority means it is closer to the start of the array. Think of grabbing a composition refuel station before a vehicle refuel station.", uiwidget: UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(ESupportStationPriority), category: "General Settings")]
91  protected ESupportStationPriority m_eSupportStationPriority;
92 
93  [Attribute("7", desc: "In meters, Range in which the entity which the player interacts is needs to be. If -1 it will not add itself to the Support Station Manager and can only be used by the action manager that is also a component of the entity this component is part of, note that the action manager will also never check if any are around it only the component on the entity.", category: "General Settings")]
94  protected float m_fRange;
95 
96  [Attribute("1", desc: "Enable/disable the supply Station.", category: "General Settings")]
97  protected bool m_bIsEnabled;
98 
99  [Attribute("0", desc: "When executing the action and isUsingSupplies this is the base supply cost of the action regardless of any additional supply costs. 0 to have no upfront cost (note inherented classes might still have their own supply cost calculation)", params: "0 inf 1", category: "Supplies")]
100  protected int m_iBaseSupplyCostOnUse;
101 
102  [Attribute("0", desc: "If Supply station has range it can ignore itself. If you set this false it will also grab itself when looking for stations in range. Think of a fuel tank able to refuel itself. If this is true it cannot if this is false it can. Not that compartments on vehicles are seen as seperate. So a fuel provider cannot refuel itself but it can still refuel the truck for driving", category: "Specific Settings")]
103  protected bool m_bIgnoreSelf;
104 
105  [Attribute(desc: "Offset of the center of the support station. Note the Area Mesh zone will only visualise this correctly on runtime not in workbench", uiwidget: UIWidgets.Coords, params: "inf inf 0 purpose=coords space=entity", category: "Specific Settings")]
106  protected vector m_vOffset;
107 
108  [Attribute(desc: "Set faction of user that can use Support Station, will be ignored if non are selected. Requires a 'FactionAffiliationComponent' on the Support Station or (or 'AllowGetFactionFromParent' is true on vehicle compartments). It will always allow interaction if user does not have 'FactionAffiliationComponent'. Default faction is the faction associated with the Initial Support Station faction. Flags are checked in order. DISALLOW ON null is only checked when Default faction check is not set.", uiwidget: UIWidgets.Flags, enums: ParamEnumArray.FromEnum(ESupportStationFactionUsage), category: "Faction Settings")]
110 
111  [Attribute(desc: "Action name when executing the action. Note that if this is left empty then the default ActionManager action name is used", category: "General Settings")]
113 
114  protected SCR_ResourceConsumer m_ResourceConsumer;
115 
116  //~ Will send bool over if enabled or not
117  protected ref ScriptInvoker Event_OnEnabledChanged;
118 
119  //Refs
120  protected Physics m_Physics;
122  protected FactionAffiliationComponent m_FactionAffiliationComponent;
123  protected SCR_ServicePointComponent m_ServicePointComponent;
124  //~ if the handler exists than supplies are synced with server
126 
127  //======================================== EXECUTE ========================================\\
128  //------------------------------------------------------------------------------------------------
134  void OnExecutedServer(notnull IEntity actionOwner, notnull IEntity actionUser, notnull SCR_BaseUseSupportStationAction action)
135  {
136  RplId ownerId;
137  RplId userId;
138  int playerId;
139 
140  FindEntityIds(actionOwner, actionUser, ownerId, userId, playerId);
141 
142  OnExecute(actionOwner, actionUser, playerId, action);
143  Rpc(OnExecuteBroadcast, ownerId, userId, playerId, action.GetActionID());
144  }
145 
146  //------------------------------------------------------------------------------------------------
147  //~ Get ids for replication
148  protected void FindEntityIds(IEntity owner, IEntity user, out RplId ownerId, out RplId userId, out int playerId)
149  {
150  if (owner)
151  {
152  ownerId = Replication.FindId(owner.FindComponent(RplComponent));
153 
154  if (ownerId == Replication.INVALID_ID)
155  {
156  IEntity parent = owner.GetParent();
157  if (parent)
158  ownerId = Replication.FindId(parent.FindComponent(RplComponent));
159  }
160  }
161 
162  if (user)
163  userId = Replication.FindId(user.FindComponent(RplComponent));
164 
165  PlayerManager playerManager = GetGame().GetPlayerManager();
166  if (playerManager)
167  playerId = playerManager.GetPlayerIdFromControlledEntity(user);
168  }
169 
170  //------------------------------------------------------------------------------------------------
171  protected void GetEntitiesFromID(RplId ownerId, RplId userId, out IEntity owner, out IEntity user)
172  {
173  RplComponent rpl = RplComponent.Cast(Replication.FindItem(ownerId));
174  if (rpl)
175  owner = rpl.GetEntity();
176 
177  rpl = RplComponent.Cast(Replication.FindItem(userId));
178  if (rpl)
179  user = rpl.GetEntity();
180  }
181 
182  //------------------------------------------------------------------------------------------------
183  //~ called by Server to convert ReplicationIDs to entities
184  [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
185  protected void OnExecuteBroadcast(RplId ownerId, RplId userId, int userPlayerId, int actionId)
186  {
187  IEntity actionOwner, actionUser;
188  GetEntitiesFromID(ownerId, userId, actionOwner, actionUser);
189 
190  //~ Get action
192  if (actionOwner)
193  {
194  ActionsManagerComponent actionManager = ActionsManagerComponent.Cast(actionOwner.FindComponent(ActionsManagerComponent));
195 
196  if (actionManager)
197  action = SCR_BaseUseSupportStationAction.Cast(actionManager.FindAction(actionId));
198  }
199 
200  OnExecute(actionOwner, actionUser, userPlayerId, action);
201  }
202 
203  //------------------------------------------------------------------------------------------------
206  protected void OnExecute(IEntity actionOwner, IEntity actionUser, int playerId, SCR_BaseUseSupportStationAction action)
207  {
208  //~ On succesfully executed
209  OnSuccessfullyExecuted(actionOwner, actionUser, action);
210  }
211 
212  //------------------------------------------------------------------------------------------------
213  //~ Support station was successfully executed. Called on server and client but only by inherited versions
214  protected void OnSuccessfullyExecuted(IEntity actionOwner, IEntity actionUser, SCR_BaseUseSupportStationAction action)
215  {
216  SCR_SupportStationManagerComponent.OnSupportStationExecutedSuccessfully(this, GetSupportStationType(), actionUser, actionOwner, action);
217  }
218 
219  //======================================== AUDIO ========================================\\
220  //------------------------------------------------------------------------------------------------
221  //~ Play SoundEffect
222  protected void PlaySoundEffect(SCR_AudioSourceConfiguration audioConfig, notnull IEntity soundOwner, SCR_BaseUseSupportStationAction action)
223  {
224  //~ No audio given so ignore function. It might be that no event name or file name are assigned
225  if (!audioConfig)
226  return;
227 
228  //~ Get sound component
229  SoundComponent soundComponent = SoundComponent.Cast(soundOwner.FindComponent(SoundComponent));
230 
231  //~ Has sound component. Play sound with that offset
232  if (soundComponent)
233  {
234  //~ Check if sound can be played. If true simply play the sound and return
235  if (soundComponent.GetEventIndex(audioConfig.m_sSoundEventName) > 0)
236  {
237  if (action)
238  soundComponent.SoundEventOffset(audioConfig.m_sSoundEventName, action.GetLocalPositionAction());
239  else
240  soundComponent.SoundEventOffset(audioConfig.m_sSoundEventName, vector.Zero);
241  return;
242  }
243  //~ Sound was not played
244  else
245  {
246  Print(string.Format("'SCR_BaseSupportStationComponent': Trying to play sound for '%1' but sound either sound event '%2' or more likely sound file '%3' is not included on the SoundComponent! SCR_SoundManagerEntity is used instead but that means position of sound is not updated if entity moves while sound is playing.", soundOwner, audioConfig.m_sSoundEventName, audioConfig.m_sSoundProject), LogLevel.WARNING);
247  }
248  }
249 
250  //~ No sound manager
251  SCR_SoundManagerEntity soundManagerEntity = GetGame().GetSoundManagerEntity();
252  if (!soundManagerEntity)
253  return;
254 
255  vector transform[4];
256  soundOwner.GetTransform(transform);
257 
258  if (action)
259  transform[3] = action.GetWorldPositionAction();
260  else
261  transform[3] = soundOwner.GetOrigin();
262 
263  //~ Play sound
264  soundManagerEntity.CreateAndPlayAudioSource(soundOwner, audioConfig, transform);
265  }
266 
267  //------------------------------------------------------------------------------------------------
268  //~ Place voice event for given character if any events are assigned is assigned
269  protected void PlayCharacterVoiceEvent(IEntity character)
270  {
271  if (!character)
272  return;
273 
274  //~ Grab Communication sound component of character
275  CommunicationSoundComponent communicationSoundComponent = CommunicationSoundComponent.Cast(character.FindComponent(CommunicationSoundComponent));
276  if (!communicationSoundComponent)
277  return;
278 
279  //~ Grab class data
281  if (!classData)
282  return;
283 
284  string characterVoiceEventOnUse;
285  int characterVoicePriority;
286 
287  //~ Get character voice variables
288  classData.GetCharacterVoiceSoundEventVariables(characterVoiceEventOnUse, characterVoicePriority);
289 
290  //~ Check if voice has been assigned
291  if (!SCR_StringHelper.IsEmptyOrWhiteSpace(characterVoiceEventOnUse))
292  communicationSoundComponent.SoundEventPriority(characterVoiceEventOnUse, characterVoicePriority, true);
293  }
294 
295  //======================================== IS VALID ========================================\\
296  //------------------------------------------------------------------------------------------------
306  bool IsValid(IEntity actionOwner, IEntity actionUser, SCR_BaseUseSupportStationAction action, vector actionPosition, out ESupportStationReasonInvalid reasonInvalid, out int supplyCost)
307  {
308  //~ Check if enabled
309  if (!IsEnabled())
310  {
311  //~ Check if uses range and if it should ignore self and is self. In that case simply show not in range
312  if (UsesRange() && IgnoreSelf() && actionOwner == GetOwner())
313  reasonInvalid = ESupportStationReasonInvalid.NOT_IN_RANGE;
314  //~ Inform players if for example trying to repair a vehicle. If the support station is on the Action owner itself than the action will simply not show
315  else
316  reasonInvalid = ESupportStationReasonInvalid.DISABLED;
317 
318  return false;
319  }
320 
321  //~ If has service point and is not online show not in range
322  if (m_ServicePointComponent && m_ServicePointComponent.GetServiceState() != SCR_EServicePointStatus.ONLINE)
323  {
324  //~ Todo: Add various ESupportStationReasonInvalid for status such as BROKEN
325  reasonInvalid = ESupportStationReasonInvalid.NOT_IN_RANGE;
326  return false;
327  }
328 
329  //~ Check if it should ignore itself. If so check if the action owner is itself
330  if (IgnoreSelf() && actionOwner == GetOwner())
331  {
332  reasonInvalid = ESupportStationReasonInvalid.NOT_IN_RANGE;
333  return false;
334  }
335 
336  //~ If uses range check if the station is in range
337  if (UsesRange())
338  {
339  //~ Check if in range
340  if (vector.DistanceSq(actionPosition, GetPosition()) > GetRange())
341  {
342  reasonInvalid = ESupportStationReasonInvalid.NOT_IN_RANGE;
343  return false;
344  }
345  }
346 
347  //~ Check if Station is destroyed
348  if (m_eCurrentDamageState == EDamageState.DESTROYED)
349  {
350  reasonInvalid = ESupportStationReasonInvalid.DESTROYED_STATION;
351  return false;
352  }
353 
354  //~ Check if station is a valid faction
355  if (!IsUserValidFaction(actionUser))
356  {
357  reasonInvalid = ESupportStationReasonInvalid.INVALID_FACTION;
358  return false;
359  }
360 
361  //~ Check if it uses supplies
362  if (AreSuppliesEnabled())
363  {
364  //~ Set amount of supplies used on action
365  supplyCost = GetSupplyCostAction(actionOwner, actionUser, action);
366 
367  //~ Check if there are enough supplies
368  if (!HasEnoughSupplies(actionOwner, actionUser, supplyCost))
369  {
370  reasonInvalid = ESupportStationReasonInvalid.NO_SUPPLIES;
371  return false;
372  }
373  }
374  //~ No supplies used so set cost -1 so system knows not to display supply amount
375  else
376  {
377  supplyCost = -1;
378  }
379 
380  //~ Check if the support station is moving
381  if (IsMoving())
382  {
383  reasonInvalid = ESupportStationReasonInvalid.IS_MOVING;
384  return false;
385  }
386 
387  return true;
388  }
389 
390  //======================================== GETTERS / SETTERS ========================================\\
391  //---------------------------------------- Type ----------------------------------------\\
392  //------------------------------------------------------------------------------------------------
396  {
397  //~ OVERWRITE IN INHERIT CLASS
398  return ESupportStationType.NONE;
399  }
400 
401  //---------------------------------------- Priority ----------------------------------------\\
402  //------------------------------------------------------------------------------------------------
406  {
407  return m_eSupportStationPriority;
408  }
409 
410 
411  //---------------------------------------- Enabled ----------------------------------------\\
412  //------------------------------------------------------------------------------------------------
415  void SetEnabled(bool enable)
416  {
417  if (m_bIsEnabled == enable)
418  return;
419 
420  SetEnabledBroadcast(enable);
421  Rpc(SetEnabledBroadcast, enable);
422  }
423 
424  //------------------------------------------------------------------------------------------------
425  [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
426  protected void SetEnabledBroadcast(bool enable)
427  {
428  if (m_bIsEnabled == enable)
429  return;
430 
431  m_bIsEnabled = enable;
432 
433  //~ Create and invoke onEnabledChanged
435  Event_OnEnabledChanged = new ScriptInvoker;
436 
438 
439  //~ Todo: Needs new mapmarker function and the map marker should have an inherented function that listens to the support station not the otherway around
440  //~ Set map marker active or not if any
441 // SCR_CampaignServiceMapDescriptorComponent mapMarker = SCR_CampaignServiceMapDescriptorComponent.Cast(GetOwner().FindComponent(SCR_CampaignServiceMapDescriptorComponent));
442 // if (mapMarker)
443 // mapMarker.SetServiceMarkerActive(enable);
444  }
445 
446  //------------------------------------------------------------------------------------------------
449  bool IsEnabled()
450  {
451  return m_bIsEnabled;
452  }
453 
454  //------------------------------------------------------------------------------------------------
458  ScriptInvoker GetOnEnabledChanged()
459  {
461  Event_OnEnabledChanged = new ScriptInvoker();
462 
463  return Event_OnEnabledChanged;
464  }
465 
466  //---------------------------------------- IsMoving ----------------------------------------\\
467  //------------------------------------------------------------------------------------------------
468  protected bool IsMoving()
469  {
470  //~ If has physics assigned check if it is moving. Otherwise return false
471  if (!m_Physics)
472  return false;
473 
474  return m_Physics.GetVelocity() != vector.Zero || m_Physics.GetAngularVelocity() != vector.Zero;
475  }
476 
477  //---------------------------------------- Faction Check ----------------------------------------\\
478  //------------------------------------------------------------------------------------------------
479  protected bool IsUserValidFaction(IEntity user)
480  {
481  //~ No Flags set so Ignore
482  if (m_eFactionUsageCheck == 0 || !user)
483  return true;
484 
485  //~ Support station does not have a faction affiliation component so it is always valid
487  return true;
488 
489  //~ Check if user has Faction affiliation. If no then user is considered neutral and always true
490  FactionAffiliationComponent userFactionAffiliation = FactionAffiliationComponent.Cast(user.FindComponent(FactionAffiliationComponent));
491  if (!userFactionAffiliation)
492  return true;
493 
494  //~ Check if user has Faction. If no then user is considered neutral and always true
495  Faction userFaction = userFactionAffiliation.GetAffiliatedFaction();
496  if (!userFaction)
497  return true;
498 
499  Faction supportStationFaction;
500 
501  //~ Checks current faction
502  if (SCR_Enum.HasFlag(m_eFactionUsageCheck, ESupportStationFactionUsage.SAME_CURRENT_FACTION) || SCR_Enum.HasFlag(m_eFactionUsageCheck, ESupportStationFactionUsage.FRIENDLY_CURRENT_FACTION))
503  {
504  //~ Only check if has current faction
505  supportStationFaction = m_FactionAffiliationComponent.GetAffiliatedFaction();
506  if (supportStationFaction)
507  {
508  //~ If faction is the same
509  if (SCR_Enum.HasFlag(m_eFactionUsageCheck, ESupportStationFactionUsage.SAME_CURRENT_FACTION) && supportStationFaction.GetFactionKey() == userFaction.GetFactionKey())
510  return true;
511 
512  //~ If faction is friendly
513  if (SCR_Enum.HasFlag(m_eFactionUsageCheck, ESupportStationFactionUsage.FRIENDLY_CURRENT_FACTION) && supportStationFaction.IsFactionFriendly(userFaction))
514  return true;
515 
516  //~ Current faction exists but is not the same (or if friendly is checked and is not friendly)
517  return false;
518  }
519  }
520 
521  //~ Checks default faction
522  if (SCR_Enum.HasFlag(m_eFactionUsageCheck, ESupportStationFactionUsage.SAME_DEFAULT_FACTION) || SCR_Enum.HasFlag(m_eFactionUsageCheck, ESupportStationFactionUsage.FRIENDLY_DEFAULT_FACTION))
523  {
524  //~ No default faction so return true
525  supportStationFaction = m_FactionAffiliationComponent.GetDefaultAffiliatedFaction();
526  if (!supportStationFaction)
527  return true;
528 
529  //~ If default faction is the same
530  if (SCR_Enum.HasFlag(m_eFactionUsageCheck, ESupportStationFactionUsage.SAME_DEFAULT_FACTION) && supportStationFaction.GetFactionKey() == userFaction.GetFactionKey())
531  return true;
532 
533  //~ If default faction is friendly
534  if (SCR_Enum.HasFlag(m_eFactionUsageCheck, ESupportStationFactionUsage.FRIENDLY_DEFAULT_FACTION) && supportStationFaction.IsFactionFriendly(userFaction))
535  return true;
536 
537  //~ Default faction exists but is not the same (or if friendly is checked and is not friendly)
538  return false;
539  }
540 
541  //~ Has no current faction and did not check Default faction. So check if it is allowed to be used neutral
542  return !SCR_Enum.HasFlag(m_eFactionUsageCheck, ESupportStationFactionUsage.DISALLOW_USE_ON_CURRENT_FACTION_NULL);
543  }
544 
545  //---------------------------------------- Faction Check ----------------------------------------\\
546  //------------------------------------------------------------------------------------------------
550  {
552  return null;
553 
554  SCR_Faction faction = SCR_Faction.Cast(m_FactionAffiliationComponent.GetAffiliatedFaction());
555  if (faction)
556  return faction;
557 
558  //~ If allow get default do that if no faction was found
559  if (!SCR_Enum.HasFlag(m_eFactionUsageCheck, ESupportStationFactionUsage.DISALLOW_USE_ON_CURRENT_FACTION_NULL))
560  faction = SCR_Faction.Cast(m_FactionAffiliationComponent.GetDefaultAffiliatedFaction());
561 
562  return faction;
563  }
564 
565  //======================================== SUPPLIES ========================================\\
566 
567  //------------------------------------------------------------------------------------------------
571  protected int GetSupplyCostAction(IEntity actionOwner, IEntity actionUser, SCR_BaseUseSupportStationAction action)
572  {
573  return m_iBaseSupplyCostOnUse;
574  }
575 
576  //------------------------------------------------------------------------------------------------
580  {
582  return int.MAX;
583 
584  //~ Make sure to create or poke the consumer handler so server sends updates for clients
585  if (Replication.IsClient())
586  {
589  else
590  m_ResourceSubscriptionHandleConsumer = GetGame().GetResourceSystemSubscriptionManager().RequestSubscriptionListenerHandleGraceful(m_ResourceConsumer, Replication.FindId(SCR_ResourcePlayerControllerInventoryComponent.Cast(GetGame().GetPlayerController().FindComponent(SCR_ResourcePlayerControllerInventoryComponent))));
591  }
592  //~ Simply update if server
593  else
594  {
595  GetGame().GetResourceGrid().UpdateInteractor(m_ResourceConsumer);
596  }
597 
598  return m_ResourceConsumer.GetAggregatedResourceValue();
599  }
600 
601  //------------------------------------------------------------------------------------------------
602  //~ Check if enough supplies to execute the action
603  protected bool HasEnoughSupplies(IEntity actionOwner, IEntity actionUser, int supplyAmountToCheck)
604  {
605  if (supplyAmountToCheck <= 0 || !AreSuppliesEnabled())
606  return true;
607 
608  //~ Make sure to create or poke the consumer handler so server sends updates for clients
609  if (Replication.IsClient())
610  {
613  else
614  m_ResourceSubscriptionHandleConsumer = GetGame().GetResourceSystemSubscriptionManager().RequestSubscriptionListenerHandleGraceful(m_ResourceConsumer, Replication.FindId(SCR_ResourcePlayerControllerInventoryComponent.Cast(GetGame().GetPlayerController().FindComponent(SCR_ResourcePlayerControllerInventoryComponent))));
615  }
616  //~ Simply update if server
617  else
618  {
619  GetGame().GetResourceGrid().UpdateInteractor(m_ResourceConsumer);
620  }
621 
622  //~ Check availability
623  return m_ResourceConsumer.GetAggregatedResourceValue() >= supplyAmountToCheck;
624  }
625 
626  //------------------------------------------------------------------------------------------------
630  protected bool OnConsumeSuppliesServer(int amount)
631  {
632  if (amount <= 0 || !AreSuppliesEnabled())
633  return true;
634 
635  //~ Check if consumption was successful
636  SCR_ResourceConsumtionResponse response = m_ResourceConsumer.RequestConsumtion(amount);
637 
638  return response.GetReason() == EResourceReason.SUFFICIENT;
639  }
640 
641  //------------------------------------------------------------------------------------------------
645  {
646  SCR_ResourceComponent resourceComponent = GetResourceComponent();
647 
648  return resourceComponent && resourceComponent.IsResourceTypeEnabled();
649  }
650 
651  //------------------------------------------------------------------------------------------------
653  SCR_ResourceConsumer GetResourceConsumer()
654  {
655  return m_ResourceConsumer;
656  }
657 
658  //------------------------------------------------------------------------------------------------
659  protected SCR_ResourceComponent GetResourceComponent()
660  {
661  IEntity owner = GetOwner();
662  if (!owner)
663  return null;
664 
665  return SCR_ResourceComponent.FindResourceComponent(owner);
666  }
667 
668  //---------------------------------------- Range ----------------------------------------\\
669  //------------------------------------------------------------------------------------------------
672  float GetRange()
673  {
674  return m_fRange;
675  }
676 
677  //------------------------------------------------------------------------------------------------
681  bool UsesRange()
682  {
683  return m_fRange > 0;
684  }
685 
686  //---------------------------------------- Position ----------------------------------------\\
687  //------------------------------------------------------------------------------------------------
690  vector GetPosition()
691  {
692  return GetOwner().CoordToParent(GetOffset());
693  }
694 
695  //---------------------------------------- Position Offset ----------------------------------------\\
696  //------------------------------------------------------------------------------------------------
698  vector GetOffset()
699  {
700  return m_vOffset;
701  }
702 
703 
704  //---------------------------------------- Other ----------------------------------------\\
705  //------------------------------------------------------------------------------------------------
708  bool IgnoreSelf()
709  {
710  return m_bIgnoreSelf;
711  }
712 
713  //------------------------------------------------------------------------------------------------
716  {
718  }
719 
720  //---------------------------------------- Notification ----------------------------------------\\
721  protected bool GetSendNotificationOnUse()
722  {
724  return classData && classData.GetSendNotificationOnUse();
725  }
726 
727  //---------------------------------------- Sound ----------------------------------------\\
728 
729  //------------------------------------------------------------------------------------------------
730  protected SCR_AudioSourceConfiguration GetOnUseAudioConfig()
731  {
733  if (!classData)
734  return null;
735 
736  return classData.GetOnUseAudioConfig();
737  }
738 
739  //======================================== PLAYERS IN VEHICLE ========================================\\
740 
741  //------------------------------------------------------------------------------------------------
742  //~ Get an array of all player Ids within vehicle
743  protected void GetPlayerIdsInVehicle(IEntity vehicle, out notnull array<int> playerIds)
744  {
745  playerIds.Clear();
746 
747  if (!vehicle)
748  return;
749 
750  SCR_BaseCompartmentManagerComponent compartmentManager = SCR_BaseCompartmentManagerComponent.Cast(vehicle.FindComponent(SCR_BaseCompartmentManagerComponent));
751  if (!compartmentManager)
752  {
753  IEntity parent = vehicle.GetParent();
754  if (parent)
755  compartmentManager = SCR_BaseCompartmentManagerComponent.Cast(parent.FindComponent(SCR_BaseCompartmentManagerComponent));
756 
757  if (!compartmentManager)
758  return;
759  }
760 
761  PlayerManager playerManager = GetGame().GetPlayerManager();
762  if (!playerManager)
763  return;
764 
765  array<IEntity> occupants = {};
766  compartmentManager.GetOccupants(occupants);
767  CompartmentAccessComponent compartmentAccess;
768 
769  int playerID;
770 
771  foreach (IEntity occupant : occupants)
772  {
773  playerID = playerManager.GetPlayerIdFromControlledEntity(occupant);
774 
775  if (playerID > 0)
776  playerIds.Insert(playerID);
777  }
778  }
779 
780  //======================================== DAMAGE ========================================\\
781 
782  //------------------------------------------------------------------------------------------------
788  bool OverrideDamageState(EDamageState damageState, bool checkIfHasDamageSystem)
789  {
790  //~ Already the same state
791  if (damageState == m_eCurrentDamageState)
792  return false;
793 
794  //~ Check if there is a damage system and ignore this call if there is
795  if (checkIfHasDamageSystem)
796  {
797  //~ Check has damage manager
798  SCR_DamageManagerComponent damageManager = SCR_DamageManagerComponent.Cast(GetOwner().FindComponent(SCR_DamageManagerComponent));
799  if (damageManager)
800  return false;
801 
803  if (hitZoneContainer)
804  {
805  SCR_HitZone defaultHitZone = SCR_HitZone.Cast(hitZoneContainer.GetDefaultHitZone());
806  if (defaultHitZone)
807  return false;
808  }
809  }
810 
811  OnDamageStateChanged(damageState);
812  return true;
813  }
814 
815  //---------------------------------------- On HitZone damage state changed ----------------------------------------\\
816  //------------------------------------------------------------------------------------------------
818  protected void OnHitZoneDamageStateChanged(SCR_HitZone defaultHitZone)
819  {
820  OnDamageStateChanged(defaultHitZone.GetDamageState());
821  }
822 
823  //---------------------------------------- On damage state changed ----------------------------------------\\
824  //------------------------------------------------------------------------------------------------
826  protected void OnDamageStateChanged(EDamageState damageState)
827  {
828  //~ Same state so ignore
829  if (damageState == m_eCurrentDamageState)
830  return;
831 
832  //~ If using range make sure to add self or remove self from manager
833  if (UsesRange())
834  {
835  //~ Is destroyed so remove self from support stations
836  if (damageState == EDamageState.DESTROYED)
837  {
838  SCR_SupportStationManagerComponent supportStationManager = SCR_SupportStationManagerComponent.GetInstance();
839  if (!supportStationManager)
840  return;
841 
842  supportStationManager.RemoveSupportStation(this);
843  }
844  //~ No longer destroyed so add itself back to the manager
845  else if (m_eCurrentDamageState == EDamageState.DESTROYED)
846  {
847  SCR_SupportStationManagerComponent supportStationManager = SCR_SupportStationManagerComponent.GetInstance();
848  if (!supportStationManager)
849  return;
850 
851  supportStationManager.AddSupportStation(this);
852  }
853  }
854 
855  //~ Update damage state
856  m_eCurrentDamageState = damageState;
857  }
858 
859  //---------------------------------------- Subscribe/Unsubscribe On damage state changed ----------------------------------------\\
860  //------------------------------------------------------------------------------------------------
862  protected void AddRemoveOnDamageStateChanged(IEntity owner, bool subscribe)
863  {
864  SCR_DamageManagerComponent damageManager = SCR_DamageManagerComponent.Cast(owner.FindComponent(SCR_DamageManagerComponent));
865  if (damageManager)
866  {
867  //~ Subscribe to on damage state changed
868  if (subscribe)
869  {
870  //~ Also set current state
871  m_eCurrentDamageState = damageManager.GetState();
872  damageManager.GetOnDamageStateChanged().Insert(OnDamageStateChanged);
873  }
874  //~ Unsubscribe to on damage state changed
875  else
876  {
877  damageManager.GetOnDamageStateChanged().Remove(OnDamageStateChanged);
878  }
879 
880  }
881 
882  HitZoneContainerComponent hitZoneContainer = HitZoneContainerComponent.Cast(owner.FindComponent(HitZoneContainerComponent));
883  if (hitZoneContainer)
884  {
885  SCR_HitZone defaultHitZone = SCR_HitZone.Cast(hitZoneContainer.GetDefaultHitZone());
886 
887  if (defaultHitZone)
888  {
889  //~ Subscribe to on damage state changed
890  if (subscribe)
891  {
892  //~ Also set current state
893  m_eCurrentDamageState = defaultHitZone.GetDamageState();
894  defaultHitZone.GetOnDamageStateChanged().Insert(OnHitZoneDamageStateChanged);
895  }
896  //~ Unsubscribe to on damage state changed
897  else
898  {
899  defaultHitZone.GetOnDamageStateChanged().Remove(OnHitZoneDamageStateChanged);
900  }
901  }
902  }
903  }
904 
905  //======================================== RPL ========================================\\
906 
907  //------------------------------------------------------------------------------------------------
908  override bool RplSave(ScriptBitWriter writer)
909  {
910  writer.WriteBool(m_bIsEnabled);
911 
912  return true;
913  }
914 
915  //------------------------------------------------------------------------------------------------
916  override bool RplLoad(ScriptBitReader reader)
917  {
918  int enabled;
919 
920  reader.ReadBool(enabled);
921 
922  SetEnabledBroadcast(enabled);
923 
924  return true;
925  }
926 
927  //======================================== INIT ========================================\\
928 
929  //------------------------------------------------------------------------------------------------
930  protected bool InitValidSetup()
931  {
933  {
934  Print("'" + GetOwner().GetName() + "' No Support Station type assigned in the inherented class. Overwrite the 'GetSupportStationType()' function and do not use the base class!", LogLevel.ERROR);
935  return false;
936  }
937 
938  return true;
939  }
940 
941  //------------------------------------------------------------------------------------------------
942  //~ Temp solution until replication fixed
944  {
945  SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(GetOwner());
946  if (resourceComponent)
947  m_ResourceConsumer = resourceComponent.GetConsumer(EResourceGeneratorID.DEFAULT, EResourceType.SUPPLIES);
948  }
949 
950  //------------------------------------------------------------------------------------------------
951  override void EOnInit(IEntity owner)
952  {
953  //~ Call init later to make sure vehicle slot has a parent
954  GetGame().GetCallqueue().CallLater(DelayedInit, param1: owner);
955  }
956 
957  //------------------------------------------------------------------------------------------------
958  protected void DelayedInit(IEntity owner)
959  {
960  if (!InitValidSetup() || !owner)
961  return;
962 
963  if (AreSuppliesEnabled())
964  {
965  SCR_ResourceComponent resourceComponent = GetResourceComponent();
966  if (resourceComponent)
967  {
968  m_ResourceConsumer = resourceComponent.GetConsumer(EResourceGeneratorID.DEFAULT, EResourceType.SUPPLIES);
969  if (!m_ResourceConsumer)
970  Print("'SCR_BaseSupportStationComponent' 'EOnInit': '" + GetOwner() + "' Support Station is set to use supplies but the consumer configuration in m_ResourceConsumer is missing", LogLevel.ERROR);
971  //~ Temp solution until replication fixed
972  else
973  resourceComponent.TEMP_GetOnInteractorReplicated().Insert(TEMP_OnInteractorReplicated);
974  }
975  else
976  {
977  Print("'SCR_BaseSupportStationComponent' 'EOnInit': '" + GetOwner() + "' Support Station is set to use supplies but it has no SCR_ResourceComponent", LogLevel.ERROR);
978  }
979  }
980 
981  //~ Subscribe to on damage state changed
982  AddRemoveOnDamageStateChanged(owner, true);
983 
984  SCR_BaseSupportStationComponentClass classData = SCR_BaseSupportStationComponentClass.Cast(GetComponentData(owner));
985 
986  //~ Not static so get Physics component
987  if (classData && classData.CanMoveWithPhysics())
988  {
989  Vehicle vehicle = Vehicle.Cast(owner);
990  if (!vehicle)
991  vehicle = Vehicle.Cast(owner.GetParent());
992 
993  if (vehicle)
994  m_Physics = vehicle.GetPhysics();
995  }
996 
997  //~ If faction is checked on use set faction affiliation ref
998  m_FactionAffiliationComponent = FactionAffiliationComponent.Cast(owner.FindComponent(FactionAffiliationComponent));
999 
1000  //~ Could not find Faction affiliation component
1002  {
1003  //~ Get Faction affiliation from parent
1004  if (classData && classData.AllowGetFactionFromParent())
1005  {
1006  IEntity parent = owner.GetParent();
1007  if (parent)
1008  m_FactionAffiliationComponent = FactionAffiliationComponent.Cast(parent.FindComponent(FactionAffiliationComponent));
1009  }
1010 
1011  //~ Support Station (nor parent if checked) has Faction affiliation component and it needs to be there for the IsValid check
1013  Print(string.Format("'SCR_BaseSupportStationComponent' of type '%1' has Faction usage check set to not ignore but is missing a 'FactionAffiliationComponent'", typename.EnumToString(ESupportStationType, GetSupportStationType())), LogLevel.ERROR);
1014  }
1015 
1016  //~ Uses range so add self to the manager if not destroyed
1017  if (UsesRange())
1018  {
1019  //~ Has damage manager and is destroyed so do not add self to manager
1020  if (m_eCurrentDamageState == EDamageState.DESTROYED)
1021  return;
1022 
1023  SCR_SupportStationManagerComponent supportStationManager = SCR_SupportStationManagerComponent.GetInstance();
1024  if (!supportStationManager)
1025  {
1026  //~ Entity exists in the world when loaded instead of later spawned
1027  if (owner.IsLoaded())
1028  Print("'SCR_BaseSupportStationComponent' Support station on entity that exists in world when loaded has range but no 'SCR_SupportStationManagerComponent' availible on GameMode. So it won't work!", LogLevel.WARNING);
1029  //~ Show VME for any new support stations added
1030  else
1031  Debug.Error2("SCR_BaseSupportStationComponent", "Support station exists with range but no 'SCR_SupportStationManagerComponent' availible on GameMode!");
1032 
1033  return;
1034  }
1035 
1036  //~ Add self to manager
1037  supportStationManager.AddSupportStation(this);
1038  }
1039 
1040  //~ Get service point to see if it is online
1041  m_ServicePointComponent = SCR_ServicePointComponent.Cast(owner.FindComponent(SCR_ServicePointComponent));
1042  }
1043 
1044  //------------------------------------------------------------------------------------------------
1045  override void OnPostInit(IEntity owner)
1046  {
1047  if (SCR_Global.IsEditMode())
1048  return;
1049 
1050  SetEventMask(owner, EntityEvent.INIT);
1051 
1052  //~ Make sure to use distanceSq
1053  if (m_fRange > 0)
1054  m_fRange = Math.Pow(m_fRange, 2);
1055  }
1056 
1057  //======================================== DESTROY ========================================\\
1058 
1059  //------------------------------------------------------------------------------------------------
1060  override void OnDelete(IEntity owner)
1061  {
1062  if (SCR_Global.IsEditMode() || !InitValidSetup())
1063  return;
1064 
1065  //~ Unsubscribe to onDamage state changed
1066  AddRemoveOnDamageStateChanged(owner, false);
1067 
1068  //~ Does not use range so do not remove self to supportStationManager
1069  if (!UsesRange())
1070  return;
1071 
1072  if (m_eCurrentDamageState == EDamageState.DESTROYED)
1073  return;
1074 
1075  SCR_SupportStationManagerComponent supportStationManager = SCR_SupportStationManagerComponent.GetInstance();
1076  if (!supportStationManager)
1077  return;
1078 
1079  supportStationManager.RemoveSupportStation(this);
1080 
1082  {
1083  SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(owner);
1084  if (!resourceComponent && owner.GetParent())
1085  resourceComponent = SCR_ResourceComponent.FindResourceComponent(owner.GetParent());
1086 
1087  if (resourceComponent)
1088  resourceComponent.TEMP_GetOnInteractorReplicated().Remove(TEMP_OnInteractorReplicated);
1089  }
1090  }
1091 
1092  //------------------------------------------------------------------------------------------------
1097  static SCR_BaseSupportStationComponent FindSupportStation(notnull IEntity entity, SCR_ESupportStationResupplyType type = SCR_ESupportStationResupplyType.NONE, SCR_EComponentFinderQueryFlags queryFlags = SCR_EComponentFinderQueryFlags.ENTITY | SCR_EComponentFinderQueryFlags.SLOTS)
1098  {
1099  SCR_BaseSupportStationComponent foundSupportStation;
1100  array<Managed> supportStations = {};
1101 
1102  if (SCR_Enum.HasFlag(queryFlags, SCR_EComponentFinderQueryFlags.ENTITY))
1103  {
1104  entity.FindComponents(SCR_BaseSupportStationComponent, supportStations);
1105 
1106  //~ Get correct support station
1107  foreach (Managed supportStation : supportStations)
1108  {
1109  foundSupportStation = SCR_BaseSupportStationComponent.Cast(supportStation);
1110  if (!foundSupportStation)
1111  continue;
1112 
1113  if (type == SCR_ESupportStationResupplyType.NONE || foundSupportStation.GetSupportStationType() == type)
1114  return foundSupportStation;
1115  }
1116  }
1117 
1118  //~ If vehicle loop through slotted entities
1119  if (SCR_Enum.HasFlag(queryFlags, SCR_EComponentFinderQueryFlags.SLOTS))
1120  {
1121  SlotManagerComponent slotManager = SlotManagerComponent.Cast(entity.FindComponent(SlotManagerComponent));
1122  if (slotManager)
1123  {
1124  array<EntitySlotInfo> slotInfos = {};
1125  slotManager.GetSlotInfos(slotInfos);
1126  IEntity slotEntity;
1127 
1128  foreach (EntitySlotInfo slotInfo : slotInfos)
1129  {
1130  slotEntity = slotInfo.GetAttachedEntity();
1131  if (!slotEntity)
1132  continue;
1133 
1134  slotEntity.FindComponents(SCR_BaseSupportStationComponent, supportStations);
1135 
1136  foreach (Managed supportStation : supportStations)
1137  {
1138  foundSupportStation = SCR_BaseSupportStationComponent.Cast(supportStation);
1139  if (!foundSupportStation)
1140  continue;
1141 
1142  if (type == SCR_ESupportStationResupplyType.NONE || foundSupportStation.GetSupportStationType() == type)
1143  return foundSupportStation;
1144  }
1145  }
1146  }
1147  }
1148 
1149  //~ Find support station in children
1150  if (SCR_Enum.HasFlag(queryFlags, SCR_EComponentFinderQueryFlags.CHILDREN))
1151  {
1152  IEntity child = entity.GetChildren();
1153 
1154  while (child)
1155  {
1156  child.FindComponents(SCR_BaseSupportStationComponent, supportStations);
1157 
1158  //~ Get correct support station
1159  foreach (Managed supportStation : supportStations)
1160  {
1161  foundSupportStation = SCR_BaseSupportStationComponent.Cast(supportStation);
1162  if (!foundSupportStation)
1163  continue;
1164 
1165  if (type == SCR_ESupportStationResupplyType.NONE || foundSupportStation.GetSupportStationType() == type)
1166  return foundSupportStation;
1167  }
1168 
1169  child = child.GetSibling();
1170  }
1171  }
1172 
1173  IEntity parent;
1174 
1175  //~ Find in parent
1176  if (SCR_Enum.HasFlag(queryFlags, SCR_EComponentFinderQueryFlags.PARENT))
1177  {
1178  parent = entity.GetParent();
1179 
1180  if (parent)
1181  {
1182  parent.FindComponents(SCR_BaseSupportStationComponent, supportStations);
1183 
1184  //~ Get correct support station
1185  foreach (Managed supportStation : supportStations)
1186  {
1187  foundSupportStation = SCR_BaseSupportStationComponent.Cast(supportStation);
1188  if (!foundSupportStation)
1189  continue;
1190 
1191  if (type == SCR_ESupportStationResupplyType.NONE || foundSupportStation.GetSupportStationType() == type)
1192  return foundSupportStation;
1193  }
1194  }
1195  }
1196 
1197  //~ Find in vehicle slots of parent
1198  if (SCR_Enum.HasFlag(queryFlags, SCR_EComponentFinderQueryFlags.PARENT_SLOTS))
1199  {
1200  if (!parent)
1201  parent = entity.GetParent();
1202 
1203  if (parent)
1204  foundSupportStation = SCR_BaseSupportStationComponent.FindSupportStation(parent, type, SCR_EComponentFinderQueryFlags.SLOTS);
1205 
1206  if (foundSupportStation)
1207  return foundSupportStation;
1208  }
1209 
1210  IEntity rootParent;
1211 
1212  //~ Find in root parent
1213  if (SCR_Enum.HasFlag(queryFlags, SCR_EComponentFinderQueryFlags.ROOT_PARENT))
1214  {
1215  rootParent = entity.GetRootParent();
1216 
1217  if (rootParent)
1218  {
1219  rootParent.FindComponents(SCR_BaseSupportStationComponent, supportStations);
1220 
1221  //~ Get correct support station
1222  foreach (Managed supportStation : supportStations)
1223  {
1224  foundSupportStation = SCR_BaseSupportStationComponent.Cast(supportStation);
1225  if (!foundSupportStation)
1226  continue;
1227 
1228  if (type == SCR_ESupportStationResupplyType.NONE || foundSupportStation.GetSupportStationType() == type)
1229  return foundSupportStation;
1230  }
1231  }
1232  }
1233 
1234  //~ Find in vehicle slots of root parent
1235  if (SCR_Enum.HasFlag(queryFlags, SCR_EComponentFinderQueryFlags.PARENT_SLOTS))
1236  {
1237  if (!rootParent)
1238  rootParent = entity.GetRootParent();
1239 
1240  if (rootParent)
1241  foundSupportStation = SCR_BaseSupportStationComponent.FindSupportStation(rootParent, type, SCR_EComponentFinderQueryFlags.SLOTS);
1242 
1243  if (foundSupportStation)
1244  return foundSupportStation;
1245  }
1246 
1247  //~ Find in siblings
1248  if (SCR_Enum.HasFlag(queryFlags, SCR_EComponentFinderQueryFlags.SIBLINGS))
1249  {
1250  if (!parent)
1251  parent = entity.GetParent();
1252 
1253  if (parent)
1254  {
1255  //~ Get siblings from parent
1256  IEntity child = parent.GetChildren();
1257 
1258  while (child)
1259  {
1260  //~ Ignore self
1261  if (child == entity)
1262  {
1263  child = child.GetSibling();
1264  continue;
1265  }
1266 
1267  child.FindComponents(SCR_BaseSupportStationComponent, supportStations);
1268 
1269  //~ Get correct support station
1270  foreach (Managed supportStation : supportStations)
1271  {
1272  foundSupportStation = SCR_BaseSupportStationComponent.Cast(supportStation);
1273  if (!foundSupportStation)
1274  continue;
1275 
1276  if (type == SCR_ESupportStationResupplyType.NONE || foundSupportStation.GetSupportStationType() == type)
1277  return foundSupportStation;
1278  }
1279 
1280  child = child.GetSibling();
1281  }
1282  }
1283  }
1284 
1285  //~ Not found
1286  return null;
1287  }
1288 }
1289 
1291 {
1297 }
SCR_BaseSupportStationComponentClass
Definition: SCR_BaseSupportStationComponent.c:2
m_sOnUseSoundEffectFile
protected ResourceName m_sOnUseSoundEffectFile
Definition: SCR_BaseSupportStationComponent.c:12
Attribute
SCR_BaseSupportStationComponentClass ScriptComponentClass Attribute("0", desc:"Priority dictates the array order when trying to get the first availible support station. Higher priority means it is closer to the start of the array. Think of grabbing a composition refuel station before a vehicle refuel station.", uiwidget:UIWidgets.SearchComboBox, enums:ParamEnumArray.FromEnum(ESupportStationPriority), category:"General Settings")] protected ESupportStationPriority m_eSupportStationPriority
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
m_Physics
protected Physics m_Physics
Definition: SCR_BaseSupportStationComponent.c:120
m_bAllowGetFactionFromParent
protected bool m_bAllowGetFactionFromParent
Definition: SCR_BaseSupportStationComponent.c:9
m_ResourceConsumer
protected SCR_ResourceConsumer m_ResourceConsumer
Definition: SCR_BaseSupportStationComponent.c:114
GetOnEnabledChanged
ScriptInvoker GetOnEnabledChanged()
Definition: SCR_BaseSupportStationComponent.c:458
SCR_Enum
Definition: SCR_Enum.c:1
SetEnabledBroadcast
protected void SetEnabledBroadcast(bool enable)
Definition: SCR_BaseSupportStationComponent.c:426
m_iBaseSupplyCostOnUse
protected int m_iBaseSupplyCostOnUse
Definition: SCR_BaseSupportStationComponent.c:100
GetName
string GetName()
Definition: SCR_ScenarioFrameworkLayerBase.c:85
ESupportStationPriority
ESupportStationPriority
Definition: ESupportStationPriority.c:2
GetSupplyCostAction
protected int GetSupplyCostAction(IEntity actionOwner, IEntity actionUser, SCR_BaseUseSupportStationAction action)
Definition: SCR_BaseSupportStationComponent.c:571
m_sOverrideUserActionName
protected LocalizedString m_sOverrideUserActionName
Definition: SCR_BaseSupportStationComponent.c:112
GetFaction
SCR_Faction GetFaction()
Definition: SCR_BaseSupportStationComponent.c:549
ScriptComponent
SCR_SiteSlotEntityClass ScriptComponent
FRIENDLY_DEFAULT_FACTION
@ FRIENDLY_DEFAULT_FACTION
he user with a faction that is a friendly faction to the default faction of the support station can i...
Definition: SCR_BaseSupportStationComponent.c:1295
FindEntityIds
protected void FindEntityIds(IEntity owner, IEntity user, out RplId ownerId, out RplId userId, out int playerId)
Definition: SCR_BaseSupportStationComponent.c:148
m_bIgnoreSelf
protected bool m_bIgnoreSelf
Definition: SCR_BaseSupportStationComponent.c:103
OnExecute
protected void OnExecute(IEntity actionOwner, IEntity actionUser, int playerId, SCR_BaseUseSupportStationAction action)
Definition: SCR_BaseSupportStationComponent.c:206
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
EAudioSourceConfigurationFlag
EAudioSourceConfigurationFlag
Definition: SCR_AudioSourceConfiguration.c:1
GetEntitiesFromID
protected void GetEntitiesFromID(RplId ownerId, RplId userId, out IEntity owner, out IEntity user)
Definition: SCR_BaseSupportStationComponent.c:171
EResourceReason
EResourceReason
Definition: SCR_ResourceConsumtionResponse.c:1
OnDelete
override void OnDelete(IEntity owner)
Definition: SCR_BaseSupportStationComponent.c:1060
m_fRange
protected float m_fRange
Definition: SCR_BaseSupportStationComponent.c:94
DelayedInit
protected void DelayedInit(IEntity owner)
Definition: SCR_BaseSupportStationComponent.c:958
m_eFactionUsageCheck
protected ESupportStationFactionUsage m_eFactionUsageCheck
Definition: SCR_BaseSupportStationComponent.c:109
IsMoving
protected bool IsMoving()
Definition: SCR_BaseSupportStationComponent.c:468
IsValid
bool IsValid(IEntity actionOwner, IEntity actionUser, SCR_BaseUseSupportStationAction action, vector actionPosition, out ESupportStationReasonInvalid reasonInvalid, out int supplyCost)
Definition: SCR_BaseSupportStationComponent.c:306
m_vOffset
protected vector m_vOffset
Definition: SCR_BaseSupportStationComponent.c:106
SCR_StringHelper
Definition: SCR_StringHelper.c:1
OnSuccessfullyExecuted
protected void OnSuccessfullyExecuted(IEntity actionOwner, IEntity actionUser, SCR_BaseUseSupportStationAction action)
Definition: SCR_BaseSupportStationComponent.c:214
EDamageState
EDamageState
Definition: EDamageState.c:12
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
SCR_SoundManagerEntity
Definition: SCR_SoundManagerEntity.c:17
TEMP_OnInteractorReplicated
protected void TEMP_OnInteractorReplicated()
Definition: SCR_BaseSupportStationComponent.c:943
m_sOnUseSoundEffectEventName
protected string m_sOnUseSoundEffectEventName
Definition: SCR_BaseSupportStationComponent.c:15
GetPlayerController
proto external PlayerController GetPlayerController()
Definition: SCR_PlayerDeployMenuHandlerComponent.c:307
GetSupportStationType
ESupportStationType GetSupportStationType()
Definition: SCR_BaseSupportStationComponent.c:395
EntitySlotInfo
Adds ability to attach an object to a slot.
Definition: EntitySlotInfo.c:8
GetSupportStationPriority
ESupportStationPriority GetSupportStationPriority()
Definition: SCR_BaseSupportStationComponent.c:405
HitZoneContainerComponent
Definition: HitZoneContainerComponent.c:12
Event_OnEnabledChanged
protected ref ScriptInvoker Event_OnEnabledChanged
Definition: SCR_BaseSupportStationComponent.c:117
PlaySoundEffect
protected void PlaySoundEffect(SCR_AudioSourceConfiguration audioConfig, notnull IEntity soundOwner, SCR_BaseUseSupportStationAction action)
Definition: SCR_BaseSupportStationComponent.c:222
PlayCharacterVoiceEvent
protected void PlayCharacterVoiceEvent(IEntity character)
Definition: SCR_BaseSupportStationComponent.c:269
GetOverrideUserActionName
LocalizedString GetOverrideUserActionName()
Definition: SCR_BaseSupportStationComponent.c:715
ESupportStationReasonInvalid
ESupportStationReasonInvalid
Definition: ESupportStationReasonInvalid.c:3
OnDamageStateChanged
protected void OnDamageStateChanged(EDamageState damageState)
Called when damage manager (or default hitZone) damage state changes.
Definition: SCR_BaseSupportStationComponent.c:826
SCR_SupportStationManagerComponent
Definition: SCR_SupportStationManagerComponent.c:10
m_iCharacterVoicePriority
protected int m_iCharacterVoicePriority
Definition: SCR_BaseSupportStationComponent.c:21
SAME_CURRENT_FACTION
@ SAME_CURRENT_FACTION
The user with the same faction as the current faction can interact with the support station.
Definition: SCR_BaseSupportStationComponent.c:1292
RplSave
override bool RplSave(ScriptBitWriter writer)
Definition: SCR_BaseSupportStationComponent.c:908
m_ResourceSubscriptionHandleConsumer
protected SCR_ResourceSystemSubscriptionHandleBase m_ResourceSubscriptionHandleConsumer
Definition: SCR_BaseSupportStationComponent.c:125
OverrideDamageState
bool OverrideDamageState(EDamageState damageState, bool checkIfHasDamageSystem)
Definition: SCR_BaseSupportStationComponent.c:788
DISALLOW_USE_ON_CURRENT_FACTION_NULL
@ DISALLOW_USE_ON_CURRENT_FACTION_NULL
If set it disallows the support station to be used if the faction of the Support station is not set....
Definition: SCR_BaseSupportStationComponent.c:1296
OnConsumeSuppliesServer
protected bool OnConsumeSuppliesServer(int amount)
Definition: SCR_BaseSupportStationComponent.c:630
m_OnUseAudioSourceConfiguration
protected ref SCR_AudioSourceConfiguration m_OnUseAudioSourceConfiguration
Definition: SCR_BaseSupportStationComponent.c:23
ESupportStationType
ESupportStationType
Definition: ESupportStationType.c:2
GetResourceConsumer
SCR_ResourceConsumer GetResourceConsumer()
Definition: SCR_BaseSupportStationComponent.c:653
IsEnabled
bool IsEnabled()
Definition: SCR_BaseSupportStationComponent.c:449
OnExecuteBroadcast
protected void OnExecuteBroadcast(RplId ownerId, RplId userId, int userPlayerId, int actionId)
Definition: SCR_BaseSupportStationComponent.c:185
m_eCurrentDamageState
protected EDamageState m_eCurrentDamageState
Definition: SCR_BaseSupportStationComponent.c:121
AddRemoveOnDamageStateChanged
protected void AddRemoveOnDamageStateChanged(IEntity owner, bool subscribe)
Grabs either damage manager or HitZoneContainer to subscribe to OnDamageStateChanged.
Definition: SCR_BaseSupportStationComponent.c:862
EResourceType
EResourceType
Definition: SCR_ResourceContainer.c:1
OnPostInit
override void OnPostInit(IEntity owner)
Called on PostInit when all components are added.
Definition: SCR_BaseSupportStationComponent.c:1045
SCR_ResourceConsumtionResponse
void SCR_ResourceConsumtionResponse(float availableResource=0, float resourceMultiplier=0, float range=0, EResourceReason reasonCode=EResourceReason.UNAVAILABLE)
Definition: SCR_ResourceConsumtionResponse.c:17
m_bIsEnabled
protected bool m_bIsEnabled
Definition: SCR_BaseSupportStationComponent.c:97
FRIENDLY_CURRENT_FACTION
@ FRIENDLY_CURRENT_FACTION
The user with a faction that is a friendly faction as the current faction can interact with the suppo...
Definition: SCR_BaseSupportStationComponent.c:1293
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
GetResourceComponent
protected SCR_ResourceComponent GetResourceComponent()
Definition: SCR_BaseSupportStationComponent.c:659
OnHitZoneDamageStateChanged
protected void OnHitZoneDamageStateChanged(SCR_HitZone defaultHitZone)
Called when default hitZone damage state changed. Not called if entity has a damage manager.
Definition: SCR_BaseSupportStationComponent.c:818
EOnInit
override void EOnInit(IEntity owner)
Definition: SCR_BaseSupportStationComponent.c:951
SCR_EComponentFinderQueryFlags
SCR_EComponentFinderQueryFlags
Used for component finding to know where it can search to get the given component.
Definition: SCR_EntityHelper.c:424
Faction
Definition: Faction.c:12
InitValidSetup
protected bool InitValidSetup()
Definition: SCR_BaseSupportStationComponent.c:930
SCR_HitZone
Definition: SCR_HitZone.c:1
UsesRange
bool UsesRange()
Definition: SCR_BaseSupportStationComponent.c:681
m_sCharacterVoiceEventOnUse
protected string m_sCharacterVoiceEventOnUse
Definition: SCR_BaseSupportStationComponent.c:18
SCR_Global
Definition: Functions.c:6
RplLoad
override bool RplLoad(ScriptBitReader reader)
Definition: SCR_BaseSupportStationComponent.c:916
m_FactionAffiliationComponent
protected FactionAffiliationComponent m_FactionAffiliationComponent
Definition: SCR_BaseSupportStationComponent.c:122
GetPlayerIdsInVehicle
protected void GetPlayerIdsInVehicle(IEntity vehicle, out notnull array< int > playerIds)
Definition: SCR_BaseSupportStationComponent.c:743
IsUserValidFaction
protected bool IsUserValidFaction(IEntity user)
Definition: SCR_BaseSupportStationComponent.c:479
type
EDamageType type
Definition: SCR_DestructibleTreeV2.c:32
ESupportStationFactionUsage
ESupportStationFactionUsage
Definition: SCR_BaseSupportStationComponent.c:1290
m_bSendNotificationOnUse
protected bool m_bSendNotificationOnUse
Definition: SCR_BaseSupportStationComponent.c:6
SCR_ResourcePlayerControllerInventoryComponent
Definition: SCR_ResourcePlayerControllerInventoryComponent.c:20
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
AreSuppliesEnabled
bool AreSuppliesEnabled()
Definition: SCR_BaseSupportStationComponent.c:644
HasEnoughSupplies
protected bool HasEnoughSupplies(IEntity actionOwner, IEntity actionUser, int supplyAmountToCheck)
Definition: SCR_BaseSupportStationComponent.c:603
GetOffset
vector GetOffset()
Definition: SCR_BaseSupportStationComponent.c:698
SAME_DEFAULT_FACTION
@ SAME_DEFAULT_FACTION
The user with the same faction as the default faction of the support station can interact with the su...
Definition: SCR_BaseSupportStationComponent.c:1294
SCR_ResourceSystemSubscriptionHandleBase
Definition: SCR_ResourceSystemSubscriptionHandleBase.c:1
SCR_BaseUseSupportStationAction
Definition: SCR_BaseUseSupportStationAction.c:1
OnExecutedServer
void OnExecutedServer(notnull IEntity actionOwner, notnull IEntity actionUser, notnull SCR_BaseUseSupportStationAction action)
Definition: SCR_BaseSupportStationComponent.c:134
m_ServicePointComponent
protected SCR_ServicePointComponent m_ServicePointComponent
Definition: SCR_BaseSupportStationComponent.c:123
GetOnUseAudioConfig
SCR_AudioSourceConfiguration GetOnUseAudioConfig()
Definition: SCR_BaseSupportStationComponent.c:54
GetPosition
vector GetPosition()
Definition: SCR_BaseSupportStationComponent.c:690
LocalizedString
Definition: LocalizedString.c:21
IgnoreSelf
bool IgnoreSelf()
Definition: SCR_BaseSupportStationComponent.c:708
PlayerManager
Definition: PlayerManager.c:12
SetEnabled
void SetEnabled(bool enable)
Definition: SCR_BaseSupportStationComponent.c:415
SCR_Faction
Definition: SCR_Faction.c:6
m_bIsVehicle
protected bool m_bIsVehicle
Definition: SCR_BaseSupportStationComponent.c:3
GetMaxAvailableSupplies
int GetMaxAvailableSupplies()
Definition: SCR_BaseSupportStationComponent.c:579
GetRange
float GetRange()
Definition: SCR_BaseSupportStationComponent.c:672
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180
EResourceGeneratorID
EResourceGeneratorID
Definition: SCR_ResourceGenerator.c:1