7
7
using GameFrameX . Core . Timer ;
8
8
using GameFrameX . Core . Utility ;
9
9
using GameFrameX . Foundation . Logger ;
10
+ using GameFrameX . Utility ;
10
11
using GameFrameX . Utility . Extensions ;
11
12
using GameFrameX . Utility . Setting ;
12
13
@@ -25,7 +26,7 @@ public static class ActorManager
25
26
private const int CrossDayNotRoleWaitSeconds = 120 ;
26
27
private static readonly ConcurrentDictionary < long , Actor > ActorMap = new ( ) ;
27
28
28
- private static readonly ConcurrentDictionary < long , DateTime > ActiveTimeDic = new ( ) ;
29
+ private static readonly ConcurrentDictionary < long , DateTime > ActiveTimeDic = new ConcurrentDictionary < long , DateTime > ( ) ;
29
30
30
31
private static readonly List < WorkerActor > WorkerActors = new ( ) ;
31
32
@@ -154,7 +155,7 @@ internal static async Task<Actor> GetOrNew(long actorId)
154
155
var actorType = ActorIdGenerator . GetActorType ( actorId ) ;
155
156
if ( actorType < GlobalConst . ActorTypeSeparator )
156
157
{
157
- var now = DateTime . Now ;
158
+ var now = TimeHelper . GetUtcNow ( ) ;
158
159
if ( ActiveTimeDic . TryGetValue ( actorId , out var activeTime )
159
160
&& ( now - activeTime ) . TotalMinutes < 10
160
161
&& ActorMap . TryGetValue ( actorId , out var actor ) )
@@ -184,7 +185,7 @@ private static Actor Get(long actorId)
184
185
Actor valueActor ;
185
186
if ( actorType < GlobalConst . ActorTypeSeparator )
186
187
{
187
- var now = DateTime . Now ;
188
+ var now = TimeHelper . GetUtcNow ( ) ;
188
189
if ( ActiveTimeDic . TryGetValue ( actorId , out var activeTime )
189
190
&& ( now - activeTime ) . TotalMinutes < 10
190
191
&& ActorMap . TryGetValue ( actorId , out var actor ) )
@@ -241,11 +242,11 @@ public static Task CheckIdle()
241
242
242
243
async Task Func ( )
243
244
{
244
- if ( actor . AutoRecycle && ( DateTime . Now - ActiveTimeDic [ actor . Id ] ) . TotalMinutes > 15 )
245
+ if ( actor . AutoRecycle && ( TimeHelper . GetUtcNow ( ) - ActiveTimeDic [ actor . Id ] ) . TotalMinutes > 15 )
245
246
{
246
247
async Task < bool > Work ( )
247
248
{
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 )
249
250
{
250
251
// 防止定时回存失败时State被直接移除
251
252
if ( actor . ReadyToDeActive )
@@ -257,7 +258,7 @@ async Task<bool> Work()
257
258
else
258
259
{
259
260
// 不能存就久一点再判断
260
- ActiveTimeDic [ actor . Id ] = DateTime . Now ;
261
+ ActiveTimeDic [ actor . Id ] = TimeHelper . GetUtcNow ( ) ;
261
262
}
262
263
}
263
264
0 commit comments