diff --git a/Assets/PerfectWorld/Resources/WorldTargetSO.asset b/Assets/PerfectWorld/Resources/WorldTargetSO.asset new file mode 100644 index 0000000000..cc2b6f80ca --- /dev/null +++ b/Assets/PerfectWorld/Resources/WorldTargetSO.asset @@ -0,0 +1,51 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f04e4cee6b3592d46866e3d631e4d4e0, type: 3} + m_Name: WorldTargetSO + m_EditorClassIdentifier: + worldTargets: + - id: 9047 + name: + Name: "\u4E5D\u5195\u5C18\u5BF0\u53F0" + world_id: 161 + vecPos: + x: -799.016 + y: 45 + z: -282.283 + domain_id: -1 + - id: 9048 + name: + Name: "\u841D\u4F1A\u57CE" + world_id: 161 + vecPos: + x: -162.798 + y: 36 + z: 299.386 + domain_id: -1 + - id: 9049 + name: + Name: "\u5D06\u5CD2\u53E4\u9547" + world_id: 161 + vecPos: + x: 876.326 + y: 51 + z: 369.481 + domain_id: -1 + - id: 9050 + name: + Name: "\u6A2A\u5929\u9619" + world_id: 161 + vecPos: + x: 887.151 + y: 154 + z: -295.974 + domain_id: -1 diff --git a/Assets/PerfectWorld/Resources/WorldTargetSO.asset.meta b/Assets/PerfectWorld/Resources/WorldTargetSO.asset.meta new file mode 100644 index 0000000000..11c4566449 --- /dev/null +++ b/Assets/PerfectWorld/Resources/WorldTargetSO.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3e25bab2c9ca9714ea2d7d5f094ddd5b +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PerfectWorld/Scripts/Common/DataProcess/ScriptableObjects.meta b/Assets/PerfectWorld/Scripts/Common/DataProcess/ScriptableObjects.meta new file mode 100644 index 0000000000..751dcd7506 --- /dev/null +++ b/Assets/PerfectWorld/Scripts/Common/DataProcess/ScriptableObjects.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 33958689dea439040976b900bc6494d5 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PerfectWorld/Scripts/Common/DataProcess/ScriptableObjects/WorldTargetSO.cs b/Assets/PerfectWorld/Scripts/Common/DataProcess/ScriptableObjects/WorldTargetSO.cs new file mode 100644 index 0000000000..408bee1c55 --- /dev/null +++ b/Assets/PerfectWorld/Scripts/Common/DataProcess/ScriptableObjects/WorldTargetSO.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace BrewMonster.Scripts.Common.DataProcess.ScriptableObjects +{ + [CreateAssetMenu(fileName = "WorldTargetSO", menuName = "BrewMonster/WorldTargetSO")] + public class WorldTargetSO : ScriptableObject + { + public List worldTargets; + } +} \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/Common/DataProcess/ScriptableObjects/WorldTargetSO.cs.meta b/Assets/PerfectWorld/Scripts/Common/DataProcess/ScriptableObjects/WorldTargetSO.cs.meta new file mode 100644 index 0000000000..df57f0550d --- /dev/null +++ b/Assets/PerfectWorld/Scripts/Common/DataProcess/ScriptableObjects/WorldTargetSO.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: f04e4cee6b3592d46866e3d631e4d4e0 \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/Common/DataProcess/globaldataman.cs b/Assets/PerfectWorld/Scripts/Common/DataProcess/globaldataman.cs index 6aeaf0b9d7..00294e29d5 100644 --- a/Assets/PerfectWorld/Scripts/Common/DataProcess/globaldataman.cs +++ b/Assets/PerfectWorld/Scripts/Common/DataProcess/globaldataman.cs @@ -2,6 +2,8 @@ using System; using System.Collections.Generic; using System.IO; using System.Runtime.InteropServices; +using BrewMonster; +using BrewMonster.Scripts.Common.DataProcess.ScriptableObjects; using CSNetwork.GPDataType; using UnityEngine; @@ -12,6 +14,7 @@ public struct TRANS_TARGET [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public ushort[] name; + public string Name; public int world_id; public A3DVECTOR3 vecPos; public int domain_id; @@ -98,9 +101,40 @@ public static class BinaryReaderExtensions } } +public class GlobalDataManager +{ + public static void globaldata_load() + { + // read world target data + var worldTargetSO = Resources.Load("WorldTargetSO"); + if(worldTargetSO == null) + { + BMLogger.LogError("GlobalDataManager: world target data not found"); + + #if UNITY_EDITOR + // show a dialouge for the error + UnityEditor.EditorUtility.DisplayDialog("GlobalDataManager", "World target data not found", "OK"); + #endif + + return; + } + + GlobalTransmitData.global_trans_targets = worldTargetSO.worldTargets; + + //TODO: Load the domain info file. It's a binary file. + // now load domain info file + // AFileImage domainFile = new AFileImage(); + // if( !domainFile.Open("Data\\domain.data", AFILE_OPENEXIST | AFILE_BINARY) ) + // { + // a_LogOutput(1, "GlobalData_Load(), Failed to open domain data file"); + // return false; + // } + } +} + public class GlobalTransmitData { - private static List global_trans_targets = new(); + public static List global_trans_targets = new(); private static List global_trans_targets_server = new(); public static List globaldata_gettranstargets => global_trans_targets; diff --git a/Assets/PerfectWorld/Scripts/MainFiles/EC_Game.cs b/Assets/PerfectWorld/Scripts/MainFiles/EC_Game.cs index 12c38216ab..61b287dcae 100644 --- a/Assets/PerfectWorld/Scripts/MainFiles/EC_Game.cs +++ b/Assets/PerfectWorld/Scripts/MainFiles/EC_Game.cs @@ -138,6 +138,8 @@ namespace BrewMonster.Network // 加载 coord_data.txt(C++:Configs/Coord_data.txt)用于任务可点击链接的自动移动。 LoadObjectCoord(); LoadPetAutoSkill(); + + GlobalDataManager.globaldata_load(); return true; } public static CECConfigs GetConfigs() { return m_pConfigs; } diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs index 0c34668c25..c6bc63a45d 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs @@ -1018,6 +1018,7 @@ namespace CSNetwork.GPDataType } [StructLayout(LayoutKind.Sequential, Pack = 1)] + [System.Serializable] public struct A3DVECTOR3 { public float x; @@ -2303,6 +2304,60 @@ namespace CSNetwork.GPDataType { public ushort waypoint; }; + + public struct cmd_waypoint_list + { + public uint count; + public ushort[] list; + + public bool FromBytes(byte[] data) + { + const int CountSize = sizeof(uint); + const int ItemSize = sizeof(ushort); + + if (data == null || data.Length < CountSize) + { + count = 0; + list = Array.Empty(); + return false; + } + + ReadOnlySpan buffer = data; + uint parsedCount = BinaryPrimitives.ReadUInt32LittleEndian(buffer.Slice(0, CountSize)); + uint maxCount = (uint)((data.Length - CountSize) / ItemSize); + + if (parsedCount > maxCount || parsedCount > int.MaxValue) + { + count = 0; + list = Array.Empty(); + return false; + } + + int itemCount = (int)parsedCount; + if (itemCount == 0) + { + count = parsedCount; + list = Array.Empty(); + return true; + } + + ushort[] parsedList = list; + if (parsedList == null || parsedList.Length != itemCount) + parsedList = new ushort[itemCount]; + + int offset = CountSize; + for (int i = 0; i < itemCount; i++) + { + parsedList[i] = BinaryPrimitives.ReadUInt16LittleEndian(buffer.Slice(offset, ItemSize)); + offset += ItemSize; + } + + count = parsedCount; + list = parsedList; + return true; + } + } + [StructLayout(LayoutKind.Sequential, Pack = 1)] public static class GNETRoles { diff --git a/Assets/PerfectWorld/Scripts/UI/GamePlay/EC_GameUIMan.cs b/Assets/PerfectWorld/Scripts/UI/GamePlay/EC_GameUIMan.cs index 02d5301b7c..5700d61c25 100644 --- a/Assets/PerfectWorld/Scripts/UI/GamePlay/EC_GameUIMan.cs +++ b/Assets/PerfectWorld/Scripts/UI/GamePlay/EC_GameUIMan.cs @@ -37,6 +37,14 @@ namespace BrewMonster.UI public CDlgMiniMap m_pDlgMiniMap; + //TODO: There're some managers here. We probably need to implement them in the future. + // CECCustomizeMgr *m_CustomizeMgr; + // CECHomeDlgsMgr *m_HomeDlgsMgr; + // CECMiniBarMgr *m_pMiniBarMgr; + private CECMapDlgsMgr m_pMapDlgsMgr; + // CECShortcutMgr *m_pShortcutMgr; + // CECIconStateMgr *m_pIconStateMgr; + private readonly ChatEmotionDisplayPipeline _chatEmotionPipeline = new ChatEmotionDisplayPipeline(); /// @@ -437,7 +445,15 @@ namespace BrewMonster.UI m_IconMap[(byte)EC_GAMEUI_ICONS.ICONS_INVENTORY] = (INVENTORY_ICONLIST_NAME, Resources.LoadAll(INVENTORY_ICONLIST_NAME)); m_IconMap[(byte)EC_GAMEUI_ICONS.ICONS_STATE] = (STATE_ICONLIST_NAME, Resources.LoadAll(STATE_ICONLIST_NAME)); m_IconMap[(byte)EC_GAMEUI_ICONS.ICONS_SKILLGRP] = (SKILL_GROUP_ICON_NAME, Resources.LoadAll(SKILL_GROUP_ICON_NAME)); + + m_pMapDlgsMgr = new CECMapDlgsMgr(); } + + public CECMapDlgsMgr GetMapDlgsMgr() + { + return m_pMapDlgsMgr; + } + public AUIImagePictureBase SetCover(AUIImagePictureBase pImgPic, string nameImage, EC_GAMEUI_ICONS iCONS_TYPE) { if (pImgPic == null) diff --git a/Assets/PerfectWorld/Scripts/UI/WorldMap/DlgWorldMap.cs b/Assets/PerfectWorld/Scripts/UI/WorldMap/DlgWorldMap.cs index 78a4c7ee78..f98f7207db 100644 --- a/Assets/PerfectWorld/Scripts/UI/WorldMap/DlgWorldMap.cs +++ b/Assets/PerfectWorld/Scripts/UI/WorldMap/DlgWorldMap.cs @@ -201,7 +201,7 @@ namespace BrewMonster.UI public Dictionary m_transPoints = new(); // update player way-points - public void UpdateWayPoints(object pData, int iSize, bool bClear) + public void UpdateWayPoints(ushort[] pData, uint iSize, bool bClear) { var vecTarget = GlobalTransmitData.globaldata_gettranstargets; @@ -213,7 +213,7 @@ namespace BrewMonster.UI // got valid points. for(int i = 0; i < iSize; i++ ) { - int idThis = *(pData+i); + int idThis = pData[i];//*(pData+i); for(int j = 0; j < vecTarget.Count; j++ ) { if( idThis != vecTarget[j].id ) continue; @@ -221,7 +221,7 @@ namespace BrewMonster.UI TRANS_POINT tp; tp.id = idThis; - tp.strName = ByteToStringUtils.UshortArrayToUnicodeString(vecTarget[j].name); + tp.strName = vecTarget[j].Name; tp.vecPos = vecTarget[j].vecPos; tp.worldid = vecTarget[j].world_id; diff --git a/Assets/Scripts/CECHostPlayer.World.cs b/Assets/Scripts/CECHostPlayer.World.cs index fb2a72a562..c7839afe91 100644 --- a/Assets/Scripts/CECHostPlayer.World.cs +++ b/Assets/Scripts/CECHostPlayer.World.cs @@ -1,5 +1,6 @@ using BrewMonster.Network; using BrewMonster.Scripts; +using BrewMonster.UI; using CSNetwork; using CSNetwork.GPDataType; using Cysharp.Threading.Tasks; @@ -57,7 +58,7 @@ namespace BrewMonster void OnMsgHstWayPoint(ECMSG Msg) { - CECGameUIMan pGameUI = EC_Game.GetGameRun().GetUIManager().GetInGameUIMan(); + CECGameUIMan pGameUI = CECUIManager.Instance.GetInGameUIMan(); if (Convert.ToInt32(Msg.dwParam2) == CommandID.ACTIVATE_WAYPOINT) { @@ -67,6 +68,17 @@ namespace BrewMonster // add to waypoints array // pGameUI.GetMapDlgsMgr().UpdateWayPoints(&pCmd.waypoint, 1, false); } + else if (Convert.ToInt32(Msg.dwParam2) == CommandID.WAYPOINT_LIST) + { + cmd_waypoint_list pCmd = new cmd_waypoint_list(); + pCmd.FromBytes((byte[])Msg.dwParam1); + + for (int i=0; i < pCmd.count; i++) + m_aWayPoints.Add(pCmd.list[i]); + + // update the whole list + pGameUI.GetMapDlgsMgr().UpdateWayPoints(pCmd.list, pCmd.count, true); + } } private void OnMsgHstPressCancel(ECMSG Msg) diff --git a/Assets/Scripts/CECUIManager.cs b/Assets/Scripts/CECUIManager.cs index 60795916e8..31d407656b 100644 --- a/Assets/Scripts/CECUIManager.cs +++ b/Assets/Scripts/CECUIManager.cs @@ -49,6 +49,7 @@ public class CECUIManager : MonoSingleton Sprite[] m_iconlistIvtr; private CDlgInfoTooltip m_pDlgSkillTooltip; + // Task update timer / 任务更新计时器 private float _nextTaskUpdateTime = 0f; private const float TASK_UPDATE_INTERVAL = .1f;