Fix data type wrong convert

This commit is contained in:
HungDK
2025-10-14 10:51:36 +07:00
parent 1ed01cd4c5
commit a591d0b868
3 changed files with 16 additions and 6 deletions
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 3b9d74e7123c6e144ae35ceb982d00de
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4ed0dfeaea062ad4b9990837c319097b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -56,7 +56,7 @@ namespace PerfectWorld.Scripts.Managers
{
Debug.Log("MATTERINFO");
//ENABLE LATER: It fetch all matters in the game world, causing performance issues
//OnMsgMatterInfo(Msg);
OnMsgMatterInfo(Msg);
break;
}
case int value when value == EC_MsgDef.MSG_MM_MATTERENTWORLD:
@@ -83,9 +83,9 @@ namespace PerfectWorld.Scripts.Managers
// Parse the data structure: count + info_matter array
int offset = 0;
// Read count (int)
int count = BitConverter.ToInt32(data, offset);
offset += sizeof(int);
// Read count (ushort)
ushort count = BitConverter.ToUInt16(data, offset);
offset += sizeof(ushort);
Debug.Log($"MATTERINFO: Received {count} matter entries");
@@ -137,11 +137,11 @@ namespace PerfectWorld.Scripts.Managers
private void SpawnMatterCube(int matterId)
{
// Check if matter is within 1000 units of the host player
if (!IsMatterWithinPlayerRange(matterId, 10000f))
/*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<pickupItem>();