Show 1 warning first then 10m each
This commit is contained in:
@@ -100,18 +100,33 @@ partial class CECGameRun
|
||||
public float healthPlaytimeChatReminderIntervalSeconds = 600f;
|
||||
|
||||
private uint _healthPlaytimeChatReminderAccumMs;
|
||||
private bool _healthPlaytimeChatReminderDidImmediateThisSession;
|
||||
|
||||
private const string HealthPlaytimeChatReminderText =
|
||||
"Chơi game quá 180 phút có hại cho sức khoẻ";
|
||||
|
||||
private static void PublishHealthPlaytimeChatReminder()
|
||||
{
|
||||
string redMsg = "<color=#FF0000>" + HealthPlaytimeChatReminderText + "</color>";
|
||||
EventBus.Publish(new GameSession.ChatMessageEvent(redMsg, (byte)ChatChannel.GP_CHAT_SYSTEM));
|
||||
}
|
||||
|
||||
private void TickHealthPlaytimeChatReminder(uint dwDeltaMs)
|
||||
{
|
||||
if (GetGameState() != (int)GameState.GS_GAME)
|
||||
{
|
||||
_healthPlaytimeChatReminderAccumMs = 0;
|
||||
_healthPlaytimeChatReminderDidImmediateThisSession = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_healthPlaytimeChatReminderDidImmediateThisSession)
|
||||
{
|
||||
_healthPlaytimeChatReminderDidImmediateThisSession = true;
|
||||
_healthPlaytimeChatReminderAccumMs = 0;
|
||||
PublishHealthPlaytimeChatReminder();
|
||||
}
|
||||
|
||||
float intervalSec = Mathf.Max(0.1f, healthPlaytimeChatReminderIntervalSeconds);
|
||||
uint intervalMs = (uint)(intervalSec * 1000f);
|
||||
if (intervalMs < 1)
|
||||
@@ -121,8 +136,7 @@ partial class CECGameRun
|
||||
while (_healthPlaytimeChatReminderAccumMs >= intervalMs)
|
||||
{
|
||||
_healthPlaytimeChatReminderAccumMs -= intervalMs;
|
||||
string redMsg = "<color=#FF0000>" + HealthPlaytimeChatReminderText + "</color>";
|
||||
EventBus.Publish(new GameSession.ChatMessageEvent(redMsg, (byte)ChatChannel.GP_CHAT_SYSTEM));
|
||||
PublishHealthPlaytimeChatReminder();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user