Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_RefuelTaskSupportEntity.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
2 [EntityEditorProps(category: "GameScripted/Tasks", description: "Refuel task support entity.", color: "0 0 255 255")]
4 {
5 };
6 
7 //------------------------------------------------------------------------------------------------
9 {
10  [Attribute("0.5", params: "0 1 0.01", desc: "Player can request refuel once fuel in the tank is below this value. (x Max fuel in tank)")]
11  protected float m_fFuelLimit;
12 
13  //------------------------------------------------------------------------------------------------
14  // Call only if you null checked GetTaskManager()!
15  protected SCR_RefuelTask CreateNewRefuelTask(int requesterID, IEntity targetVehicle = null)
16  {
17  SCR_RefuelTask refuelTask = SCR_RefuelTask.Cast(CreateTask());
18  if (!refuelTask)
19  return null;
20 
21  SCR_BaseTaskExecutor requester = SCR_BaseTaskExecutor.GetTaskExecutorByID(requesterID);
22 
23  SetRequester(refuelTask, requester); //Replicated inside
24  refuelTask.SetTargetVehicle(targetVehicle); //Only set on server
25 
26  return refuelTask;
27  }
28 
29  //------------------------------------------------------------------------------------------------
30  //This should only be called on the server!
31  void RequestRefuel(int requesterID, IEntity vehicle, vector position)
32  {
33  if (!GetTaskManager())
34  return;
35 
36  SCR_RefuelTask refuelTask = CreateNewRefuelTask(requesterID, vehicle);
37 
38  if (!refuelTask)
39  return;
40 
41  MoveTask(position, refuelTask.GetTaskID());
42  }
43 
44  //------------------------------------------------------------------------------------------------
45  override bool CanRequest()
46  {
47  if (!super.CanRequest())
48  return false;
49 
50  SCR_BaseTaskExecutor localTaskExecutor = SCR_BaseTaskExecutor.GetLocalExecutor();
51  if (!localTaskExecutor)
52  return false;
53 
54  if (!SCR_RefuelTask.CheckRefuelRequestConditions(localTaskExecutor))
55  return false;
56 
57  return true;
58  }
59 
60  //------------------------------------------------------------------------------------------------
61  override void Request()
62  {
63  PlayerController playerController = GetGame().GetPlayerController();
64  if (!playerController)
65  return;
66 
67  SCR_MapRadialUI ctxMenu = SCR_MapRadialUI.GetInstance();
68  if (!ctxMenu)
69  return;
70 
71  vector position = ctxMenu.GetMenuWorldPosition();
72 
73  // Find task network component to send RPC to server
74  SCR_CampaignTaskNetworkComponent taskNetworkComponent = SCR_CampaignTaskNetworkComponent.Cast(playerController.FindComponent(SCR_CampaignTaskNetworkComponent));
75  if (!taskNetworkComponent)
76  return;
77 
78  if (!SCR_UIRequestEvacTaskComponent.HasSignal(playerController))
79  return;
80 
81  taskNetworkComponent.RequestRefuel(position);
82  }
83 
84  //------------------------------------------------------------------------------------------------
85  float GetFuelLimit()
86  {
87  return m_fFuelLimit;
88  }
89 };
SCR_RefuelTask
Definition: SCR_RefuelTask.c:7
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
SCR_RequestedTaskSupportEntityClass
Definition: SCR_RequestedTaskSupportEntity.c:3
SCR_UIRequestEvacTaskComponent
Definition: SCR_UIRequestEvacTaskComponent.c:1
SCR_MapRadialUI
2D map radial menu UI
Definition: SCR_MapRadialUI.c:13
SCR_CampaignTaskNetworkComponent
void SCR_CampaignTaskNetworkComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_CampaignTaskNetworkComponent.c:264
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_RequestedTaskSupportEntity
Definition: SCR_RequestedTaskSupportEntity.c:8
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
Attribute
typedef Attribute
Post-process effect of scripted camera.
GetTaskManager
SCR_BaseTaskManager GetTaskManager()
Definition: SCR_BaseTaskManager.c:7
SCR_BaseTaskExecutor
Definition: SCR_BaseTaskExecutor.c:7
SCR_RefuelTaskSupportEntityClass
Definition: SCR_RefuelTaskSupportEntity.c:3
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
CreateTask
protected bool CreateTask()
Definition: SCR_ScenarioFrameworkLayerTask.c:389
SCR_RefuelTaskSupportEntity
Definition: SCR_RefuelTaskSupportEntity.c:8
position
vector position
Definition: SCR_DestructibleTreeV2.c:30
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180