riversong code showcase

This commit is contained in:
Daniele Marotta
2026-05-21 15:52:18 +02:00
commit 4c9eea1c02
462 changed files with 23406 additions and 0 deletions

View File

@@ -0,0 +1,88 @@
using System.Collections;
using System.Collections.Generic;
using Unity.Mathematics;
namespace DanieleMarotta.RiversongCodeShowcase
{
public struct TileRange : IEnumerable<int2>
{
public int2 Min;
public int2 Max;
private TileRange(int2 min, int2 max)
{
Min = min;
Max = max;
}
public static TileRange From(in TileRect rect)
{
return new TileRange(rect.Min, rect.Max);
}
public static TileRange From(int2 min, int2 max)
{
return From(new TileRect(min, max));
}
public Enumerator GetEnumerator()
{
return new Enumerator(Min, Max);
}
IEnumerator<int2> IEnumerable<int2>.GetEnumerator()
{
return GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public struct Enumerator : IEnumerator<int2>
{
public int2 Min;
public int2 Max;
public int2 Current { get; private set; }
object IEnumerator.Current => Current;
public Enumerator(int2 min, int2 max) : this()
{
Min = min;
Max = max;
Reset();
}
public bool MoveNext()
{
if (Current.x < Max.x)
{
Current = new int2(Current.x + 1, Current.y);
return true;
}
if (Current.y < Max.y)
{
Current = new int2(Min.x, Current.y + 1);
return true;
}
return false;
}
public void Reset()
{
Current = new int2(Min.x - 1, Min.y);
}
public void Dispose()
{
}
}
}
}