change game session

This commit is contained in:
CuongNV
2026-03-09 16:57:56 +07:00
parent 530dab31ef
commit e08939e5c6
@@ -14,6 +14,7 @@ using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using BrewMonster.PerfectWorld.Scripts.UI;
using BrewMonster.Scripts;
using BrewMonster.Scripts.Chat;
using BrewMonster.Scripts.Managers;
@@ -573,6 +574,9 @@ namespace CSNetwork
case ProtocolType.PROTOCOL_CHATMESSAGE:
OnPrtcChatMessage(protocol, false);
break;
case ProtocolType.PROTOCOL_WORLDCHAT:
OnPrtcWorldChat(protocol, false);
break;
case ProtocolType.PROTOCOL_PLAYERBASEINFO_RE:
OnPrtcPlayerBaseInfoRe(protocol);
break;
@@ -1596,6 +1600,8 @@ namespace CSNetwork
/// <param name="iSlot"></param>
public void SendChatData(byte cChannel, in string szMsg, int iPack, int iSlot)
{
EventBus.Publish(new EventChatMessageOnTopPlayer(szMsg));
EventBus.Publish(new ChatMessageEvent(szMsg));
publicchat publicChat = new publicchat();
publicChat.Channel = cChannel;
publicChat.Roleid = m_iCharID;
@@ -1636,6 +1642,12 @@ namespace CSNetwork
m_iCharID = iCharID;
}
private bool OnPrtcWorldChat(Protocol pProtocol, bool bCalledagain)
{
Debug.Log("[Cuong] OnPrtcWorldChat");
return true;
}
private bool OnPrtcChatMessage(Protocol pProtocol, bool bCalledagain)
{
CECGameUIMan pGameUI = EC_Game.GetGameRun().GetUIManager().GetInGameUIMan();
@@ -1654,7 +1666,6 @@ namespace CSNetwork
string szMsg = null;
string strTemp = Encoding.Unicode.GetString(p.Msg.ToArray(), 0, p.Msg.Length);
//string strTemp = Encoding.Unicode.GetString(p.Msg.ToArray());
string strMsgOrigion = strTemp;
// Todo: Show Text on Ui Game
//strTemp = pGameUI.FilterInvalidTags(strTemp, pItem==NULL);
@@ -1680,7 +1691,8 @@ namespace CSNetwork
else
{
Debug.Log("[Cuong] 5");
EC_Game.GetGameRun().AddChatMessage(szMsg, p.Channel, p.Srcroleid, null, 0, p.Emotion);
EventBus.Publish(new ChatMessageEvent(strTemp));
//EC_Game.GetGameRun().AddChatMessage(szMsg, p.Channel, p.Srcroleid, null, 0, p.Emotion);
}
}else if (p.Channel == (byte)ChatChannel.GP_CHAT_INSTANCE && p.Srcroleid == 1)
{
@@ -1696,7 +1708,7 @@ namespace CSNetwork
if (ISPLAYERID(p.Srcroleid))
{
string szName = EC_Game.GetGameRun().GetPlayerName(p.Srcroleid, false);
Debug.Log("[Cuong] Other Msg" + szName);
Debug.Log("[Cuong] Other Msg " + szName);
if (szName == null)
{
if (!bCalledagain)
@@ -1716,11 +1728,14 @@ namespace CSNetwork
szName,
szMsg
);
EC_Game.GetGameRun().AddChatMessage(str, p.Channel, p.Srcroleid,
null, 0, p.Emotion, pItem, strMsgOrigion);
// Convert to EventBus
/*EC_Game.GetGameRun().AddChatMessage(str, p.Channel, p.Srcroleid,
null, 0, p.Emotion, pItem, strMsgOrigion); */
EventBus.Publish(new ChatMessageEvent(str));
// Set player's last said words
CECPlayer pPlayer = EC_Game.GetGameRun().GetWorld().GetPlayerMan().GetPlayer(p.Srcroleid);
Debug.Log("[Cuong] name " + pPlayer == null ? "null" : "have name");
if (pPlayer != null)
{
if (p.Channel == (byte)ChatChannel.GP_CHAT_SUPERFARCRY) {
@@ -1730,7 +1745,8 @@ namespace CSNetwork
strTemp = "";
}
//pPlayer.SetLastSaidWords(strTemp, p.Emotion, pItem);
EventBus.Publish(new ChatMessageEvent(strTemp));
Debug.Log("[Cuong] " + pPlayer);
EventBus.Publish(new EventChatMessageOnTopPlayer(strTemp));
}
}
}
@@ -1748,15 +1764,16 @@ namespace CSNetwork
pNPC.GetName(),
szMsg
);
EC_Game.GetGameRun().AddChatMessage(
/*EC_Game.GetGameRun().AddChatMessage(
message,
p.Channel,
p.Srcroleid,
null,
0,
p.Emotion
);
);*/
EventBus.Publish(new ChatMessageEvent(message));
CECUIHelper.RemoveNameFlagFromNPCChat(strTemp, out szMsg);