From 05adae4f21791ae4ac9b75d2b910880153d5d12e Mon Sep 17 00:00:00 2001
From: HungDK <>
Date: Wed, 25 Mar 2026 11:36:29 +0700
Subject: [PATCH] Add health warning message
---
Assets/Scripts/EC_GameRun.cs | 2 ++
Assets/Scripts/EC_GameRunChat.cs | 32 ++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+)
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));
+ }
+ }
}