9 static const string CAMPAIGN_TASK_RECONFIGURED_TEXT =
"#AR-CampaignTasks_Reconfigured-UC";
10 static const string CAMPAIGN_TASK_RECONFIGURED_BY_TEXT =
"#AR-CampaignTasks_ReconfiguredBy-UC";
16 [
Attribute(defvalue:
"Task title for reconfigure.",
desc:
"The task title visible to the player.")]
17 protected string m_sNameReconfigure;
18 [
Attribute(defvalue:
"Task description.",
desc:
"The task description visible to the player.")]
19 protected string m_sDescriptionReconfigure;
21 protected string m_sAffix;
34 protected override bool DoneByAssignee()
37 if (assignee && m_TargetBase)
40 int reconfigurerID = m_TargetBase.GetReconfiguredByID();
41 if (assigneeID == reconfigurerID)
50 protected override void ShowAvailableTask(
bool afterAssigneeRemoved =
false)
53 if (CanBeAssigned(reason))
58 string text = TASK_AVAILABLE_TEXT +
" " + GetTitle();
62 baseName = GetBaseNameWithCallsign();
70 override protected void ShowTaskProgress(
bool showMsg =
true)
73 if (campaign && showMsg)
78 baseName = GetBaseNameWithCallsign();
89 override string GetIconSuffix()
98 override void DoNotifyAssignment(
int assigneeID)
103 SCR_CampaignNetworkComponent assigneeNetworkComponent = SCR_CampaignNetworkComponent.GetCampaignNetworkComponent(assigneeID);
104 if (!assigneeNetworkComponent)
107 assigneeNetworkComponent.SendPlayerMessage(GetAssignMessage(), m_TargetBase.GetCallsign());
112 override string GetTitle()
115 return m_sNameReconfigure;
121 override void SetIsPriority(
bool isPrio)
123 super.SetIsPriority(isPrio);
126 m_sAffix =
"<br/><br/>#AR-Campaign_PriorityTaskInfo";
128 m_sAffix =
string.Empty;
135 override string GetDescription()
138 return m_sDescriptionReconfigure + m_sAffix;
144 override void Finish(
bool showMsg =
true)
147 super.Finish(showMsg);
149 SCR_XPHandlerComponent comp = SCR_XPHandlerComponent.Cast(
GetGame().
GetGameMode().FindComponent(SCR_XPHandlerComponent));
155 array<int> players = {};
156 playerManager.GetPlayers(players);
157 array<SCR_BaseTaskExecutor> assignees = {};
158 GetAssignees(assignees);
159 vector baseOrigin = m_TargetBase.GetOwner().GetOrigin();
160 int radius = m_TargetBase.GetRadius();
163 IEntity playerEntity;
176 radiusSq = radius * radius;
178 foreach (
int playerId : players)
180 playerEntity = playerManager.GetPlayerControlledEntity(playerId);
190 if (vector.DistanceSq(playerEntity.GetOrigin(), baseOrigin) < radiusSq)
198 if (assigneeID == playerId)
205 float multiplier = 1.0;
210 comp.AwardXP(playerId, rewardID, multiplier, isAssignee);
218 baseName = GetBaseNameWithCallsign();
223 if (m_bIndividualTask)
225 if (IsAssignedToLocalPlayer())
227 if (DoneByAssignee())
238 if (m_aAssignees && m_aAssignees.Count() > 0)
246 GetFinishTextData(text, par1, par2, par3, par4, par5);
260 override void Fail(
bool showMsg =
true)
279 override string GetFinishText()
289 if (m_bIndividualTask && DoneByAssignee())
290 text =
string.Format(CAMPAIGN_TASK_RECONFIGURED_BY_TEXT, GetBaseNameWithCallsign(), GetAllAssigneeNamesString());
292 text =
string.Format(CAMPAIGN_TASK_RECONFIGURED_TEXT, GetBaseNameWithCallsign());
303 void GetFinishTextData(out
string text =
"", out
string param1 =
"", out
string param2 =
"", out
string param3 =
"", out
string param4 =
"", out
string param5 =
"")
310 if (m_bIndividualTask && DoneByAssignee())
312 text = CAMPAIGN_TASK_RECONFIGURED_BY_TEXT;
313 param1 = GetBaseNameWithCallsign();
314 param2 = GetAllAssigneeNamesString();
318 text = CAMPAIGN_TASK_RECONFIGURED_TEXT;
319 param1 = GetBaseNameWithCallsign();
328 override string GetMapDescriptorText()
330 return GetTaskListTaskText();
338 override void SetTitleWidgetText(notnull TextWidget textWidget,
string taskText)
343 baseName = GetBaseNameWithCallsign();
345 textWidget.SetTextFormat(taskText, baseName);
349 override string GetTitleText()
354 baseName = GetBaseNameWithCallsign();
356 return string.Format(
"%1 %2",
m_sName, baseName);
360 override void SetDescriptionWidgetText(notnull TextWidget textWidget,
string taskText)
365 baseName = GetBaseNameWithCallsign();
367 textWidget.SetTextFormat(taskText, baseName);
389 override void Deserialize(ScriptBitReader reader)
391 super.Deserialize(reader);
399 override void Serialize(ScriptBitWriter writer)
401 super.Serialize(writer);
409 super.SetTargetBase(targetBase);
414 void OnTargetBaseCaptured(SCR_MilitaryBaseComponent base,
Faction faction)
427 supportEntity.FinishTask(
this);
449 if (!m_TargetBase.IsHQRadioTrafficPossible(castFaction))
450 supportEntity.FailTask(
this);
461 SCR_GameModeCampaign.GetInstance().GetBaseManager().GetOnSignalChanged().Insert(OnCampaignBaseSignalChanged);
478 system.GetOnBaseFactionChanged().Remove(OnTargetBaseCaptured);
484 campaign.GetBaseManager().GetOnSignalChanged().Remove(OnCampaignBaseSignalChanged);