File tree Expand file tree Collapse file tree 2 files changed +28
-4
lines changed
Edelstein.Common.Gameplay.Game/Continent
Edelstein.Common.Utilities/Tickers Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change 1
1
using System ;
2
+ using Edelstein . Common . Utilities . Tickers ;
2
3
using Edelstein . Protocol . Gameplay . Game . Continents ;
3
4
using Edelstein . Protocol . Utilities ;
4
- using Edelstein . Protocol . Utilities . Tickers ;
5
5
6
6
namespace Edelstein . Common . Gameplay . Game . Continent ;
7
7
8
8
public class ContiMoveManagerTicker (
9
9
IDateTimeProvider dateTime ,
10
10
IContiMoveManager manager
11
- ) : ITickerAction
11
+ ) : AbstractTickerActionTerm ( dateTime , TimeSpan . FromSeconds ( 20 ) )
12
12
{
13
- public void Act ( )
13
+ protected override void ActAfter ( DateTime now )
14
14
{
15
- var now = dateTime . Now ;
16
15
var records = manager . RetrieveAll ( ) . Result ;
17
16
18
17
foreach ( var contimove in records )
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using Edelstein . Protocol . Utilities ;
3
+ using Edelstein . Protocol . Utilities . Tickers ;
4
+
5
+ namespace Edelstein . Common . Utilities . Tickers ;
6
+
7
+ public abstract class AbstractTickerActionTerm (
8
+ IDateTimeProvider dateTime ,
9
+ TimeSpan term
10
+ ) : ITickerAction
11
+ {
12
+ private DateTime DateLastUpdate { get ; set ; }
13
+
14
+ public void Act ( )
15
+ {
16
+ var now = dateTime . Now ;
17
+
18
+ if ( now - DateLastUpdate <= term ) return ;
19
+
20
+ DateLastUpdate = now ;
21
+ ActAfter ( now ) ;
22
+ }
23
+
24
+ protected abstract void ActAfter ( DateTime now ) ;
25
+ }
You can’t perform that action at this time.
0 commit comments