Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_RadioCoverageMapDescriptorComponent.c
Go to the documentation of this file.
2{
3 [Attribute("{C35F29E48086221A}Configs/Campaign/CampaignGraphLinesConfig.conf", category: "Lines")]
5
6 //------------------------------------------------------------------------------------------------
11}
12
13class SCR_RadioCoverageMapDescriptorComponent : SCR_MapDescriptorComponent
14{
15 SCR_CoverageRadioComponent m_Radio;
16
17 //------------------------------------------------------------------------------------------------
19 {
20 IEntity owner = Item().Entity();
21
22 if (!owner)
23 return null;
24
26
27 if (!componentData)
28 return null;
29
30 return componentData.GetGraphLinesData();
31 }
32
33 //------------------------------------------------------------------------------------------------
34 void SetParentRadio(SCR_CoverageRadioComponent radio)
35 {
36 m_Radio = radio;
37
38 if (m_Radio)
39 {
42 }
43 else
44 {
48 }
49 }
50
51 //------------------------------------------------------------------------------------------------
52 SCR_CoverageRadioComponent GetParentRadio()
53 {
54 return m_Radio;
55 }
56
57 //------------------------------------------------------------------------------------------------
58 protected void OnMapOpen(MapConfiguration config)
59 {
61 }
62
63 //------------------------------------------------------------------------------------------------
64 protected void OnMapClose(MapConfiguration config)
65 {
67 }
68
69 //------------------------------------------------------------------------------------------------
70 protected void CreateLinks()
71 {
72 MapItem mapItem = Item();
73
74 if (!mapItem)
75 return;
76
77 SCR_Faction playerFaction = SCR_Faction.Cast(SCR_FactionManager.SGetLocalPlayerFaction());
78
79 if (!playerFaction)
80 return;
81
82 string playerFactionEncryption = playerFaction.GetFactionRadioEncryptionKey();
83
84 if (playerFactionEncryption.IsEmpty())
85 return;
86
87 string radioEncryption = m_Radio.GetEncryptionKey();
88 SCR_ERadioCoverageStatus coverage = m_Radio.GetCoverageByEncryption(radioEncryption);
89
90 if (radioEncryption != playerFactionEncryption || coverage == SCR_ERadioCoverageStatus.NONE || coverage == SCR_ERadioCoverageStatus.SEND)
91 return;
92
93 array<SCR_CoverageRadioComponent> radios = {};
94 m_Radio.GetRadiosInRange(radios);
95
96 SCR_RadioCoverageMapDescriptorComponent target;
97 MapItem targetItem;
98 array<MapLink> targetLinks = {};
99 MapLink link;
100
101 foreach (SCR_CoverageRadioComponent radio : radios)
102 {
103 target = SCR_RadioCoverageMapDescriptorComponent.Cast(radio.GetOwner().FindComponent(SCR_RadioCoverageMapDescriptorComponent));
104
105 if (!target)
106 continue;
107
108 targetItem = target.Item();
109
110 if (!targetItem || !targetItem.IsVisible())
111 continue;
112
113 bool linked;
114 targetLinks.Clear();
115 targetItem.GetLinks(targetLinks);
116
117 // Don't create two links between the same bases
118 foreach (MapLink targetLink : targetLinks)
119 {
120 if (targetLink.Target() == mapItem)
121 {
122 linked = true;
123 break;
124 }
125 }
126
127 if (linked)
128 continue;
129
130 link = mapItem.LinkTo(targetItem);
131 ColorMapLink(link, false);
132 }
133 }
134
135 //------------------------------------------------------------------------------------------------
136 protected void DeleteLinks()
137 {
138 MapItem mapItem = Item();
139
140 if (!mapItem)
141 return;
142
143 mapItem.ClearLinks();
144 }
145
146 //------------------------------------------------------------------------------------------------
148 {
149 DeleteLinks();
150 CreateLinks();
151 }
152
153 //------------------------------------------------------------------------------------------------
154 void OnIconHovered(bool hovering)
155 {
156 MapItem mapItem = Item();
157
158 if (!mapItem)
159 return;
160
161 array<MapLink> links = {};
162 mapItem.GetLinks(links);
163
164 // Add links saved in neighboring components so we can potentially highlight them as well
165 array<SCR_CoverageRadioComponent> radiosInRange = {};
166 m_Radio.GetRadiosInRange(radiosInRange);
167
168 SCR_RadioCoverageMapDescriptorComponent comp;
169 MapItem otherMapItem;
170 array<MapLink> otherLinks = {};
171
172 foreach (SCR_CoverageRadioComponent radioInRange : radiosInRange)
173 {
174 comp = SCR_RadioCoverageMapDescriptorComponent.Cast(radioInRange.GetOwner().FindComponent(SCR_RadioCoverageMapDescriptorComponent));
175
176 if (!comp)
177 continue;
178
179 otherMapItem = comp.Item();
180
181 otherLinks.Clear();
182 otherMapItem.GetLinks(otherLinks);
183
184 foreach (MapLink otherLink : otherLinks)
185 {
186 if (otherLink.Target() == mapItem)
187 links.Insert(otherLink);
188 }
189 }
190
191 foreach (MapLink link : links)
192 {
193 if (!link)
194 continue;
195
196 ColorMapLink(link, hovering);
197 }
198 }
199
200 //------------------------------------------------------------------------------------------------
201 protected void ColorMapLink(notnull MapLink link, bool isHovering)
202 {
203 MapLinkProps props = link.GetMapLinkProps();
204
205 if (!props)
206 return;
207
209
210 if (!linesData)
211 return;
212
213 props.SetLineWidth(linesData.GetLineWidth());
214
215 Color c = Color.FromInt(props.GetLineColor().PackToInt());
216
217 if (!c)
218 return;
219
220 if (isHovering)
221 c.SetA(linesData.GetHighlightedAlpha());
222 else
223 c.SetA(linesData.GetDefaultAlpha());
224
225 props.SetLineColor(c);
226 }
227}
void OnMapClose(MapConfiguration config)
void OnMapOpen(MapConfiguration config)
SCR_CharacterSoundComponentClass GetComponentData()
void SCR_FactionManager(IEntitySource src, IEntity parent)
SCR_RadioCoverageMapDescriptorComponentClass m_Radio
void OnIconHovered(bool hovering)
SCR_GraphLinesData GetGraphLinesData()
void ColorMapLink(notnull MapLink link, bool isHovering)
void SetParentRadio(SCR_CoverageRadioComponent radio)
SCR_CoverageRadioComponent GetParentRadio()
Definition Color.c:13
static ScriptInvokerBase< MapConfigurationInvoker > GetOnMapClose()
Get on map close invoker.
static ScriptInvokerBase< MapConfigurationInvoker > GetOnMapOpen()
Get on map open invoker.
SCR_FieldOfViewSettings Attribute