From 072d4e2177e9bccdad94b22bf558d89b4b2b7143 Mon Sep 17 00:00:00 2001
From: HungDK <>
Date: Wed, 25 Mar 2026 11:46:16 +0700
Subject: [PATCH] Show 1 warning first then 10m each
---
Assets/Scripts/EC_GameRunChat.cs | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/Assets/Scripts/EC_GameRunChat.cs b/Assets/Scripts/EC_GameRunChat.cs
index eec1fa7fe5..477047a261 100644
--- a/Assets/Scripts/EC_GameRunChat.cs
+++ b/Assets/Scripts/EC_GameRunChat.cs
@@ -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 = "" + HealthPlaytimeChatReminderText + "";
+ 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 = "" + HealthPlaytimeChatReminderText + "";
- EventBus.Publish(new GameSession.ChatMessageEvent(redMsg, (byte)ChatChannel.GP_CHAT_SYSTEM));
+ PublishHealthPlaytimeChatReminder();
}
}
}