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

This commit is contained in:
VDH
2025-09-16 11:12:30 +07:00
16 changed files with 1473 additions and 90 deletions
@@ -9,21 +9,33 @@ namespace ModelRenderer.Scripts.Common
{
if (ushortArray == null || ushortArray.Length == 0)
return string.Empty;
// First convert ushort array to byte array
// Each ushort (16 bits) can be up to two bytes in GBK
byte[] byteArray = new byte[ushortArray.Length * 2];
// Determine actual length up to the first null terminator
int codeUnitCount = ushortArray.Length;
for (int i = 0; i < ushortArray.Length; i++)
{
if (ushortArray[i] == 0)
{
codeUnitCount = i;
break;
}
}
if (codeUnitCount == 0)
return string.Empty;
// Convert ushort code units to a byte array (UTF-16LE expected)
byte[] byteArray = new byte[codeUnitCount * 2];
Buffer.BlockCopy(ushortArray, 0, byteArray, 0, byteArray.Length);
// Convert bytes to string using GBK encoding
// Convert bytes to string using Unicode (UTF-16LE)
try
{
return Encoding.Unicode.GetString(byteArray);
}
catch (Exception ex)
{
UnityEngine.Debug.LogError($"Error converting bytes to GBK string: {ex.Message}");
UnityEngine.Debug.LogError($"Error converting bytes to Unicode string: {ex.Message}");
return string.Empty;
}
}
@@ -46,15 +58,29 @@ namespace ModelRenderer.Scripts.Common
{
if (byteArray == null || byteArray.Length == 0)
return string.Empty;
try
{
// Code page 936 is the code page for Simplified Chinese (GB2312/GBK)
// You may need to import System.Text.Encoding.CodePages package for Unity/modern .NET
Encoding cp936Encoding = Encoding.GetEncoding(936);
// Trim at first null terminator, if present
int length = byteArray.Length;
for (int i = 0; i < byteArray.Length; i++)
{
if (byteArray[i] == 0)
{
length = i;
break;
}
}
if (length <= 0)
return string.Empty;
// Convert the byte array to a string using code page 936 encoding
return cp936Encoding.GetString(byteArray);
return cp936Encoding.GetString(byteArray, 0, length);
}
catch (Exception ex)
{
@@ -68,7 +94,51 @@ namespace ModelRenderer.Scripts.Common
if (byteArray == null || byteArray.Length == 0)
return string.Empty;
return Encoding.Unicode.GetString(byteArray);
// Trim at first null terminator (two-byte aligned not guaranteed; treat any 0 byte as terminator)
int length = byteArray.Length;
for (int i = 0; i < byteArray.Length; i++)
{
if (byteArray[i] == 0)
{
length = i;
break;
}
}
if (length <= 0)
return string.Empty;
return Encoding.Unicode.GetString(byteArray, 0, length);
}
public static string ByteArrayToUTF8String(byte[] byteArray)
{
if (byteArray == null || byteArray.Length == 0)
return string.Empty;
// Trim at first null terminator
int length = byteArray.Length;
for (int i = 0; i < byteArray.Length; i++)
{
if (byteArray[i] == 0)
{
length = i;
break;
}
}
if (length <= 0)
return string.Empty;
try
{
return Encoding.UTF8.GetString(byteArray, 0, length);
}
catch (Exception ex)
{
UnityEngine.Debug.LogError($"Error converting bytes to UTF-8 string: {ex.Message}");
return string.Empty;
}
}
}
}
@@ -1,5 +1,6 @@
using System;
using ModelRenderer.Scripts.GameData;
using UnityEngine;
namespace BrewMonster
{
@@ -24,7 +25,7 @@ namespace BrewMonster
}
catch (Exception ex)
{
Logger.LogError($"ElementDataManProvider: Failed to load element data: {ex}");
Logger.LogError($"ElementDataManProvider: Failed to load element data: {ex} - {ex.StackTrace}");
}
}
@@ -586,11 +586,11 @@ namespace ModelRenderer.Scripts.GameData
add_id_data(ID_SPACE.ID_SPACE_ESSENCE, item.id, item);
}
//foreach (var item in unionscroll_essence_array)
//{
// add_id_index(ID_SPACE.ID_SPACE_ESSENCE, item.id, DATA_TYPE.DT_UNIONSCROLL_ESSENCE);
// add_id_data(ID_SPACE.ID_SPACE_ESSENCE, item.id, item);
//}
/*foreach (var item in unionscroll_essence_array)
{
add_id_index(ID_SPACE.ID_SPACE_ESSENCE, item.id, DATA_TYPE.DT_UNIONSCROLL_ESSENCE);
add_id_data(ID_SPACE.ID_SPACE_ESSENCE, item.id, item);
}*/
}
public void SaveDataToTextFile()
@@ -0,0 +1,133 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace PerfectWorld.Scripts.Managers
{
public static class EC_Inventory
{
private static readonly Dictionary<byte, int> _packSizeByPackage = new Dictionary<byte, int>();
private static readonly Dictionary<byte, Dictionary<int, InventoryItemData>> _itemsByPackage = new Dictionary<byte, Dictionary<int, InventoryItemData>>();
private const int MaxContentHexToLog = 64;
private static string GetPackageName(byte pkg)
{
switch (pkg)
{
case 0: return "PACK_INVENTORY";
case 1: return "PACK_EQUIPMENT";
case 2: return "PACK_TASKINVENTORY";
default: return "PACK_UNKNOWN";
}
}
private static string BytesToHex(byte[] bytes, int max)
{
if (bytes == null || bytes.Length == 0) return "";
int len = Math.Min(bytes.Length, max);
string hex = BitConverter.ToString(bytes, 0, len);
if (bytes.Length > len) hex += "-...";
return hex;
}
public static void UpdatePack(byte byPackage, int ivtrSize, IEnumerable<InventoryItemData> items)
{
_packSizeByPackage[byPackage] = ivtrSize;
if (!_itemsByPackage.TryGetValue(byPackage, out var slots))
{
slots = new Dictionary<int, InventoryItemData>();
_itemsByPackage[byPackage] = slots;
}
slots.Clear();
if (items != null)
{
foreach (var it in items)
{
if (it != null && it.Slot >= 0)
{
slots[it.Slot] = it;
}
}
}
// Log this pack's items
LogPackInternal(byPackage, ivtrSize, slots);
}
private static void LogPackInternal(byte byPackage, int ivtrSize, IReadOnlyDictionary<int, InventoryItemData> slots)
{
Debug.Log($"[Inventory] === Pack {GetPackageName(byPackage)}({byPackage}) size={ivtrSize}, items={(slots?.Count ?? 0)} ===");
if (slots == null || slots.Count == 0)
{
Debug.Log("[Inventory] (empty)");
return;
}
foreach (var kv in slots)
{
var it = kv.Value;
string itemName = EC_IvtrItem.ResolveItemName(it.TemplateId);
string extraHex = it.Content != null && it.Content.Length > 0 ? EC_IvtrItem.BytesToHex(it.Content, MaxContentHexToLog) : "";
int extraLen = it.Content?.Length ?? 0;
Debug.Log(
$"[Inventory] pkg={GetPackageName(it.Package)}({it.Package}) slot={it.Slot} tid={it.TemplateId}{(string.IsNullOrEmpty(itemName) ? "" : " \"" + itemName + "\"")} count={it.Count} state={it.State} expire={it.ExpireDate} crc={it.Crc} content_len={extraLen}{(extraLen > 0 ? ", content_hex=" + extraHex : "")}"
);
}
}
public static void LogInventoryPacket(string tag, byte[] buffer, int hostId)
{
if (buffer == null)
{
Debug.LogWarning($"[Inventory] {tag}: buffer is null (hostId={hostId})");
return;
}
int index = 0;
if (buffer.Length < 6)
{
Debug.LogWarning($"[Inventory] {tag}: buffer too small: {buffer.Length} bytes (hostId={hostId})");
LogInventoryRaw(tag, buffer);
return;
}
byte byPackage = buffer[index++];
byte ivtrSize = buffer[index++];
uint contentLength = BitConverter.ToUInt32(buffer, index); index += 4;
int remaining = buffer.Length - index;
int contentBytes = remaining;
if (contentLength < (uint)remaining)
{
contentBytes = (int)contentLength;
}
Debug.Log($"[Inventory] {tag}: hostId={hostId}, totalBytes={buffer.Length}, byPackage={byPackage}, ivtrSize={ivtrSize}, contentLength={contentLength}, actualContentBytes={contentBytes}");
if (contentBytes > 0)
{
byte[] content = new byte[contentBytes];
Buffer.BlockCopy(buffer, index, content, 0, contentBytes);
Debug.Log($"[Inventory] {tag}: content HEX=\n{BitConverter.ToString(content)}");
}
int trailing = buffer.Length - (index + contentBytes);
if (trailing > 0)
{
byte[] tail = new byte[trailing];
Buffer.BlockCopy(buffer, index + contentBytes, tail, 0, trailing);
Debug.Log($"[Inventory] {tag}: trailing {trailing} byte(s) HEX=\n{BitConverter.ToString(tail)}");
}
}
public static void LogInventoryRaw(string tag, byte[] buffer)
{
Debug.Log($"[Inventory] {tag}: RAW HEX (len={buffer?.Length ?? 0})=\n{(buffer == null ? "<null>" : BitConverter.ToString(buffer))}");
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: b060723330d7f49409ca241f4e460bed
@@ -0,0 +1,238 @@
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
namespace PerfectWorld.Scripts.Managers
{
public class EC_InventoryUI : MonoBehaviour
{
[Header("UI References")]
[SerializeField] private GridLayoutGroup gridLayoutGroup;
[SerializeField] private GameObject inventoryButtonPrefab;
[SerializeField] private Transform inventoryContainer;
[Header("Inventory Settings")]
[SerializeField] private byte targetPackage = 0; // 0 = PACK_INVENTORY, 1 = PACK_EQUIPMENT, 2 = PACK_TASKINVENTORY
[SerializeField] private bool autoRefresh = true;
[SerializeField] private float refreshInterval = 1.0f;
private List<GameObject> inventoryButtons = new List<GameObject>();
private float lastRefreshTime;
private void Start()
{
InitializeUI();
RefreshInventory();
}
private void Update()
{
if (autoRefresh && Time.time - lastRefreshTime >= refreshInterval)
{
RefreshInventory();
}
}
private void InitializeUI()
{
if (gridLayoutGroup == null)
{
Debug.LogError("[InventoryUI] GridLayoutGroup is not assigned!");
return;
}
if (inventoryButtonPrefab == null)
{
Debug.LogError("[InventoryUI] Inventory Button Prefab is not assigned!");
return;
}
if (inventoryContainer == null)
{
inventoryContainer = gridLayoutGroup.transform;
}
}
public void RefreshInventory()
{
lastRefreshTime = Time.time;
ClearInventoryButtons();
// Get inventory data from EC_Inventory
var inventoryData = GetInventoryData(targetPackage);
if (inventoryData == null || inventoryData.Count == 0)
{
Debug.Log($"[InventoryUI] No items found in package {targetPackage}");
return;
}
// Create buttons for each inventory item
foreach (var item in inventoryData.Values.OrderBy(x => x.Slot))
{
CreateInventoryButton(item);
}
Debug.Log($"[InventoryUI] Refreshed inventory with {inventoryData.Count} items");
}
private Dictionary<int, InventoryItemData> GetInventoryData(byte package)
{
// Access the private _itemsByPackage dictionary from EC_Inventory using reflection
var inventoryType = typeof(EC_Inventory);
var itemsByPackageField = inventoryType.GetField("_itemsByPackage",
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
if (itemsByPackageField == null)
{
Debug.LogError("[InventoryUI] Could not access _itemsByPackage field from EC_Inventory");
return new Dictionary<int, InventoryItemData>();
}
var itemsByPackage = itemsByPackageField.GetValue(null) as Dictionary<byte, Dictionary<int, InventoryItemData>>;
if (itemsByPackage == null)
{
Debug.LogError("[InventoryUI] _itemsByPackage is null");
return new Dictionary<int, InventoryItemData>();
}
if (itemsByPackage.TryGetValue(package, out var packageItems))
{
return packageItems;
}
return new Dictionary<int, InventoryItemData>();
}
private void CreateInventoryButton(InventoryItemData itemData)
{
if (inventoryButtonPrefab == null) return;
// Instantiate button
GameObject buttonObj = Instantiate(inventoryButtonPrefab, inventoryContainer);
inventoryButtons.Add(buttonObj);
// Get button components
Button button = buttonObj.GetComponent<Button>();
if (button == null)
{
Debug.LogWarning("[InventoryUI] Button component not found on prefab");
return;
}
// Set up button text
SetupButtonText(buttonObj, itemData);
// Set up button click handler
button.onClick.RemoveAllListeners();
button.onClick.AddListener(() => OnInventoryItemClicked(itemData));
// Set up button visual state
SetupButtonVisual(buttonObj, itemData);
}
private void SetupButtonText(GameObject buttonObj, InventoryItemData itemData)
{
// Try to find Text component (for older UI system)
Text textComponent = buttonObj.GetComponentInChildren<Text>();
if (textComponent != null)
{
string itemName = EC_IvtrItem.ResolveItemName(itemData.TemplateId);
string displayText = string.IsNullOrEmpty(itemName) ?
$"Item {itemData.TemplateId}" : itemName;
if (itemData.Count > 1)
{
displayText += $" x{itemData.Count}";
}
textComponent.text = displayText;
return;
}
// Try to find TextMeshProUGUI component (for TextMeshPro)
var tmpComponent = buttonObj.GetComponentInChildren<TMPro.TextMeshProUGUI>();
if (tmpComponent != null)
{
string itemName = EC_IvtrItem.ResolveItemName(itemData.TemplateId);
string displayText = string.IsNullOrEmpty(itemName) ?
$"Item {itemData.TemplateId}" : itemName;
if (itemData.Count > 1)
{
displayText += $" x{itemData.Count}";
}
tmpComponent.text = displayText;
return;
}
Debug.LogWarning("[InventoryUI] No text component found on button prefab");
}
private void SetupButtonVisual(GameObject buttonObj, InventoryItemData itemData)
{
// Set button color based on item state or other properties
Image buttonImage = buttonObj.GetComponent<Image>();
if (buttonImage != null)
{
// You can customize colors based on item properties
if (itemData.State != 0)
{
buttonImage.color = Color.yellow; // Highlight special state items
}
else if (itemData.Count <= 0)
{
buttonImage.color = Color.gray; // Gray out empty items
}
else
{
buttonImage.color = Color.white; // Default color
}
}
}
private void OnInventoryItemClicked(InventoryItemData itemData)
{
string itemName = EC_IvtrItem.ResolveItemName(itemData.TemplateId);
Debug.Log($"[InventoryUI] Item clicked: {itemName} (ID: {itemData.TemplateId}, Count: {itemData.Count}, Slot: {itemData.Slot})");
// Add your custom item click logic here
// For example: show item details, use item, etc.
}
private void ClearInventoryButtons()
{
foreach (GameObject button in inventoryButtons)
{
if (button != null)
{
DestroyImmediate(button);
}
}
inventoryButtons.Clear();
}
public void SetTargetPackage(byte package)
{
targetPackage = package;
RefreshInventory();
}
public void ToggleAutoRefresh()
{
autoRefresh = !autoRefresh;
}
public void SetRefreshInterval(float interval)
{
refreshInterval = Mathf.Max(0.1f, interval);
}
private void OnDestroy()
{
ClearInventoryButtons();
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 12345678901234567890123456789012
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,269 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using BrewMonster;
using ModelRenderer.Scripts.Common;
using ModelRenderer.Scripts.GameData;
using UnityEngine;
namespace PerfectWorld.Scripts.Managers
{
public class InventoryItemData
{
public byte Package;
public int Slot;
public int TemplateId;
public int ExpireDate;
public int State;
public int Count;
public ushort Crc;
public byte[] Content; // variable-length item-specific payload (can be null)
}
public static class EC_IvtrItem
{
private static readonly Dictionary<int, string> _tidNameCache = new Dictionary<int, string>();
private const int MaxContentHexToLog = 64;
public static string ResolveItemName(int templateId)
{
if (templateId <= 0) return "";
if (_tidNameCache.TryGetValue(templateId, out var cached)) return cached;
try
{
var edm = ElementDataManProvider.GetElementDataMan();
if (edm == null) return CacheAndReturn(templateId, "");
uint id = unchecked((uint)templateId);
object data = edm.get_data_ptr(id, ID_SPACE.ID_SPACE_ESSENCE);
string name = ExtractNameFromElement(data);
if (string.IsNullOrEmpty(name))
{
name = TryFindNameByScanningArrays(edm, id);
}
return CacheAndReturn(templateId, name ?? "");
}
catch (Exception ex)
{
Debug.LogWarning($"[Inventory] ResolveItemName error for tid={templateId}: {ex.Message}");
return CacheAndReturn(templateId, "");
}
}
private static string CacheAndReturn(int tid, string name)
{
_tidNameCache[tid] = name ?? "";
return name ?? "";
}
private static string ExtractNameFromElement(object data)
{
if (data == null) return "";
var t = data.GetType();
// Debug: Log all available fields and properties
Debug.Log($"[Inventory] Data type: {t.Name}");
var fields = t.GetFields(BindingFlags.Public | BindingFlags.Instance);
foreach (var f in fields)
{
Debug.Log($"[Inventory] Field: {f.Name} ({f.FieldType.Name})");
}
var props = t.GetProperties(BindingFlags.Public | BindingFlags.Instance);
foreach (var p in props)
{
Debug.Log($"[Inventory] Property: {p.Name} ({p.PropertyType.Name})");
}
var methods = t.GetMethods(BindingFlags.Public | BindingFlags.Instance);
foreach (var m in methods)
{
if (m.Name.ToLower().Contains("name") || m.Name.ToLower().Contains("getname"))
{
Debug.Log($"[Inventory] Method: {m.Name} ({m.ReturnType.Name})");
}
}
// Prefer decoding the raw fields first to control encoding (Unicode for Vietnamese),
// then fall back to any string properties if needed.
var fieldName = t.GetField("name", BindingFlags.Public | BindingFlags.Instance);
if (fieldName != null && fieldName.FieldType == typeof(ushort[]))
{
var arr = fieldName.GetValue(data) as ushort[];
// Debug: Log the raw ushort array data
if (arr != null && arr.Length > 0)
{
var rawData = string.Join(",", arr.Take(Math.Min(10, arr.Length)));
Debug.Log($"[Inventory] Raw ushort array data (first 10): [{rawData}]");
}
// Vietnamese names are stored as wide chars; decode as Unicode first.
var s = ByteToStringUtils.UshortArrayToUnicodeString(arr);
// Debug log to see what we're getting
Debug.Log($"[Inventory] Unicode decode result: '{s}' (length: {s?.Length ?? 0})");
if (!string.IsNullOrEmpty(s) && !string.IsNullOrWhiteSpace(s)) return s;
// Fallback to legacy CP936 if Unicode was empty
s = ByteToStringUtils.UshortArrayToCP936String(arr);
Debug.Log($"[Inventory] CP936 fallback result: '{s}' (length: {s?.Length ?? 0})");
if (!string.IsNullOrEmpty(s)) return s;
}
// Try calling GetName method if it exists (similar to C++ pIt->GetName())
var getNameMethod = t.GetMethod("GetName", BindingFlags.Public | BindingFlags.Instance);
if (getNameMethod != null && getNameMethod.ReturnType == typeof(string))
{
try
{
var val = getNameMethod.Invoke(data, null) as string;
Debug.Log($"[Inventory] GetName method result: '{val}' (length: {val?.Length ?? 0})");
if (!string.IsNullOrEmpty(val) && !string.IsNullOrWhiteSpace(val)) return val;
}
catch (Exception ex)
{
Debug.LogWarning($"[Inventory] Error calling GetName method: {ex.Message}");
}
}
return "";
}
private static string TryFindNameByScanningArrays(object edm, uint id)
{
try
{
var fields = edm.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
foreach (var f in fields)
{
if (!f.FieldType.IsArray) continue;
var arr = f.GetValue(edm) as Array;
if (arr == null || arr.Length == 0) continue;
var elemType = f.FieldType.GetElementType();
var idField = elemType.GetField("id", BindingFlags.Public | BindingFlags.Instance);
if (idField == null || idField.FieldType != typeof(uint)) continue;
for (int i = 0; i < arr.Length; i++)
{
var element = arr.GetValue(i);
if (element == null) continue;
var value = (uint)idField.GetValue(element);
if (value == id)
{
var name = ExtractNameFromElement(element);
if (!string.IsNullOrEmpty(name)) return name;
var toStr = element.ToString();
if (!string.IsNullOrEmpty(toStr)) return toStr;
}
}
}
}
catch { }
return "";
}
public static bool TryParseInventoryDetail(byte[] buffer, out byte byPackage, out byte ivtrSize, out List<InventoryItemData> items)
{
byPackage = 0;
ivtrSize = 0;
items = null;
if (buffer == null || buffer.Length < 6)
{
return false;
}
int index = 0;
byPackage = buffer[index++];
ivtrSize = buffer[index++];
uint contentLength = BitConverter.ToUInt32(buffer, index); index += 4;
int remaining = buffer.Length - index;
int contentBytes = remaining;
if (contentLength < (uint)remaining)
{
contentBytes = (int)contentLength;
}
if (contentBytes <= 0)
{
items = new List<InventoryItemData>();
return true;
}
byte[] content = new byte[contentBytes];
Buffer.BlockCopy(buffer, index, content, 0, contentBytes);
// Parse S2C::cmd_own_ivtr_detail_info.content
int ci = 0;
if (contentBytes < 4)
{
return false;
}
int numItems = BitConverter.ToInt32(content, ci); ci += 4;
items = new List<InventoryItemData>(numItems > 0 ? numItems : 0);
for (int i = 0; i < numItems; i++)
{
// Ensure enough bytes for fixed part: index, tid, expire, state, amount, crc(2), len(2) => 4*5 + 2 + 2 = 24 bytes
if (ci + 24 > contentBytes)
{
return false;
}
int slotIndex = BitConverter.ToInt32(content, ci); ci += 4;
if (slotIndex < 0)
{
// Skip invalid slot but continue parsing to keep stream in sync
// Still need to consume fields even if slot is negative
int skipTid = BitConverter.ToInt32(content, ci); ci += 4;
int skipExpire = BitConverter.ToInt32(content, ci); ci += 4;
int skipState = BitConverter.ToInt32(content, ci); ci += 4;
int skipAmt = BitConverter.ToInt32(content, ci); ci += 4;
ushort skipCrc = BitConverter.ToUInt16(content, ci); ci += 2;
ushort skipLen = BitConverter.ToUInt16(content, ci); ci += 2;
if (skipLen > 0)
{
if (ci + skipLen > contentBytes) return false;
ci += skipLen;
}
continue;
}
int tid = BitConverter.ToInt32(content, ci); ci += 4;
int expireDate = BitConverter.ToInt32(content, ci); ci += 4;
int state = BitConverter.ToInt32(content, ci); ci += 4;
int amount = BitConverter.ToInt32(content, ci); ci += 4;
ushort crc = BitConverter.ToUInt16(content, ci); ci += 2;
ushort extraLen = BitConverter.ToUInt16(content, ci); ci += 2;
byte[] extra = null;
if (extraLen > 0)
{
if (ci + extraLen > contentBytes)
{
return false;
}
extra = new byte[extraLen];
Buffer.BlockCopy(content, ci, extra, 0, extraLen);
ci += extraLen;
}
var item = new InventoryItemData
{
Package = byPackage,
Slot = slotIndex,
TemplateId = tid,
ExpireDate = expireDate,
State = state,
Count = amount,
Crc = crc,
Content = extra
};
items.Add(item);
}
return true;
}
public static string BytesToHex(byte[] bytes, int max)
{
if (bytes == null || bytes.Length == 0) return "";
int len = Math.Min(bytes.Length, max);
string hex = BitConverter.ToString(bytes, 0, len);
if (bytes.Length > len) hex += "-...";
return hex;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 423a6efd71f143f08096d684ca414bba
timeCreated: 1757752654
@@ -1,6 +1,7 @@
using BrewMonster;
using CSNetwork;
using CSNetwork.Protocols;
using CSNetwork.C2SCommand;
using CSNetwork.Protocols.RPCData;
using CSNetwork.Security;
using System;
@@ -126,6 +127,36 @@ namespace BrewMonster.Network
Instance._gameSession.RequestInventoryAsync(callback);
}
public static void RequestInventoryByPackageAsync(byte byPackage, Action callback = null)
{
var req = new gamedatasend();
req.Data = C2SCommandFactory.CreateGetInventoryDetail(byPackage);
SendProtocol(req, callback);
}
public static void RequestAllInventoriesAsync(Action callback = null, params byte[] packages)
{
if (packages == null || packages.Length == 0)
{
packages = new byte[] { 0, 1, 2 };
}
int remaining = packages.Length;
Action onOneDone = () =>
{
remaining--;
if (remaining <= 0)
{
callback?.Invoke();
}
};
foreach (var p in packages)
{
RequestInventoryByPackageAsync(p, onOneDone);
}
}
public void LoadScene(string sceneName, LoadSceneMode mode, Action<bool> actDone)
{
StartCoroutine(LoadSceneCoroutine(sceneName, mode, actDone));
@@ -113,8 +113,6 @@ namespace BrewMonster.UI
Timeout = 0
}
);
/* Debug.Log("OnSelectRoleComplete");
UnityGameSession.EnterWorldAsync(roleInfo, OnEnterWorldComplete);*/
};
string nameScene = "NPCRender";
UnityGameSession.Instance.LoadScene(nameScene, LoadSceneMode.Single, (value) =>
@@ -129,6 +127,7 @@ namespace BrewMonster.UI
actLoadChar?.Invoke();
});
}, null);
OnEnterWorldComplete();
}
private async void OnEnterWorldComplete()
@@ -137,7 +136,8 @@ namespace BrewMonster.UI
await Task.Delay(2000);
Logger.Log("Entered world successfully.");
UnityGameSession.RequestInventoryAsync(() => { Logger.Log("Sent Inventory Detail Request"); });
// Request all known packages: 0=Inventory,1=Equipment,2=Task
UnityGameSession.RequestAllInventoriesAsync(() => { Logger.Log("Sent Inventory Detail Requests (all packs)"); }, 0, 1, 2);
}
//private void OnInventoryReceived(List<InventoryItem> inventoryData)
+259
View File
@@ -0,0 +1,259 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3569639223418896037
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4197760401065366055}
- component: {fileID: 7744838066738098412}
- component: {fileID: 2571139630770903399}
m_Layer: 5
m_Name: Text (TMP)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &4197760401065366055
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3569639223418896037}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 6621119105527269815}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7744838066738098412
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3569639223418896037}
m_CullTransparentMesh: 1
--- !u!114 &2571139630770903399
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3569639223418896037}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text:
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4281479730
m_fontColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 24
m_fontSizeBase: 24
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 2048
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_TextWrappingMode: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 0
m_ActiveFontFeatures: 6e72656b
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_EmojiFallbackSupport: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &4284317386921833337
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6621119105527269815}
- component: {fileID: 1222411267809432398}
- component: {fileID: 548372213818333226}
- component: {fileID: 2775214500131835999}
m_Layer: 5
m_Name: IvtrItem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &6621119105527269815
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4284317386921833337}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 4197760401065366055}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 92.5, y: -50}
m_SizeDelta: {x: 185, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1222411267809432398
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4284317386921833337}
m_CullTransparentMesh: 1
--- !u!114 &548372213818333226
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4284317386921833337}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &2775214500131835999
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4284317386921833337}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 548372213818333226}
m_OnClick:
m_PersistentCalls:
m_Calls: []
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: bcc3d1c058b14e4488aba5e177e87e90
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+394
View File
@@ -1595,6 +1595,7 @@ GameObject:
- component: {fileID: 197360893}
- component: {fileID: 197360892}
- component: {fileID: 197360891}
- component: {fileID: 197360895}
m_Layer: 5
m_Name: Canvas (1)
m_TagString: Untagged
@@ -1678,6 +1679,8 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 164962915}
- {fileID: 390842481}
- {fileID: 1276511500}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
@@ -1685,6 +1688,24 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!114 &197360895
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 197360890}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 12345678901234567890123456789012, type: 3}
m_Name:
m_EditorClassIdentifier:
gridLayoutGroup: {fileID: 1276511503}
inventoryButtonPrefab: {fileID: 4284317386921833337, guid: bcc3d1c058b14e4488aba5e177e87e90, type: 3}
inventoryContainer: {fileID: 1276511500}
targetPackage: 0
autoRefresh: 0
refreshInterval: 1
--- !u!28 &208282478
Texture2D:
m_ObjectHideFlags: 0
@@ -4409,6 +4430,143 @@ Mesh:
offset: 0
size: 0
path:
--- !u!1 &390842480
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 390842481}
- component: {fileID: 390842484}
- component: {fileID: 390842483}
- component: {fileID: 390842485}
m_Layer: 5
m_Name: IvtrBtn
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &390842481
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 390842480}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 509465122}
m_Father: {fileID: 197360894}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 909.7, y: 39.52}
m_SizeDelta: {x: 168.9, y: 69.5}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &390842483
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 390842480}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &390842484
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 390842480}
m_CullTransparentMesh: 1
--- !u!114 &390842485
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 390842480}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9085046f02f69544eb97fd06b6048fe2, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 390842483}
toggleTransition: 1
graphic: {fileID: 0}
m_Group: {fileID: 0}
onValueChanged:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 1276511499}
m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine
m_MethodName: SetActive
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_IsOn: 0
--- !u!1 &393317435
GameObject:
m_ObjectHideFlags: 0
@@ -7171,6 +7329,142 @@ Material:
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []
m_AllowLocking: 1
--- !u!1 &509465121
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 509465122}
- component: {fileID: 509465124}
- component: {fileID: 509465123}
m_Layer: 5
m_Name: Text (TMP)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &509465122
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 509465121}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 390842481}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &509465123
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 509465121}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: INVENTORY
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4281479730
m_fontColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 24
m_fontSizeBase: 24
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_TextWrappingMode: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 0
m_ActiveFontFeatures: 6e72656b
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_EmojiFallbackSupport: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!222 &509465124
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 509465121}
m_CullTransparentMesh: 1
--- !u!1 &513492226
GameObject:
m_ObjectHideFlags: 0
@@ -17423,6 +17717,106 @@ Material:
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []
m_AllowLocking: 1
--- !u!1 &1276511499
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1276511500}
- component: {fileID: 1276511502}
- component: {fileID: 1276511501}
- component: {fileID: 1276511503}
m_Layer: 5
m_Name: InventoryUI
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!224 &1276511500
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1276511499}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 197360894}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 510, y: 25}
m_SizeDelta: {x: -1580, y: -350}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1276511501
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1276511499}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0.392}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &1276511502
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1276511499}
m_CullTransparentMesh: 1
--- !u!114 &1276511503
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1276511499}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8a8695521f0d02e499659fee002a26c2, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Padding:
m_Left: 0
m_Right: 0
m_Top: 0
m_Bottom: 0
m_ChildAlignment: 0
m_StartCorner: 0
m_StartAxis: 0
m_CellSize: {x: 185, y: 100}
m_Spacing: {x: 10, y: 10}
m_Constraint: 0
m_ConstraintCount: 2
--- !u!1 &1286780124
GameObject:
m_ObjectHideFlags: 0
+34 -69
View File
@@ -206,6 +206,27 @@ public class CECHostPlayer : MonoBehaviour
OnMsgHstIvtrInfo(Msg);
break;
}
case int value when value == EC_MsgDef.MSG_HST_OWNITEMINFO:
{
OnMsgHstOwnItemInfo(Msg);
break;
}
}
}
public void OnMsgHstOwnItemInfo(ECMSG Msg)
{
int cmd = Convert.ToInt32(Msg.dwParam2);
switch (cmd)
{
case CommandID.OWN_ITEM_INFO:
{
Debug.Log("[Inventory] OWN_ITEM_INFO received");
var data = Msg.dwParam1 as byte[];
int hostId = Convert.ToInt32(Msg.dwParam3);
PerfectWorld.Scripts.Managers.EC_Inventory.LogInventoryPacket("OWN_ITEM_INFO", data, hostId);
break;
}
}
}
public void OnMsgHstIvtrInfo(ECMSG Msg)
@@ -219,33 +240,26 @@ public class CECHostPlayer : MonoBehaviour
case CommandID.OWN_IVTR_DATA:
{
Debug.Log("[Inventory] OWN_IVTR_DATA received");
LogInventoryPacket("OWN_IVTR_DATA", data, hostId);
PerfectWorld.Scripts.Managers.EC_Inventory.LogInventoryPacket("OWN_IVTR_DATA", data, hostId);
break;
}
case CommandID.OWN_IVTR_DETAIL_DATA:
{
Debug.Log("[Inventory] OWN_IVTR_DETAIL_DATA received");
LogInventoryPacket("OWN_IVTR_DETAIL_DATA", data, hostId);
break;
}
case CommandID.GET_OWN_MONEY:
{
Debug.Log("[Inventory] GET_OWN_MONEY received");
LogInventoryRaw("GET_OWN_MONEY", data);
break;
}
case CommandID.CHANGE_IVTR_SIZE:
{
Debug.Log("[Inventory] CHANGE_IVTR_SIZE received");
LogInventoryRaw("CHANGE_IVTR_SIZE", data);
break;
}
default:
{
Debug.Log($"[Inventory] Unhandled inventory cmd={cmd}");
LogInventoryRaw($"CMD_{cmd}", data);
PerfectWorld.Scripts.Managers.EC_Inventory.LogInventoryPacket("OWN_IVTR_DETAIL_DATA", data, hostId);
// Parse and store
if (data != null && data.Length >= 6)
{
byte byPackage = data[0];
byte ivtrSize = data[1];
if (PerfectWorld.Scripts.Managers.EC_IvtrItem.TryParseInventoryDetail(data, out var pkg, out var size, out var items))
{
PerfectWorld.Scripts.Managers.EC_Inventory.UpdatePack(pkg, size, items);
}
}
break;
}
}
}
public void OnMsgHstCorrectPos(in ECMSG Msg)
@@ -266,55 +280,6 @@ public class CECHostPlayer : MonoBehaviour
}
private void LogInventoryPacket(string tag, byte[] buffer, int hostId)
{
if (buffer == null)
{
Debug.LogWarning($"[Inventory] {tag}: buffer is null (hostId={hostId})");
return;
}
int index = 0;
if (buffer.Length < 6)
{
Debug.LogWarning($"[Inventory] {tag}: buffer too small: {buffer.Length} bytes (hostId={hostId})");
LogInventoryRaw(tag, buffer);
return;
}
byte byPackage = buffer[index++];
byte ivtrSize = buffer[index++];
uint contentLength = BitConverter.ToUInt32(buffer, index); index += 4;
int remaining = buffer.Length - index;
int contentBytes = remaining;
if (contentLength < (uint)remaining)
{
contentBytes = (int)contentLength;
}
Debug.Log($"[Inventory] {tag}: hostId={hostId}, totalBytes={buffer.Length}, byPackage={byPackage}, ivtrSize={ivtrSize}, contentLength={contentLength}, actualContentBytes={contentBytes}");
if (contentBytes > 0)
{
byte[] content = new byte[contentBytes];
Buffer.BlockCopy(buffer, index, content, 0, contentBytes);
Debug.Log($"[Inventory] {tag}: content HEX=\n{BitConverter.ToString(content)}");
}
int trailing = buffer.Length - (index + contentBytes);
if (trailing > 0)
{
byte[] tail = new byte[trailing];
Buffer.BlockCopy(buffer, index + contentBytes, tail, 0, trailing);
Debug.Log($"[Inventory] {tag}: trailing {trailing} byte(s) HEX=\n{BitConverter.ToString(tail)}");
}
}
private void LogInventoryRaw(string tag, byte[] buffer)
{
Debug.Log($"[Inventory] {tag}: RAW HEX (len={buffer?.Length ?? 0})=\n{(buffer == null ? "<null>" : BitConverter.ToString(buffer))}");
}
private void SetPos(Vector3 pos)
{
transform.position = pos;
Binary file not shown.