1 [
EntityEditorProps(
category:
"GameScripted/Tasks", description:
"This this entity to receive and complete tasks.", color:
"0 0 255 255")]
10 static const int INVALID_PLAYER_ID = -1;
11 protected static ref map<SCR_BaseTaskExecutor, int> s_mTaskExecutors =
new map<SCR_BaseTaskExecutor, int>();
25 static map<SCR_BaseTaskExecutor, int> GetTaskExecutorsMap()
27 return s_mTaskExecutors;
36 return s_mTaskExecutors.Get(taskExecutor);
40 static int GetLocalExecutorID()
42 return GetTaskExecutorID(GetLocalExecutor());
49 if (s_LocalTaskExecutor)
50 return s_LocalTaskExecutor;
52 PlayerController playerController =
GetGame().GetPlayerController();
53 if (!playerController)
56 int playerID = playerController.GetPlayerId();
70 return s_mTaskExecutors.GetKeyByValue(playerID);
92 IEntity GetControlledEntity()
94 return SCR_PossessingManagerComponent.GetPlayerMainEntity(s_mTaskExecutors.Get(
this));
101 return m_CurrentTask;
106 string GetPlayerName()
108 return GetGame().GetPlayerManager().GetPlayerName(GetTaskExecutorID(
this));
113 void SetPlayerID(
int playerID)
118 s_mTaskExecutors.Set(
this, playerID);
125 if (task == m_CurrentTask)
128 OnNewTaskAssigned(m_CurrentTask, task);
129 m_CurrentTask = task;
138 void OnAssignedTaskRemoved()
140 m_CurrentTask =
null;
145 void OnAssignedTaskFailed()
147 m_CurrentTask =
null;
152 void OnAssignedTaskFinished()
154 m_CurrentTask =
null;
175 if (s_mTaskExecutors)
182 if (s_mTaskExecutors)
183 s_mTaskExecutors.Remove(
this);