Merge branch 'develop' into feature/elseplayer

This commit is contained in:
Tungdv
2025-09-25 17:28:23 +07:00
14 changed files with 1088 additions and 10 deletions
Binary file not shown.
@@ -81,12 +81,12 @@ namespace BrewMonster.Network
byte byDir, ushort wStamp, int iTime)
{
Debug.LogWarning("HoangDev : c2s_SendCmdStopMove");
Instance._gameSession.c2s_SendCmdStopMove(EC_Utility.ToNumerics( vDest),fSpeed,iMoveMode,byDir,wStamp,iTime);
Instance._gameSession.c2s_SendCmdStopMove(EC_Utility.ToNumerics(vDest), fSpeed, iMoveMode, byDir, wStamp, iTime);
}
public void c2s_CmdPlayerMove(in Vector3 vCurPos, in Vector3 vDest,
int iTime, float fSpeed, int iMoveMode, ushort wStamp)
{
Instance._gameSession.c2s_CmdPlayerMove(EC_Utility.ToNumerics(vCurPos),EC_Utility.ToNumerics( vDest),iTime,fSpeed,iMoveMode,wStamp);
Instance._gameSession.c2s_CmdPlayerMove(EC_Utility.ToNumerics(vCurPos), EC_Utility.ToNumerics(vDest), iTime, fSpeed, iMoveMode, wStamp);
}
protected override void Initialize()
{
@@ -161,7 +161,15 @@ namespace BrewMonster.Network
RequestInventoryAsync(p, onOneDone);
}
}
#region Task
public static void c2s_CmdGetAllData(bool byPack, bool byEquip, bool byTask)
{
Debug.Log("[Dat]- SendCmdGetAllData");
Instance._gameSession.c2s_SendCmdGetAllData(byPack, byEquip, byTask);
}
#endregion
public void LoadScene(string sceneName, LoadSceneMode mode, Action<bool> actDone)
{
StartCoroutine(LoadSceneCoroutine(sceneName, mode, actDone));
@@ -45,6 +45,14 @@ namespace BrewMonster.UI
_selectCharacterScreen.InitScreen(_roleInfos, OnClickSelectCharacter);
_roleInfos = null;
}
#if UNITY_EDITOR
if (Input.GetKeyUp(KeyCode.LeftAlt))
{
_usernameInputField.text = "test025";
_passwordInputField.text = "123456";
}
#endif
}
public async void OnLoginButtonClicked()
@@ -125,6 +133,7 @@ namespace BrewMonster.UI
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);
UnityGameSession.c2s_CmdGetAllData(true, true, false);
}
//private void OnInventoryReceived(List<InventoryItem> inventoryData)
+89 -4
View File
@@ -3,18 +3,19 @@ using CSNetwork;
using CSNetwork.GPDataType;
using CSNetwork.Protocols;
using CSNetwork.Protocols.RPCData;
using PerfectWorld.Scripts.Managers;
using PerfectWorld.Scripts.Task;
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using TMPro;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using Scene = UnityEngine.SceneManagement.Scene;
using System.Runtime.InteropServices;
using Unity.VisualScripting;
using PerfectWorld.Scripts.Managers;
public class CECHostPlayer : EC_Player
{
@@ -196,7 +197,8 @@ public class CECHostPlayer : EC_Player
public void ProcessMessage(in ECMSG Msg)
{
Debug.LogWarning("HoangDev : ProcessMessageProcessMessageProcessMessage");
switch ((int)Msg.dwMsg)
var msg = (int)Msg.dwMsg;
switch (msg)
{
case int value when value == EC_MsgDef.MSG_HST_CORRECTPOS: OnMsgHstCorrectPos(Msg); break;
case int value when value == EC_MsgDef.MSG_HST_GOTO: OnMsgHstGoto(Msg); break;
@@ -210,6 +212,12 @@ public class CECHostPlayer : EC_Player
OnMsgHstOwnItemInfo(Msg);
break;
}
case int value when value == EC_MsgDef.MSG_HST_TASKDATA:
{
OnMsgHstTaskData(Msg);
Debug.LogError("[Dat]- OnMsgHstTaskData");
break;
}
case int value when value == EC_MsgDef.MSG_HST_ITEMOPERATION:
OnMsgHstItemOperation(Msg);
break;
@@ -377,6 +385,83 @@ public class CECHostPlayer : EC_Player
SetModelHostPlayer();
Debug.LogError("Pos Character = " + pos);
}
#region Task
public void OnMsgHstTaskData(ECMSG Msg)
{
int cmd = Convert.ToInt32(Msg.dwParam2);
if (cmd == CommandID.TASK_DATA)
{
Debug.Log("[Dat]- OnMsgHstTaskData- TASK_DATA");
//a_LogOutput(1, "[Dat]- EC_HostMsg- OnMsgHstTaskData- TASK_DATA");
//cmd_task_data* pCmd = (cmd_task_data*)Msg.dwParam1;
//ASSERT(pCmd);
//int iActiveListSize = (int)pCmd->active_list_size;
//BYTE* pData = (BYTE*)pCmd + sizeof(size_t);
//void* pActiveListbuf = pData;
//pData += iActiveListSize;
//int iFinishedListSize = *(int*)pData;
//pData += sizeof(int);
//void* pFinishedListBuf = pData;
//pData += iFinishedListSize;
//int iFinishTimeListSize = *(int*)pData;
//pData += sizeof(int);
//void* pFinishTimeListBuf = pData;
//pData += iFinishTimeListSize;
//int iFinishedCountListSize = *(int*)pData;
//pData += sizeof(int);
//void* pFinishedCountListBuf = pData;
//pData += iFinishedCountListSize;
//int iStorageTasksListSize = *(int*)pData;
//pData += sizeof(int);
//void* pStorageTaskListBuf = pData;
//pData += iStorageTasksListSize;
//A3DRELEASE(m_pTaskInterface);
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;
}
//m_pTaskInterface.CheckPQEnterWorldInit();
//// check if player has equipped goblin
//if (m_pEquipPack->GetItem(EQUIPIVTR_GOBLIN) != NULL)
//{
// CECIvtrGoblin* pIvtrGoblin = (CECIvtrGoblin*)m_pEquipPack->GetItem(EQUIPIVTR_GOBLIN);
// m_pGoblin = new CECHostGoblin();
// m_pGoblin->Init(pIvtrGoblin->GetTemplateID(), pIvtrGoblin, this);
//}
//// Note: this command now is also used as the end flag of responding
//// for GET_ALL_DATA request
//g_pGame->GetGameSession()->LoadConfigData();
//// ¸ù¾Ý×°±¸°ü¹ü¸üÐÂ×°±¸¼¼Äܵ½¼¼ÄÜÁбí
//if (UpdateEquipSkills())
// UpdateEquipSkillCoolDown();
}
else if (cmd == CommandID.TASK_VAR_DATA)
{
//cmd_task_var_data* pCmd = (cmd_task_var_data*)Msg.dwParam1;
//ASSERT(pCmd);
//if (m_pTaskInterface)
// OnServerNotify(m_pTaskInterface, pCmd->data, pCmd->size);
//else
// ASSERT(m_pTaskInterface);
}
}
#endregion
}
public enum StateAnim
+83 -3
View File
@@ -1,6 +1,15 @@
using CSNetwork.GPDataType;
using System;
using System.Runtime.InteropServices;
using UnityEngine;
struct cmd_get_all_data
{
byte byPack; // Get detail info. flag
byte byEquip;
byte byTask;
};
struct cmd_player_move
{
Vector3 vCurPos;
@@ -17,7 +26,78 @@ struct cmd_host_correct_pos
};
struct cmd_notify_hostpos
{
public Vector3 vPos;
public int tag;
public int line;
public Vector3 vPos;
public int tag;
public int line;
};
struct cmd_task_data
{
public uint active_list_size;
public byte[] active_list;
public uint finished_list_size;
public byte[] finished_list;
public uint finished_time_list_size;
public byte[] finished_time_list;
public uint finished_count_size;
public byte[] finished_count;
public uint storage_task_size;
public byte[] storage_task;
public static cmd_task_data FromPointer(IntPtr ptr)
{
// Copy enough memory into managed buffer (you can optimize this later)
int maxExpectedSize = 1024 * 10;
byte[] buffer = new byte[maxExpectedSize];
Marshal.Copy(ptr, buffer, 0, buffer.Length);
return FromBuffer(buffer);
}
public static cmd_task_data FromBuffer(byte[] buffer)
{
cmd_task_data result = new cmd_task_data();
int offset = 0;
result.active_list_size = (uint)ReadULong(buffer, ref offset);
result.active_list = ReadBytes(buffer, ref offset, (int)result.active_list_size);
result.finished_list_size = (uint)ReadULong(buffer, ref offset);
result.finished_list = ReadBytes(buffer, ref offset, (int)result.finished_list_size);
result.finished_time_list_size = (uint)ReadULong(buffer, ref offset);
result.finished_time_list = ReadBytes(buffer, ref offset, (int)result.finished_time_list_size);
result.finished_count_size = (uint)ReadULong(buffer, ref offset);
result.finished_count = ReadBytes(buffer, ref offset, (int)result.finished_count_size);
result.storage_task_size = (uint)ReadULong(buffer, ref offset);
result.storage_task = ReadBytes(buffer, ref offset, (int)result.storage_task_size);
return result;
}
private static ulong ReadULong(byte[] buffer, ref int offset)
{
ulong value = BitConverter.ToUInt64(buffer, offset);
offset += 8;
return value;
}
private static byte[] ReadBytes(byte[] buffer, ref int offset, int count)
{
byte[] result = new byte[count];
Buffer.BlockCopy(buffer, offset, result, 0, count);
offset += count;
return result;
}
};
struct cmd_task_var_data
{
public uint size;
public byte[] data;
};
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b7b3600ea9146f345883726da0f9c37e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+217
View File
@@ -0,0 +1,217 @@
using ModelRenderer.Scripts.GameData;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
namespace PerfectWorld.Scripts.Task
{
public struct TASK_PACK_HEADER
{
public ulong magic;
public ulong version;
public ulong item_count;
};
public class ATaskTemplMan
{
public const ulong TASK_PACK_MAGIC = 0x93858361;
public const ulong _task_templ_cur_version = 121;
private ulong g_ulNewCount = 0;// do we need this?
private Dictionary<ulong, ATaskTempl> m_TaskTemplMap = new Dictionary<ulong, ATaskTempl>();
private Dictionary<ulong, ATaskTempl> m_AllTemplMap = new Dictionary<ulong, ATaskTempl>();
private Dictionary<ulong, ATaskTempl> m_DynTaskMap = new Dictionary<ulong, ATaskTempl>();
private Dictionary<ulong, ATaskTempl> m_TitleTaskMap = new Dictionary<ulong, ATaskTempl>();
private Dictionary<ulong, ATaskTempl> m_ExlusiveAwardTaskMap = new Dictionary<ulong, ATaskTempl>();
private Dictionary<ulong, ATaskTempl> m_ProtectNPCMap = new Dictionary<ulong, ATaskTempl>();
private Dictionary<ulong, ATaskTempl> m_AutoDelvMap = new Dictionary<ulong, ATaskTempl>();
private Dictionary<ulong, ATaskTempl> m_DeathTrigMap = new Dictionary<ulong, ATaskTempl>();
private Dictionary<ulong, ATaskTempl> m_PQTemplMap = new Dictionary<ulong, ATaskTempl>();
private List<ATaskTempl> m_SkillTaskLst = new List<ATaskTempl>();
private List<ATaskTempl> m_TmLmtChkLst = new List<ATaskTempl>();
private elementdataman m_pEleDataMan;
public void Release()
{
}
public void Init(elementdataman pMan)
{
m_pEleDataMan = pMan;
}
public bool LoadTasksFromPack(string szPackPath, bool bLoadDescript)
{
//TaskInterface::WriteLog(0, 0, 2, "LoadPack begin");
FileStream fs = new FileStream(szPackPath, FileMode.Open, FileAccess.Read);
if (fs == null) return false;
TASK_PACK_HEADER tph;
// fread(&tph, sizeof(tph), 1, fp);
tph = ReadStruct<TASK_PACK_HEADER>(fs);
if (tph.magic != TASK_PACK_MAGIC
|| tph.version != _task_templ_cur_version)
return false;
if (tph.item_count == 0) return true;
long[] pOffs = new long[tph.item_count];
g_ulNewCount++;
// fread(pOffs, sizeof(long), tph.item_count, fp);
// Convert fread(pOffs, sizeof(long), tph.item_count, fp); to C#
// Read tph.item_count 8-byte integers (long) from the FileStream fs into pOffs array
byte[] offsBuffer = new byte[tph.item_count * sizeof(long)];
int bytesRead = fs.Read(offsBuffer, 0, offsBuffer.Length);
if (bytesRead != offsBuffer.Length)
throw new EndOfStreamException("Could not read enough bytes for offsets");
for (ulong i = 0; i < tph.item_count; i++)
{
pOffs[i] = System.BitConverter.ToInt64(offsBuffer, (int)(i * sizeof(long)));
}
for (ulong i = 0; i < tph.item_count; i++)
{
// if (fseek(fp, pOffs[i], SEEK_SET) != 0)
// continue;
if (fs.Seek(pOffs[i], SeekOrigin.Begin) != 0)
continue;
ATaskTempl pTempl = new ATaskTempl();
g_ulNewCount++;
if (!pTempl.LoadFromBinFile(fs))
{
CECTaskInterface.WriteLog(0, (int)pTempl.m_ID, 0, "Cant Load Task");
// LOG_DELETE(pTempl);
continue;
}
AddOneTaskTempl(pTempl);
// TaskInterface::WriteLog(0, pTempl->m_ID, 2, "LoadTask");
}
// char log[1024];
// sprintf(log, "LoadTask, Count = %d", m_TaskTemplMap.size());
// TaskInterface::WriteLog(0, 0, 2, log);
//todo: check
// LOG_DELETE_ARR(pOffs);
fs.Close();
UpdateTimeLimitCheckList();
#if _ELEMENTCLIENT
_task_err.Release();
_task_err.Init("Configs\\task_err.txt", true);
#endif
return true;
}
// General method to read a struct from a FileStream
private T ReadStruct<T>(FileStream stream) where T : struct
{
int size = System.Runtime.InteropServices.Marshal.SizeOf(typeof(T));
byte[] buffer = new byte[size];
int bytesRead = stream.Read(buffer, 0, size);
if (bytesRead != size)
throw new EndOfStreamException("Could not read enough bytes for struct");
var handle = System.Runtime.InteropServices.GCHandle.Alloc(buffer, System.Runtime.InteropServices.GCHandleType.Pinned);
try
{
return (T)System.Runtime.InteropServices.Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(T));
}
finally
{
handle.Free();
}
}
public bool LoadNPCInfoFromPack(string szPath)
{
return true;
}
public void VerifyDynTasksPack(string szPath)
{
}
private void AddOneTaskTempl(ATaskTempl pTask)
{
//todo: recheck - wrong logic
if (m_AllTemplMap.ContainsKey(pTask.m_ID))
{
CECTaskInterface.WriteLog(0, (int)pTask.m_ID, 0, "Dup Task Found");
// Optionally log duplicate task found, e.g.:
// Debug.LogWarning($"Duplicate Task Found: {pTempl.m_ID}");
return;
}
m_TaskTemplMap[pTask.m_ID] = pTask;
if (pTask.m_bDeathTrig) m_DeathTrigMap[pTask.m_ID] = pTask;
else if (pTask.m_bAutoDeliver) m_AutoDelvMap[pTask.m_ID] = pTask;
if (pTask.m_bPQTask) m_PQTemplMap[pTask.m_ID] = pTask;
if (pTask.m_bSkillTask) m_SkillTaskLst.Add(pTask);
//todo: recheck m_DynTaskType type
if (!string.IsNullOrEmpty(pTask.m_DynTaskType))
{
if (m_DynTaskMap.TryGetValue(pTask.m_ID, out ATaskTempl task))
{
CECTaskInterface.WriteLog(0, (int)pTask.m_ID, 0, "Dup Dyn Task Found");
}
m_DynTaskMap[pTask.m_ID] = pTask;
}
if (pTask.m_bDisplayInTitleTaskUI)
m_TitleTaskMap[pTask.m_ID] = pTask;
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
AddTaskToMap(pTask);
}
private void AddTaskToMap(ATaskTempl pTempl)
{
if (pTempl.m_enumMethod == (ulong)TaskMethod.enumTMProtectNPC && pTempl.m_ulNPCToProtect > 0)
m_ProtectNPCMap[pTempl.m_ulNPCToProtect] = pTempl;
m_AllTemplMap[pTempl.m_ID] = pTempl;
ATaskTempl pChild = pTempl.m_pFirstChild;
while (pChild != null)
{
AddTaskToMap(pChild);
pChild = pChild.m_pNextSibling;
}
}
void UpdateTimeLimitCheckList()
{
m_TmLmtChkLst.Clear();
foreach (var entry in m_TaskTemplMap)
{
if (entry.Value.m_ulMaxReceiver != 0)
{
m_TmLmtChkLst.Add(entry.Value);
}
}
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: fb2a99ced76b6c847810e2eadf598724
+118
View File
@@ -0,0 +1,118 @@
using System.Collections.Generic;
namespace PerfectWorld.Scripts.Task
{
public class CECTaskInterface : TaskInterface
{
CECHostPlayer m_pHost;
object[] 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);
ATaskTemplMan pTaskMan = GetTaskTemplMan();
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 static void WriteLog(int nPlayerId, int nTaskId, int nType, string szLog)
{
//do something?
}
private ATaskTemplMan GetTaskTemplMan()
{
//return g_pGame->GetTaskTemplateMan();
return null;
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: fb2c49d4eb415e343b0b312e215a2d00
+7
View File
@@ -0,0 +1,7 @@
namespace PerfectWorld.Scripts.Task
{
public interface TaskInterface
{
bool Init(object[] pActiveListBuf, int iActiveListLen, object[] pFinishedListBuf, int iFinishedListLen, object[] pFinishedTimeListBuf, int iFinishedTimeListLen, object[] pFinishedCountListBuf, int iFinishedCountListLen, object[] pStorageTaskListBuf, int iStorageTaskListLen);
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 1247ada478ebf564e9086d6142776d50
+538
View File
@@ -0,0 +1,538 @@
using UnityEngine;
using System.IO;
namespace PerfectWorld.Scripts.Task
{
/// <summary>
/// Completion Method
/// </summary>
public enum TaskMethod
{
enumTMNone = 0, // None
enumTMKillNumMonster, // Kill a number of monsters
enumTMCollectNumArticle, // Collect a number of items
enumTMTalkToNPC, // Talk to a specific NPC
enumTMReachSite, // Reach a specific location
enumTMWaitTime, // Wait for a specified time
enumTMAnswerQuestion, // Answer a question
enumTMTinyGame, // Mini-game
enumTMProtectNPC, // Protect a specific NPC
enumTMNPCReachSite, // NPC reaches a specific location
enumTMGlobalValOK, // Global variable condition satisfied
enumTMLeaveSite, // Leave a specific location
enumTMReachTreasureZone, // Reach the treasure area
enumTMKillPlayer, // Kill another player
enumTMTransform, // Transform state
enumTMReachLevel, // Check level: normal level, rebirth count, realm level
enumTMSimpleClientTask, // Simple client task (only client-side validation, currently just checks UI triggers)
enumTMSimpleClientTaskForceNavi // Force navigation
}
public class ATaskTemplFixedData
{
public ulong m_ID;
public ulong m_ulNPCToProtect;
public ulong m_ulProtectTimeLen;
public ulong m_enumMethod;
public ulong m_enumFinishType;
//Hierarchy
public ATaskTempl m_pParent;
public ATaskTempl m_pPrevSibling;
public ATaskTempl m_pNextSibling;
public ATaskTempl m_pFirstChild;
// Required items
public ulong m_ulPremItems;
// public ItemWanted[] m_PremItems; // [MAX_ITEM_WANTED]
public bool m_bShowByItems;
public bool m_bPremItemsAnyOne;
// Level condition
public ulong m_ulPremise_Lev_Min;
public ulong m_ulPremise_Lev_Max;
public ulong m_bPremCheckMaxHistoryLevel;
public bool m_bShowByLev;
// Monster controller
public long m_lMonsCtrl;
public bool m_bTrigCtrl;
// Auto trigger when conditions are met
public bool m_bAutoDeliver;
// Whether to display in exclusive UI
public bool m_bDisplayInExclusiveUI;
public bool m_bReadyToNotifyServer;
// Whether used in token shop
public bool m_bUsedInTokenShop;
// Trigger on death
public bool m_bDeathTrig;
// Whether clear all acquired items
public bool m_bClearAcquired;
// Recommended level
public ulong m_ulSuitableLevel;
// Whether to show prompt
public bool m_bShowPrompt;
// Whether it is a key task
public bool m_bKeyTask;
// Deliver NPC
public ulong m_ulDelvNPC;
// Award NPC
public ulong m_ulAwardNPC;
// Whether it is a skill task
public bool m_bSkillTask;
// Can be sought out
public bool m_bCanSeekOut;
// Whether to show direction
public bool m_bShowDirection;
// Marriage
public bool m_bMarriage;
// Change global key/value
public ulong m_ulChangeKeyCnt;
public long[] m_plChangeKey; // [TASK_AWARD_MAX_CHANGE_VALUE]
public long[] m_plChangeKeyValue;
public bool[] m_pbChangeType;
// Switch scene fail
public bool m_bSwitchSceneFail;
// Hidden task
public bool m_bHidden;
// Whether to deliver skill [Yongdong, 2010-1-6]
public bool m_bDeliverySkill;
public int m_iDeliveredSkillID;
public int m_iDeliveredSkillLevel;
// Whether to show task finished effect [Yongdong, 2010-1-21]
public bool m_bShowGfxFinished; // Show effect when task is completed
// Whether change PQ ranking
public bool m_bChangePQRanking;
// Compare items with player inventory before delivery
public bool m_bCompareItemAndInventory;
public ulong m_ulInventorySlotNum; // Required number of inventory slots
// Whether it is a PQ task
public bool m_bPQTask;
// PQ task global variable display
public ulong m_ulPQExpCnt;
// Dynamic task type
public string m_DynTaskType;
// Special award ID, used for events
public ulong m_ulSpecialAward;
// Whether to display in the title task UI
public bool m_bDisplayInTitleTaskUI;
// Maximum number of receivers
public ulong m_ulMaxReceiver;
}
public class ATaskTempl : ATaskTemplFixedData
{
const int MAX_TASK_NAME_LEN = 30;
public bool LoadFromBinFile(FileStream fp)
{
LoadBinary(fp);
// CheckDepth();
return true;
}
private void LoadBinary(FileStream fp)
{
LoadFixedDataFromBinFile(fp);
// LoadDescriptionBin(fp);
// LoadTributeBin(fp);
//# ifndef _TASK_CLIENT
// CheckMask();
//#else
// SyncTaskType();
//#endif
// namechar code = (namechar)m_ID;
// m_DelvTaskTalk.load(fp);
// convert_talk_text(&m_DelvTaskTalk, code);
// m_UnqualifiedTalk.load(fp);
// convert_talk_text(&m_UnqualifiedTalk, code);
// m_DelvItemTalk.load(fp);
// convert_talk_text(&m_DelvItemTalk, code);
// m_ExeTalk.load(fp);
// convert_talk_text(&m_ExeTalk, code);
// m_AwardTalk.load(fp);
// convert_talk_text(&m_AwardTalk, code);
// fread(&m_nSubCount, sizeof(m_nSubCount), 1, fp);
// for (int i = 0; i < m_nSubCount; i++)
// {
// ATaskTempl* pSub = new ATaskTempl;
// g_ulNewCount++;
// AddSubTaskTempl(pSub);
// pSub->LoadBinary(fp);
// }
// SynchID();
//return true;
}
private bool LoadFixedDataFromBinFile(FileStream fp)
{
// LOG_DELETE(m_Award_S);
// LOG_DELETE(m_Award_F);
// LOG_DELETE(m_AwByRatio_S);
// LOG_DELETE(m_AwByRatio_F);
// LOG_DELETE(m_AwByItems_S);
// LOG_DELETE(m_AwByItems_F);
// LOG_DELETE_ARR(m_tmStart);
// LOG_DELETE_ARR(m_tmEnd);
// LOG_DELETE_ARR(m_plChangeKey);
// LOG_DELETE_ARR(m_plChangeKeyValue);
// LOG_DELETE_ARR(m_pbChangeType);
// LOG_DELETE_ARR(m_PremItems);
// LOG_DELETE_ARR(m_GivenItems);
// LOG_DELETE_ARR(m_TeamMemsWanted);
// LOG_DELETE_ARR(m_ItemsWanted);
// LOG_DELETE_ARR(m_PlayerWanted);
// LOG_DELETE_ARR(m_MonsterWanted);
// LOG_DELETE_ARR(m_pszSignature);
// LOG_DELETE_ARR(m_pszExp);
// LOG_DELETE_ARR(m_pExpArr);
// LOG_DELETE_ARR(m_pTaskChar);
// LOG_DELETE_ARR(m_pszPQExp);
// LOG_DELETE_ARR(m_pPQExpArr);
// LOG_DELETE_ARR(m_MonstersContrib);
// LOG_DELETE_ARR(m_pDelvRegion);
// LOG_DELETE_ARR(m_pEnterRegion);
// LOG_DELETE_ARR(m_pLeaveRegion);
// LOG_DELETE_ARR(m_pReachSite);
// LOG_DELETE_ARR(m_pLeaveSite);
// LOG_DELETE_ARR(m_PremTitles);
ulong i;
//write method FRead convert this to c#
//fread(this, sizeof(*this), 1, fp);
//convert_txt(m_szName, MAX_TASK_NAME_LEN, (namechar)m_ID);
// m_Award_S = new AWARD_DATA;
// g_ulNewCount++;
// m_Award_F = new AWARD_DATA;
// g_ulNewCount++;
// m_AwByRatio_S = new AWARD_RATIO_SCALE;
// g_ulNewCount++;
// m_AwByRatio_F = new AWARD_RATIO_SCALE;
// g_ulNewCount++;
// m_AwByItems_S = new AWARD_ITEMS_SCALE;
// g_ulNewCount++;
// m_AwByItems_F = new AWARD_ITEMS_SCALE;
// g_ulNewCount++;
// m_tmStart = NULL;
// m_tmEnd = NULL;
// m_plChangeKey = NULL;
// m_plChangeKeyValue = NULL;
// m_pbChangeType = NULL;
// m_PremItems = NULL;
// m_GivenItems = NULL;
// m_TeamMemsWanted= NULL;
// m_ItemsWanted = NULL;
// m_PlayerWanted = NULL;
// m_MonsterWanted = NULL;
// m_pszSignature = NULL;
// m_pszExp = NULL;
// m_pExpArr = NULL;
// m_pTaskChar = NULL;
// m_pszPQExp = NULL;
// m_pPQExpArr = NULL;
// m_MonstersContrib = NULL;
// m_PremTitles = NULL;
// if (m_bHasSign)
// {
// m_pszSignature = new task_char[MAX_TASK_NAME_LEN];
// g_ulNewCount++;
// fread(m_pszSignature, sizeof(task_char), MAX_TASK_NAME_LEN, fp);
// convert_txt(m_pszSignature, MAX_TASK_NAME_LEN, (namechar)m_ID);
// }
// if (m_ulTimetable)
// {
// m_tmStart = new task_tm[m_ulTimetable];
// g_ulNewCount++;
// m_tmEnd = new task_tm[m_ulTimetable];
// g_ulNewCount++;
// }
// for (i = 0; i < m_ulTimetable; i++)
// {
// fread(&m_tmStart[i], sizeof(task_tm), 1, fp);
// fread(&m_tmEnd[i], sizeof(task_tm), 1, fp);
// }
// if (m_ulChangeKeyCnt)
// {
// m_plChangeKey = new long[m_ulChangeKeyCnt];
// m_plChangeKeyValue = new long[m_ulChangeKeyCnt];
// m_pbChangeType = new bool[m_ulChangeKeyCnt];
// }
// for (i=0; i<m_ulChangeKeyCnt; i++)
// {
// fread(&m_plChangeKey[i], sizeof(long), 1, fp);
// fread(&m_plChangeKeyValue[i], sizeof(long), 1, fp);
// fread(&m_pbChangeType[i], sizeof(bool), 1, fp);
// }
// if (m_ulPQExpCnt)
// {
// m_pszPQExp = new char[m_ulPQExpCnt][TASK_AWARD_MAX_DISPLAY_CHAR_LEN];
// memset(m_pszPQExp, 0, m_ulPQExpCnt*TASK_AWARD_MAX_DISPLAY_CHAR_LEN);
// m_pPQExpArr = new TASK_EXPRESSION[m_ulPQExpCnt][TASK_AWARD_MAX_DISPLAY_CHAR_LEN];
// memset(m_pPQExpArr, 0, sizeof(TASK_EXPRESSION)*m_ulPQExpCnt*TASK_AWARD_MAX_DISPLAY_CHAR_LEN);
// for (i=0; i<m_ulPQExpCnt; i++)
// {
// fread(m_pszPQExp[i], 1, TASK_AWARD_MAX_DISPLAY_CHAR_LEN, fp);
// fread(m_pPQExpArr[i], sizeof(TASK_EXPRESSION), TASK_AWARD_MAX_DISPLAY_CHAR_LEN, fp);
// }
// }
// if (m_ulMonsterContribCnt)
// {
// m_MonstersContrib = new MONSTERS_CONTRIB[m_ulMonsterContribCnt];
// g_ulNewCount++;
// }
// for (i = 0; i < m_ulMonsterContribCnt; i++)
// {
// MONSTERS_CONTRIB& mc = m_MonstersContrib[i];
// fread(&mc, sizeof(mc), 1, fp);
// }
// // version 80
// if (m_ulDelvRegionCnt>0)
// {
// m_pDelvRegion = new Task_Region[m_ulDelvRegionCnt];
// g_ulNewCount++;
// }
// else m_pDelvRegion = NULL;
// for (i=0;i<m_ulDelvRegionCnt;i++)
// {
// Task_Region& t = m_pDelvRegion[i];
// fread(&t,sizeof(Task_Region),1,fp);
// }
// if (m_ulEnterRegionCnt>0)
// {
// m_pEnterRegion = new Task_Region[m_ulEnterRegionCnt];
// g_ulNewCount++;
// }
// else m_pEnterRegion = NULL;
// for (i=0;i<m_ulEnterRegionCnt;i++)
// {
// Task_Region& t = m_pEnterRegion[i];
// fread(&t,sizeof(Task_Region),1,fp);
// }
// if (m_ulLeaveRegionCnt>0)
// {
// m_pLeaveRegion = new Task_Region[m_ulLeaveRegionCnt];
// g_ulNewCount++;
// }
// else m_pLeaveRegion = NULL;
// for (i=0;i<m_ulLeaveRegionCnt;i++)
// {
// Task_Region& t = m_pLeaveRegion[i];
// fread(&t,sizeof(Task_Region),1,fp);
// }
// // ÈÎÎñ¿ªÆôÌõ¼þ¼°·½Ê½
// if (m_ulPremItems)
// {
// m_PremItems = new ITEM_WANTED[m_ulPremItems];
// g_ulNewCount++;
// }
// for (i = 0; i < m_ulPremItems; i++)
// {
// ITEM_WANTED& iw = m_PremItems[i];
// fread(&iw, sizeof(iw), 1, fp);
// }
// m_ulGivenCmnCount = 0;
// m_ulGivenTskCount = 0;
// if (m_ulGivenItems)
// {
// m_GivenItems = new ITEM_WANTED[m_ulGivenItems];
// g_ulNewCount++;
// }
// for (i = 0; i < m_ulGivenItems; i++)
// {
// ITEM_WANTED& iw = m_GivenItems[i];
// fread(&iw, sizeof(iw), 1, fp);
// if (iw.m_bCommonItem) m_ulGivenCmnCount++;
// else m_ulGivenTskCount++;
// }
// if (m_bTeamwork)
// {
// if (m_ulTeamMemsWanted)
// {
// m_TeamMemsWanted = new TEAM_MEM_WANTED[m_ulTeamMemsWanted];
// g_ulNewCount++;
// }
// for (i = 0; i < m_ulTeamMemsWanted; i++)
// {
// TEAM_MEM_WANTED& tmw = m_TeamMemsWanted[i];
// fread(&tmw, sizeof(tmw), 1, fp);
// }
// }
// if (m_iPremTitleNumTotal)
// {
// m_PremTitles = new int[m_iPremTitleNumTotal];
// g_ulNewCount++;
// for (i = 0; i < m_iPremTitleNumTotal; i++)
// {
// fread(&m_PremTitles[i], sizeof(int), 1, fp);
// }
// }
// /* ÈÎÎñÍê³ÉµÄ·½Ê½¼°Ìõ¼þ */
// if (m_ulMonsterWanted)
// {
// m_MonsterWanted = new MONSTER_WANTED[m_ulMonsterWanted];
// g_ulNewCount++;
// }
// for (i = 0; i < m_ulMonsterWanted; i++)
// {
// MONSTER_WANTED& mw = m_MonsterWanted[i];
// fread(&mw, sizeof(mw), 1, fp);
// }
// if (m_ulPlayerWanted)
// {
// m_PlayerWanted = new PLAYER_WANTED[m_ulPlayerWanted];
// g_ulNewCount++;
// }
// for (i = 0; i < m_ulPlayerWanted; ++i)
// {
// PLAYER_WANTED& pw = m_PlayerWanted[i];
// fread(&pw, sizeof(pw), 1, fp);
// }
// if (m_ulItemsWanted)
// {
// m_ItemsWanted = new ITEM_WANTED[m_ulItemsWanted];
// g_ulNewCount++;
// }
// for (i = 0; i < m_ulItemsWanted; i++)
// {
// ITEM_WANTED& iw = m_ItemsWanted[i];
// fread(&iw, sizeof(iw), 1, fp);
// }
// if (m_ulExpCnt)
// {
// m_pszExp = new char[m_ulExpCnt][TASK_AWARD_MAX_DISPLAY_CHAR_LEN];
// memset(m_pszExp, 0, m_ulExpCnt*TASK_AWARD_MAX_DISPLAY_CHAR_LEN);
// m_pExpArr = new TASK_EXPRESSION[m_ulExpCnt][TASK_AWARD_MAX_DISPLAY_CHAR_LEN];
// memset(m_pExpArr, 0, sizeof(TASK_EXPRESSION)*m_ulExpCnt*TASK_AWARD_MAX_DISPLAY_CHAR_LEN);
// for (i=0; i<m_ulExpCnt; i++)
// {
// fread(m_pszExp[i], 1, TASK_AWARD_MAX_DISPLAY_CHAR_LEN, fp);
// fread(m_pExpArr[i], sizeof(TASK_EXPRESSION), TASK_AWARD_MAX_DISPLAY_CHAR_LEN, fp);
// }
// }
// if (m_ulTaskCharCnt)
// {
// m_pTaskChar = new task_char[m_ulTaskCharCnt][TASK_AWARD_MAX_DISPLAY_CHAR_LEN];
// memset(m_pTaskChar, 0, sizeof(task_char)*m_ulTaskCharCnt*TASK_AWARD_MAX_DISPLAY_CHAR_LEN);
// for (i=0; i<m_ulTaskCharCnt; i++)
// {
// fread(m_pTaskChar[i], sizeof(task_char), TASK_AWARD_MAX_DISPLAY_CHAR_LEN, fp);
// }
// }
// // version 80
// if (m_ulReachSiteCnt>0)
// {
// m_pReachSite = new Task_Region[m_ulReachSiteCnt];
// g_ulNewCount++;
// }
// else m_pReachSite = NULL;
// for (i=0;i<m_ulReachSiteCnt;i++)
// {
// Task_Region& t = m_pReachSite[i];
// fread(&t,sizeof(Task_Region),1,fp);
// }
// if (m_ulLeaveSiteCnt>0)
// {
// m_pLeaveSite = new Task_Region[m_ulLeaveSiteCnt];
// g_ulNewCount++;
// }
// else m_pLeaveSite = NULL;
// for (i=0;i<m_ulLeaveSiteCnt;i++)
// {
// Task_Region& t = m_pLeaveSite[i];
// fread(&t,sizeof(Task_Region),1,fp);
// }
// LoadAwardDataBin(fp, *m_Award_S, _task_templ_cur_version);
// LoadAwardDataBin(fp, *m_Award_F, _task_templ_cur_version);
// LoadAwardDataRatioScale(fp, *m_AwByRatio_S, _task_templ_cur_version);
// LoadAwardDataRatioScale(fp, *m_AwByRatio_F, _task_templ_cur_version);
// LoadAwardDataItemsScale(fp, *m_AwByItems_S, _task_templ_cur_version);
// LoadAwardDataItemsScale(fp, *m_AwByItems_F, _task_templ_cur_version);
return true;
}
string ConvertTxt(string str, char code)
{
char[] chars = str.ToCharArray();
for (int i = 0; i < chars.Length; i++)
{
chars[i] = (char)(chars[i] ^ code);
}
return new string(chars);
}
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 7428b1ddedbd2da409ed16996d66f7c6