@irysius/grid-math
Version:
Tools to assist with grid math and algorithms
39 lines • 1.62 kB
TypeScript
declare module "@irysius/grid-math/CoordManager" {
import { IVector2 } from "@irysius/grid-math/Vector2";
import { IScreenPosition } from "@irysius/grid-math/ScreenPosition";
import { IWorldPosition } from "@irysius/grid-math/WorldPosition";
import { ICellCoord } from "@irysius/grid-math/CellCoord";
import { IScreenRect } from "@irysius/grid-math/ScreenRect";
import { ICellOffset } from "@irysius/grid-math/Cell";
import { ISize } from "@irysius/grid-math/Size";
export type IOptions = IClientState | IServerState;
export interface IState {
gridBounds: IScreenRect;
position: IWorldPosition;
cellSize: ISize;
cellOffset: ICellOffset;
}
/**
* State for the CoordManager, on the client side. Clients should receive cellSize and cellOffset from the server.
*/
export interface IClientState {
gridBounds: IScreenRect;
position: IWorldPosition;
}
/**
* State for the CoordManager, on the server side. Servers do not care about grid bounds or camera position.
*/
export interface IServerState {
cellSize: ISize;
cellOffset: ICellOffset;
}
export interface ICoordManager {
getState(): IState;
updateWithState(newState: Partial<IState>): void;
toWorldPosition(v: IVector2): IWorldPosition;
toScreenPosition(v: IVector2): IScreenPosition;
toCellCoord(v: IVector2): ICellCoord;
getWorldTopLeft(): IWorldPosition;
}
export function CoordManager(options: IOptions): ICoordManager;
}