Skip to content

Commit

Permalink
Update ContiMoveManagerTicker to act every 20s
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaioru committed Sep 28, 2024
1 parent fc39a0f commit 3cc897d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
using System;
using Edelstein.Common.Utilities.Tickers;
using Edelstein.Protocol.Gameplay.Game.Continents;
using Edelstein.Protocol.Utilities;
using Edelstein.Protocol.Utilities.Tickers;

namespace Edelstein.Common.Gameplay.Game.Continent;

public class ContiMoveManagerTicker(
IDateTimeProvider dateTime,
IContiMoveManager manager
) : ITickerAction
) : AbstractTickerActionTerm(dateTime, TimeSpan.FromSeconds(20))
{
public void Act()
protected override void ActAfter(DateTime now)
{
var now = dateTime.Now;
var records = manager.RetrieveAll().Result;

foreach (var contimove in records)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using Edelstein.Protocol.Utilities;
using Edelstein.Protocol.Utilities.Tickers;

namespace Edelstein.Common.Utilities.Tickers;

public abstract class AbstractTickerActionTerm(
IDateTimeProvider dateTime,
TimeSpan term
) : ITickerAction
{
private DateTime DateLastUpdate { get; set; }

public void Act()
{
var now = dateTime.Now;

if (now - DateLastUpdate <= term) return;

DateLastUpdate = now;
ActAfter(now);
}

protected abstract void ActAfter(DateTime now);
}

0 comments on commit 3cc897d

Please sign in to comment.