diff --git a/Assets/NetworkLib/Debug/netstandard2.1/CSNetwork.dll b/Assets/NetworkLib/Debug/netstandard2.1/CSNetwork.dll index 368d4eb1fc..a2f5ec13c0 100644 Binary files a/Assets/NetworkLib/Debug/netstandard2.1/CSNetwork.dll and b/Assets/NetworkLib/Debug/netstandard2.1/CSNetwork.dll differ diff --git a/Assets/PerfectWorld/Scripts/Common/DataProcess/elementdataman.cs b/Assets/PerfectWorld/Scripts/Common/DataProcess/elementdataman.cs index a229caaf54..6939e25d96 100644 --- a/Assets/PerfectWorld/Scripts/Common/DataProcess/elementdataman.cs +++ b/Assets/PerfectWorld/Scripts/Common/DataProcess/elementdataman.cs @@ -1,7 +1,9 @@ -using System.Collections.Generic; +using BrewMonster; +using System.Collections.Generic; using System.IO; +using System.Linq; using System.Text; -using BrewMonster; +using Unity.VisualScripting; namespace ModelRenderer.Scripts.GameData { @@ -41,6 +43,10 @@ namespace ModelRenderer.Scripts.GameData public Dictionary recipe_index_id_map = new Dictionary(); public Dictionary recipe_id_data_map = new Dictionary(); + public Dictionary addon_id_data_type_map = new Dictionary(); + public Dictionary addon_index_id_map = new Dictionary(); + public Dictionary addon_id_data_map = new Dictionary(); + public EQUIPMENT_ADDON[] equipment_addon_array = new EQUIPMENT_ADDON[0]; public WEAPON_MAJOR_TYPE[] weapon_major_type_array = new WEAPON_MAJOR_TYPE[0]; public WEAPON_SUB_TYPE[] weapon_sub_type_array = new WEAPON_SUB_TYPE[0]; @@ -1406,7 +1412,17 @@ namespace ModelRenderer.Scripts.GameData case ID_SPACE.ID_SPACE_ESSENCE: essence_id_data_type_map[id] = type; break; - + case ID_SPACE.ID_SPACE_ADDON: + addon_id_data_type_map[id] = type; + break; + //case ID_SPACE.ID_SPACE_TALK: + // add_id_index_talk(id, type, pos, start); + // break; + //case ID_SPACE.ID_SPACE_FACE: + // add_id_index_face(id, type, pos, start); + // break; + //case ID_SPACE.ID_SPACE_RECIPE: + // add_id_index_recipe(id, type, pos, start); case ID_SPACE.ID_SPACE_CONFIG: config_id_data_type_map[id] = type; break; @@ -1453,6 +1469,10 @@ namespace ModelRenderer.Scripts.GameData id = recipe_index_id_map[index]; dataType = recipe_id_data_type_map[id]; break; + case ID_SPACE.ID_SPACE_ADDON: + id = addon_index_id_map[index]; + dataType = addon_id_data_type_map[id]; + break; default: break; @@ -1501,6 +1521,17 @@ namespace ModelRenderer.Scripts.GameData { case ID_SPACE.ID_SPACE_ESSENCE: return essence_id_data_type_map.Count; + case ID_SPACE.ID_SPACE_ADDON: + return addon_id_data_type_map.Count; + + // case ID_SPACE.ID_SPACE_TALK: + // return talk_id_index_map.Count; + + // case ID_SPACE.ID_SPACE_FACE: + // return face_id_index_map.Count; + + // case ID_SPACE.ID_SPACE_RECIPE: + // return recipe_id_index_map.Count; case ID_SPACE.ID_SPACE_CONFIG: return config_id_data_type_map.Count; @@ -1536,6 +1567,12 @@ namespace ModelRenderer.Scripts.GameData return configType; } break; + case ID_SPACE.ID_SPACE_ADDON: + if (addon_id_data_type_map.TryGetValue(id, out DATA_TYPE addonType)) + { + return addonType; + } + break; case ID_SPACE.ID_SPACE_TALK: if (talk_id_data_type_map.TryGetValue(id, out DATA_TYPE talkType)) @@ -1606,11 +1643,116 @@ namespace ModelRenderer.Scripts.GameData } break; + case ID_SPACE.ID_SPACE_ADDON: + if (addon_id_data_map.TryGetValue(id, out data)) + { + dataType = addon_id_data_type_map[id]; + return data; + } + break; + default: return null; } return null; } + + //public uint get_first_data_id(ID_SPACE idspace,ref DATA_TYPE datatype) + //{ + // uint id = 0; + // switch (idspace) + // { + // case ID_SPACE.ID_SPACE_ESSENCE: + // if (essence_id_data_type_map.Count==0) + // { + // id = 0; + // datatype = DATA_TYPE.DT_INVALID; + // } + // else + // { + // var firstElement = essence_id_data_type_map.FirstOrDefault(); + // id = firstElement.Key; + // datatype = firstElement.Value; + // } + // break; + + // case ID_SPACE.ID_SPACE_ADDON: + // addon_id_index_itr = addon_id_index_map.begin(); + // if (addon_id_index_itr == addon_id_index_map.end()) + // { + // id = 0; + // datatype = DT_INVALID; + // } + // else + // { + // id = addon_id_index_itr->first; + // datatype = (addon_id_index_itr->second).type; + // } + // break; + + // case ID_SPACE.ID_SPACE_TALK: + // talk_id_index_itr = talk_id_index_map.begin(); + // if (talk_id_index_itr == talk_id_index_map.end()) + // { + // id = 0; + // datatype = DT_INVALID; + // } + // else + // { + // id = talk_id_index_itr->first; + // datatype = (talk_id_index_itr->second).type; + // } + // break; + + // case ID_SPACE.ID_SPACE_FACE: + // face_id_index_itr = face_id_index_map.begin(); + // if (face_id_index_itr == face_id_index_map.end()) + // { + // id = 0; + // datatype = DT_INVALID; + // } + // else + // { + // id = face_id_index_itr->first; + // datatype = (face_id_index_itr->second).type; + // } + // break; + + // case ID_SPACE.ID_SPACE_RECIPE: + // recipe_id_index_itr = recipe_id_index_map.begin(); + // if (recipe_id_index_itr == recipe_id_index_map.end()) + // { + // id = 0; + // datatype = DT_INVALID; + // } + // else + // { + // id = recipe_id_index_itr->first; + // datatype = (recipe_id_index_itr->second).type; + // } + // break; + + // case ID_SPACE.ID_SPACE_CONFIG: + // config_id_index_itr = config_id_index_map.begin(); + // if (config_id_index_itr == config_id_index_map.end()) + // { + // id = 0; + // datatype = DT_INVALID; + // } + // else + // { + // id = config_id_index_itr->first; + // datatype = (config_id_index_itr->second).type; + // } + // break; + + // default: + // id = 0; + // datatype = DATA_TYPE.DT_INVALID; + // break; + // } + // return id; + //} } } \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/UI/Login/LoginScreenUI.cs b/Assets/PerfectWorld/Scripts/UI/Login/LoginScreenUI.cs index f2dc05e6cb..c0ff032792 100644 --- a/Assets/PerfectWorld/Scripts/UI/Login/LoginScreenUI.cs +++ b/Assets/PerfectWorld/Scripts/UI/Login/LoginScreenUI.cs @@ -49,7 +49,7 @@ namespace BrewMonster.UI #if UNITY_EDITOR if (Input.GetKeyUp(KeyCode.LeftAlt)) { - _usernameInputField.text = "test025"; + _usernameInputField.text = "test004"; _passwordInputField.text = "123456"; } #endif @@ -129,11 +129,13 @@ namespace BrewMonster.UI private async void OnEnterWorldComplete() { - await Task.Delay(2000); // Request all known packages: 0=Inventory,1=Equipment,2=Task UnityGameSession.RequestAllInventoriesAsync(() => { Logger.Log("Sent Inventory Detail Requests (all packs)"); }, 0, 1, 2); + + await Task.Delay(2000); UnityGameSession.c2s_CmdGetAllData(true, true, false); + EC_Game.Init(); } //private void OnInventoryReceived(List inventoryData) diff --git a/Assets/Scripts/CECHostPlayer.cs b/Assets/Scripts/CECHostPlayer.cs index 30ee27f79a..225b9ddfba 100644 --- a/Assets/Scripts/CECHostPlayer.cs +++ b/Assets/Scripts/CECHostPlayer.cs @@ -215,7 +215,7 @@ public class CECHostPlayer : EC_Player case int value when value == EC_MsgDef.MSG_HST_TASKDATA: { OnMsgHstTaskData(Msg); - Debug.LogError("[Dat]- OnMsgHstTaskData"); + Debug.Log("[Dat]- OnMsgHstTaskData"); break; } case int value when value == EC_MsgDef.MSG_HST_ITEMOPERATION: @@ -423,18 +423,18 @@ public class CECHostPlayer : EC_Player //pData += iStorageTasksListSize; //A3DRELEASE(m_pTaskInterface); + + return; + var m_pTaskInterface = new CECTaskInterface(this); - //todo - //var m_pTaskInterface = new CECTaskInterface(this); + if (!m_pTaskInterface.Init(null, 0, null, 0, + null, 0, null, 0, null, 0)) + { + //a_LogOutput(1, "CECHostPlayer::OnMsgHstTaskData, failed to initialize task interface"); + return; + } - //if (!m_pTaskInterface.Init(null, 0, null, 0, - // null, 0, null, 0, null, 0)) - //{ - // //a_LogOutput(1, "CECHostPlayer::OnMsgHstTaskData, failed to initialize task interface"); - // return; - //} - - //m_pTaskInterface.CheckPQEnterWorldInit(); + m_pTaskInterface.CheckPQEnterWorldInit(); //// check if player has equipped goblin //if (m_pEquipPack->GetItem(EQUIPIVTR_GOBLIN) != NULL) diff --git a/Assets/Scripts/MainFiles.meta b/Assets/Scripts/MainFiles.meta new file mode 100644 index 0000000000..2a3c3bc448 --- /dev/null +++ b/Assets/Scripts/MainFiles.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7c78d146782232847ac2e4a6cec64dbf +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/MainFiles/EC_Game.cs b/Assets/Scripts/MainFiles/EC_Game.cs new file mode 100644 index 0000000000..615f715b06 --- /dev/null +++ b/Assets/Scripts/MainFiles/EC_Game.cs @@ -0,0 +1,36 @@ +using ModelRenderer.Scripts.GameData; +using PerfectWorld.Scripts.Task; +using UnityEngine; +namespace BrewMonster.Network +{ + public static class EC_Game + { + #region Fields + private static ATaskTemplMan m_pTaskMan; // Task template manager + private static elementdataman m_pElementDataMan; // global element templates manager + #endregion + + #region Properties + public static ATaskTemplMan GetTaskTemplateMan() { return m_pTaskMan; } + public static elementdataman GetElementDataMan() { return m_pElementDataMan; } + #endregion + + #region Public Methods + public static bool Init() + { + m_pElementDataMan = elementdataman.Instance; + + // Load task templates + if (m_pTaskMan == null) m_pTaskMan = new ATaskTemplMan(); + + m_pTaskMan.Init(m_pElementDataMan); + if (!m_pTaskMan.InitStorageTask()) + { + Debug.LogError("[Dat]- CECGame::Init, Storage task Init Failed!"); + return false; + } + return true; + } + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/MainFiles/EC_Game.cs.meta b/Assets/Scripts/MainFiles/EC_Game.cs.meta new file mode 100644 index 0000000000..731734f727 --- /dev/null +++ b/Assets/Scripts/MainFiles/EC_Game.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: e9b6b5b70c94a5c4e9dbaa1b2e1c323c \ No newline at end of file diff --git a/Assets/Scripts/Task/ATaskTemplMan.cs b/Assets/Scripts/Task/ATaskTemplMan.cs index 363c3d3fa1..c505a09efd 100644 --- a/Assets/Scripts/Task/ATaskTemplMan.cs +++ b/Assets/Scripts/Task/ATaskTemplMan.cs @@ -1,3 +1,4 @@ +using BrewMonster; using ModelRenderer.Scripts.GameData; using System.Collections.Generic; using System.IO; @@ -28,6 +29,10 @@ namespace PerfectWorld.Scripts.Task private Dictionary m_DeathTrigMap = new Dictionary(); private Dictionary m_PQTemplMap = new Dictionary(); + private Dictionary m_StorageEssenseMap = new Dictionary(); + private Dictionary m_WeightEssenseMap = new Dictionary(); + private Dictionary m_StorageTaskMap = new Dictionary(); + private List m_SkillTaskLst = new List(); private List m_TmLmtChkLst = new List(); @@ -44,10 +49,8 @@ namespace PerfectWorld.Scripts.Task public bool LoadTasksFromPack(string szPackPath, bool bLoadDescript) { //TaskInterface::WriteLog(0, 0, 2, "LoadPack begin"); + Debug.Log("[Dat]- szPackPath: " + szPackPath); FileStream fs = new FileStream(szPackPath, FileMode.Open, FileAccess.Read); - - if (fs == null) return false; - TASK_PACK_HEADER tph; // fread(&tph, sizeof(tph), 1, fp); @@ -177,10 +180,10 @@ namespace PerfectWorld.Scripts.Task if (pTask.m_bAutoDeliver && pTask.m_bDisplayInExclusiveUI) m_ExlusiveAwardTaskMap[pTask.m_ID] = pTask; -//#if _TASK_CLIENT -// if (pTask.m_ulDelvNPC != 0 && pTask.m_bCanSeekOut) -// m_TasksCanSeekOut.Add(pTask); -//#endif + //#if _TASK_CLIENT + // if (pTask.m_ulDelvNPC != 0 && pTask.m_bCanSeekOut) + // m_TasksCanSeekOut.Add(pTask); + //#endif AddTaskToMap(pTask); } @@ -213,5 +216,59 @@ namespace PerfectWorld.Scripts.Task } } + + public bool InitStorageTask() + { + m_StorageEssenseMap.Clear(); + m_WeightEssenseMap.Clear(); + + DATA_TYPE dt; + + //ID_SPACE.ID_SPACE_ESSENCE + foreach (var pair in m_pEleDataMan.essence_id_data_type_map) + { + if (pair.Value == DATA_TYPE.DT_NPC_TASK_OUT_SERVICE) + { + dt = pair.Value; + NPC_TASK_OUT_SERVICE pData = (NPC_TASK_OUT_SERVICE)m_pEleDataMan.get_data_ptr(pair.Key, ID_SPACE.ID_SPACE_ESSENCE, ref dt); + + if (pData.storage_id == 0) continue; + + if (pData.storage_id > CECTaskInterface.TASK_STORAGE_COUNT) return false; + if (m_StorageEssenseMap.ContainsKey(pData.storage_id)) return false; + m_StorageEssenseMap[pData.storage_id] = pData.id; + for (var i = 0; i < pData.id_tasks.Length; i++) + { + if (pData.id_tasks[i] > 0) + { + m_StorageTaskMap[(int)pData.id_tasks[i]] = (int)pData.storage_id; + } + } + } + } + // ID_SPACE_CONFIG + foreach (var pair in m_pEleDataMan.config_id_data_type_map) + { + if (pair.Value == DATA_TYPE.DT_NPC_TASK_OUT_SERVICE) + { + dt = pair.Value; + NPC_TASK_OUT_SERVICE pData = (NPC_TASK_OUT_SERVICE)m_pEleDataMan.get_data_ptr(pair.Key, ID_SPACE.ID_SPACE_ESSENCE, ref dt); + + if (pData.storage_id == 0) continue; + + if (pData.storage_id > CECTaskInterface.TASK_STORAGE_COUNT) return false; + if (m_StorageEssenseMap.ContainsKey(pData.storage_id)) return false; + m_StorageEssenseMap[pData.storage_id] = pData.id; + for (var i = 0; i < pData.id_tasks.Length; i++) + { + if (pData.id_tasks[i] > 0) + { + m_StorageTaskMap[(int)pData.id_tasks[i]] = (int)pData.storage_id; + } + } + } + } + return true; + } } } \ No newline at end of file diff --git a/Assets/Scripts/Task/CECTaskInterface.cs b/Assets/Scripts/Task/CECTaskInterface.cs index 007a4d195a..b9b9d90ac8 100644 --- a/Assets/Scripts/Task/CECTaskInterface.cs +++ b/Assets/Scripts/Task/CECTaskInterface.cs @@ -1,11 +1,29 @@ +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; - object[] m_pActiveListBuf; // Active task list buffer + 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 @@ -29,11 +47,11 @@ namespace PerfectWorld.Scripts.Task 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_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))) //{ @@ -92,17 +110,45 @@ namespace PerfectWorld.Scripts.Task //if (iStorageTaskListLen < TASK_STORAGE_LIST_BUF_SIZE) // memset((BYTE*)m_pStorageTaskListBuf + iStorageTaskListLen, 0, TASK_STORAGE_LIST_BUF_SIZE - iStorageTaskListLen); - //ATaskTemplMan pTaskMan = GetTaskTemplMan(); - //pTaskMan.Release(); - //pTaskMan.LoadTasksFromPack("data\\tasks.data", true); - //pTaskMan.LoadNPCInfoFromPack("data\\task_npc.data"); - //pTaskMan.VerifyDynTasksPack("userdata\\dyn_tasks.data"); - //InitActiveTaskList(); + 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 aEntries = new List(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_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) { @@ -111,8 +157,11 @@ namespace PerfectWorld.Scripts.Task private ATaskTemplMan GetTaskTemplMan() { - //return g_pGame->GetTaskTemplateMan(); - return null; + return EC_Game.GetTaskTemplateMan(); + } + private ActiveTaskList GetActiveTaskList() + { + return m_pActiveListBuf; } } } diff --git a/Assets/Scripts/Task/TaskProcess.cs b/Assets/Scripts/Task/TaskProcess.cs new file mode 100644 index 0000000000..24230b2a9e --- /dev/null +++ b/Assets/Scripts/Task/TaskProcess.cs @@ -0,0 +1,176 @@ +using System; +using System.Runtime.InteropServices; +using PerfectWorld.Scripts.Task; +using UnityEngine; + +public class TaskProcess +{ + +} +[Flags] +public enum TaskState : byte +{ + TASK_STATE_FINISHED = 0x01, // Is finished + TASK_STATE_SUCCESS = 0x02, // Is successful + TASK_STATE_GIVEUP = 0x04, // Is given up + TASK_STATE_ERR_REPORTED = 0x08, // Error has been reported to client + TASK_STATE_AWARD_NOTIFY_TEAM = 0x10, // Award has been notified to team + TASK_STATE_CONTRIBUTION_FINISH = 0x20 // Contribution finished +} + +// Cur Size 21 bytes +public class TASK_ENTRY_FIXED_DATA +{ + public ushort m_ID; // ID + public char m_ParentIndex; // Parent node index + public char m_PrevSblIndex; // Previous sibling node index + public char m_NextSblIndex; // Next sibling node index + public char m_ChildIndex; // Child node index + public char m_uState; // Task state + public ulong m_ulTaskTime; // Timestamp + public ushort m_uCapTaskId; // Captain task ID + public ulong m_ulTemplAddr; // Template address + public ulong m_ulCapTemplAddr; // Captain task template address +}; + + // ´óСΪTASK_DATA_BUF_MAX_LEN +public class ActiveTaskEntry : TASK_ENTRY_FIXED_DATA +{ + // Buffer union simplified (C# does not support union directly) + public byte[] m_BufData; // Raw data buffer + public ushort[] m_wMonsterNum; // Monster numbers + public int m_iUsefulData1; + public char m_iUsefulData2; + + // bool IsFinished() const { return (m_uState & TASK_STATE_FINISHED) != 0; } + // bool IsSuccess() const { return (m_uState & TASK_STATE_SUCCESS) != 0; } + // bool IsGiveUp() const { return (m_uState & TASK_STATE_GIVEUP) != 0; } + // bool IsErrReported() const { return (m_uState & TASK_STATE_ERR_REPORTED) != 0; } + // bool IsAwardNotifyTeam() const { return (m_uState & TASK_STATE_AWARD_NOTIFY_TEAM) != 0; } + // bool IsContributionFinish() const { return (m_uState & TASK_STATE_CONTRIBUTION_FINISH) != 0; } + // --- State check methods --- + public bool IsFinished() => (m_uState & (byte)TaskState.TASK_STATE_FINISHED) != 0; + public bool IsSuccess() => (m_uState & (byte)TaskState.TASK_STATE_SUCCESS) != 0; + public bool IsGiveUp() => (m_uState & (byte)TaskState.TASK_STATE_GIVEUP) != 0; + public bool IsErrReported() => (m_uState & (byte)TaskState.TASK_STATE_ERR_REPORTED) != 0; + public bool IsAwardNotifyTeam() => (m_uState & (byte)TaskState.TASK_STATE_AWARD_NOTIFY_TEAM) != 0; + public bool IsContributionFinish() => (m_uState & (byte)TaskState.TASK_STATE_CONTRIBUTION_FINISH) != 0; + + // void SetFinished() { m_uState |= TASK_STATE_FINISHED; } + // void ClearFinished() { m_uState &= ~TASK_STATE_FINISHED; } + // void SetSuccess() { m_uState |= TASK_STATE_SUCCESS; } + // void ClearSuccess() { m_uState &= ~TASK_STATE_SUCCESS; } + // void SetGiveUp() { m_uState |= TASK_STATE_GIVEUP; } + // void ClearGiveUp() { m_uState &= ~TASK_STATE_GIVEUP; } + // void SetErrReported() { m_uState |= TASK_STATE_ERR_REPORTED; } + // void ClearErrReported() { m_uState &= ~TASK_STATE_ERR_REPORTED; } + // void SetAwardNotifyTeam() { m_uState |= TASK_STATE_AWARD_NOTIFY_TEAM; } + // void ClearAwardNotifyTeam() { m_uState &= ~TASK_STATE_AWARD_NOTIFY_TEAM; } + // void SetContributionFinish() { m_uState |= TASK_STATE_CONTRIBUTION_FINISH; } + // void ClearContributionFinish() { m_uState &= ~TASK_STATE_CONTRIBUTION_FINISH; } + // + public ATaskTempl GetTempl() + { + if (m_ulTemplAddr == 0) return null; + return Marshal.PtrToStructure( + new IntPtr(unchecked((long)m_ulTemplAddr)) + ); + // return reinterpret_cast(m_ulTemplAddr); + } + // const ATaskTempl* GetCap() const { return reinterpret_cast(m_ulCapTemplAddr); } + // const ATaskTempl* GetCapOrSelf() const + // { + // if (m_ulCapTemplAddr) return GetCap(); + // else return GetTempl(); + // } + // bool HasParent() const { return m_ParentIndex != 0xff; } + // bool HasChildren() const { return m_ChildIndex != 0xff; } + // bool IsValid(unsigned char uIndex, unsigned char uMaxCount) const + // { + // if (m_ParentIndex != 0xff) + // { + // if (m_ParentIndex >= uIndex || m_ParentIndex >= uMaxCount) + // return false; + // } + // + // if (m_PrevSblIndex != 0xff) + // { + // if (m_PrevSblIndex >= uIndex || m_PrevSblIndex >= uMaxCount) + // return false; + // } + // + // if (m_NextSblIndex != 0xff) + // { + // if (m_NextSblIndex <= uIndex || m_NextSblIndex >= uMaxCount) + // return false; + // } + // + // if (m_ChildIndex != 0xff) + // { + // if (m_ChildIndex <= uIndex || m_ChildIndex >= uMaxCount) + // return false; + // } + // + // return true; + // } +}; + +public class ActiveTaskList +{ + // --- Header Fields --- + public byte[] header = new byte[CECTaskInterface.TASK_ACTIVE_LIST_HEADER_LEN]; + + public byte m_uTaskCount; // number of tasks + public byte m_uUsedCount; // used count + public ushort m_Version; // version + public byte m_uTopShowTaskCount; // top show task count + public byte m_uListState; // list state + public byte m_uTopHideTaskCount; // top hide task count + + private byte _flags; // simulate bitfield (1 bit + 7 bits) + + public bool m_uMaxSimultaneousCount + { + get => (_flags & 0x01) != 0; + set + { + if (value) _flags |= 0x01; + else _flags &= unchecked((byte)~0x01); + } + } + + public byte m_uTitleTaskCount + { + get => (byte)((_flags & 0xFE) >> 1); + set => _flags = (byte)((_flags & 0x01) | ((value & 0x7F) << 1)); + } + + public ActiveTaskEntry[] m_TaskEntries = new ActiveTaskEntry[CECTaskInterface.TASK_ACTIVE_LIST_MAX_LEN]; + + // void UpdateTaskMask(unsigned long& ulMask) const; + // void UpdateUsedCount(); + // void RealignTask(ActiveTaskEntry* pEntry, unsigned char uReserve); + // void ClearTask(TaskInterface* pTask, ActiveTaskEntry* pEntry, bool bRemoveItem); + // void RecursiveClearTask(TaskInterface* pTask, ActiveTaskEntry* pEntry, bool bRemoveItem, bool bRemoveAcquired, bool bClearTask); + // void ClearChildrenOf(TaskInterface* pTask, ActiveTaskEntry* pParent, bool bRemoveItem = true); + // ActiveTaskEntry* GetEntry(unsigned long ulId) + // { + // for (unsigned char i = 0; i < m_uTaskCount; i++) + // if (m_TaskEntries[i].m_ID == ulId) + // return &m_TaskEntries[i]; + // + // return NULL; + // } + // void RemoveAll() + // { + // unsigned short ver = m_Version; + // memset(this, 0, sizeof(*this)); + // m_Version = ver; + // } + // bool IsValid() const { return m_uTaskCount <= TASK_ACTIVE_LIST_MAX_LEN; } + // bool IsTimeMarkUpdate() const { return (m_uListState & TLIST_STATE_UPDATE_TIME_MARK) != 0; } + // void SetTimeMarkUpdate() { m_uListState |= TLIST_STATE_UPDATE_TIME_MARK; } + // void ClearTimeMarkUpdate() { m_uListState &= ~TLIST_STATE_UPDATE_TIME_MARK; } + // int GetMaxSimultaneousCount() {return m_uMaxSimultaneousCount ? TASK_MAX_SIMULTANEOUS_COUT : TASK_DEFAULT_MAX_SIMULTANEOUS_COUT;} + // void ExpandMaxSimultaneousCount() {m_uMaxSimultaneousCount = 1;} +}; \ No newline at end of file diff --git a/Assets/Scripts/Task/TaskProcess.cs.meta b/Assets/Scripts/Task/TaskProcess.cs.meta new file mode 100644 index 0000000000..6bb9640cdd --- /dev/null +++ b/Assets/Scripts/Task/TaskProcess.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 624d08204f26c7c49bc8b1885be16f22 \ No newline at end of file diff --git a/Assets/Scripts/Task/TaskTempl.cs b/Assets/Scripts/Task/TaskTempl.cs index a631b54d15..17a6054756 100644 --- a/Assets/Scripts/Task/TaskTempl.cs +++ b/Assets/Scripts/Task/TaskTempl.cs @@ -146,6 +146,7 @@ namespace PerfectWorld.Scripts.Task public class ATaskTempl : ATaskTemplFixedData { const int MAX_TASK_NAME_LEN = 30; + public byte m_uValidCount; public bool LoadFromBinFile(FileStream fp) { LoadBinary(fp); @@ -533,6 +534,8 @@ namespace PerfectWorld.Scripts.Task } return new string(chars); } + + public void IncValidCount() { m_uValidCount++; } } } \ No newline at end of file