diff --git a/orleans/Adventure/AdventureGrains/MonsterGrain.cs b/orleans/Adventure/AdventureGrains/MonsterGrain.cs index 713994e422a..6f9e7239783 100644 --- a/orleans/Adventure/AdventureGrains/MonsterGrain.cs +++ b/orleans/Adventure/AdventureGrains/MonsterGrain.cs @@ -1,25 +1,27 @@ -using AdventureGrainInterfaces; +using AdventureGrainInterfaces; namespace AdventureGrains; -public class MonsterGrain : Grain, IMonsterGrain +public class MonsterGrain : Grain, IMonsterGrain, IDisposable { private MonsterInfo _monsterInfo = new(); + private IGrainTimer? _timer; private IRoomGrain? _roomGrain; // Current room public override Task OnActivateAsync(CancellationToken cancellationToken) { _monsterInfo = _monsterInfo with { Id = this.GetPrimaryKeyLong() }; - RegisterTimer( + _timer = RegisterGrainTimer( _ => Move(), - null!, TimeSpan.FromSeconds(150), TimeSpan.FromMinutes(150)); return base.OnActivateAsync(cancellationToken); } + public void Dispose() => _timer?.Dispose(); + Task IMonsterGrain.SetInfo(MonsterInfo info) { _monsterInfo = info;