Files
test/Assets/Scripts/Task/CECTaskInterface.cs
T
2025-10-01 15:12:40 +07:00

168 lines
7.0 KiB
C#

using BrewMonster.Network;
using System.Collections.Generic;
using UnityEngine;
namespace PerfectWorld.Scripts.Task
{
public class CECTaskInterface : TaskInterface
{
public const int TASK_MAX_DELIVER_COUNT = 5;
public const int TASK_STORAGE_COUNT = 32;
public const int TASK_STORAGE_LEN = 10;
public const float TASK_STORAGE_WHELL_SCALE = 10000;
public const int TASK_ACTIVE_LIST_HEADER_LEN = 8;
public const int TASK_ACTIVE_LIST_MAX_LEN = 175;
public const int TASK_FINISHED_LIST_MAX_LEN = 2040;
public const int TASK_DATA_BUF_MAX_LEN = 32;
public const int TASK_FINISH_TIME_MAX_LEN = 1700;
public const int TASK_FINISH_COUNT_MAX_LEN = 730;
// µ±Ç°¼¤»îµÄÈÎÎñÁÐ±í»º³åÇø´óС
public int TASK_ACTIVE_LIST_BUF_SIZE =>
(TASK_ACTIVE_LIST_MAX_LEN * TASK_DATA_BUF_MAX_LEN + TASK_ACTIVE_LIST_HEADER_LEN);
CECHostPlayer m_pHost;
ActiveTaskList m_pActiveListBuf; // Active task list buffer
object[] m_pFinishedListBuf; // Finished task list buffer
object[] m_pFinishedTimeListBuf; // Finished time list buffer
object[] m_pFinishedCountListBuf;// Finished count list buffer
object[] m_pStorageTaskListBuf; // Storage tasks list buffer
private Dictionary<int, bool> m_TasksToConfirm = new Dictionary<int, bool>();
public CECTaskInterface()
{
}
public CECTaskInterface(CECHostPlayer pHost)
{
m_pHost = pHost;
m_pActiveListBuf = null;
m_pFinishedListBuf = null;
m_pFinishedTimeListBuf = null;
m_pFinishedCountListBuf = null;
m_pStorageTaskListBuf = null;
}
public bool Init(object[] pActiveListBuf, int iActiveListLen, object[] pFinishedListBuf, int iFinishedListLen, object[] pFinishedTimeListBuf, int iFinishedTimeListLen, object[] pFinishedCountListBuf, int iFinishedCountListLen, object[] pStorageTaskListBuf, int iStorageTaskListLen)
{
// if (!(m_pActiveListBuf = a_malloc(TASK_ACTIVE_LIST_BUF_SIZE)))
// {
// glb_ErrorOutput(ECERR_NOTENOUGHMEMORY, "CECTaskInterface::Init", __LINE__);
// return false;
// }
//if (!(m_pFinishedListBuf = a_malloc(TASK_FINISHED_LIST_BUF_SIZE)))
//{
// a_free(m_pActiveListBuf);
// m_pFinishedListBuf = NULL;
// glb_ErrorOutput(ECERR_NOTENOUGHMEMORY, "CECTaskInterface::Init", __LINE__);
// return false;
//}
//if (!(m_pFinishedTimeListBuf = a_malloc(TASK_FINISH_TIME_LIST_BUF_SIZE)))
//{
// a_free(m_pActiveListBuf);
// a_free(m_pFinishedListBuf);
// glb_ErrorOutput(ECERR_NOTENOUGHMEMORY, "CECTaskInterface::Init", __LINE__);
// return false;
//}
//if (!(m_pFinishedCountListBuf = a_malloc(TASK_FINISH_COUNT_LIST_BUF_SIZE)))
//{
// a_free(m_pActiveListBuf);
// a_free(m_pFinishedListBuf);
// a_free(m_pFinishedCountListBuf);
// glb_ErrorOutput(ECERR_NOTENOUGHMEMORY, "CECTaskInterface::Init", __LINE__);
// return false;
//}
//if (!(m_pStorageTaskListBuf = a_malloc(TASK_STORAGE_LIST_BUF_SIZE)))
//{
// a_free(m_pActiveListBuf);
// a_free(m_pFinishedListBuf);
// a_free(m_pFinishedCountListBuf);
// a_free(m_pStorageTaskListBuf);
// glb_ErrorOutput(ECERR_NOTENOUGHMEMORY, "CECTaskInterface::Init", __LINE__);
// return false;
//}
//ASSERT(pActiveListBuf && pFinishedListBuf && pFinishedTimeListBuf && pFinishedCountListBuf);
//memcpy(m_pActiveListBuf, pActiveListBuf, iActiveListLen);
//memcpy(m_pFinishedListBuf, pFinishedListBuf, iFinishedListLen);
//memcpy(m_pFinishedTimeListBuf, pFinishedTimeListBuf, iFinishedTimeListLen);
//memcpy(m_pFinishedCountListBuf, pFinishedCountListBuf, iFinishedCountListLen);
//memcpy(m_pStorageTaskListBuf, pStorageTaskListBuf, iStorageTaskListLen);
//// Clear rest buffer
//if (iActiveListLen < TASK_ACTIVE_LIST_BUF_SIZE)
// memset((BYTE*)m_pActiveListBuf + iActiveListLen, 0, TASK_ACTIVE_LIST_BUF_SIZE - iActiveListLen);
//if (iFinishedListLen < TASK_FINISHED_LIST_BUF_SIZE)
// memset((BYTE*)m_pFinishedListBuf + iFinishedListLen, 0, TASK_FINISHED_LIST_BUF_SIZE - iFinishedListLen);
//if (iFinishedTimeListLen < TASK_FINISH_TIME_LIST_BUF_SIZE)
// memset((BYTE*)m_pFinishedTimeListBuf + iFinishedTimeListLen, 0, TASK_FINISH_TIME_LIST_BUF_SIZE - iFinishedTimeListLen);
//if (iFinishedCountListLen < TASK_FINISH_COUNT_LIST_BUF_SIZE)
// memset((BYTE*)m_pFinishedCountListBuf + iFinishedCountListLen, 0, TASK_FINISH_COUNT_LIST_BUF_SIZE - iFinishedCountListLen);
//if (iStorageTaskListLen < TASK_STORAGE_LIST_BUF_SIZE)
// memset((BYTE*)m_pStorageTaskListBuf + iStorageTaskListLen, 0, TASK_STORAGE_LIST_BUF_SIZE - iStorageTaskListLen);
Debug.Log("[Dat]- Init GetTaskTemplMan");
ATaskTemplMan pTaskMan = GetTaskTemplMan();
if (pTaskMan == null)
{
Debug.LogError("[Dat]- fail to create ATaskTemplMan");
return false;
}
pTaskMan.Release();
// pTaskMan.LoadTasksFromPack("data\\tasks.data", true);
// pTaskMan.LoadNPCInfoFromPack("data\\task_npc.data");
// pTaskMan.VerifyDynTasksPack("userdata\\dyn_tasks.data");
// InitActiveTaskList();
//m_bForceNavigateFinish = false;
return true;
}
public void CheckPQEnterWorldInit()
{
return;
ActiveTaskList pList = GetActiveTaskList();
List<ActiveTaskEntry> aEntries = new List<ActiveTaskEntry>(pList.m_TaskEntries);
for(var i = 0; i < pList.m_uTaskCount; i++)
{
var CurEntry = aEntries[i];
if (CurEntry.m_ulTemplAddr == 0)
continue;
ATaskTempl pTempl = CurEntry.GetTempl();
if (pTempl == null || !pTempl.m_FixedData.m_bPQTask)
continue;
pTempl.IncValidCount();
// _notify_svr(this, TASK_CLT_NOTIFY_PQ_CHECK_INIT, CurEntry.m_ID);
}
}
public static void WriteLog(int nPlayerId, int nTaskId, int nType, string szLog)
{
//do something?
}
private ATaskTemplMan GetTaskTemplMan()
{
return EC_Game.GetTaskTemplateMan();
}
private ActiveTaskList GetActiveTaskList()
{
return m_pActiveListBuf;
}
}
}