using System; using BrewMonster.Scripts.Task; using CSNetwork; using CSNetwork.GPDataType; using UnityEngine; using System.Runtime.InteropServices; // ���׶� // Contribution info [StructLayout(LayoutKind.Sequential, Pack = 1)] public struct CONTRIB_INFO { public int consume_contrib; // �����ѵ� // Consume contribution public int exp_contrib; // �ɶһ����ɾ���� // Experience contribution public int cumulate_contrib; // �ۻ�ֵ // Cumulative contribution // public CONTRIB_INFO() // { // consume_contrib = 0; // exp_contrib = 0; // cumulate_contrib = 0; // } } public partial class CECHostPlayer { private int m_idTradePlayer; // ID of player who is trading with us private CECTaskInterface m_pTaskInterface; private int m_iBoothState; // Booth state. 0, none; 1, prepare; 2, open booth; 3, visite other's booth private CONTRIB_INFO m_contribInfo; public CECTaskInterface GetTaskInterface() { return m_pTaskInterface; } // Is host player trading ? public bool IsTrading() { return m_idTradePlayer != 0; } public CONTRIB_INFO GetContribInfo() { return m_contribInfo; } public int GetBoothState() { return m_iBoothState; } private void OnMsgHstTaskData(ECMSG Msg) { // decode header to distinguish TASK_DATA vs TASK_VAR_DATA // if (!(Msg.dwParam2 is cmd_header header)) // { // Debug.LogError("OnMsgHstTaskData: invalid header"); // return; // } int header = Convert.ToInt32(Msg.dwParam2); byte[] pDataBuf = Msg.dwParam1 as byte[]; if (pDataBuf == null) { Debug.LogError("OnMsgHstTaskData: missing payload buffer"); return; } if (header == CommandID.TASK_DATA) { #if !LOAD_TASK_TEMPL return; // Task templates loading not implemented in C# #endif // Parse aggregated task buffers cmd_task_data pCmd = cmd_task_data.FromBuffer(pDataBuf); // cmd_task_data pCmd = GPDataTypeHelper.FromBytes(pDataBuf); // Release and recreate task interface m_pTaskInterface = null; m_pTaskInterface = new CECTaskInterface(this); if (!m_pTaskInterface.Init( pCmd.active_list, (int)pCmd.active_list_size, pCmd.finished_list, (int)pCmd.finished_list_size, pCmd.finished_time_list, (int)pCmd.finished_time_list_size, pCmd.finished_count, (int)pCmd.finished_count_size, pCmd.storage_task, (int)pCmd.storage_task_size)) { Debug.LogError("CECHostPlayer::OnMsgHstTaskData, failed to initialize task interface"); return; } m_pTaskInterface.CheckPQEnterWorldInit(); // check if player has equipped goblin (not yet implemented in C#) // TODO: implement goblin initialization when equipment system is ready // GET_ALL_DATA end flag tasks were here in C++ (LoadConfigData), omitted in C# // if (UpdateEquipSkills()) UpdateEquipSkillCoolDown(); // methods not ported yet } else if (header == CommandID.TASK_VAR_DATA) { // Minimal forwarding; original code passes inner data pointer and size if (m_pTaskInterface != null) { OnServerNotify(m_pTaskInterface, pDataBuf, pDataBuf.Length); } else { Debug.LogError("OnMsgHstTaskData: m_pTaskInterface is null on TASK_VAR_DATA"); } } } private void OnServerNotify(CECTaskInterface pInterface, byte[] data, int size) { // TODO: Implement server notify handling for task var data } }