Merge remote-tracking branch 'origin/develop' into feature/movement

# Conflicts:
#	Assets/NetworkLib/Debug/netstandard2.1/CSNetwork.dll
#	Assets/Scripts/Move/EC_Player.cs
#	Assets/Scripts/PlayerVisual.cs
This commit is contained in:
NguyenVanDat
2025-10-07 09:31:01 +07:00
163 changed files with 16015 additions and 192 deletions
+11 -11
View File
@@ -214,7 +214,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:
@@ -422,18 +422,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)
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7c78d146782232847ac2e4a6cec64dbf
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+36
View File
@@ -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
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e9b6b5b70c94a5c4e9dbaa1b2e1c323c
+2 -2
View File
@@ -20,13 +20,13 @@ public class PlayerVisual : MonoBehaviour
namedAnimancer = GetComponentInChildren<NamedAnimancerComponent>();
if(namedAnimancer == null)
{
BrewMonster.Logger.LogError("animancer == null");
BrewMonster.BMLogger.LogError("animancer == null");
return;
}
var player = GetComponentInParent<EC_Player>();
if(player == null)
{
BrewMonster.Logger.LogError("player == null");
BrewMonster.BMLogger.LogError("player == null");
return;
}
_playerInfo = player.GetPlayInfo();
+104 -60
View File
@@ -1,3 +1,4 @@
using BrewMonster;
using ModelRenderer.Scripts.GameData;
using System.Collections.Generic;
using System.IO;
@@ -5,12 +6,6 @@ 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;
@@ -28,6 +23,10 @@ namespace PerfectWorld.Scripts.Task
private Dictionary<ulong, ATaskTempl> m_DeathTrigMap = new Dictionary<ulong, ATaskTempl>();
private Dictionary<ulong, ATaskTempl> m_PQTemplMap = new Dictionary<ulong, ATaskTempl>();
private Dictionary<uint, uint> m_StorageEssenseMap = new Dictionary<uint, uint>();
private Dictionary<uint, uint> m_WeightEssenseMap = new Dictionary<uint, uint>();
private Dictionary<int, int> m_StorageTaskMap = new Dictionary<int, int>();
private List<ATaskTempl> m_SkillTaskLst = new List<ATaskTempl>();
private List<ATaskTempl> m_TmLmtChkLst = new List<ATaskTempl>();
@@ -41,17 +40,21 @@ namespace PerfectWorld.Scripts.Task
{
m_pEleDataMan = pMan;
}
public bool LoadTasksFromPack(string szPackPath, bool bLoadDescript)
{
//TaskInterface::WriteLog(0, 0, 2, "LoadPack begin");
BMLogger.Log("[Dat]- szPackPath: " + szPackPath);
if (!File.Exists(szPackPath))
{
BMLogger.LogError("[Dat]- File not found: " + szPackPath);
return false;
}
long readBytes = 0;
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);
TASK_PACK_HEADER tph = AAssit.ReadFromBinaryOf<TASK_PACK_HEADER>(fs, ref readBytes);
if (tph.magic != TASK_PACK_MAGIC
|| tph.version != _task_templ_cur_version)
@@ -59,37 +62,24 @@ namespace PerfectWorld.Scripts.Task
if (tph.item_count == 0) return true;
long[] pOffs = new long[tph.item_count];
uint[] pOffs = new uint[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
pOffs = AAssit.ReadArrayFromBinary<uint>(fs, tph.item_count, ref readBytes);
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++)
for (int 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;
fs.Seek(pOffs[i], SeekOrigin.Begin);
ATaskTempl pTempl = new ATaskTempl();
g_ulNewCount++;
if (!pTempl.LoadFromBinFile(fs))
{
CECTaskInterface.WriteLog(0, (int)pTempl.m_ID, 0, "Cant Load Task");
CECTaskInterface.WriteLog(0, (int)pTempl.m_FixedData.m_ID, 0, "Cant Load Task");
// LOG_DELETE(pTempl);
continue;
}
@@ -98,14 +88,14 @@ namespace PerfectWorld.Scripts.Task
// 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);
// // char log[1024];
// // sprintf(log, "LoadTask, Count = %d", m_TaskTemplMap.size());
// // TaskInterface::WriteLog(0, 0, 2, log);
//todo: check
// LOG_DELETE_ARR(pOffs);
// //todo: check
// // LOG_DELETE_ARR(pOffs);
fs.Close();
UpdateTimeLimitCheckList();
// UpdateTimeLimitCheckList();
#if _ELEMENTCLIENT
_task_err.Release();
@@ -145,52 +135,52 @@ namespace PerfectWorld.Scripts.Task
private void AddOneTaskTempl(ATaskTempl pTask)
{
//todo: recheck - wrong logic
if (m_AllTemplMap.ContainsKey(pTask.m_ID))
if (m_AllTemplMap.ContainsKey(pTask.m_FixedData.m_ID))
{
CECTaskInterface.WriteLog(0, (int)pTask.m_ID, 0, "Dup Task Found");
CECTaskInterface.WriteLog(0, (int)pTask.m_FixedData.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;
m_TaskTemplMap[pTask.m_FixedData.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_FixedData.m_bDeathTrig) m_DeathTrigMap[pTask.m_FixedData.m_ID] = pTask;
else if (pTask.m_FixedData.m_bAutoDeliver) m_AutoDelvMap[pTask.m_FixedData.m_ID] = pTask;
if (pTask.m_bPQTask) m_PQTemplMap[pTask.m_ID] = pTask;
if (pTask.m_FixedData.m_bPQTask) m_PQTemplMap[pTask.m_FixedData.m_ID] = pTask;
if (pTask.m_bSkillTask) m_SkillTaskLst.Add(pTask);
if (pTask.m_FixedData.m_bSkillTask) m_SkillTaskLst.Add(pTask);
//todo: recheck m_DynTaskType type
if (!string.IsNullOrEmpty(pTask.m_DynTaskType))
if (!string.IsNullOrEmpty(pTask.m_FixedData.m_DynTaskType))
{
if (m_DynTaskMap.TryGetValue(pTask.m_ID, out ATaskTempl task))
if (m_DynTaskMap.TryGetValue(pTask.m_FixedData.m_ID, out ATaskTempl task))
{
CECTaskInterface.WriteLog(0, (int)pTask.m_ID, 0, "Dup Dyn Task Found");
CECTaskInterface.WriteLog(0, (int)pTask.m_FixedData.m_ID, 0, "Dup Dyn Task Found");
}
m_DynTaskMap[pTask.m_ID] = pTask;
m_DynTaskMap[pTask.m_FixedData.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 (pTask.m_FixedData.m_bDisplayInTitleTaskUI)
m_TitleTaskMap[pTask.m_FixedData.m_ID] = pTask;
if (pTask.m_FixedData.m_bAutoDeliver && pTask.m_FixedData.m_bDisplayInExclusiveUI)
m_ExlusiveAwardTaskMap[pTask.m_FixedData.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);
}
private void AddTaskToMap(ATaskTempl pTempl)
{
if (pTempl.m_enumMethod == (ulong)TaskMethod.enumTMProtectNPC && pTempl.m_ulNPCToProtect > 0)
m_ProtectNPCMap[pTempl.m_ulNPCToProtect] = pTempl;
if (pTempl.m_FixedData.m_enumMethod == (ulong)TaskMethod.enumTMProtectNPC && pTempl.m_FixedData.m_ulNPCToProtect > 0)
m_ProtectNPCMap[pTempl.m_FixedData.m_ulNPCToProtect] = pTempl;
m_AllTemplMap[pTempl.m_ID] = pTempl;
m_AllTemplMap[pTempl.m_FixedData.m_ID] = pTempl;
ATaskTempl pChild = pTempl.m_pFirstChild;
while (pChild != null)
@@ -206,12 +196,66 @@ namespace PerfectWorld.Scripts.Task
foreach (var entry in m_TaskTemplMap)
{
if (entry.Value.m_ulMaxReceiver != 0)
if (entry.Value.m_FixedData.m_ulMaxReceiver != 0)
{
m_TmLmtChkLst.Add(entry.Value);
}
}
}
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;
}
}
}
+63 -14
View File
@@ -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<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)
{
@@ -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;
}
}
}
+13
View File
@@ -0,0 +1,13 @@
namespace PerfectWorld.Scripts.Task
{
public struct TASK_EXPRESSION
{
public int type;
public float value;
public bool Equals(TASK_EXPRESSION src)
{
return (type == src.type && value == src.value);
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 9d2bf3627a0e544b2a6d78e170a46142
+176
View File
@@ -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<ATaskTempl>(
new IntPtr(unchecked((long)m_ulTemplAddr))
);
// return reinterpret_cast<const ATaskTempl*>(m_ulTemplAddr);
}
// const ATaskTempl* GetCap() const { return reinterpret_cast<const ATaskTempl*>(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;}
};
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 624d08204f26c7c49bc8b1885be16f22
+281 -77
View File
@@ -1,7 +1,100 @@
using UnityEngine;
using System.IO;
using System.Runtime.InteropServices;
namespace PerfectWorld.Scripts.Task
{
public sealed class TaskConstant
{
public const int MAX_OCCUPATIONS = 12;
public const int MAX_TASK_NAME_LEN = 30;
public const int MAX_AWARD_NPC_NUM = 8;
public const int MAX_PREM_TASK_COUNT = 20;
public const int MAX_MUTEX_TASK_COUNT = 5;
public const int MAX_TEAM_MEM_WANTED = MAX_OCCUPATIONS;
public const int MAX_TIMETABLE_SIZE = 24;
public const int MAX_AWARD_SCALES = 5;
public const int MAX_AWARD_CANDIDATES = 12;
public const int MAX_LIVING_SKILLS = 4;
public const int MAX_CONTRIB_MONSTERS = 100;
public const int MAX_AWARD_PQ_RANKING = 32;
public const int MAX_TITLE_NUM = 10;
public const int MAX_TASKREGION = 8;
public const int TASK_GENDER_NONE = 0;
public const int TASK_GENDER_MALE = 1;
public const int TASK_GENDER_FEMALE = 2;
public const int TASK_MAX_PATH = 260;
public const int INVALID_VAL = -1;
public const int TASK_MAX_LINE_LEN = TASK_MAX_PATH;
public const int TASK_MAX_VALID_COUNT = 6;
public const int TASK_TREASURE_MAP_SIDE_MULTIPLE = 30;
public readonly long[] task_week_map =
{
7,
1,
2,
3,
4,
5,
6
};
}
public struct task_tm
{
public int year;
public int month;
public int day;
public int hour;
public int min;
public int wday;
}
public struct TASK_PACK_HEADER
{
public uint magic;
public uint version;
public int item_count;
}
public struct MONSTERS_CONTRIB
{
public ulong m_ulMonsterTemplId; // Monster ID
public int m_iWholeContrib; // Team exclusive contribution
public int m_iShareContrib; // Team shared contribution
public int m_iPersonalWholeContrib; // Personal exclusive contribution
public bool Equals(MONSTERS_CONTRIB src)
{
return (m_ulMonsterTemplId == src.m_ulMonsterTemplId &&
m_iWholeContrib == src.m_iWholeContrib &&
m_iShareContrib == src.m_iShareContrib &&
m_iPersonalWholeContrib == src.m_iPersonalWholeContrib);
}
}
public struct ZONE_VERT
{
public float x;
public float y;
public float z;
}
public enum task_tm_type
{
enumTaskTimeDate = 0,
enumTaskTimeMonth,
enumTaskTimeWeek,
enumTaskTimeDay
};
/// <summary>
/// Completion Method
/// </summary>
@@ -27,31 +120,141 @@ namespace PerfectWorld.Scripts.Task
enumTMSimpleClientTaskForceNavi // Force navigation
}
public class ATaskTemplFixedData
public struct Task_Region
{
public ulong m_ID;
public ulong m_ulNPCToProtect;
public ulong m_ulProtectTimeLen;
public ulong m_enumMethod;
public ulong m_enumFinishType;
public ZONE_VERT zvMin;
public ZONE_VERT zvMax;
//Hierarchy
public ATaskTempl m_pParent;
public ATaskTempl m_pPrevSibling;
public ATaskTempl m_pNextSibling;
public ATaskTempl m_pFirstChild;
public bool Equals(Task_Region src)
{
return (zvMin.x == src.zvMin.x && zvMin.y == src.zvMin.y && zvMin.z == src.zvMin.z &&
zvMax.x == src.zvMax.x && zvMax.y == src.zvMax.y && zvMax.z == src.zvMax.z);
}
// Required items
public ulong m_ulPremItems;
// public ItemWanted[] m_PremItems; // [MAX_ITEM_WANTED]
public bool m_bShowByItems;
public bool m_bPremItemsAnyOne;
public static bool operator ==(Task_Region a, Task_Region b)
{
return a.Equals(b);
}
// Level condition
public ulong m_ulPremise_Lev_Min;
public ulong m_ulPremise_Lev_Max;
public ulong m_bPremCheckMaxHistoryLevel;
public bool m_bShowByLev;
public static bool operator !=(Task_Region a, Task_Region b)
{
return !a.Equals(b);
}
public override bool Equals(object obj)
{
if (obj is Task_Region)
return Equals((Task_Region)obj);
return false;
}
public override int GetHashCode()
{
return zvMin.GetHashCode() ^ zvMax.GetHashCode();
}
}
public struct ATaskTemplFixedData
{
/* Task object properties */
// Task ID
public uint m_ID;
// Task name
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TaskConstant.MAX_TASK_NAME_LEN)]
public ushort[] m_szName;
// Task signature
public bool m_bHasSign;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TaskConstant.MAX_TASK_NAME_LEN)]
public ushort[] m_pszSignature;
// Task type
public uint m_ulType;
// Time limit
public uint m_ulTimeLimit;
// Task fails when offline
public bool m_bOfflineFail;
// Absolute failure time
public bool m_bAbsFail;
public task_tm m_tmAbsFailTime;
// Do not take items during task validation
public bool m_bItemNotTakeOff;
// Whether using absolute time
public bool m_bAbsTime;
// Number of time periods
public ulong m_ulTimetable;
// Time method
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TaskConstant.MAX_TIMETABLE_SIZE)]
public byte[] m_tmType;
// Start time for delivery
public task_tm[] m_tmStart; // [MAX_TIMETABLE_SIZE]
// End time for delivery
public task_tm[] m_tmEnd; // [MAX_TIMETABLE_SIZE]
// Delivery frequency
public long m_lAvailFrequency;
public long m_lPeriodLimit;
// Execute single subtask
public bool m_bChooseOne;
// Randomly rotate single subtask execution
public bool m_bRandOne;
// Whether subtasks have order
public bool m_bExeChildInOrder;
// Whether parent task fails when subtask fails
public bool m_bParentAlsoFail;
// Whether parent task succeeds when subtask succeeds
public bool m_bParentAlsoSucc;
// Whether task can be abandoned
public bool m_bCanGiveUp;
// Whether task can be repeated
public bool m_bCanRedo;
// Whether task can be redone after failure
public bool m_bCanRedoAfterFailure;
// Clear task on abandonment
public bool m_bClearAsGiveUp;
// Whether recording is needed
public bool m_bNeedRecord;
// Whether task fails when player dies
public bool m_bFailAsPlayerDie;
// Maximum number of receivers
public uint m_ulMaxReceiver;
// Delivery zone
public bool m_bDelvInZone;
public uint m_ulDelvWorld;
public uint m_ulDelvRegionCnt;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TaskConstant.MAX_TASKREGION)]
public Task_Region[] m_pDelvRegion;
// Enter region task failure
public bool m_bEnterRegionFail;
public uint m_ulEnterRegionWorld;
public uint m_ulEnterRegionCnt;
//public ZONE_VERT m_EnterRegionMinVert;
//public ZONE_VERT m_EnterRegionMaxVert;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TaskConstant.MAX_TASKREGION)]
public Task_Region[] m_pEnterRegion;
// Leave region task failure
public bool m_bLeaveRegionFail;
public uint m_ulLeaveRegionWorld;
public uint m_ulLeaveRegionCnt;
//public ZONE_VERT m_LeaveRegionMinVert;
//public ZONE_VERT m_LeaveRegionMaxVert;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TaskConstant.MAX_TASKREGION)]
public Task_Region[] m_pLeaveRegion;
// Leave force failure
public bool m_bLeaveForceFail;
// Transport to specific point
public bool m_bTransTo;
public uint m_ulTransWldId;
public ZONE_VERT m_TransPt;
// Monster controller
public long m_lMonsCtrl;
@@ -67,14 +270,14 @@ namespace PerfectWorld.Scripts.Task
// Whether used in token shop
public bool m_bUsedInTokenShop;
// Trigger on death
// Death trigger
public bool m_bDeathTrig;
// Whether clear all acquired items
public bool m_bClearAcquired;
// Recommended level
public ulong m_ulSuitableLevel;
public uint m_ulSuitableLevel;
// Whether to show prompt
public bool m_bShowPrompt;
@@ -82,56 +285,77 @@ namespace PerfectWorld.Scripts.Task
// Whether it is a key task
public bool m_bKeyTask;
// Deliver NPC
public ulong m_ulDelvNPC;
// Delivery NPC
public uint m_ulDelvNPC;
// Award NPC
public ulong m_ulAwardNPC;
public uint m_ulAwardNPC;
// Whether it is a skill task
public bool m_bSkillTask;
// Can be sought out
// Whether can be searched
public bool m_bCanSeekOut;
// Whether to show direction
// Whether 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 uint m_ulChangeKeyCnt;
public long[] m_plChangeKey; // [TASK_AWARD_MAX_CHANGE_VALUE]
public long[] m_plChangeKeyValue;
public bool[] m_pbChangeType;
// Switch scene fail
// Fail on scene switch
public bool m_bSwitchSceneFail;
// Hidden task
public bool m_bHidden;
// Whether to deliver skill [Yongdong, 2010-1-6]
// Whether deliver skill
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 show task completion effect
public bool m_bShowGfxFinished;
// Whether change PQ ranking
// Whether change player ranking in PQ
public bool m_bChangePQRanking;
// Compare items with player inventory before delivery
// Compare delivery items with player inventory slots
public bool m_bCompareItemAndInventory;
public ulong m_ulInventorySlotNum; // Required number of inventory slots
public uint m_ulInventorySlotNum;
// Whether it is a PQ task
public bool m_bPQTask;
/////////////////////////////////////////////// PQ Task start
// 是否是PQ任务
public bool m_bPQTask;
// PQ任务全局变量显示
public uint m_ulPQExpCnt;
public uint m_ulNPCToProtect;
public uint m_ulProtectTimeLen;
public uint m_enumMethod;
public uint m_enumFinishType;
// 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;
// PQ task global variable display
public ulong m_ulPQExpCnt;
// Dynamic task type
public string m_DynTaskType;
@@ -140,12 +364,21 @@ namespace PerfectWorld.Scripts.Task
// Whether to display in the title task UI
public bool m_bDisplayInTitleTaskUI;
// Maximum number of receivers
public ulong m_ulMaxReceiver;
}
public class ATaskTempl : ATaskTemplFixedData
public class ATaskTempl
{
public ATaskTemplFixedData m_FixedData;
//Hierarchy
public ATaskTempl m_pParent;
public ATaskTempl m_pPrevSibling;
public ATaskTempl m_pNextSibling;
public ATaskTempl m_pFirstChild;
const int MAX_TASK_NAME_LEN = 30;
public byte m_uValidCount;
public bool LoadFromBinFile(FileStream fp)
{
LoadBinary(fp);
@@ -197,41 +430,10 @@ namespace PerfectWorld.Scripts.Task
}
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);
long readBytes = 0;
ATaskTemplFixedData fixedData = AAssit.ReadFromBinaryOf<ATaskTemplFixedData>(fp, ref readBytes);
//convert_txt(m_szName, MAX_TASK_NAME_LEN, (namechar)m_ID);
@@ -533,6 +735,8 @@ namespace PerfectWorld.Scripts.Task
}
return new string(chars);
}
public void IncValidCount() { m_uValidCount++; }
}
}
+24
View File
@@ -0,0 +1,24 @@
using System.IO;
using UnityEngine;
namespace PerfectWorld.Scripts.Task
{
public class TaskTest : MonoBehaviour
{
ATaskTemplMan m_pTaskMan;
[ContextMenu("Load Data")]
void LoadTaskData()
{
if (m_pTaskMan == null)
{
m_pTaskMan = new ATaskTemplMan();
}
string path = Path.Combine(Application.streamingAssetsPath, "data/tasks.data");
m_pTaskMan.LoadTasksFromPack(path, true);
}
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 561ff33122f704147a67d91c42fde5a4