Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_CampaignBuildingSupplyEditorUIComponent.c
Go to the documentation of this file.
1
class
SCR_CampaignBuildingSupplyEditorUIComponent
:
SCR_BaseEditorUIComponent
2
{
3
protected
SCR_FactionAffiliationComponent
m_FactionComponent
;
4
protected
TextWidget
m_ProviderName
;
5
protected
TextWidget
m_ProviderCallsign
;
6
protected
Widget
m_wInGameSupply
;
7
protected
TextWidget
m_ProviderSupplyCurrent
;
8
protected
TextWidget
m_ProviderSupplyMax
;
9
protected
OverlayWidget
m_ProviderIcon
;
10
11
protected
SCR_ResourceComponent
m_ResourceComponent
;
12
protected
SCR_ResourceConsumer
m_ResourceConsumer
;
13
protected
ref
SCR_ResourceSystemSubscriptionHandleBase
m_ResourceSubscriptionHandleConsumer
;
14
protected
RplId
m_ResourceInventoryPlayerComponentRplId
;
15
16
//------------------------------------------------------------------------------------------------
17
override
void
HandlerAttached
(
Widget
w)
18
{
19
super.HandlerAttached(w);
20
m_ProviderName
=
TextWidget
.Cast(w.FindAnyWidget(
"Provider_Name"
));
21
m_ProviderCallsign
=
TextWidget
.Cast(w.FindAnyWidget(
"Provider_Callsign"
));
22
m_ProviderSupplyCurrent
=
TextWidget
.Cast(w.FindAnyWidget(
"Supply_Value_Current"
));
23
m_wInGameSupply
= w.FindAnyWidget(
"Supply_InGame_Supply"
);
24
m_ProviderSupplyMax
=
TextWidget
.Cast(w.FindAnyWidget(
"Supply_Value_Max"
));
25
m_ProviderIcon
=
OverlayWidget
.Cast(w.FindAnyWidget(
"Provider_Icon_Overlay"
));
26
27
SCR_CampaignBuildingEditorComponent buildingEditorComponent = SCR_CampaignBuildingEditorComponent.Cast(SCR_CampaignBuildingEditorComponent.GetInstance(SCR_CampaignBuildingEditorComponent));
28
if
(!buildingEditorComponent)
29
return
;
30
31
IEntity
targetEntity = buildingEditorComponent.GetProviderEntity();
32
if
(!targetEntity)
33
return
;
34
35
m_FactionComponent
= buildingEditorComponent.GetProviderFactionComponent();
36
if
(!
m_FactionComponent
)
37
return
;
38
39
SetSourceIcon
(targetEntity);
40
SetProviderName
(targetEntity);
41
42
if
(!buildingEditorComponent.GetProviderResourceComponent(
m_ResourceComponent
))
43
return
;
44
45
if
(!
m_ResourceComponent
|| !
m_ResourceComponent
.GetConsumer(
EResourceGeneratorID
.DEFAULT,
EResourceType
.SUPPLIES,
m_ResourceConsumer
))
46
return
;
47
48
m_ResourceInventoryPlayerComponentRplId
=
Replication
.FindItemId(
SCR_ResourcePlayerControllerInventoryComponent
.Cast(
GetGame
().
GetPlayerController
().FindComponent(
SCR_ResourcePlayerControllerInventoryComponent
)));
49
m_ResourceSubscriptionHandleConsumer
=
GetGame
().GetResourceSystemSubscriptionManager().RequestSubscriptionListenerHandle(
m_ResourceConsumer
,
m_ResourceInventoryPlayerComponentRplId
);
50
51
m_ResourceComponent
.TEMP_GetOnInteractorReplicated().Insert(
UpdateResources
);
52
// Update once at the beginning and then every time the supply value has changed.
53
UpdateResources
();
54
}
55
56
//------------------------------------------------------------------------------------------------
57
override
void
HandlerDeattached
(
Widget
w)
58
{
59
super.HandlerDeattached(w);
60
61
if
(
m_ResourceComponent
)
62
m_ResourceComponent
.TEMP_GetOnInteractorReplicated().Remove(
UpdateResources
);
63
64
m_ResourceSubscriptionHandleConsumer
= null;
65
}
66
67
//------------------------------------------------------------------------------------------------
68
protected
void
SetSourceIcon
(
IEntity
targetEntity)
69
{
70
if
(!
m_ProviderIcon
)
71
return
;
72
73
SCR_GameModeCampaign
campaign =
SCR_GameModeCampaign
.GetInstance();
74
75
if
(!campaign)
76
return
;
77
78
Color
factionColor;
79
// We need to check both here, as vehicle has not set AffiliatedFaction if it is empty, to prevent AI to shoot at the empty vehicle.
80
Faction
faction =
m_FactionComponent
.GetAffiliatedFaction();
81
if
(!faction)
82
faction =
m_FactionComponent
.GetDefaultAffiliatedFaction();
83
84
if
(faction)
85
factionColor =
GetColorForFaction
(faction.GetFactionKey());
86
87
//This marker thing should be converted into more sandbox solution later.
88
SCR_MilitarySymbolUIComponent
m_SymbolUI
=
SCR_MilitarySymbolUIComponent
.Cast(
m_ProviderIcon
.FindHandler(
SCR_MilitarySymbolUIComponent
));
89
SCR_MilitarySymbol
baseIcon =
new
SCR_MilitarySymbol
();
90
91
switch
(faction.GetFactionKey())
92
{
93
case
campaign.GetFactionKeyByEnum(
SCR_ECampaignFaction
.INDFOR):
94
{
95
baseIcon.
SetIdentity
(
EMilitarySymbolIdentity
.INDFOR);
96
break
;
97
}
98
99
case
campaign.GetFactionKeyByEnum(
SCR_ECampaignFaction
.OPFOR):
100
{
101
baseIcon.
SetIdentity
(
EMilitarySymbolIdentity
.OPFOR);
102
break
;
103
}
104
105
case
campaign.GetFactionKeyByEnum(
SCR_ECampaignFaction
.BLUFOR):
106
{
107
baseIcon.
SetIdentity
(
EMilitarySymbolIdentity
.BLUFOR);
108
break
;
109
}
110
111
case
"Unknown"
:
112
{
113
baseIcon.
SetIdentity
(
EMilitarySymbolIdentity
.UNKNOWN);
114
break
;
115
}
116
}
117
118
if
(
Vehicle
.Cast(
m_FactionComponent
.GetOwner()))
119
baseIcon.
SetIcons
(
EMilitarySymbolIcon
.MOTORIZED);
120
121
baseIcon.
SetDimension
(2);
122
m_ProviderIcon
.SetColor(factionColor);
123
m_SymbolUI
.Update(baseIcon);
124
}
125
126
//------------------------------------------------------------------------------
127
protected
Color
GetColorForFaction
(
string
factionKey)
128
{
129
FactionManager fm =
GetGame
().GetFactionManager();
130
if
(!fm)
131
return
null;
132
133
Faction
faction = fm.GetFactionByKey(factionKey);
134
if
(!faction)
135
return
null;
136
137
return
faction.GetFactionColor();
138
}
139
140
//------------------------------------------------------------------------------------------------
141
protected
void
UpdateResources
()
142
{
143
if
(!
m_ResourceComponent
)
144
return
;
145
146
SCR_ResourceConsumer consumer =
m_ResourceComponent
.GetConsumer(
EResourceGeneratorID
.DEFAULT,
EResourceType
.SUPPLIES);
147
148
if
(!consumer)
149
return
;
150
151
if
(
m_ProviderSupplyCurrent
)
152
m_ProviderSupplyCurrent
.SetText(consumer.GetAggregatedResourceValue().ToString());
153
154
if
(
m_ProviderSupplyMax
)
155
m_ProviderSupplyMax
.SetText(consumer.GetAggregatedMaxResourceValue().ToString());
156
157
// Visualize supply state
158
if
(consumer.GetAggregatedResourceValue() == 0)
159
m_wInGameSupply
.SetColor(
UIColors
.WARNING);
160
else
161
m_wInGameSupply
.SetColor(
Color
.FromInt(
Color
.WHITE));
162
}
163
164
//------------------------------------------------------------------------------------------------
165
[
Obsolete
(
"SCR_CampaignBuildingSupplyEditorUIComponent.UpdateResources() should be used instead."
)]
166
protected
void
UpdateSupply
()
167
{
168
if
(!
m_ResourceComponent
)
169
return
;
170
171
SCR_ResourceConsumer consumer =
m_ResourceComponent
.GetConsumer(
EResourceGeneratorID
.DEFAULT,
EResourceType
.SUPPLIES);
172
if
(!consumer)
173
return
;
174
175
if
(
m_ProviderSupplyCurrent
)
176
m_ProviderSupplyCurrent
.SetText(consumer.GetAggregatedResourceValue().ToString());
177
178
if
(
m_ProviderSupplyMax
)
179
m_ProviderSupplyMax
.SetText(consumer.GetAggregatedMaxResourceValue().ToString());
180
181
// Visualize supply state
182
if
(consumer.GetAggregatedResourceValue() == 0)
183
m_wInGameSupply
.SetColor(
UIColors
.WARNING);
184
else
185
m_wInGameSupply
.SetColor(
Color
.FromInt(
Color
.WHITE));
186
}
187
188
//------------------------------------------------------------------------------------------------
189
protected
void
SetProviderName
(
IEntity
targetEntity)
190
{
191
SCR_CampaignBuildingProviderComponent providerComponent = SCR_CampaignBuildingProviderComponent.Cast(targetEntity.
FindComponent
(SCR_CampaignBuildingProviderComponent));
192
if
(!providerComponent)
193
return
;
194
195
string
providerName = providerComponent.GetProviderDisplayName();
196
string
callsignName;
197
198
// Campaign behavior
199
SCR_GameModeCampaign
campaign =
SCR_GameModeCampaign
.GetInstance();
200
if
(campaign)
201
{
202
SCR_CampaignMilitaryBaseComponent
targetBase = providerComponent.GetCampaignMilitaryBaseComponent();
203
if
(targetBase)
204
{
205
callsignName = targetBase.GetCallsignDisplayName();
206
providerName = targetBase.
GetBaseName
();
207
}
208
}
209
else
210
{
211
SCR_MilitaryBaseComponent targetBase = providerComponent.GetMilitaryBaseComponent();
212
if
(targetBase)
213
callsignName = targetBase.GetCallsignDisplayName();
214
}
215
216
m_ProviderCallsign
.SetText(callsignName);
217
m_ProviderName
.SetText(providerName);
218
}
219
}
EMilitarySymbolIdentity
EMilitarySymbolIdentity
Definition
EMilitarySymbol.c:2
EMilitarySymbolIcon
EMilitarySymbolIcon
Definition
EMilitarySymbol.c:30
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
SCR_ECampaignFaction
SCR_ECampaignFaction
Definition
SCR_CampaignFactionManager.c:134
SCR_GameModeCampaign
void SCR_GameModeCampaign(IEntitySource src, IEntity parent)
Definition
SCR_GameModeCampaign.c:1812
m_SymbolUI
SCR_MilitarySymbolUIComponent m_SymbolUI
Definition
SCR_GroupEditableEntityUIComponent.c:6
EResourceType
EResourceType
Definition
SCR_ResourceContainer.c:2
EResourceGeneratorID
EResourceGeneratorID
Definition
SCR_ResourceGenerator.c:2
Color
Definition
Color.c:13
Faction
Definition
Faction.c:13
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
OverlayWidget
Definition
OverlayWidget.c:16
Replication
Main replication API.
Definition
Replication.c:14
RplId
Replication item identifier.
Definition
RplId.c:14
SCR_BaseEditorUIComponent
Definition
SCR_BaseEditorUIComponent.c:4
SCR_CampaignBuildingSupplyEditorUIComponent
Definition
SCR_CampaignBuildingSupplyEditorUIComponent.c:2
SCR_CampaignBuildingSupplyEditorUIComponent::SetSourceIcon
void SetSourceIcon(IEntity targetEntity)
Definition
SCR_CampaignBuildingSupplyEditorUIComponent.c:68
SCR_CampaignBuildingSupplyEditorUIComponent::UpdateSupply
void UpdateSupply()
Definition
SCR_CampaignBuildingSupplyEditorUIComponent.c:166
SCR_CampaignBuildingSupplyEditorUIComponent::m_ResourceSubscriptionHandleConsumer
ref SCR_ResourceSystemSubscriptionHandleBase m_ResourceSubscriptionHandleConsumer
Definition
SCR_CampaignBuildingSupplyEditorUIComponent.c:13
SCR_CampaignBuildingSupplyEditorUIComponent::GetColorForFaction
Color GetColorForFaction(string factionKey)
Definition
SCR_CampaignBuildingSupplyEditorUIComponent.c:127
SCR_CampaignBuildingSupplyEditorUIComponent::m_ResourceComponent
SCR_ResourceComponent m_ResourceComponent
Definition
SCR_CampaignBuildingSupplyEditorUIComponent.c:11
SCR_CampaignBuildingSupplyEditorUIComponent::m_ProviderCallsign
TextWidget m_ProviderCallsign
Definition
SCR_CampaignBuildingSupplyEditorUIComponent.c:5
SCR_CampaignBuildingSupplyEditorUIComponent::m_ResourceInventoryPlayerComponentRplId
RplId m_ResourceInventoryPlayerComponentRplId
Definition
SCR_CampaignBuildingSupplyEditorUIComponent.c:14
SCR_CampaignBuildingSupplyEditorUIComponent::m_ProviderSupplyCurrent
TextWidget m_ProviderSupplyCurrent
Definition
SCR_CampaignBuildingSupplyEditorUIComponent.c:7
SCR_CampaignBuildingSupplyEditorUIComponent::m_ResourceConsumer
SCR_ResourceConsumer m_ResourceConsumer
Definition
SCR_CampaignBuildingSupplyEditorUIComponent.c:12
SCR_CampaignBuildingSupplyEditorUIComponent::HandlerDeattached
override void HandlerDeattached(Widget w)
Definition
SCR_CampaignBuildingSupplyEditorUIComponent.c:57
SCR_CampaignBuildingSupplyEditorUIComponent::m_ProviderIcon
OverlayWidget m_ProviderIcon
Definition
SCR_CampaignBuildingSupplyEditorUIComponent.c:9
SCR_CampaignBuildingSupplyEditorUIComponent::m_ProviderName
TextWidget m_ProviderName
Definition
SCR_CampaignBuildingSupplyEditorUIComponent.c:4
SCR_CampaignBuildingSupplyEditorUIComponent::m_ProviderSupplyMax
TextWidget m_ProviderSupplyMax
Definition
SCR_CampaignBuildingSupplyEditorUIComponent.c:8
SCR_CampaignBuildingSupplyEditorUIComponent::m_FactionComponent
SCR_FactionAffiliationComponent m_FactionComponent
Definition
SCR_CampaignBuildingSupplyEditorUIComponent.c:3
SCR_CampaignBuildingSupplyEditorUIComponent::m_wInGameSupply
Widget m_wInGameSupply
Definition
SCR_CampaignBuildingSupplyEditorUIComponent.c:6
SCR_CampaignBuildingSupplyEditorUIComponent::UpdateResources
void UpdateResources()
Definition
SCR_CampaignBuildingSupplyEditorUIComponent.c:141
SCR_CampaignBuildingSupplyEditorUIComponent::SetProviderName
void SetProviderName(IEntity targetEntity)
Definition
SCR_CampaignBuildingSupplyEditorUIComponent.c:189
SCR_CampaignBuildingSupplyEditorUIComponent::HandlerAttached
override void HandlerAttached(Widget w)
Definition
SCR_CampaignBuildingSupplyEditorUIComponent.c:17
SCR_CampaignMilitaryBaseComponent
Definition
SCR_CampaignMilitaryBaseComponent.c:38
SCR_CampaignMilitaryBaseComponent::GetBaseName
string GetBaseName()
Returns the name of this base.
Definition
SCR_CampaignMilitaryBaseComponent.c:2197
SCR_FactionAffiliationComponent
Definition
SCR_FactionAffiliationComponent.c:11
SCR_MilitarySymbol
Definition
SCR_MilitarySymbol.c:3
SCR_MilitarySymbol::SetDimension
void SetDimension(EMilitarySymbolDimension dimension)
Definition
SCR_MilitarySymbol.c:44
SCR_MilitarySymbol::SetIcons
void SetIcons(EMilitarySymbolIcon icons)
Definition
SCR_MilitarySymbol.c:60
SCR_MilitarySymbol::SetIdentity
void SetIdentity(EMilitarySymbolIdentity identity)
Definition
SCR_MilitarySymbol.c:28
SCR_MilitarySymbolUIComponent
Definition
SCR_MilitarySymbolUIComponent.c:2
SCR_ResourcePlayerControllerInventoryComponent
Definition
SCR_ResourcePlayerControllerInventoryComponent.c:25
SCR_ResourceSystemSubscriptionHandleBase
Definition
SCR_ResourceSystemSubscriptionHandleBase.c:2
TextWidget
Definition
TextWidget.c:16
UIColors
Definition
Constants.c:17
Widget
Definition
Widget.c:13
Vehicle
enum EPhysicsLayerPresets Vehicle
Definition
gameLib.c:24
Obsolete
typedef Obsolete
Definition
HelicopterAutopilotHelperComponent.c:16
GetPlayerController
proto external PlayerController GetPlayerController()
Definition
SCR_PlayerDeployMenuHandlerComponent.c:307
scripts
Game
Editor
UI
Components
Common
SCR_CampaignBuildingSupplyEditorUIComponent.c
Generated by
1.17.0