diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_ManMatter.cs b/Assets/PerfectWorld/Scripts/Managers/EC_ManMatter.cs
index fded88deee..6ed1f6cb7b 100644
--- a/Assets/PerfectWorld/Scripts/Managers/EC_ManMatter.cs
+++ b/Assets/PerfectWorld/Scripts/Managers/EC_ManMatter.cs
@@ -1,5 +1,6 @@
using BrewMonster;
using BrewMonster.Network;
+using BrewMonster.Scripts.World;
using CSNetwork;
using CSNetwork.GPDataType;
using CSNetwork.Protocols;
@@ -10,323 +11,220 @@ using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
+using System.Threading.Tasks;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace PerfectWorld.Scripts.Managers
{
- namespace BrewMonster.Managers
+ ///
+ /// Matter Manager - Handles matter data storage and provides access to other classes
+ ///
+ /// Usage Examples:
+ /// // Get matter manager instance
+ /// var matterManager = EC_ManMessageMono.Instance.GetECManMatter;
+ ///
+ /// // Get specific matter data
+ /// var matterData = matterManager.GetMatterData(12345);
+ ///
+ /// // Get individual fields
+ /// int? mid = matterManager.GetMatterId(12345);
+ /// int? tid = matterManager.GetMatterTid(12345);
+ /// A3DVECTOR3? pos = matterManager.GetMatterPosition(12345);
+ /// byte? state = matterManager.GetMatterState(12345);
+ ///
+ /// // Find matters by criteria
+ /// int[] mattersByTid = matterManager.FindMattersByTid(100);
+ /// int[] mattersByState = matterManager.FindMattersByState(1);
+ /// int[] nearbyMatters = matterManager.FindMattersNearPosition(new A3DVECTOR3(0,0,0), 10.0f);
+ ///
+ [Serializable]
+ public class EC_ManMatter : IMsgHandler
{
- ///
- /// Matter Manager - Handles matter data storage and provides access to other classes
- ///
- /// Usage Examples:
- /// // Get matter manager instance
- /// var matterManager = EC_ManMessageMono.Instance.GetECManMatter;
- ///
- /// // Get specific matter data
- /// var matterData = matterManager.GetMatterData(12345);
- ///
- /// // Get individual fields
- /// int? mid = matterManager.GetMatterId(12345);
- /// int? tid = matterManager.GetMatterTid(12345);
- /// A3DVECTOR3? pos = matterManager.GetMatterPosition(12345);
- /// byte? state = matterManager.GetMatterState(12345);
- ///
- /// // Find matters by criteria
- /// int[] mattersByTid = matterManager.FindMattersByTid(100);
- /// int[] mattersByState = matterManager.FindMattersByState(1);
- /// int[] nearbyMatters = matterManager.FindMattersNearPosition(new A3DVECTOR3(0,0,0), 10.0f);
- ///
- [Serializable]
- public class EC_ManMatter : IMsgHandler
+ public int HandlerId => (int)MANAGER_INDEX.MAN_MATTER;
+
+ // Storage for matter data that players can access later
+ private Dictionary matterDataStorage = new Dictionary();
+ private Dictionary m_MatterTab = new Dictionary();
+ public bool ProcessMessage(ECMSG Msg)
{
- public int HandlerId => (int)MANAGER_INDEX.MAN_MATTER;
+ if (Msg.iSubID == 0)
+ {
+ switch ((int)Msg.dwMsg)
+ {
+ case int value when value == EC_MsgDef.MSG_MM_MATTERINFO:
+ {
+ //ENABLE LATER: It fetch all matters in the game world, causing performance issues
+ OnMsgMatterInfo(Msg);
+ break;
+ }
+ case int value when value == EC_MsgDef.MSG_MM_MATTERENTWORLD:
+ {
+ OnMsgMatterEnterWorld(Msg);
+ break;
+ }
+ case int value when value == EC_MsgDef.MSG_MM_MATTERDISAPPEAR:
+ {
+ OnMsgMatterDisappear(Msg);
+ break;
+ }
+
+ }
+ }
+ else
+ {
+
+ }
+ return true;
+ }
+
+ public async void OnMsgMatterInfo(ECMSG Msg)
+ {
+ byte[] data = (byte[])Msg.dwParam1;
- // Storage for matter data that players can access later
- private Dictionary matterDataStorage = new Dictionary();
- public bool ProcessMessage(ECMSG Msg)
+ try
{
- if (Msg.iSubID == 0)
- {
- switch ((int)Msg.dwMsg)
- {
- case int value when value == EC_MsgDef.MSG_MM_MATTERINFO:
- {
- //ENABLE LATER: It fetch all matters in the game world, causing performance issues
- OnMsgMatterInfo(Msg);
- break;
- }
- case int value when value == EC_MsgDef.MSG_MM_MATTERENTWORLD:
- {
- OnMsgMatterEnterWorld(Msg);
- break;
- }
- }
- }
- else
- {
-
- }
- return true;
- }
-
- public void OnMsgMatterInfo(ECMSG Msg)
- {
- byte[] data = (byte[])Msg.dwParam1;
+ // Parse the data structure: count + info_matter array
+ int offset = 0;
- try
- {
- // Parse the data structure: count + info_matter array
- int offset = 0;
-
- // Read count (ushort)
- ushort count = BitConverter.ToUInt16(data, offset);
- offset += sizeof(ushort);
-
- Debug.Log($"MATTERINFO: Received {count} matter entries");
-
- // Parse each info_matter entry
- for (int i = 0; i < count; i++)
- {
- // Parse info_matter structure
- info_matter matterInfo = CSNetwork.GPDataType.GPDataTypeHelper.FromBytes(data, offset);
- info_matter_uint matterInfoUint = CSNetwork.GPDataType.GPDataTypeHelper.FromBytes(data, offset);
-
- BMLogger.Log($"OnMsgMatterEnterWorld():: mid: {matterInfoUint.mid}, tid: {matterInfoUint.tid}, pos: {matterInfoUint.pos.x}, {matterInfoUint.pos.y}, {matterInfoUint.pos.z}");
- offset += Marshal.SizeOf(typeof(info_matter));
-
- // Store the matter data for later player access
- matterDataStorage[matterInfo.mid] = matterInfo;
-
- Debug.Log($"Matter info - ID: {matterInfo.mid}, TID: {matterInfo.tid}, Position: {matterInfo.pos}, State: {matterInfo.state}");
-
- // Spawn cube for this matter since it has entered the world
- // SpawnMatterCube(matterInfo.mid);
- SpawnMatterModelObject(matterInfo);
- }
- }
- catch (Exception ex)
- {
- Debug.LogError($"Failed to parse matter info data: {ex.Message}");
- }
- }
-
- public void OnMsgMatterEnterWorld(ECMSG Msg)
- {
- byte[] data = (byte[])Msg.dwParam1;
+ // Read count (ushort)
+ ushort count = BitConverter.ToUInt16(data, offset);
+ offset += sizeof(ushort);
- try
+ Debug.Log($"MATTERINFO: Received {count} matter entries");
+
+ // Parse each info_matter entry
+ for (int i = 0; i < count; i++)
{
- // Parse the byte array into info_matter structure
- info_matter matterInfo = CSNetwork.GPDataType.GPDataTypeHelper.FromBytes(data);
- info_matter_uint matterInfoUint = CSNetwork.GPDataType.GPDataTypeHelper.FromBytes(data);
-
- BMLogger.Log($"OnMsgMatterEnterWorld():: mid: {matterInfoUint.mid}, tid: {matterInfoUint.tid}, pos: {matterInfoUint.pos.x}, {matterInfoUint.pos.y}, {matterInfoUint.pos.z}");
+ // Parse info_matter structure
+ info_matter info = CSNetwork.GPDataType.GPDataTypeHelper.FromBytes(data, offset);
+ offset += Marshal.SizeOf(typeof(info_matter));
+
// Store the matter data for later player access
- matterDataStorage[matterInfo.mid] = matterInfo;
+ matterDataStorage[info.mid] = info;
- //Debug.Log($"Matter entered world - ID: {matterInfo.mid}, TID: {matterInfo.tid}, Position: {matterInfo.pos}, State: {matterInfo.state}");
-
- // Notify pickupItem to create cube for this matter
- NotifyPickupItem(matterInfo.mid);
- }
- catch (Exception ex)
- {
- Debug.LogError($"Failed to parse matter data: {ex.Message}");
+ Debug.Log($"Matter info - ID: {info.mid}, TID: {info.tid}, Position: {info.pos}, State: {info.state}");
+ await MatterEnter(info);
}
}
+ catch (Exception ex)
+ {
+ Debug.LogError($"Failed to parse matter info data: {ex.Message}");
+ }
+ }
+
+ public async void OnMsgMatterEnterWorld(ECMSG Msg)
+ {
+ byte[] data = (byte[])Msg.dwParam1;
- private void SpawnMatterCube(int matterId)
+ try
{
- // Check if matter is within 1000 units of the host player
- /*if (!IsMatterWithinPlayerRange(matterId, 10000f))
- {
- Debug.Log($"Matter {matterId} is too far from player, skipping spawn");
- return;
- }*/
-
- // Find the pickupItem component in the scene and create cube for this specific matter
- pickupItem pickupScript = UnityEngine.Object.FindFirstObjectByType();
- if (pickupScript != null)
- {
- pickupScript.CreateMatterCube(matterId);
- }
- else
- {
- Debug.LogWarning("pickupItem component not found in scene - cannot spawn matter cube");
- }
+ // Parse the byte array into info_matter structure
+ info_matter matterInfo = CSNetwork.GPDataType.GPDataTypeHelper.FromBytes(data);
+ await MatterEnter(matterInfo);
}
-
- private void SpawnMatterModelObject(info_matter info)
+ catch (Exception ex)
{
- // Find the pickupItem component in the scene and create model object for this specific matter
- pickupItem pickupScript = UnityEngine.Object.FindFirstObjectByType();
- if (pickupScript != null)
- {
- pickupScript.CreateMatterModelObject(info);
- }
+ Debug.LogError($"Failed to parse matter data: {ex.Message}");
}
-
- private void NotifyPickupItem(int matterId)
- {
- // Check if matter is within 1000 units of the host player
- if (!IsMatterWithinPlayerRange(matterId, 1000f))
- {
- Debug.Log($"Matter {matterId} is too far from player, skipping notification");
- return;
- }
+ }
- // Find the pickupItem component in the scene and update cubes
- pickupItem pickupScript = UnityEngine.Object.FindFirstObjectByType();
- if (pickupScript != null)
- {
- pickupScript.UpdateMatterObjects();
- }
+ public void OnMsgMatterDisappear(ECMSG Msg)
+ {
+ byte[] data = (byte[])Msg.dwParam1;
+ int matterId = BitConverter.ToInt32(data);
+
+ MatterLeave(matterId);
+ }
+
+ private async Task MatterEnter(info_matter info)
+ {
+ CECMatter pMatter = GetMatter(info.mid);
+ if (pMatter != null)
+ return true;
+
+ // Create a new matter
+ pMatter = await CECMatter.Init(info);
+ if (pMatter == null)
+ {
+ Debug.LogError($"Failed to create matter: {info.mid}");
+ return false;
}
+ pMatter.SetBornStamp(CECWorld.Instance.GetBornStamp());
+ m_MatterTab[info.mid] = pMatter;
- ///
- /// Check if a matter is within the specified distance from the host player
- ///
- /// The matter ID to check
- /// Maximum distance in Unity units
- /// True if matter is within range, false otherwise
- private bool IsMatterWithinPlayerRange(int matterId, float maxDistance)
+
+ return true;
+ }
+
+ // Remove a matter
+ public void RemoveMatter(int idMatter) { MatterLeave(idMatter); }
+
+ public void MatterLeave(int mid)
+ {
+ CECMatter pMatter = GetMatter(mid);
+ if (pMatter != null)
{
- // Get the matter data
- if (!matterDataStorage.TryGetValue(matterId, out info_matter matterData))
- {
- Debug.LogWarning($"Matter data not found for ID: {matterId}");
- return false;
- }
+ UnityEngine.Object.Destroy(pMatter.gameObject);
+ m_MatterTab.Remove(mid);
+ }
+ //TODO: Might need to implement later
+ /*/
+ else
+ {
+ MatterTable::pair_type Pair = m_DynModelTab.get(mid);
- // Get the host player
- var hostPlayer = CECGameRun.Instance?.GetHostPlayer();
- if (hostPlayer == null)
+ if (Pair.second)
{
- Debug.LogWarning("Host player not found");
- return false;
- }
+ pMatter = *Pair.first;
- // Convert matter position to Unity Vector3
- Vector3 matterPosition = new Vector3(matterData.pos.x, matterData.pos.y, matterData.pos.z);
+ ReleaseMatter(pMatter);
+
+ // Remove it from active matter table
+ m_DynModelTab.erase(mid);
- // Get player position
- Vector3 playerPosition = hostPlayer.transform.position;
-
- // Calculate distance
- float distance = Vector3.Distance(matterPosition, playerPosition);
-
- Debug.Log($"Matter {matterId} distance from player: {distance:F2} units (max: {maxDistance})");
-
- return distance <= maxDistance;
- }
-
- // Public methods for players to access matter data
- public info_matter? GetMatterData(int matterId)
- {
- return matterDataStorage.TryGetValue(matterId, out info_matter data) ? data : null;
- }
-
- public Dictionary GetAllMatterData()
- {
- return new Dictionary(matterDataStorage);
- }
-
- public bool HasMatterData(int matterId)
- {
- return matterDataStorage.ContainsKey(matterId);
- }
-
- public void RemoveMatterData(int matterId)
- {
- if (matterDataStorage.ContainsKey(matterId))
- {
- matterDataStorage.Remove(matterId);
- Debug.Log($"Removed matter data for ID: {matterId}");
+ QueueMatterUndoLoad(mid);
}
}
-
- public int GetMatterCount()
- {
- return matterDataStorage.Count;
- }
-
- // Convenience methods to get specific fields from matter data
- public int? GetMatterId(int matterId)
- {
- return matterDataStorage.TryGetValue(matterId, out info_matter data) ? data.mid : null;
- }
-
- public int? GetMatterTid(int matterId)
- {
- return matterDataStorage.TryGetValue(matterId, out info_matter data) ? data.tid : null;
- }
-
- public A3DVECTOR3? GetMatterPosition(int matterId)
- {
- return matterDataStorage.TryGetValue(matterId, out info_matter data) ? data.pos : null;
- }
-
- public byte? GetMatterDir0(int matterId)
- {
- return matterDataStorage.TryGetValue(matterId, out info_matter data) ? data.dir0 : null;
- }
-
- public byte? GetMatterDir1(int matterId)
- {
- return matterDataStorage.TryGetValue(matterId, out info_matter data) ? data.dir1 : null;
- }
-
- public byte? GetMatterRadius(int matterId)
- {
- return matterDataStorage.TryGetValue(matterId, out info_matter data) ? data.rad : null;
- }
-
- public byte? GetMatterState(int matterId)
- {
- return matterDataStorage.TryGetValue(matterId, out info_matter data) ? data.state : null;
- }
-
- public byte? GetMatterValue(int matterId)
- {
- return matterDataStorage.TryGetValue(matterId, out info_matter data) ? data.value : null;
- }
-
- // Get all matter IDs
- public int[] GetAllMatterIds()
- {
- return matterDataStorage.Keys.ToArray();
- }
- public info_matter[] GetAllMatterInfo()
+ CECPlayerWrapper* pWrapper = CECAutoPolicy::GetInstance().GetPlayerWrapper();
+ if( pWrapper ) pWrapper->OnObjectDisappear(mid);
+ //*/
+ }
+
+ // Public methods for players to access matter data
+ public info_matter? GetMatterData(int matterId)
+ {
+ return matterDataStorage.TryGetValue(matterId, out info_matter data) ? data : null;
+ }
+
+ public bool HasMatterData(int matterId)
+ {
+ return matterDataStorage.ContainsKey(matterId);
+ }
+
+ public CECMatter GetMatter(int mid, uint dwBornStamp = 0)
+ {
+ if (m_MatterTab.TryGetValue(mid, out CECMatter matter))
{
- return matterDataStorage.Values.ToArray();
- }
-
- // Find matters by template ID (tid)
- public int[] FindMattersByTid(int tid)
- {
- return matterDataStorage.Where(kvp => kvp.Value.tid == tid).Select(kvp => kvp.Key).ToArray();
- }
-
- // Find matters by state
- public int[] FindMattersByState(byte state)
- {
- return matterDataStorage.Where(kvp => kvp.Value.state == state).Select(kvp => kvp.Key).ToArray();
- }
-
- // Get matters within a certain distance from a position
- public int[] FindMattersNearPosition(A3DVECTOR3 position, float maxDistance)
- {
- return matterDataStorage.Where(kvp =>
+ if (dwBornStamp != 0)
{
- float distance = (kvp.Value.pos - position).Magnitude();
- return distance <= maxDistance;
- }).Select(kvp => kvp.Key).ToArray();
+ if (matter.GetBornStamp() != dwBornStamp)
+ {
+ return null;
+ }
+ }
+
+ return matter;
}
+ return null;
+ }
+
+ public CECMatter CreateMatter(info_matter info)
+ {
+ return null;
}
}
}
\ No newline at end of file
diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_ManPlayer.cs b/Assets/PerfectWorld/Scripts/Managers/EC_ManPlayer.cs
index d72587fe2c..756394c5fb 100644
--- a/Assets/PerfectWorld/Scripts/Managers/EC_ManPlayer.cs
+++ b/Assets/PerfectWorld/Scripts/Managers/EC_ManPlayer.cs
@@ -1,4 +1,5 @@
using BrewMonster;
+using BrewMonster.Managers;
using BrewMonster.Network;
using CSNetwork;
using CSNetwork.GPDataType;
@@ -69,6 +70,9 @@ namespace PerfectWorld.Scripts.Managers
case int value when value == EC_MsgDef.MSG_PM_PLAYERRUNOUT:
OnMsgPlayerRunOut(Msg);
break;
+ case EC_MsgDef.MSG_PM_PICKUPMATTER:
+ OnMsgPlayerPickupMatter(Msg);
+ break;
}
}
else
@@ -470,6 +474,16 @@ namespace PerfectWorld.Scripts.Managers
return true;
}
+ public void OnMsgPlayerPickupMatter(ECMSG Msg)
+ {
+ cmd_matter_pickup pCmd = GPDataTypeHelper.FromBytes((byte[])Msg.dwParam1);
+ // CECHostPlayer pHost = GetHostPlayer();
+
+
+ EC_ManMessageMono.Instance.EC_ManMatter.RemoveMatter(pCmd.matter_id);
+
+ }
+
private void ElsePlayerLeave(int cid, bool bExitGame)
{
EC_ElsePlayer pPlayer = SeekOutElsePlayer(cid);
diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/EC_MsgDef.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/EC_MsgDef.cs
index 3b3b05ff41..3c7130d891 100644
--- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/EC_MsgDef.cs
+++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/EC_MsgDef.cs
@@ -192,7 +192,7 @@ namespace CSNetwork
public static int MSG_PM_PLAYERSKILLRESULT = 377; // Player skill attack result
public static int MSG_PM_PLAYERADVDATA = 378; // Player advertisement data
public static int MSG_PM_PLAYERINTEAM = 379; // Player in team notify
- public static int MSG_PM_PICKUPMATTER = 380; // Player pickup a matter
+ public const int MSG_PM_PICKUPMATTER = 380; // Player pickup a matter
public static int MSG_PM_PLAYERGATHER = 381; // Player gather mine
public static int MSG_PM_DOCONEMOTE = 382; // Player do concurrent emotion
public static int MSG_PM_PLAYERCHGSHAPE = 383; // Player change shape
diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs
index 0e0e1b85aa..4a921498a1 100644
--- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs
+++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs
@@ -774,6 +774,14 @@ namespace CSNetwork.GPDataType
public int tag;
public int line;
};
+
+ [StructLayout(LayoutKind.Sequential, Pack = 1)]
+ public struct cmd_matter_pickup
+ {
+ public int matter_id;
+ public int who;
+ }
+
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct A3DVECTOR3
{
@@ -1203,19 +1211,6 @@ namespace CSNetwork.GPDataType
public byte value;
}
- [StructLayout(LayoutKind.Sequential, Pack = 1)]
- public struct info_matter_uint
- {
- public uint mid;
- public uint tid;
- public A3DVECTOR3 pos;
- public byte dir0;
- public byte dir1;
- public byte rad;
- public byte state;
- public byte value;
- }
-
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct cmd_player_info_1_list
diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs
index ccd39c6267..3f49ae3af7 100644
--- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs
+++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs
@@ -502,8 +502,7 @@ namespace CSNetwork
pCmdHeader);
break;
case CommandID.MATTER_PICKUP:
- EC_ManMessage.PostMessage(EC_MsgDef.MSG_PM_PICKUPMATTER, (int)MANAGER_INDEX.MAN_PLAYER, -1,
- pDataBuf, pCmdHeader);
+ EC_ManMessage.PostMessage(EC_MsgDef.MSG_PM_PICKUPMATTER, (int)MANAGER_INDEX.MAN_PLAYER, -1, pDataBuf, pCmdHeader);
break;
case CommandID.PICKUP_MONEY:
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_PICKUPMONEY, (int)MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf,
@@ -640,13 +639,13 @@ namespace CSNetwork
{
int lenghtDataType1 = Marshal.SizeOf();
byte[] arrByteData1 = GetBytes(pDataBuf, lenghtDataType1, 0);
- int idObjMove1 = BitConverter.ToInt32(arrByteData1);
- if (ISPLAYERID(idObjMove1))
- EC_ManMessage.PostMessage(EC_MsgDef.MSG_PM_PLAYERDISAPPEAR, MANAGER_INDEX.MAN_PLAYER, -1,
- pDataBuf, pCmdHeader);
- else if (ISNPCID(idObjMove1))
- EC_ManMessage.PostMessage(EC_MsgDef.MSG_NM_NPCDISAPPEAR, MANAGER_INDEX.MAN_NPC, 0, pDataBuf,
- pCmdHeader);
+ int objectId = BitConverter.ToInt32(arrByteData1);
+ if (ISPLAYERID(objectId))
+ EC_ManMessage.PostMessage(EC_MsgDef.MSG_PM_PLAYERDISAPPEAR, MANAGER_INDEX.MAN_PLAYER, -1, pDataBuf, pCmdHeader);
+ else if (ISNPCID(objectId))
+ EC_ManMessage.PostMessage(EC_MsgDef.MSG_NM_NPCDISAPPEAR, MANAGER_INDEX.MAN_NPC, 0, pDataBuf, pCmdHeader);
+ else if (ISMATTERID(objectId))
+ EC_ManMessage.PostMessage(EC_MsgDef.MSG_MM_MATTERDISAPPEAR, MANAGER_INDEX.MAN_MATTER, 0, pDataBuf, pCmdHeader);
break;
}
@@ -921,6 +920,7 @@ namespace CSNetwork
return id != 0 && (id & 0x80000000) == 0;
}
public bool ISNPCID(int id) => ((id & 0x80000000) != 0) && ((id & 0x40000000) == 0);
+ public bool ISMATTERID(int id) => ((id) & 0xC0000000) == 0xC0000000;
private byte[] GetBytes(byte[] bytes, int length, int index)
{
byte[] arrByteData = new byte[length];
diff --git a/Assets/PerfectWorld/Scripts/Network/EC_ManMessageMono.cs b/Assets/PerfectWorld/Scripts/Network/EC_ManMessageMono.cs
index ea4f28f9f1..a6f9082b68 100644
--- a/Assets/PerfectWorld/Scripts/Network/EC_ManMessageMono.cs
+++ b/Assets/PerfectWorld/Scripts/Network/EC_ManMessageMono.cs
@@ -2,8 +2,8 @@ using System;
using UnityEngine;
using CSNetwork;
using CSNetwork.GPDataType;
-using BrewMonster.Scripts.Player;
using PerfectWorld.Scripts.Managers.BrewMonster.Managers;
+using PerfectWorld.Scripts.Managers;
namespace BrewMonster.Managers
{
diff --git a/Assets/PerfectWorld/Scripts/Objet/CECMatter.cs b/Assets/PerfectWorld/Scripts/Objet/CECMatter.cs
new file mode 100644
index 0000000000..b7b1b7baf7
--- /dev/null
+++ b/Assets/PerfectWorld/Scripts/Objet/CECMatter.cs
@@ -0,0 +1,99 @@
+using System.Reflection;
+using System.Threading.Tasks;
+using BrewMonster;
+using BrewMonster.Network;
+using BrewMonster.Scripts;
+using CSNetwork.GPDataType;
+using ModelRenderer.Scripts.Common;
+using PerfectWorld.Scripts.Managers;
+using UnityEngine;
+using UnityEngine.EventSystems;
+
+namespace PerfectWorld.Scripts
+{
+ public class CECMatter : CECObject, IPointerDownHandler
+ {
+ // Matter information got from server
+ public struct INFO
+ {
+ public int mid; // Matter id
+ public int tid; // Template id
+ }
+
+ protected EC_ManMatter m_pMatterMan;
+ protected INFO m_MatterInfo;
+
+ public void SetMatterInfo(INFO matterInfo)
+ {
+ m_MatterInfo = matterInfo;
+ }
+
+ public static async Task Init(info_matter Info)
+ {
+ INFO matterInfo = new INFO();
+ matterInfo.mid = Info.mid;
+ matterInfo.tid = Info.tid & 0x0000ffff;
+ BMLogger.Log($"CECMatter::Init():: tid: {matterInfo.tid}");
+ // get the matter template from elementdataman
+ DATA_TYPE DataType = DATA_TYPE.DT_INVALID;
+ var matterData = ElementDataManProvider.GetElementDataMan().get_data_ptr((uint)matterInfo.tid, ID_SPACE.ID_SPACE_ESSENCE, ref DataType);
+ if (matterData != null)
+ {
+ var matterType = matterData.GetType();
+ var fileMatterField = matterType.GetField("file_matter", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
+
+ if (fileMatterField != null)
+ {
+ var fileMatterValue = fileMatterField.GetValue(matterData);
+ string filePath = ByteToStringUtils.ByteArrayToCP936String((byte[])fileMatterValue);
+
+ var matterPrefab = await AddressableManager.Instance.LoadPrefabAsync(AFile.NormalizePath(filePath.ToLower(), true));
+ if (matterPrefab != null)
+ {
+ var matterObject = Instantiate(matterPrefab);
+ matterObject.transform.position = new Vector3(Info.pos.x, Info.pos.y, Info.pos.z);
+ matterObject.transform.localScale = new Vector3(1f, 1f, 1f);
+ matterObject.transform.localRotation = Quaternion.identity;
+ matterObject.SetActive(true);
+
+ // Add a collider if it doesn't have one
+ if (matterObject.GetComponent() == null)
+ {
+ var collider = matterObject.AddComponent();
+ collider.size = matterObject.GetComponentInChildren().bounds.size;
+ }
+
+ // Create text object to display item name above the cube
+ // CreateItemNameText(matterObject, info.tid);
+
+ // Add a script to handle click events
+ // MatterCubeClickHandler clickHandler = matterObject.AddComponent();
+ // clickHandler.Initialize(Info.mid, this);
+ CECMatter matterScript = matterObject.AddComponent();
+ matterScript.SetMatterInfo(matterInfo);
+
+ // Store reference to the cube
+ // matterGameObjects[info.mid] = matterObject;
+
+ return matterScript;
+ }
+ else
+ {
+ Debug.LogWarning($"Failed to load matter prefab from path: {filePath}");
+ }
+ }
+ else
+ {
+ Debug.LogWarning($"file_matter field not found on matter data type {matterType.FullName}");
+ }
+ }
+ return null;
+ }
+
+ public void OnPointerDown(PointerEventData eventData)
+ {
+ Debug.Log($"CECMatter::OnPointerDown():: mid: {m_MatterInfo.mid}");
+ UnityGameSession.RequestPickupItem(m_MatterInfo.mid, m_MatterInfo.tid);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/PerfectWorld/Scripts/Objet/CECMatter.cs.meta b/Assets/PerfectWorld/Scripts/Objet/CECMatter.cs.meta
new file mode 100644
index 0000000000..71b11bf864
--- /dev/null
+++ b/Assets/PerfectWorld/Scripts/Objet/CECMatter.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 37e2c93432b87924ca6ecca476765986
\ No newline at end of file
diff --git a/Assets/PerfectWorld/Scripts/UI/pickupItem.cs b/Assets/PerfectWorld/Scripts/UI/pickupItem.cs
index 6e13167eea..cc33472b84 100644
--- a/Assets/PerfectWorld/Scripts/UI/pickupItem.cs
+++ b/Assets/PerfectWorld/Scripts/UI/pickupItem.cs
@@ -346,16 +346,16 @@ public class pickupItem : MonoBehaviour
if (matterManager == null) return;
// Get all current matter IDs
- info_matter[] allMatterInfo = matterManager.GetAllMatterInfo();
+ // info_matter[] allMatterInfo = matterManager.GetAllMatterInfo();
- // Create cubes for new matters (but skip items previously picked up by player)
- foreach (info_matter info in allMatterInfo)
- {
- if (!matterGameObjects.ContainsKey(info.mid) && !pickedUpItems.Contains(info.mid))
- {
- CreateMatterModelObject(info);
- }
- }
+ // // Create cubes for new matters (but skip items previously picked up by player)
+ // foreach (info_matter info in allMatterInfo)
+ // {
+ // if (!matterGameObjects.ContainsKey(info.mid) && !pickedUpItems.Contains(info.mid))
+ // {
+ // CreateMatterModelObject(info);
+ // }
+ // }
// Remove cubes for matters that no longer exist
List matterToRemove = new List();