mirror of
https://github.com/kwsch/NHSE.git
synced 2026-04-17 14:16:02 -05:00
working on it, untested. decoupled 99% of the logic, need to ensure the rendering uses the correct item grid which now includes deepsea L+R sides for 3.0.0
23 lines
818 B
C#
23 lines
818 B
C#
namespace NHSE.Core;
|
|
|
|
/// <summary>
|
|
/// Basic logic implementation for interacting with the manipulatable map grid.
|
|
/// </summary>
|
|
public abstract record AcreSelectionGrid(TileGridViewport TileInfo)
|
|
{
|
|
protected int GetAcreTileIndex(int acreIndex, int tileIndex)
|
|
{
|
|
var acre = AcreCoordinate.Acres[acreIndex];
|
|
var x = (tileIndex % TileInfo.ViewWidth);
|
|
var y = (tileIndex / TileInfo.ViewHeight);
|
|
return TileInfo.GetTileIndex(acre.X, acre.Y, x, y);
|
|
}
|
|
|
|
public int GetAcre(int x, int y) => (x / TileInfo.ViewWidth) + ((y / TileInfo.ViewHeight) * TileInfo.Columns);
|
|
|
|
public void GetViewAnchorCoordinates(int acre, out int x, out int y)
|
|
{
|
|
x = (acre % TileInfo.Columns) * TileInfo.ViewWidth;
|
|
y = (acre / TileInfo.Columns) * TileInfo.ViewHeight;
|
|
}
|
|
} |