Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ServicePointComponent.c
Go to the documentation of this file.
2 {
3 }
4 
5 class SCR_ServicePointComponent : SCR_MilitaryBaseLogicComponent
6 {
7  [Attribute(SCR_EServicePointType.SUPPLY_DEPOT.ToString(), uiwidget: UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(SCR_EServicePointType))]
9 
10  [Attribute(defvalue: "0", uiwidget: UIWidgets.SearchComboBox, desc: "Type", enums: ParamEnumArray.FromEnum(EEditableEntityLabel))]
12 
13  [Attribute("", UIWidgets.ResourceNamePicker, "Prefab of entity which will hold the UI data in case this entity gets streamed out.", "et")]
14  protected ResourceName m_sDelegatePrefab;
15 
16  // This var will later represent a service status - functional, broken or any other...
17  [RplProp(onRplName: "ServiceStateChanged")]
18  protected SCR_EServicePointStatus m_eServiceState = SCR_EServicePointStatus.OFFLINE;
19 
21  protected static bool s_bSpawnAsOffline;
22  protected ref ScriptInvoker m_OnServiceStateChanged;
23  protected SCR_ServicePointDelegateComponent m_Delegate;
24 
25  //------------------------------------------------------------------------------------------------
28  {
29  if (!m_FactionControl)
30  return null;
31 
32  Faction faction = m_FactionControl.GetAffiliatedFaction();
33  if (!faction)
34  faction = m_FactionControl.GetDefaultAffiliatedFaction();
35 
36  return faction;
37  }
38 
39  //------------------------------------------------------------------------------------------------
41  ResourceName GetDelegatePrefab()
42  {
43  return m_sDelegatePrefab;
44  }
45 
46  //------------------------------------------------------------------------------------------------
48  ScriptInvoker GetOnServiceStateChanged()
49  {
51  m_OnServiceStateChanged = new ScriptInvoker();
52 
54  }
55 
56  //------------------------------------------------------------------------------------------------
59  {
60  return m_eType;
61  }
62 
63  //------------------------------------------------------------------------------------------------
66  {
67  return m_eBuildingLabel;
68  }
69 
70  //------------------------------------------------------------------------------------------------
72  SCR_EServicePointStatus GetServiceState()
73  {
74  return m_eServiceState;
75  }
76 
77  //------------------------------------------------------------------------------------------------
79  void SetServiceState(SCR_EServicePointStatus state)
80  {
81  m_eServiceState = state;
83  m_OnServiceStateChanged.Invoke(state, this);
84 
85  Replication.BumpMe();
86  }
87 
88  //------------------------------------------------------------------------------------------------
91  {
94  }
95 
96  //------------------------------------------------------------------------------------------------
98  void SetDelegate(notnull SCR_ServicePointDelegateComponent delegate)
99  {
100  m_Delegate = delegate;
101  }
102 
103  //------------------------------------------------------------------------------------------------
104  override void OnBaseUnregistered(notnull SCR_MilitaryBaseComponent base)
105  {
107  m_OnServiceStateChanged.Invoke(SCR_EServicePointStatus.DELETED, this);
108  }
109 
110  //------------------------------------------------------------------------------------------------
111  protected void OnFactionChanged(FactionAffiliationComponent owner, Faction previousFaction, Faction faction);
112 
113  //------------------------------------------------------------------------------------------------
116  {
117  SCR_MilitaryBaseSystem baseManager = SCR_MilitaryBaseSystem.GetInstance();
118  if (!baseManager)
119  return;
120 
121  baseManager.RegisterLogicComponent(this);
122 
123  if (m_FactionControl)
124  {
125  Faction faction = m_FactionControl.GetAffiliatedFaction();
126  if (!faction)
127  faction = m_FactionControl.GetDefaultAffiliatedFaction();
128 
129  OnFactionChanged(null, null, faction);
130  m_FactionControl.GetOnFactionChanged().Insert(OnFactionChanged);
131  }
132  }
133 
134  //------------------------------------------------------------------------------------------------
136  static void SpawnAsOffline(bool val)
137  {
138  s_bSpawnAsOffline = val;
139  }
140 
141  //------------------------------------------------------------------------------------------------
144  {
145  SetServiceState(SCR_EServicePointStatus.ONLINE);
146  }
147 
148  //------------------------------------------------------------------------------------------------
149  override void OnPostInit(IEntity owner)
150  {
152 
153  super.OnPostInit(owner);
154 
155  SCR_EditorLinkComponent linkComponent = SCR_EditorLinkComponent.Cast(SCR_EntityHelper.GetMainParent(GetOwner(), true).FindComponent(SCR_EditorLinkComponent));
156  if (linkComponent)
157  linkComponent.GetOnLinkedEntitiesSpawned().Insert(RegisterService);
158  else
159  RegisterService();
160 
161  if (s_bSpawnAsOffline && linkComponent)
162  {
163  linkComponent.GetOnLinkedEntitiesSpawned().Insert(SetServiceOnline);
164  return;
165  }
166 
167  SetServiceState(SCR_EServicePointStatus.ONLINE);
168  }
169 
170  //------------------------------------------------------------------------------------------------
171  override void OnDelete(IEntity owner)
172  {
173  super.OnDelete(owner);
174 
175  if (m_Delegate)
176  RplComponent.DeleteRplEntity(m_Delegate.GetOwner(), false);
177  }
178 }
179 
181 {
192 }
193 
194 enum SCR_EServicePointStatus
195 {
196  OFFLINE,
197  ONLINE,
199  BROKEN,
200  DELETED
201 }
FIELD_HOSPITAL
@ FIELD_HOSPITAL
Definition: SCR_ServicePointComponent.c:185
EEditableEntityLabel
EEditableEntityLabel
Definition: EEditableEntityLabel.c:1
HELIPAD
@ HELIPAD
Definition: SCR_ServicePointComponent.c:188
m_sDelegatePrefab
protected ResourceName m_sDelegatePrefab
Definition: SCR_ServicePointComponent.c:14
SCR_EntityHelper
Definition: SCR_EntityHelper.c:1
GetType
SCR_EServicePointType GetType()
Definition: SCR_ServicePointComponent.c:58
SCR_MilitaryBaseLogicComponentClass
Definition: SCR_MilitaryBaseLogicComponent.c:1
Attribute
SCR_ServicePointComponentClass SCR_MilitaryBaseLogicComponentClass Attribute(SCR_EServicePointType.SUPPLY_DEPOT.ToString(), uiwidget:UIWidgets.ComboBox, enums:ParamEnumArray.FromEnum(SCR_EServicePointType))] protected SCR_EServicePointType m_eType
RplProp
SCR_RplTestEntityClass RplProp
Used for handling entity spawning requests for SCR_CatalogEntitySpawnerComponent and inherited classe...
m_Delegate
protected SCR_ServicePointDelegateComponent m_Delegate
Definition: SCR_ServicePointComponent.c:23
OnFactionChanged
protected void OnFactionChanged(FactionAffiliationComponent owner, Faction previousFaction, Faction faction)
Event which is triggered when the owning faction changes.
Definition: SCR_ArsenalDisplayComponent.c:41
SetServiceState
void SetServiceState(SCR_EServicePointStatus state)
Set the current operational state of the service.
Definition: SCR_ServicePointComponent.c:79
OnDelete
override void OnDelete(IEntity owner)
Definition: SCR_ServicePointComponent.c:171
SCR_MilitaryBaseSystem
Definition: SCR_MilitaryBaseSystem.c:11
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
ServiceStateChanged
void ServiceStateChanged()
Called from RplProp event.
Definition: SCR_ServicePointComponent.c:90
RADIO_ANTENNA
@ RADIO_ANTENNA
Definition: SCR_ServicePointComponent.c:187
LIGHT_VEHICLE_DEPOT
@ LIGHT_VEHICLE_DEPOT
Definition: SCR_ServicePointComponent.c:183
DELETED
@ DELETED
Definition: SCR_NameTagData.c:24
BARRACKS
@ BARRACKS
Definition: SCR_ServicePointComponent.c:186
SCR_ServicePointComponentClass
Definition: SCR_ServicePointComponent.c:1
HEAVY_VEHICLE_DEPOT
@ HEAVY_VEHICLE_DEPOT
Definition: SCR_ServicePointComponent.c:184
SUPPLY_DEPOT
@ SUPPLY_DEPOT
Definition: SCR_ServicePointComponent.c:191
GetOnServiceStateChanged
ScriptInvoker GetOnServiceStateChanged()
Definition: SCR_ServicePointComponent.c:48
GetFaction
Faction GetFaction()
Definition: SCR_ServicePointComponent.c:27
m_OnServiceStateChanged
protected ref ScriptInvoker m_OnServiceStateChanged
Definition: SCR_ServicePointComponent.c:22
SetDelegate
void SetDelegate(notnull SCR_ServicePointDelegateComponent delegate)
Definition: SCR_ServicePointComponent.c:98
m_eServiceState
protected SCR_EServicePointStatus m_eServiceState
Definition: SCR_ServicePointComponent.c:18
OnPostInit
override void OnPostInit(IEntity owner)
Editable Mine.
Definition: SCR_ServicePointComponent.c:149
m_eBuildingLabel
protected EEditableEntityLabel m_eBuildingLabel
Definition: SCR_ServicePointComponent.c:11
OFFLINE
enum SCR_EServicePointType OFFLINE
ARMORY
@ ARMORY
Definition: SCR_ServicePointComponent.c:182
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
BROKEN
enum SCR_EServicePointType BROKEN
REPAIR_DEPOT
@ REPAIR_DEPOT
Definition: SCR_ServicePointComponent.c:190
RegisterService
void RegisterService()
Definition: SCR_ServicePointComponent.c:115
Faction
Definition: Faction.c:12
m_eType
protected SCR_ECampaignBaseType m_eType
Definition: SCR_CampaignMilitaryBaseComponent.c:59
UNDER_CONSTRUCTION
enum SCR_EServicePointType UNDER_CONSTRUCTION
GetDelegatePrefab
ResourceName GetDelegatePrefab()
Definition: SCR_ServicePointComponent.c:41
m_FactionControl
protected SCR_FactionAffiliationComponent m_FactionControl
Definition: SCR_ServicePointComponent.c:20
FUEL_DEPOT
@ FUEL_DEPOT
Definition: SCR_ServicePointComponent.c:189
GetServiceState
SCR_EServicePointStatus GetServiceState()
Definition: SCR_ServicePointComponent.c:72
SCR_FactionAffiliationComponent
Definition: SCR_FactionAffiliationComponent.c:10
ONLINE
enum SCR_EServicePointType ONLINE
GetLabel
EEditableEntityLabel GetLabel()
Definition: SCR_ServicePointComponent.c:65
SCR_EServicePointType
SCR_EServicePointType
Definition: SCR_ServicePointComponent.c:180
OnBaseUnregistered
override void OnBaseUnregistered(notnull SCR_MilitaryBaseComponent base)
Definition: SCR_ServicePointComponent.c:104
SetServiceOnline
void SetServiceOnline()
Switch service to online status.
Definition: SCR_ServicePointComponent.c:143