Add SearchPatternShotSelector

This commit is contained in:
drewjcooper
2023-04-23 17:55:48 +10:00
parent d21b41d3a7
commit aa6a06cdc8
7 changed files with 107 additions and 66 deletions

View File

@@ -0,0 +1,22 @@
using System.Collections.Immutable;
namespace Salvo.Targetting;
internal class SearchPattern
{
private static readonly ImmutableArray<Offset> _offsets =
ImmutableArray.Create<Offset>(new(1, 1), new(-1, 1), new(1, -3), new(1, 1), new(0, 2), new(-1, 1));
private int _nextIndex;
internal bool TryGetOffset(out Offset offset)
{
offset = default;
if (_nextIndex >= _offsets.Length) { return false; }
offset = _offsets[_nextIndex++];
return true;
}
internal void Reset() => _nextIndex = 0;
}