13 int m_iRequesterID = -1;
16 static const string TASK_REQUEST_TRANSMITTED_TEXT =
"#AR-Tasks_StatusTransmitted-UC";
17 static const string TASK_SUPPORT_CANCELLED_TEXT =
"#AR-Tasks_StatusCancelled-UC";
18 protected static const string LOCAL_PLAYER_REQUEST =
"#AR-Tasks_TitleRequest";
21 protected override void ShowAvailableTask(
bool afterAssigneeRemoved =
false)
24 if (localExecutor == m_Requester)
26 if (!afterAssigneeRemoved)
34 localPlayerFaction = factionManager.GetLocalPlayerFaction();
36 if (localPlayerFaction == GetTargetFaction())
41 protected bool IsLocallyRequestedTask()
50 return this == supportEntity.GetLocallyRequestedTask();
54 override void SetTitleWidgetText(notnull TextWidget textWidget,
string taskText)
56 if (IsLocallyRequestedTask())
62 textWidget.SetTextFormat(taskText, m_Requester.GetPlayerName());
66 override string GetTitleText()
68 if (IsLocallyRequestedTask())
72 return string.Format(
"%1 %2",
m_sName, m_Requester.GetPlayerName());
78 override Widget GenerateTaskDescriptionUI(notnull Widget rootWidget, array<Widget> widgets)
80 Widget w = super.GenerateTaskDescriptionUI(rootWidget, widgets);
82 if (IsLocallyRequestedTask())
84 Widget description = w.FindAnyWidget(
"TaskDescription");
91 override void DoNotifyAssignment(
int assigneeID)
93 SCR_CampaignNetworkComponent assigneeNetworkComponent = SCR_CampaignNetworkComponent.GetCampaignNetworkComponent(assigneeID);
95 if (assigneeNetworkComponent)
96 assigneeNetworkComponent.SendPlayerMessage(GetAssignMessage(), calledID: m_iRequesterID);
100 override void DoNotifyUnassign(
int assigneeID)
102 SCR_CampaignNetworkComponent assigneeNetworkComponent = SCR_CampaignNetworkComponent.GetCampaignNetworkComponent(assigneeID);
104 if (assigneeNetworkComponent)
105 assigneeNetworkComponent.SendPlayerMessage(GetUnassignMessage(), calledID: m_iRequesterID);
109 override void SetDescriptionWidgetText(notnull TextWidget textWidget,
string taskText)
111 textWidget.SetTextFormat(taskText, GetRequesterName());
115 override string GetTaskListTaskText()
117 if (IsLocallyRequestedTask())
118 return LOCAL_PLAYER_REQUEST;
120 return super.GetTaskListTaskText();
124 override void Cancel(
bool showMsg =
true)
127 if (localExecutor == m_Requester || localExecutor == GetAssignee())
137 override void Fail(
bool showMsg =
true)
141 if (localExecutor == GetAssignee())
146 if (localExecutor.GetTaskExecutorID(localExecutor) == m_iRequesterID)
151 if (localExecutor == m_Requester)
160 override void Finish(
bool showMsg =
true)
168 if (localExecutor && (localExecutor == GetRequester() || localExecutor == assignee))
177 SCR_XPHandlerComponent comp = SCR_XPHandlerComponent.Cast(
GetGame().
GetGameMode().FindComponent(SCR_XPHandlerComponent));
182 super.Finish(showMsg);
190 if (!taskManager || taskManager.IsProxy())
197 supportEntity.FailTask(
this);
207 string GetRequesterName()
209 return GetGame().GetPlayerManager().GetPlayerName(m_iRequesterID);
213 void OnEntityDeath(IEntity killedEntity)
217 if (killedEntity == m_Requester.GetControlledEntity())
222 void SetRequesterID(
int requesterID)
224 m_iRequesterID = requesterID;
225 SetEventMask(EntityEvent.FRAME);
229 bool AutoSetRequester()
231 if (m_iRequesterID == -1)
237 SetRequester(requester);
253 if (localExecutor == m_Requester)
259 return super.CanBeAssigned(reason, playerID);
275 m_Requester = requester;
278 IEntity requesterEntity = requester.GetControlledEntity();
279 if (!requesterEntity)
283 if (!characterControllerComponent)
286 characterControllerComponent.GetOnPlayerDeath().Insert(RequesterDied);
289 if (localTaskExecutor == requester)
290 supportEntity.SetLocallyRequestedTask(
this);
292 FactionAffiliationComponent factionAffiliationComponent = FactionAffiliationComponent.Cast(requesterEntity.FindComponent(FactionAffiliationComponent));
293 if (factionAffiliationComponent)
298 override void EOnFrame(IEntity owner,
float timeSlice)
305 override void Deserialize(ScriptBitReader reader)
307 super.Deserialize(reader);
310 reader.ReadInt(requesterID);
311 SetRequesterID(requesterID);
315 override void Serialize(ScriptBitWriter writer)
317 super.Serialize(writer);
319 writer.WriteInt(m_iRequesterID);
323 override void EOnInit(IEntity owner)
325 super.EOnInit(owner);
334 SetEventMask(EntityEvent.FRAME);