Files
caliverse_server/GameServer/Contents/GameMode/Mode-Battle/Tickers/BattleEventNotifyTicker.cs
2025-05-01 07:20:41 +09:00

66 lines
1.7 KiB
C#

using Google.Protobuf;
using Google.Protobuf.WellKnownTypes;
using ServerCore;
using ServerBase;
using ServerCommon;
using ServerCommon.BusinessLogDomain;
using MetaAssets;
namespace GameServer;
public class BattleEventNotifyTicker : EntityTicker
{
public BattleEventNotifyTicker(double onTickIntervalMilliseconds, CancellationTokenSource? cts)
: base(EntityType.BattleInstanceStateCheckTicker, onTickIntervalMilliseconds, cts)
{
}
public override async Task onTaskTick()
{
if (false == BattleRoomHelper.checkBattleActive()) return;
//필요한 Noti가 있다면 broadCast
await notifyBattleEvent();
}
private async Task notifyBattleEvent()
{
await Task.CompletedTask;
var battle_events = BattleInstanceManager.It.getSystemBattleEvents().Values;
var now = DateTimeHelper.Current;
List<Int32> event_ids = new();
foreach (var ev in battle_events)
{
if (ev.m_ready_time < now && now <= ev.m_start_time && ev.m_is_send_noti == false)
{
event_ids.Add(ev.m_event_id);
ev.m_is_send_noti = true;
}
}
List<BattleEventInfo> infos = new();
foreach (var event_id in event_ids)
{
if (false == BattleInstanceManager.It.getSystemBattleEvent(event_id, out var battleEvent))
{
continue;
}
infos.Add(BattleInstanceManager.It.makeProtoBattleEvent(battleEvent));
}
if (infos.Count > 0)
{
BattleRoomNotifyHelper.broadcast_GS2C_NTF_BATTLE_EVENT(infos);
}
}
}