diff --git a/Assets/NetworkLib/Debug/netstandard2.1/CSNetwork.dll b/Assets/NetworkLib/Debug/netstandard2.1/CSNetwork.dll index 3d7d6fdd65..f79f6e0391 100644 Binary files a/Assets/NetworkLib/Debug/netstandard2.1/CSNetwork.dll and b/Assets/NetworkLib/Debug/netstandard2.1/CSNetwork.dll differ diff --git a/Assets/PerfectWorld/Scripts/GameData/ExpTypes.cs b/Assets/PerfectWorld/Scripts/GameData/ExpTypes.cs index a6e4127cf5..d760b942dc 100644 --- a/Assets/PerfectWorld/Scripts/GameData/ExpTypes.cs +++ b/Assets/PerfectWorld/Scripts/GameData/ExpTypes.cs @@ -4615,7 +4615,7 @@ namespace BrewMonster [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] action_prefix; // action prefix - public string ActionPrefix => ByteToStringUtils.ByteArrayToUnicodeString(action_prefix); + public string ActionPrefix => ByteToStringUtils.ByteArrayToCP936String(action_prefix); [StructLayout(LayoutKind.Sequential)] public struct ActionWeaponSuffix @@ -4623,7 +4623,7 @@ namespace BrewMonster [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] suffix; // weapon-specific action suffix - public string Suffix => ByteToStringUtils.ByteArrayToUnicodeString(suffix); + public string Suffix => ByteToStringUtils.ByteArrayToCP936String(suffix); } [MarshalAs(UnmanagedType.ByValArray, SizeConst = 15)] diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_ManPlayer.cs b/Assets/PerfectWorld/Scripts/Managers/EC_ManPlayer.cs index 1a1f37838a..4a745fae9f 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_ManPlayer.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_ManPlayer.cs @@ -2,6 +2,7 @@ using BrewMonster.Network; using CSNetwork; using CSNetwork.GPDataType; +using CSNetwork.Protocols; using CSNetwork.Protocols.RPCData; using PerfectWorld.Scripts.Player; using System; @@ -49,6 +50,10 @@ namespace PerfectWorld.Scripts.Managers OnMsgPlayerStopMove(Msg); break; } + case int value when value == EC_MsgDef.MSG_PM_FACTION_PVP_MASK_MODIFY: + Debug.Log("EC_MsgDef.MSG_PM_FACTION_PVP_MASK_MODIFY"); + TransmitMessage(Msg); + break; } } else @@ -403,6 +408,65 @@ namespace PerfectWorld.Scripts.Managers { } + public bool TransmitMessage(ECMSG msg) + { + int cid = 0; + var host = GameController.Instance.GetHostPlayer(); + + switch (msg.dwMsg) + { + /*case long value when value == EC_MsgDef.MSG_PM_PLAYEREQUIPDATA: + if (msg.dwParam2 == S2C.EQUIP_DATA) + cid = ((cmd_equip_data)msg.dwParam1).idPlayer; + else // EQUIP_DATA_CHANGED + cid = ((cmd_equip_data_changed)msg.dwParam1).idPlayer; + break;*/ + + case long value when value == EC_MsgDef.MSG_PM_PLAYERBASEINFO: + cid = (int)((playerbaseinfo_re)msg.dwParam1).Player.id; + // Xoá khỏi cache + //g_pGame.GetGameSession().GetC2SCmdCache().RemovePlayerBaseInfo(cid); + break; + + /*case long value when value == EC_MsgDef.MSG_PM_PLAYERCUSTOM: + cid = ((GetCustomData_Re)msg.dwParam1).cus_roleid; + break; + + case long value when value == EC_MsgDef.MSG_PM_PLAYERFLY: + if (msg.dwParam2 == S2C.OBJECT_TAKEOFF) + cid = ((cmd_object_takeoff)msg.dwParam1).object_id; + else + cid = ((cmd_object_landing)msg.dwParam1).object_id; + break;*/ + + // ⚠️ Các case khác cũng tương tự, chỉ việc lấy ra đúng trường id / caster / user ... + // Do quá dài nên bạn có thể copy dần từng case từ C++ sang. + + default: + System.Diagnostics.Debug.Assert(false, "Unknown message"); + return false; + } + + /* if (cid == 0) + { + System.Diagnostics.Debug.Assert(false, "cid = 0"); + return false; + } + + if (host != null && cid == host.GetCharacterID()) + { + host.ProcessMessage(msg); + } + else + { + var elsePlayer = SeekOutElsePlayer(cid); + if (elsePlayer != null) + elsePlayer.ProcessMessage(msg); + }*/ + + return true; + } + } } } \ No newline at end of file diff --git a/Assets/PerfectWorld/Scripts/UI/Login/LoginScreenUI.cs b/Assets/PerfectWorld/Scripts/UI/Login/LoginScreenUI.cs index 99b5d2ff5d..6efe193374 100644 --- a/Assets/PerfectWorld/Scripts/UI/Login/LoginScreenUI.cs +++ b/Assets/PerfectWorld/Scripts/UI/Login/LoginScreenUI.cs @@ -121,10 +121,8 @@ namespace BrewMonster.UI private async void OnEnterWorldComplete() { - Debug.Log("OnEnterWorldDelay"); await Task.Delay(2000); - Logger.Log("Entered world successfully."); // Request all known packages: 0=Inventory,1=Equipment,2=Task UnityGameSession.RequestAllInventoriesAsync(() => { Logger.Log("Sent Inventory Detail Requests (all packs)"); }, 0, 1, 2); } diff --git a/Assets/Prefabs/HostPlayer.prefab b/Assets/Prefabs/HostPlayer.prefab index 8edd55e729..c3464222f7 100644 --- a/Assets/Prefabs/HostPlayer.prefab +++ b/Assets/Prefabs/HostPlayer.prefab @@ -42,6 +42,7 @@ GameObject: - component: {fileID: 5695237227048099898} - component: {fileID: 2967440448469171042} - component: {fileID: 2038764726549499828} + - component: {fileID: 6892195500068497589} m_Layer: 3 m_Name: HostPlayer m_TagString: Untagged @@ -114,3 +115,15 @@ MonoBehaviour: serializedVersion: 2 m_Bits: 0 slopeToleranceDeg: 2 +--- !u!114 &6892195500068497589 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6513559496054861882} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a78da6c5cf986974bae4f219bec9686b, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/Assets/Scenes/NPCRender.unity b/Assets/Scenes/NPCRender.unity index 95d29cfbf8..9140121acd 100644 --- a/Assets/Scenes/NPCRender.unity +++ b/Assets/Scenes/NPCRender.unity @@ -725,6 +725,7 @@ GameObject: - component: {fileID: 19544887} - component: {fileID: 19544890} - component: {fileID: 19544891} + - component: {fileID: 19544892} m_Layer: 3 m_Name: A3DSkinnedMeshRenderer(Clone) m_TagString: Untagged @@ -792,6 +793,25 @@ Animation: m_AnimatePhysics: 0 m_UpdateMode: 0 m_CullingType: 0 +--- !u!114 &19544892 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 19544886} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c75c0dcb6d50eb64abd727a90406ca2b, type: 3} + m_Name: + m_EditorClassIdentifier: + _Animator: {fileID: 19544890} + _ActionOnDisable: 0 + _PlayAutomatically: 1 + _Animations: + - {fileID: 7400000, guid: 29895f3687b86a24ba1bff2318b1d817, type: 2} + - {fileID: 7400000, guid: 9b5c3773d9888954c95132e25788ae54, type: 2} + - {fileID: 7400000, guid: 5f21aa4feb9cf1e49b63d5e7b7d9ad58, type: 2} --- !u!21 &19752687 Material: serializedVersion: 8 @@ -8776,7 +8796,7 @@ Transform: m_Children: - {fileID: 1581551008} m_Father: {fileID: 1935403418} - m_LocalEulerAnglesHint: {x: 1.4292676, y: 4.5578613, z: -1.2086567} + m_LocalEulerAnglesHint: {x: 1.8178657, y: -1.9374411, z: -0.59139097} --- !u!21 &119299862 Material: serializedVersion: 8 @@ -24649,7 +24669,7 @@ Transform: m_Children: - {fileID: 544427527} m_Father: {fileID: 910546517} - m_LocalEulerAnglesHint: {x: -0.00000010682195, y: 70.92535, z: 0.0000011250528} + m_LocalEulerAnglesHint: {x: -0.000000954647, y: 71.76492, z: 0.0000007902426} --- !u!1 &350119752 GameObject: m_ObjectHideFlags: 0 @@ -28388,7 +28408,7 @@ Transform: m_Children: - {fileID: 927195058} m_Father: {fileID: 446543210} - m_LocalEulerAnglesHint: {x: -16.884571, y: 177.04556, z: -83.74739} + m_LocalEulerAnglesHint: {x: -6.6681767, y: 177.0451, z: -83.32234} --- !u!1 &372443195 GameObject: m_ObjectHideFlags: 0 @@ -44190,7 +44210,7 @@ Transform: - {fileID: 848196782} - {fileID: 2028571851} m_Father: {fileID: 348653855} - m_LocalEulerAnglesHint: {x: 70.12514, y: -46.03195, z: 10.572675} + m_LocalEulerAnglesHint: {x: 70.15899, y: -60.410423, z: -5.098632} --- !u!1 &544761937 GameObject: m_ObjectHideFlags: 0 @@ -46744,7 +46764,7 @@ Transform: m_Children: - {fileID: 1997511859} m_Father: {fileID: 446543210} - m_LocalEulerAnglesHint: {x: -18.869505, y: 29.47179, z: -10.249526} + m_LocalEulerAnglesHint: {x: -11.039221, y: 28.380457, z: -7.081301} --- !u!1 &608525077 GameObject: m_ObjectHideFlags: 0 @@ -54335,7 +54355,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1402882656} - m_LocalEulerAnglesHint: {x: -0.0000009031419, y: -24.681396, z: 0.0000010651278} + m_LocalEulerAnglesHint: {x: -0.00000069760114, y: -29.644115, z: 0.0000008383041} --- !u!1 &725413046 GameObject: m_ObjectHideFlags: 0 @@ -63741,7 +63761,7 @@ Transform: m_Children: - {fileID: 544761938} m_Father: {fileID: 1327375124} - m_LocalEulerAnglesHint: {x: -0.00010106452, y: -74.11443, z: -0.0000368084} + m_LocalEulerAnglesHint: {x: -0.00010662674, y: -94.36407, z: 0.0000028154827} --- !u!1 &819000043 GameObject: m_ObjectHideFlags: 0 @@ -68307,7 +68327,7 @@ Transform: m_Children: - {fileID: 1367239218} m_Father: {fileID: 544427527} - m_LocalEulerAnglesHint: {x: -71.928925, y: 47.03804, z: -95.29024} + m_LocalEulerAnglesHint: {x: -74.09194, y: 49.44154, z: -95.93415} --- !u!1 &850121550 GameObject: m_ObjectHideFlags: 0 @@ -68905,7 +68925,7 @@ Transform: m_Children: - {fileID: 1935403418} m_Father: {fileID: 945815437} - m_LocalEulerAnglesHint: {x: -2.88983, y: -15.529159, z: -178.27307} + m_LocalEulerAnglesHint: {x: -1.3666012, y: -0.32128936, z: -179.05392} --- !u!1 &868672930 GameObject: m_ObjectHideFlags: 0 @@ -74189,7 +74209,7 @@ Transform: m_Children: - {fileID: 348653855} m_Father: {fileID: 2008016686} - m_LocalEulerAnglesHint: {x: 50.19849, y: 4.309895, z: -46.344612} + m_LocalEulerAnglesHint: {x: 35.333496, y: 4.499801, z: -53.608723} --- !u!1 &911593700 GameObject: m_ObjectHideFlags: 0 @@ -74795,7 +74815,7 @@ Transform: m_Children: - {fileID: 1592823476} m_Father: {fileID: 372156341} - m_LocalEulerAnglesHint: {x: 38.6756, y: 11.739685, z: 56.86085} + m_LocalEulerAnglesHint: {x: 13.065402, y: 11.504411, z: 68.36069} --- !u!43 &927232055 Mesh: m_ObjectHideFlags: 0 @@ -76491,7 +76511,7 @@ Transform: - {fileID: 867778777} - {fileID: 995061184} m_Father: {fileID: 1327375124} - m_LocalEulerAnglesHint: {x: 2.1356108, y: -4.056578, z: -11.56443} + m_LocalEulerAnglesHint: {x: 0.58568025, y: -3.6326547, z: -6.0202565} --- !u!1 &947096324 GameObject: m_ObjectHideFlags: 0 @@ -77430,7 +77450,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!4 &960760104 Transform: m_ObjectHideFlags: 0 @@ -77664,7 +77684,7 @@ Transform: m_Children: - {fileID: 306769634} m_Father: {fileID: 1327375124} - m_LocalEulerAnglesHint: {x: -0.00037753533, y: 148.9122, z: -0.000021449068} + m_LocalEulerAnglesHint: {x: -0.00037426883, y: 154.5833, z: -0.000059433} --- !u!1 &968689387 GameObject: m_ObjectHideFlags: 0 @@ -82103,7 +82123,7 @@ Transform: m_Children: - {fileID: 1574255742} m_Father: {fileID: 945815437} - m_LocalEulerAnglesHint: {x: 2.1872857, y: 68.69572, z: 174.87225} + m_LocalEulerAnglesHint: {x: 1.7745614, y: 43.735508, z: 175.74156} --- !u!1 &996127157 GameObject: m_ObjectHideFlags: 0 @@ -84385,7 +84405,7 @@ Transform: m_Children: - {fileID: 1704991185} m_Father: {fileID: 1574255742} - m_LocalEulerAnglesHint: {x: -0.40416494, y: -2.4466887, z: 2.1218336} + m_LocalEulerAnglesHint: {x: 1.1524358, y: 5.9093595, z: 3.0606961} --- !u!1 &1043393228 GameObject: m_ObjectHideFlags: 0 @@ -87016,7 +87036,7 @@ Transform: m_Children: - {fileID: 446543210} m_Father: {fileID: 1262943750} - m_LocalEulerAnglesHint: {x: 10.302944, y: -11.034387, z: -0.6075071} + m_LocalEulerAnglesHint: {x: 7.59645, y: -11.003804, z: -0.6714823} --- !u!28 &1084914121 Texture2D: m_ObjectHideFlags: 0 @@ -88654,7 +88674,7 @@ Transform: - {fileID: 1402882656} - {fileID: 115557945} m_Father: {fileID: 1592823476} - m_LocalEulerAnglesHint: {x: -76.59951, y: -84.906715, z: 37.66843} + m_LocalEulerAnglesHint: {x: -73.782875, y: -24.83398, z: -30.209316} --- !u!1 &1119867640 GameObject: m_ObjectHideFlags: 0 @@ -96172,7 +96192,7 @@ Transform: m_Children: - {fileID: 1084690608} m_Father: {fileID: 945815437} - m_LocalEulerAnglesHint: {x: 8.389646, y: -6.3102045, z: 0.86179394} + m_LocalEulerAnglesHint: {x: 4.533299, y: -6.3657193, z: 1.0729952} --- !u!1 &1263543760 GameObject: m_ObjectHideFlags: 0 @@ -103715,7 +103735,7 @@ Transform: - {fileID: 818595535} - {fileID: 963400555} m_Father: {fileID: 2068237208} - m_LocalEulerAnglesHint: {x: 9.215045e-11, y: 89.999916, z: 102.53423} + m_LocalEulerAnglesHint: {x: 0.0000016874452, y: 89.999916, z: 97.10705} --- !u!1 &1327530031 GameObject: m_ObjectHideFlags: 0 @@ -108226,7 +108246,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 848196782} - m_LocalEulerAnglesHint: {x: -0.000002827574, y: -38.820568, z: -0.000000958773} + m_LocalEulerAnglesHint: {x: -0.00000008261675, y: -36.541214, z: 0.0000005361414} --- !u!1 &1368937919 GameObject: m_ObjectHideFlags: 0 @@ -111527,7 +111547,7 @@ Transform: m_Children: - {fileID: 718823517} m_Father: {fileID: 1119797851} - m_LocalEulerAnglesHint: {x: 78.369576, y: 0.08194988, z: 41.20565} + m_LocalEulerAnglesHint: {x: 77.34563, y: 21.873825, z: 65.543846} --- !u!1 &1403901359 GameObject: m_ObjectHideFlags: 0 @@ -126925,7 +126945,7 @@ Transform: m_Children: - {fileID: 1041031438} m_Father: {fileID: 995061184} - m_LocalEulerAnglesHint: {x: -0.0000001260253, y: 26.47391, z: -0.00000020206706} + m_LocalEulerAnglesHint: {x: -0.0000000203409, y: 6.5712404, z: -0.00000007849389} --- !u!1 &1578589008 GameObject: m_ObjectHideFlags: 0 @@ -127087,7 +127107,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 119086036} - m_LocalEulerAnglesHint: {x: 0.000002614306, y: -89.11206, z: 0.00000019630072} + m_LocalEulerAnglesHint: {x: 0.0000021049605, y: -87.07461, z: 0.0000001241306} --- !u!1 &1582300033 GameObject: m_ObjectHideFlags: 0 @@ -127812,7 +127832,7 @@ Transform: m_Children: - {fileID: 1119797851} m_Father: {fileID: 927195058} - m_LocalEulerAnglesHint: {x: -0.000000515184, y: 40.82376, z: 0.0000004060857} + m_LocalEulerAnglesHint: {x: -0.00000011193368, y: 32.475494, z: -0.00000051928134} --- !u!1 &1592846884 GameObject: m_ObjectHideFlags: 0 @@ -131642,7 +131662,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1041031438} - m_LocalEulerAnglesHint: {x: -0.0000025450768, y: -87.74814, z: 0.000000058481362} + m_LocalEulerAnglesHint: {x: -0.0000028199365, y: -90.7236, z: 0.0000003678821} --- !u!1 &1706450906 GameObject: m_ObjectHideFlags: 0 @@ -150147,7 +150167,7 @@ Transform: m_Children: - {fileID: 119086036} m_Father: {fileID: 867778777} - m_LocalEulerAnglesHint: {x: 0.00000020055606, y: 41.309643, z: 0.00000015343919} + m_LocalEulerAnglesHint: {x: -0.000000029248092, y: 82.23336, z: 0.00000040711893} --- !u!1 &1935416203 GameObject: m_ObjectHideFlags: 0 @@ -153245,7 +153265,7 @@ Transform: m_Children: - {fileID: 910546517} m_Father: {fileID: 446543210} - m_LocalEulerAnglesHint: {x: -10.508322, y: 177.04562, z: 80.54116} + m_LocalEulerAnglesHint: {x: -5.4803176, y: 177.04517, z: 80.79009} --- !u!1 &2008788074 GameObject: m_ObjectHideFlags: 0 @@ -154048,7 +154068,7 @@ Transform: m_Children: - {fileID: 582355770} m_Father: {fileID: 544427527} - m_LocalEulerAnglesHint: {x: 0.033930764, y: -41.955963, z: -0.030501235} + m_LocalEulerAnglesHint: {x: 0.03527441, y: -39.3676, z: -0.028940197} --- !u!1 &2028574229 GameObject: m_ObjectHideFlags: 0 @@ -155282,7 +155302,7 @@ Transform: m_Children: - {fileID: 1327375124} m_Father: {fileID: 19544887} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_LocalEulerAnglesHint: {x: -0.0000008537736, y: -90.00006, z: -18.500004} --- !u!43 &2070228401 Mesh: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/CECHostPlayer.cs b/Assets/Scripts/CECHostPlayer.cs index b4f74fda00..c04a0d2f18 100644 --- a/Assets/Scripts/CECHostPlayer.cs +++ b/Assets/Scripts/CECHostPlayer.cs @@ -139,7 +139,7 @@ public class CECHostPlayer : EC_Player } else { - + } Vector3 finalMove = (move * playerSpeed) + (playerVelocity.y * Vector3.up); @@ -225,9 +225,9 @@ public class CECHostPlayer : EC_Player var data = Msg.dwParam1 as byte[]; int hostId = Convert.ToInt32(Msg.dwParam3); PerfectWorld.Scripts.Managers.EC_Inventory.LogInventoryPacket("OWN_ITEM_INFO", data, hostId); - break; + break; } - + } } public void OnMsgHstIvtrInfo(ECMSG Msg) @@ -260,7 +260,7 @@ public class CECHostPlayer : EC_Player } break; } - + } } public void OnMsgHstCorrectPos(in ECMSG Msg) @@ -309,13 +309,18 @@ public class CECHostPlayer : EC_Player joystick = FindAnyObjectByType(); EventBus.Subscribe(JoystickRelease); EventBus.Subscribe(JoystickStartDrag); + EventBus.Publish(new InitHostPlayerEventDone()) ; } private void JoystickStartDrag(JoystickPressEvent joystickPressEvent) { _playerStateMachine.ChangeState(_moveState); } - + private void OnDestroy() + { + EventBus.Unsubscribe(JoystickRelease); + EventBus.Unsubscribe(JoystickStartDrag); + } public void InitCharacter(info_player_1 role) { string roleName = "(Error decoding name)"; @@ -338,3 +343,7 @@ public enum StateAnim Run = 3, Jump = 4 } +public struct InitHostPlayerEventDone +{ + +} diff --git a/Assets/Scripts/CECStringTab.cs b/Assets/Scripts/CECStringTab.cs index a283c163f9..063c9594ff 100644 --- a/Assets/Scripts/CECStringTab.cs +++ b/Assets/Scripts/CECStringTab.cs @@ -126,6 +126,8 @@ public class CECStringTab var payload = allLines[j].Trim(); if (payload.Length == 0) continue; if (payload.StartsWith("#")) continue; + if (payload.StartsWith("//")) continue; + if (bIndexMode) { diff --git a/Assets/Scripts/Move/EC_Player.cs b/Assets/Scripts/Move/EC_Player.cs index e2b6fd176c..e7d9de0f77 100644 --- a/Assets/Scripts/Move/EC_Player.cs +++ b/Assets/Scripts/Move/EC_Player.cs @@ -13,7 +13,6 @@ public class EC_Player : MonoBehaviour protected void Awake() { m_PlayerActions = _default_actions; - BrewMonster.Logger.Log("m_PlayerActions " + m_PlayerActions.Length); } public static void InitStaticRes() @@ -35,7 +34,7 @@ public class EC_Player : MonoBehaviour PLAYER_ACTION_INFO_CONFIG data; int count = dataman.get_data_num(ID_SPACE.ID_SPACE_CONFIG); - + DATA_TYPE dt = default; uint id = 0; @@ -65,13 +64,11 @@ public class EC_Player : MonoBehaviour _default_actions[i].type = (PLAYER_ACTION_TYPE)i; string szName = actionNames.GetANSIString(i); - BrewMonster.Logger.Log("HoangDev: szName " + szName); if (!string.IsNullOrEmpty(szName)) { if (actionMap.TryGetValue(szName, out var it)) { - _default_actions[i].data = it; } } @@ -91,17 +88,16 @@ public class EC_Player : MonoBehaviour if (actionConfigID > 0) { DATA_TYPE dt = DATA_TYPE.DT_INVALID; - var p = ElementDataManProvider.GetElementDataMan().get_data_ptr((uint)actionConfigID, ID_SPACE. ID_SPACE_CONFIG, ref dt); + var p = ElementDataManProvider.GetElementDataMan().get_data_ptr((uint)actionConfigID, ID_SPACE.ID_SPACE_CONFIG, ref dt); if (dt == DATA_TYPE.DT_PLAYER_ACTION_INFO_CONFIG) { PLAYER_ACTION actionConfig; actionConfig.type = (PLAYER_ACTION_TYPE)iAction; - actionConfig.data = (PLAYER_ACTION_INFO_CONFIG) p; + actionConfig.data = (PLAYER_ACTION_INFO_CONFIG)p; return PlayActionWithConfig(iAction, actionConfig, bRestart, iTransTime, bQueue); } else { - BrewMonster.Logger.LogError($"CECPlayer::PlayActionWithConfig, invalid action config ID({actionConfigID})"); } } return PlayActionWithConfig(iAction, m_PlayerActions[iAction], bRestart, iTransTime, bQueue); @@ -111,9 +107,8 @@ public class EC_Player : MonoBehaviour { PLAYER_ACTION action = actionConfig; - var szAct = EC_Utility.BuildActionName(action, 10); - - BrewMonster.Logger.Log("HoangDev : szActszAct " + szAct); + var szAct = EC_Utility.BuildActionName(action, 0); + EventBus.Publish(new PlayActionEvent(szAct)); return true; } public static void Dispose() @@ -121,8 +116,6 @@ public class EC_Player : MonoBehaviour _default_actions = null; _turning_actions = null; } - - public struct PLAYER_ACTION { public PLAYER_ACTION_TYPE type; @@ -265,3 +258,11 @@ public class EC_Player : MonoBehaviour } } +public struct PlayActionEvent +{ + public string AnimationName; + public PlayActionEvent(string animationName) + { + this.AnimationName = animationName; + } +} diff --git a/Assets/Scripts/PlayerState/PlayerIdleState.cs b/Assets/Scripts/PlayerState/PlayerIdleState.cs index f62768c933..dab799fc4a 100644 --- a/Assets/Scripts/PlayerState/PlayerIdleState.cs +++ b/Assets/Scripts/PlayerState/PlayerIdleState.cs @@ -1,4 +1,5 @@ using UnityEngine; +using static EC_Player; public class PlayerIdleState : PlayerState { @@ -8,7 +9,7 @@ public class PlayerIdleState : PlayerState public override void Enter() { - + _characterCtrl.PlayAction((int)PLAYER_ACTION_TYPE.ACT_STAND, true, 1, false); } public override void Exit() diff --git a/Assets/Scripts/PlayerVisual.cs b/Assets/Scripts/PlayerVisual.cs new file mode 100644 index 0000000000..033d084ff8 --- /dev/null +++ b/Assets/Scripts/PlayerVisual.cs @@ -0,0 +1,33 @@ +using Animancer; +using System; +using UnityEngine; + +public class PlayerVisual : MonoBehaviour +{ + [SerializeField] NamedAnimancerComponent animancer; + private void Awake() + { + EventBus.Subscribe(InitHostPlayerEventDoneHandler); + EventBus.Subscribe(PlayActionEventHandler); + } + + private void PlayActionEventHandler(PlayActionEvent @event) + { + BrewMonster.Logger.Log("PlayActionEventHandler : "+@event.AnimationName); + animancer.TryPlay(@event.AnimationName); + } + + private void InitHostPlayerEventDoneHandler(InitHostPlayerEventDone done) + { + animancer = GetComponentInChildren(); + if(animancer == null) + { + BrewMonster.Logger.Log("animancer == null"); + } + } + private void OnDestroy() + { + EventBus.Unsubscribe(InitHostPlayerEventDoneHandler); + EventBus.Unsubscribe(PlayActionEventHandler); + } +} diff --git a/Assets/Scripts/PlayerVisual.cs.meta b/Assets/Scripts/PlayerVisual.cs.meta new file mode 100644 index 0000000000..2f83c8929a --- /dev/null +++ b/Assets/Scripts/PlayerVisual.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: a78da6c5cf986974bae4f219bec9686b \ No newline at end of file