/* EQEmu: EQEmulator
Copyright (C) 2001-2026 EQEmu Development Team
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
#pragma once
#include "common/repositories/character_tasks_repository.h"
#include "common/types.h"
#include "zone/task_client_state.h"
#include "zone/tasks.h"
#include
#include
#include
#include
class Client;
class Mob;
class SharedTaskRequest;
class TaskManager {
public:
int GetActivityCount(int task_id);
bool LoadTasks(int single_task = 0);
bool LoadTaskSets();
bool LoadClientState(Client *client, ClientTaskState *cts);
bool SaveClientState(Client *client, ClientTaskState *cts);
void SendTaskSelector(Client* client, Mob* mob, const std::vector& tasks);
bool ValidateLevel(int task_id, int player_level);
std::string GetTaskName(uint32 task_id);
TaskType GetTaskType(uint32 task_id);
void TaskSetSelector(Client* client, Mob* mob, int task_set_id, bool ignore_cooldown);
// task list provided by QuestManager (perl/lua)
void TaskQuestSetSelector(Client* client, Mob* mob, const std::vector& tasks, bool ignore_cooldown);
void SharedTaskSelector(Client* client, Mob* mob, const std::vector& tasks, bool ignore_cooldown);
void SendActiveTasksToClient(Client *client, bool task_complete = false);
void SendSingleActiveTaskToClient(
Client *client,
ClientTaskInformation &task_info,
bool task_complete,
bool bring_up_task_journal = false
);
void SendTaskActivityShort(Client *client, int task_id, int activity_id, int client_task_index);
void SendTaskActivityLong(
Client *client,
int task_id,
int activity_id,
int client_task_index,
bool task_complete = false
);
void SendCompletedTasksToClient(Client *c, ClientTaskState *cts);
int FirstTaskInSet(int task_set);
int LastTaskInSet(int task_set);
int NextTaskInSet(int task_set, int task_id);
bool IsTaskRepeatable(int task_id);
bool IsActiveTaskComplete(ClientTaskInformation& client_task);
int GetCurrentDzTaskID();
void EndCurrentDzTask(bool send_fail);
void EndSharedTask(Client& client, int task_id, bool send_fail);
void EndSharedTask(uint32_t dz_id, bool send_fail);
friend class ClientTaskState;
// shared tasks
void SyncClientSharedTaskState(Client *c, ClientTaskState *cts);
void HandleUpdateTasksOnKill(Client* client, NPC* npc);
const std::unordered_map& GetTaskData() const { return m_task_data; }
TaskInformation* GetTaskData(int task_id)
{
auto it = m_task_data.find(task_id);
return it != m_task_data.end() ? &it->second : nullptr;
}
static TaskManager* Instance()
{
static TaskManager instance;
return &instance;
}
private:
std::vector m_task_sets[MAXTASKSETS];
std::unordered_map m_task_data;
void SendActiveTaskDescription(
Client *client,
int task_id,
ClientTaskInformation &task_info,
int start_time,
int duration,
bool bring_up_task_journal = false
);
void SendActiveTaskToClient(ClientTaskInformation *task, Client *client, int task_index, bool task_complete);
// shared tasks
bool CanOfferSharedTask(int task_id, const SharedTaskRequest& request);
void SyncClientSharedTaskWithPersistedState(Client *c, ClientTaskState *cts);
void SyncClientSharedTaskRemoveLocalIfNotExists(Client *c, ClientTaskState *cts);
void SendSharedTaskSelector(Client* client, Mob* mob, const std::vector& tasks);
void SyncClientSharedTaskStateToLocal(Client *c);
};