Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_SupplyBasesContextAction.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
4 {
5  override bool CanBeShown(SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition, int flags)
6  {
7  IEntity owner = null;
8  int selectedEntitiesCount = 0;
9 
10  if (selectedEntities)
11  selectedEntitiesCount = selectedEntities.Count();
12 
13  // No entity to perform the action on
14  if (!hoveredEntity && selectedEntitiesCount == 0)
15  return false;
16 
17  if (hoveredEntity)
18  {
19  owner = hoveredEntity.GetOwner();
21  if (!militaryBase)
22  return false;
23 
24  if (militaryBase.GetType() == SCR_ECampaignBaseType.RELAY)
25  return false;
26  }
27 
28  for (int i = 0; i < selectedEntitiesCount; i++)
29  {
30  owner = selectedEntities[i].GetOwner();
31  if (!owner.IsInherited(SCR_CampaignMilitaryBaseComponent))
32  return false;
33  }
34 
35  return true;
36  }
37 
38  override bool CanBePerformed(SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition, int flags)
39  {
40  return true;
41  }
42 
43  override void Perform(SCR_EditableEntityComponent hoveredEntity, notnull set<SCR_EditableEntityComponent> selectedEntities, vector cursorWorldPosition,int flags, int param = -1)
44  {
45  if (hoveredEntity)
46  PerformOn(hoveredEntity);
47 
48  if (!selectedEntities)
49  return;
50 
51  int selectedEntitiesCount = selectedEntities.Count();
52  for (int i = 0; i < selectedEntitiesCount; i++)
53  {
54  if (selectedEntities[i] == hoveredEntity)
55  continue;
56 
57  PerformOn(selectedEntities[i]);
58  }
59  }
60 
61  void PerformOn(SCR_EditableEntityComponent entity)
62  {
64 
65  if (!base)
66  return;
67 
68  PlayerController pc = GetGame().GetPlayerController();
69 
70  if (!pc)
71  return;
72 
73  SCR_CampaignNetworkComponent comp = SCR_CampaignNetworkComponent.Cast(pc.FindComponent(SCR_CampaignNetworkComponent));
74 
75  if (!comp)
76  return;
77 
78  comp.AddSuppliesFromContextMenu(base, 1000);
79  }
80 };
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_ECampaignBaseType
SCR_ECampaignBaseType
Definition: SCR_CampaignMilitaryBaseComponent.c:2577
SCR_SupplyBasesContextAction
Definition: SCR_SupplyBasesContextAction.c:3
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
SCR_SelectedEntitiesContextAction
Definition: SCR_SelectedEntitiesContextAction.c:10
SCR_BaseContainerCustomTitleUIInfo
void SCR_BaseContainerCustomTitleUIInfo(string propertyName, string format="%1")
Definition: Attributes.c:788
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468
SCR_CampaignMilitaryBaseComponent
Definition: SCR_CampaignMilitaryBaseComponent.c:38