Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_UIRequestEvacTaskComponent.c
Go to the documentation of this file.
1 class SCR_UIRequestEvacTaskComponent : ScriptedWidgetComponent
2 {
3  protected static const string NO_SIGNAL = "#AR-CampaignTasks_RequestImpossibleSignal-UC";
4 
5  protected SCR_EUIRequestType m_eRequestType;
6 
7  //*********************//
8  //PUBLIC MEMBER METHODS//
9  //*********************//
10 
11  //------------------------------------------------------------------------------------------------
15  static bool IsInRange(Faction requesterFaction, IEntity requesterEntity)
16  {
17  return SCR_GameModeCampaign.GetInstance().GetBaseManager().IsEntityInFactionRadioSignal(requesterEntity, requesterFaction);
18  }
19 
20  //------------------------------------------------------------------------------------------------
24  static bool HasSignal(notnull PlayerController playerController)
25  {
26  // Replace all this with better solution
27  //--------------------------------------
28  //--------------------------------------
29  SCR_PlayerController scriptedPlayerController = SCR_PlayerController.Cast(playerController);
30 
31  IEntity controlledEntity;
32  if (scriptedPlayerController)
33  controlledEntity = scriptedPlayerController.GetMainEntity();
34  else
35  controlledEntity = playerController.GetControlledEntity();
36 
37  if (!controlledEntity)
38  return false;
39 
40  FactionAffiliationComponent factionAffiliationComponent = FactionAffiliationComponent.Cast(controlledEntity.FindComponent(FactionAffiliationComponent));
41  if (!factionAffiliationComponent)
42  return false;
43 
44  Faction requesterFaction = factionAffiliationComponent.GetAffiliatedFaction();
45  if (!requesterFaction)
46  return false;
47 
48  if (!IsInRange(requesterFaction, controlledEntity))
49  {
50  SCR_PopUpNotification.GetInstance().PopupMsg(NO_SIGNAL);
51  return false;
52  }
53 
54  return true;
55  //--------------------------------------
56  //--------------------------------------
57  }
58 
59  //------------------------------------------------------------------------------------------------
62  static void RequestReinforcements(notnull PlayerController playerController)
63  {
64  SCR_CampaignTaskNetworkComponent taskNetworkComponent = SCR_CampaignTaskNetworkComponent.Cast(playerController.FindComponent(SCR_CampaignTaskNetworkComponent));
65  if (!taskNetworkComponent)
66  return;
67 
68  if (!HasSignal(playerController))
69  return;
70 
71  taskNetworkComponent.RequestReinforcements();
72  }
73 
74  //------------------------------------------------------------------------------------------------
76  void SetRequestType(SCR_EUIRequestType type)
77  {
78  m_eRequestType = type;
79  }
80 
81  //------------------------------------------------------------------------------------------------
82  override bool OnClick(Widget w, int x, int y, int button)
83  {
84  // Find local player controller
85  PlayerController playerController = GetGame().GetPlayerController();
86  if (!playerController)
87  return false;
88 
89  switch (m_eRequestType)
90  {
91  case SCR_EUIRequestType.EVAC:
92  break;
93 
94  case SCR_EUIRequestType.REFUEL:
95  break;
96 
97  case SCR_EUIRequestType.REINFORCEMENTS:
98  RequestReinforcements(playerController);
99  break;
100 
101  case SCR_EUIRequestType.TRANSPORT:
102  break;
103  }
104 
105  return false;
106  }
107 }
108 
109 enum SCR_EUIRequestType
110 {
111  EVAC,
112  REFUEL,
114  TRANSPORT
115 }
SCR_PlayerController
Definition: SCR_PlayerController.c:31
SCR_UIRequestEvacTaskComponent
Definition: SCR_UIRequestEvacTaskComponent.c:1
SCR_CampaignTaskNetworkComponent
void SCR_CampaignTaskNetworkComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_CampaignTaskNetworkComponent.c:264
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_PopUpNotification
Takes care of dynamic and static onscreen popups.
Definition: SCR_PopupNotification.c:24
REFUEL
SCR_UIRequestEvacTaskComponent REFUEL
SCR_GameModeCampaign
void SCR_GameModeCampaign(IEntitySource src, IEntity parent)
Definition: SCR_GameModeCampaign.c:1927
REINFORCEMENTS
SCR_UIRequestEvacTaskComponent REINFORCEMENTS
TRANSPORT
UIInfoAssetCard TRANSPORT
Faction
Definition: Faction.c:12
type
EDamageType type
Definition: SCR_DestructibleTreeV2.c:32
EVAC
SCR_UIRequestEvacTaskComponent EVAC