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

# Conflicts:
#	Assets/NetworkLib/Debug/netstandard2.1/CSNetwork.deps.json
#	Assets/NetworkLib/Debug/netstandard2.1/CSNetwork.dll
This commit is contained in:
VDH
2025-09-12 08:59:33 +07:00
12 changed files with 331 additions and 22111 deletions
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RiderProjectSettingsUpdater">
<option name="singleClickDiffPreview" value="1" />
<option name="unhandledExceptionsIgnoreList" value="1" />
<option name="vcsConfiguration" value="3" />
</component>
</project>
+142
View File
@@ -0,0 +1,142 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="49831fc9-7cbb-46fb-90e9-7754de73bafb" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/ProjectSettings/EditorBuildSettings.asset" beforeDir="false" afterPath="$PROJECT_DIR$/ProjectSettings/EditorBuildSettings.asset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ProjectSettings/ShaderGraphSettings.asset" beforeDir="false" afterPath="$PROJECT_DIR$/ProjectSettings/ShaderGraphSettings.asset" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="HighlightingSettingsPerFile">
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/47e9cf78f2614f72ae7df046d55ebcf24a400/d6/1d32d257/RoleInfo.cs" root0="FORCE_HIGHLIGHTING" />
</component>
<component name="ProjectColorInfo"><![CDATA[{
"associatedIndex": 4
}]]></component>
<component name="ProjectId" id="32GqMZwPghqrbXiQw3BfBEQJAAE" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"ModuleVcsDetector.initialDetectionPerformed": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.git.unshallow": "true",
"git-widget-placeholder": "main",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"vue.rearranger.settings.migration": "true"
}
}]]></component>
<component name="RunManager" selected="Attach to Unity Editor.Attach to Unity Editor">
<configuration name="Start Unity" type="RunUnityExe" factoryName="Unity Executable">
<option name="EXE_PATH" value="C:\Program Files\Unity\Hub\Editor\6000.0.56f1\Editor\Unity.exe" />
<option name="PROGRAM_PARAMETERS" value="-projectPath E:\PerfectWorld\perfect-world-unity -debugCodeOptimization" />
<option name="WORKING_DIRECTORY" value="E:\PerfectWorld\perfect-world-unity" />
<option name="PASS_PARENT_ENVS" value="1" />
<option name="USE_EXTERNAL_CONSOLE" value="0" />
<option name="ENV_FILE_PATHS" value="" />
<option name="REDIRECT_INPUT_PATH" value="" />
<option name="PTY_MODE" value="Auto" />
<option name="MIXED_MODE_DEBUG" value="0" />
<method v="2" />
</configuration>
<configuration name="Unit Tests (batch mode)" type="RunUnityExe" factoryName="Unity Executable">
<option name="EXE_PATH" value="C:\Program Files\Unity\Hub\Editor\6000.0.56f1\Editor\Unity.exe" />
<option name="PROGRAM_PARAMETERS" value="-runTests -batchmode -projectPath E:\PerfectWorld\perfect-world-unity -testResults Logs/results.xml -logFile Logs/Editor.log -testPlatform EditMode -debugCodeOptimization" />
<option name="WORKING_DIRECTORY" value="E:\PerfectWorld\perfect-world-unity" />
<option name="PASS_PARENT_ENVS" value="1" />
<option name="USE_EXTERNAL_CONSOLE" value="0" />
<option name="ENV_FILE_PATHS" value="" />
<option name="REDIRECT_INPUT_PATH" value="" />
<option name="PTY_MODE" value="Auto" />
<option name="MIXED_MODE_DEBUG" value="0" />
<method v="2" />
</configuration>
<configuration name="Attach to Unity Editor &amp; Play" type="UNITY_DEBUG_RUN_CONFIGURATION" factoryName="UNITY_ATTACH_AND_PLAY" show_console_on_std_err="false" show_console_on_std_out="false" port="50000" address="localhost">
<option name="allowRunningInParallel" value="false" />
<option name="listenPortForConnections" value="false" />
<option name="pid" />
<option name="projectPathOnTarget" />
<option name="runtimes">
<list />
</option>
<option name="selectedOptions">
<list />
</option>
<option name="useMixedMode" value="false" />
<method v="2" />
</configuration>
<configuration name="Attach to Unity Editor" type="UNITY_DEBUG_RUN_CONFIGURATION" factoryName="Unity Debug" show_console_on_std_err="false" show_console_on_std_out="false" port="50000" address="localhost">
<option name="allowRunningInParallel" value="false" />
<option name="listenPortForConnections" value="false" />
<option name="pid" />
<option name="projectPathOnTarget" />
<option name="runtimes">
<list />
</option>
<option name="selectedOptions">
<list />
</option>
<option name="useMixedMode" value="false" />
<method v="2" />
</configuration>
<configuration name="Attach to Device" type="UnityDevicePlayer" factoryName="UnityAttachToDevicePlayer">
<method v="2" />
</configuration>
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="49831fc9-7cbb-46fb-90e9-7754de73bafb" name="Changes" comment="" />
<created>1757057210233</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1757057210233</updated>
<workItem from="1757057212282" duration="5649000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="UnityProjectConfiguration" hasMinimizedUI="true" />
<component name="UnityProjectDiscoverer">
<option name="hasUnityReference" value="true" />
<option name="unityProject" value="true" />
<option name="unityProjectFolder" value="true" />
</component>
<component name="VcsManagerConfiguration">
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<breakpoint enabled="true" type="DotNet_Exception_Breakpoints">
<properties exception="System.OperationCanceledException" breakIfHandledByOtherCode="false" displayValue="System.OperationCanceledException" />
<option name="timeStamp" value="1" />
</breakpoint>
<breakpoint enabled="true" type="DotNet_Exception_Breakpoints">
<properties exception="System.Threading.Tasks.TaskCanceledException" breakIfHandledByOtherCode="false" displayValue="System.Threading.Tasks.TaskCanceledException" />
<option name="timeStamp" value="2" />
</breakpoint>
<breakpoint enabled="true" type="DotNet_Exception_Breakpoints">
<properties exception="System.Threading.ThreadAbortException" breakIfHandledByOtherCode="false" displayValue="System.Threading.ThreadAbortException" />
<option name="timeStamp" value="3" />
</breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project>
Binary file not shown.
@@ -1,4 +1,4 @@
using System;
using System;
using System.Reflection;
using UnityEngine;
@@ -0,0 +1,40 @@
using BrewMonster;
using CSNetwork;
using CSNetwork.GPDataType;
using System;
using System.Runtime.InteropServices;
using UnityEngine;
namespace PerfectWorld.Scripts.Managers
{
namespace BrewMonster.Managers
{
public class EC_HostPlayer : IMsgHandler
{
public int HandlerId => (int)MANAGER_INDEX.MAN_PLAYER;
public bool ProcessMessage(ECMSG Msg)
{
switch ((int)Msg.dwMsg)
{
case int value when value == EC_MsgDef.MSG_HST_IVTRINFO:
{
OnMsgHstIvtrInfo(Msg);
break;
}
}
return true;
}
public void OnMsgHstIvtrInfo(ECMSG Msg)
{
switch (Convert.ToInt32(Msg.dwParam2))
{
case CommandID.OWN_IVTR_DATA:
{
Debug.Log("Chay OWN_IVTR_DATA");
break;
}
}
}
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: eece34ce0cfd6bc409982ce9b90b263b
@@ -102,6 +102,15 @@ namespace BrewMonster.Network
{
Instance._gameSession.SelectRoleAsync(roleInfo, callback);
}
public static void EnterWorldAsync(RoleInfo roleInfo, Action callback = null)
{
Instance._gameSession.EnterWorldAsync(roleInfo, callback);
}
public static void RequestInventoryAsync(Action callback = null)
{
Instance._gameSession.RequestInventoryAsync(callback);
}
public void LoadScene(string sceneName, LoadSceneMode mode, Action<bool> actDone)
{
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using BrewMonster.Network;
using CSNetwork.Protocols;
using CSNetwork.Protocols.RPCData;
@@ -84,7 +85,7 @@ namespace BrewMonster.UI
{
// now we have to enter the world
UnityGameSession.SendProtocol(
/* UnityGameSession.SendProtocol(
new enterworld()
{
Roleid = roleInfo.roleid,
@@ -95,9 +96,22 @@ namespace BrewMonster.UI
Settime = 0,
Timeout = 0
}
);
);*/
UnityGameSession.EnterWorldAsync(roleInfo, OnEnterWorldComplete);
}
private async void OnEnterWorldComplete()
{
await Task.Delay(2000);
Logger.Log("Entered world successfully.");
UnityGameSession.RequestInventoryAsync(() => { Logger.Log("Sent Inventory Detail Request"); });
}
//private void OnInventoryReceived(List<InventoryItem> inventoryData)
//{
// _inventoryUI.DisplayInventory(inventoryData);
//}
#if UNITY_EDITOR
private void OnValidate()
{
File diff suppressed because one or more lines are too long
+95 -2
View File
@@ -1,14 +1,12 @@
using BrewMonster.Network;
using CSNetwork;
using CSNetwork.GPDataType;
using CSNetwork.C2SCommand;
using CSNetwork.Protocols;
using CSNetwork.Protocols.RPCData;
using System;
using System.IO;
using System.Text;
using TMPro;
using UnityEditor.SearchService;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
@@ -188,6 +186,51 @@ public class CECHostPlayer : MonoBehaviour
{
case int value when value == EC_MsgDef.MSG_HST_CORRECTPOS: OnMsgHstCorrectPos(Msg); break;
case int value when value == EC_MsgDef.MSG_HST_GOTO: OnMsgHstGoto(Msg); break;
case int value when value == EC_MsgDef.MSG_HST_IVTRINFO:
{
OnMsgHstIvtrInfo(Msg);
break;
}
}
}
public void OnMsgHstIvtrInfo(ECMSG Msg)
{
var data = Msg.dwParam1 as byte[];
int cmd = Convert.ToInt32(Msg.dwParam2);
int hostId = Convert.ToInt32(Msg.dwParam3);
switch (cmd)
{
case CommandID.OWN_IVTR_DATA:
{
Debug.Log("[Inventory] OWN_IVTR_DATA received");
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);
break;
}
}
}
public void OnMsgHstCorrectPos(in ECMSG Msg)
@@ -207,6 +250,56 @@ public class CECHostPlayer : MonoBehaviour
cmd_notify_hostpos pCmd = (cmd_notify_hostpos)Msg.dwParam1;
}
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;
+15
View File
@@ -20,12 +20,27 @@ public class GameController : MonoBehaviour
if (instance == null)
{
instance = FindAnyObjectByType<GameController>();
if (instance == null)
{
var go = new GameObject("GameController");
instance = go.AddComponent<GameController>();
DontDestroyOnLoad(go);
}
}
return instance;
}
}
private void Awake()
{
if(instance == null)
{
instance = this;
DontDestroyOnLoad(gameObject);
}
else if(instance != this)
{
Destroy(gameObject);
}
}
private void Start()
@@ -5,6 +5,9 @@ EditorBuildSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Scenes:
- enabled: 1
path: Assets/Scenes/Demo.unity
guid: 99c9720ab356a0642a771bea13969a05
- enabled: 1
path: Assets/PerfectWorld/Scene/Boostrap.unity
guid: 40f9b53766c74f541b85df4d35cfc767