KCP gameserver with packet dispatch, scene streaming, combat, gacha and the shop, plus a small HTTP server for the login flow and the wish history page. Game data under assets is pulled out of the client instead of being typed by hand. The excel tables come from the packed bin container and the spawn points from the compiled scene scripts.
33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
using Yuanshen.Gameserver.Controllers.Attributes;
|
|
using Yuanshen.Gameserver.Controllers.Result;
|
|
using Yuanshen.Gameserver.Game;
|
|
using Yuanshen.Protocol;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace Yuanshen.Gameserver.Controllers;
|
|
|
|
[NetController]
|
|
internal sealed class GmTalkController : ControllerBase
|
|
{
|
|
private static readonly char[] Separators = { ';', '\n', '\r' };
|
|
|
|
[NetCommand(CmdType.GmTalkReq)]
|
|
public async ValueTask<IResult> OnGmTalkReq(GmCommandService gm, ILogger<GmTalkController> logger)
|
|
{
|
|
GmTalkReq req = Packet!.DecodeBody<GmTalkReq>();
|
|
string message = req.Msg ?? string.Empty;
|
|
|
|
logger.LogInformation("GmTalk: {message}", message);
|
|
|
|
List<string> reply = new();
|
|
foreach (string part in message.Split(Separators, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries))
|
|
reply.AddRange(await gm.ExecuteAsync(part));
|
|
|
|
return Response(CmdType.GmTalkRsp, new GmTalkRsp
|
|
{
|
|
Retcode = 0,
|
|
Msg = message,
|
|
Retmsg = string.Join('\n', reply)
|
|
});
|
|
}
|
|
}
|