Files
2025-05-01 07:23:28 +09:00

35 lines
1.6 KiB
C#

using Google.Protobuf.WellKnownTypes;
using Newtonsoft.Json;
using ServerCore;
namespace GameServer.Contents.GameMode.Helper;
public class GameNotifyHelper
{
public static void broadcast_GS2C_NTF_GAME_STATE_UPDATE(InstanceRoom instanceRoom, GameModeState state, DateTime nextUpdatableTime)
{
var ntf = makeNtfGameStateUpdate(instanceRoom, state, nextUpdatableTime);
Log.getLogger().debug($"broadcast_GS2C_NTF_BATTLE_INSTANCE_STATE ntf instanceRoom Id : {instanceRoom.getMap().m_room_id} data : {JsonConvert.SerializeObject(ntf.Message.NtfGameStateUpdate)}");
instanceRoom.Broadcast(ntf);
}
public static void send_GS2C_NTF_GAME_STATE_UPDATE(Player player, InstanceRoom instanceRoom, GameModeState state, DateTime nextUpdatableTime)
{
var ntf = makeNtfGameStateUpdate(instanceRoom, state, nextUpdatableTime);
Log.getLogger().debug($"send_GS2C_NTF_GAME_STATE_UPDATE ntf instanceRoom Id : {instanceRoom.getMap().m_room_id} data : {JsonConvert.SerializeObject(ntf.Message.NtfGameStateUpdate)}");
GameServerApp.getServerLogic().onSendPacket(player, ntf);
}
public static ClientToGame makeNtfGameStateUpdate(InstanceRoom instanceRoom, GameModeState state, DateTime nextUpdatableTime)
{
ClientToGame ntf = new ClientToGame();
ntf.Message = new ClientToGameMessage();
ntf.Message.NtfGameStateUpdate = new ClientToGameMessage.Types.GS2C_NTF_GAME_STATE_UPDATE_NOTI();
ntf.Message.NtfGameStateUpdate.CurrentState = state;
ntf.Message.NtfGameStateUpdate.NextUpdatableTime = Timestamp.FromDateTime(nextUpdatableTime);
return ntf;
}
}