Skip to content

Commit a3148dc

Browse files
committed
[修改]1. 修改Actor的时间为UTC时间
1 parent 6d6bfaa commit a3148dc

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

GameFrameX.Core/Actors/ActorManager.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using GameFrameX.Core.Timer;
88
using GameFrameX.Core.Utility;
99
using GameFrameX.Foundation.Logger;
10+
using GameFrameX.Utility;
1011
using GameFrameX.Utility.Extensions;
1112
using GameFrameX.Utility.Setting;
1213

@@ -25,7 +26,7 @@ public static class ActorManager
2526
private const int CrossDayNotRoleWaitSeconds = 120;
2627
private static readonly ConcurrentDictionary<long, Actor> ActorMap = new();
2728

28-
private static readonly ConcurrentDictionary<long, DateTime> ActiveTimeDic = new();
29+
private static readonly ConcurrentDictionary<long, DateTime> ActiveTimeDic = new ConcurrentDictionary<long, DateTime>();
2930

3031
private static readonly List<WorkerActor> WorkerActors = new();
3132

@@ -154,7 +155,7 @@ internal static async Task<Actor> GetOrNew(long actorId)
154155
var actorType = ActorIdGenerator.GetActorType(actorId);
155156
if (actorType < GlobalConst.ActorTypeSeparator)
156157
{
157-
var now = DateTime.Now;
158+
var now = TimeHelper.GetUtcNow();
158159
if (ActiveTimeDic.TryGetValue(actorId, out var activeTime)
159160
&& (now - activeTime).TotalMinutes < 10
160161
&& ActorMap.TryGetValue(actorId, out var actor))
@@ -184,7 +185,7 @@ private static Actor Get(long actorId)
184185
Actor valueActor;
185186
if (actorType < GlobalConst.ActorTypeSeparator)
186187
{
187-
var now = DateTime.Now;
188+
var now = TimeHelper.GetUtcNow();
188189
if (ActiveTimeDic.TryGetValue(actorId, out var activeTime)
189190
&& (now - activeTime).TotalMinutes < 10
190191
&& ActorMap.TryGetValue(actorId, out var actor))
@@ -241,11 +242,11 @@ public static Task CheckIdle()
241242

242243
async Task Func()
243244
{
244-
if (actor.AutoRecycle && (DateTime.Now - ActiveTimeDic[actor.Id]).TotalMinutes > 15)
245+
if (actor.AutoRecycle && (TimeHelper.GetUtcNow() - ActiveTimeDic[actor.Id]).TotalMinutes > 15)
245246
{
246247
async Task<bool> Work()
247248
{
248-
if (ActiveTimeDic.TryGetValue(actor.Id, out var activeTime) && (DateTime.Now - ActiveTimeDic[actor.Id]).TotalMinutes > 15)
249+
if (ActiveTimeDic.TryGetValue(actor.Id, out var activeTime) && (TimeHelper.GetUtcNow() - ActiveTimeDic[actor.Id]).TotalMinutes > 15)
249250
{
250251
// 防止定时回存失败时State被直接移除
251252
if (actor.ReadyToDeActive)
@@ -257,7 +258,7 @@ async Task<bool> Work()
257258
else
258259
{
259260
// 不能存就久一点再判断
260-
ActiveTimeDic[actor.Id] = DateTime.Now;
261+
ActiveTimeDic[actor.Id] = TimeHelper.GetUtcNow();
261262
}
262263
}
263264

0 commit comments

Comments
 (0)