diff --git a/Assets/Scripts/EC_GameRun.cs b/Assets/Scripts/EC_GameRun.cs
index 226ecd3065..aff54b0491 100644
--- a/Assets/Scripts/EC_GameRun.cs
+++ b/Assets/Scripts/EC_GameRun.cs
@@ -1243,6 +1243,8 @@ public partial class CECGameRun : ITickable
// g_TickMemoryHistory();
// #endif
+ TickHealthPlaytimeChatReminder(dwDeltaTime);
+
return true;
}
diff --git a/Assets/Scripts/EC_GameRunChat.cs b/Assets/Scripts/EC_GameRunChat.cs
index b8fb48f602..eec1fa7fe5 100644
--- a/Assets/Scripts/EC_GameRunChat.cs
+++ b/Assets/Scripts/EC_GameRunChat.cs
@@ -93,4 +93,36 @@ partial class CECGameRun
}
}
}
+
+ ///
+ /// Seconds between chat reminders (default 10). Change at runtime or in code as needed.
+ ///
+ public float healthPlaytimeChatReminderIntervalSeconds = 600f;
+
+ private uint _healthPlaytimeChatReminderAccumMs;
+
+ private const string HealthPlaytimeChatReminderText =
+ "Chơi game quá 180 phút có hại cho sức khoẻ";
+
+ private void TickHealthPlaytimeChatReminder(uint dwDeltaMs)
+ {
+ if (GetGameState() != (int)GameState.GS_GAME)
+ {
+ _healthPlaytimeChatReminderAccumMs = 0;
+ return;
+ }
+
+ float intervalSec = Mathf.Max(0.1f, healthPlaytimeChatReminderIntervalSeconds);
+ uint intervalMs = (uint)(intervalSec * 1000f);
+ if (intervalMs < 1)
+ intervalMs = 1;
+
+ _healthPlaytimeChatReminderAccumMs += dwDeltaMs;
+ while (_healthPlaytimeChatReminderAccumMs >= intervalMs)
+ {
+ _healthPlaytimeChatReminderAccumMs -= intervalMs;
+ string redMsg = "" + HealthPlaytimeChatReminderText + "";
+ EventBus.Publish(new GameSession.ChatMessageEvent(redMsg, (byte)ChatChannel.GP_CHAT_SYSTEM));
+ }
+ }
}