Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_CampaignServiceCompositionComponent.c
Go to the documentation of this file.
1 [EntityEditorProps(category: "GameScripted/Campaign", description: "This component handles service (composition) operability")]
2 class SCR_CampaignServiceCompositionComponentClass : ScriptComponentClass
3 {
4 }
5 
6 class SCR_CampaignServiceCompositionComponent : ScriptComponent
7 {
9  [Attribute("100", UIWidgets.Slider, "Initial operability of service. If this goes to (or under) Service Unavailable value, composition is not providing it's service", "0 100 1")];
10  protected int m_iServiceOperability;
11 
13  [Attribute("0", UIWidgets.Slider, "Service is unavailable when operability drops to this value (or bellow)", "0 100 1")];
14  protected int m_iServiceUnavailable;
15 
17  protected static const int SLOT_SEARCH_DISTANCE = 5;
18  protected IEntity m_Owner;
21  protected SCR_ServicePointComponent m_Service;
22 
23  ref ScriptInvoker Event_EOnServiceDisabled = new ScriptInvoker();
24  ref ScriptInvoker Event_EOnServiceRepaired = new ScriptInvoker();
25 
26  protected static const bool AVAILABLE = true;
27  protected static const bool UNAVAILABLE = false;
28 
29  //------------------------------------------------------------------------------------------------
30  override void OnPostInit(IEntity owner)
31  {
32  m_Owner = owner;
33  }
34 
35  //------------------------------------------------------------------------------------------------
38  void ChangeOperability(int operability)
39  {
40  // First check whether the Service is operable now or not.
41  bool isOperableBeforeChange = IsServiceOperable();
42 
43  // Reduce operability
44  m_iServiceOperability -= operability;
45 
47 
48  // Check if the Service was disabled.
49  if (isOperableBeforeChange && !IsServiceOperable())
50  {
51  if (desc)
52  desc.SetServiceMarkerActive(UNAVAILABLE);
53 
54  Event_EOnServiceDisabled.Invoke();
55  }
56 
57  // Check if the Service was recovered from disabled state.
58  if (!isOperableBeforeChange && IsServiceOperable())
59  {
60  if (desc)
61  desc.SetServiceMarkerActive(AVAILABLE);
62 
63  Event_EOnServiceRepaired.Invoke();
64  }
65  }
66 
67  //------------------------------------------------------------------------------------------------
70  {
72  }
73 
74  //------------------------------------------------------------------------------------------------
76  void SetService(SCR_ServicePointComponent service)
77  {
78  m_Service = service;
79  }
80 
81  //------------------------------------------------------------------------------------------------
84  {
85  return m_CompositionType;
86  }
87 
88  //------------------------------------------------------------------------------------------------
90  SCR_ServicePointComponent GetService()
91  {
92  return m_Service;
93  }
94 
95  //------------------------------------------------------------------------------------------------
96  // Get the nearest slot to this composition
97  protected bool GetNearestSlot(IEntity ent)
98  {
99  SCR_SiteSlotEntity slotEnt = SCR_SiteSlotEntity.Cast(ent);
100  if (!slotEnt)
101  return true;
102 
103  m_Slot = slotEnt;
104  return false;
105  }
106 
107  //------------------------------------------------------------------------------------------------
110  {
112  }
113 }
EEditableEntityLabel
EEditableEntityLabel
Definition: EEditableEntityLabel.c:1
Event_EOnServiceRepaired
ref ScriptInvoker Event_EOnServiceRepaired
Definition: SCR_CampaignServiceCompositionComponent.c:24
SetCompositionType
void SetCompositionType(EEditableEntityLabel type)
Definition: SCR_CampaignServiceCompositionComponent.c:69
m_CompositionType
protected EEditableEntityLabel m_CompositionType
Definition: SCR_CampaignServiceCompositionComponent.c:20
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
ScriptComponent
SCR_SiteSlotEntityClass ScriptComponent
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
m_Owner
protected IEntity m_Owner
Definition: SCR_CampaignServiceCompositionComponent.c:18
SCR_ServicePointMapDescriptorComponent
void SCR_ServicePointMapDescriptorComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_ServicePointMapDescriptorComponent.c:198
m_Base
protected SCR_CampaignMilitaryBaseComponent m_Base
Definition: SCR_CampaignServiceCompositionComponent.c:19
m_Service
protected SCR_ServicePointComponent m_Service
Definition: SCR_CampaignServiceCompositionComponent.c:21
ChangeOperability
void ChangeOperability(int operability)
Definition: SCR_CampaignServiceCompositionComponent.c:38
IsServiceOperable
bool IsServiceOperable()
Definition: SCR_CampaignServiceCompositionComponent.c:109
OnPostInit
override void OnPostInit(IEntity owner)
Called on PostInit when all components are added.
Definition: SCR_CampaignServiceCompositionComponent.c:30
GetCompositionType
EEditableEntityLabel GetCompositionType()
Definition: SCR_CampaignServiceCompositionComponent.c:83
Event_EOnServiceDisabled
ref ScriptInvoker Event_EOnServiceDisabled
Definition: SCR_CampaignServiceCompositionComponent.c:23
SCR_CampaignServiceCompositionComponentClass
Definition: SCR_CampaignServiceCompositionComponent.c:2
SCR_SiteSlotEntity
Definition: SCR_SiteSlotEntity.c:26
type
EDamageType type
Definition: SCR_DestructibleTreeV2.c:32
m_iServiceOperability
protected int m_iServiceOperability
Definition: SCR_CampaignServiceCompositionComponent.c:10
m_iServiceUnavailable
protected int m_iServiceUnavailable
Service operability limit.
Definition: SCR_CampaignServiceCompositionComponent.c:13
GetService
SCR_ServicePointComponent GetService()
Definition: SCR_CampaignServiceCompositionComponent.c:90
Attribute
SCR_CampaignServiceCompositionComponentClass ScriptComponentClass Attribute("100", UIWidgets.Slider, "Initial operability of service. If this goes to (or under) Service Unavailable value, composition is not providing it's service", "0 100 1")]
Service operability (initial)
SetService
void SetService(SCR_ServicePointComponent service)
Definition: SCR_CampaignServiceCompositionComponent.c:76
m_Slot
protected SCR_SiteSlotEntity m_Slot
Definition: SCR_CampaignServiceCompositionComponent.c:16
GetNearestSlot
protected bool GetNearestSlot(IEntity ent)
Definition: SCR_CampaignServiceCompositionComponent.c:97
UNAVAILABLE
@ UNAVAILABLE
Definition: SCR_ResourceConsumtionResponse.c:5
SCR_CampaignMilitaryBaseComponent
Definition: SCR_CampaignMilitaryBaseComponent.c:38
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180