screeps-cartographer
Version:
An advanced (and open source) movement library for Screeps
82 lines (81 loc) • 2.6 kB
TypeScript
/// <reference types="screeps" />
declare global {
interface RoomPosition {
__packedPos: number;
}
}
export interface Coord {
x: number;
y: number;
}
/**
* Pack RoomPosition to two Unicode characters with screeps-utf15
*/
export declare const packPos: (pos: RoomPosition) => string;
/**
* Unpack a single packed RoomPosition from two Unicode characters
*/
export declare const unpackPos: (str: string) => RoomPosition;
/**
* Pack a Coord to 12 bits with utf15
*/
export declare const packCoord: (coord: Coord) => string;
/**
* Unpack a coord with utf15
*/
export declare const unpackCoord: (str: string) => Coord;
/**
* Pack a list of Coords as compactly as possible with utf15
*/
export declare const packCoordList: (coords: Coord[]) => string;
/**
* Unpack a list of Coords as compactly as possible with utf15
*/
export declare const unpackCoordList: (str: string) => Coord[];
/**
* Pack a list of RoomPositions to two Unicode characters each with screeps-utf15
*/
export declare const packPosList: (posList: RoomPosition[]) => string;
/**
* Unpack a list of RoomPositions from two Unicode characters each
*/
export declare const unpackPosList: (str: string) => RoomPosition[] | undefined;
export declare const roomNameToCoords: (roomName: string) => {
wx: number;
wy: number;
};
export declare const roomNameFromCoords: (x: number, y: number) => string;
export declare const globalPosition: (pos: RoomPosition) => {
x: number;
y: number;
};
export declare const fromGlobalPosition: (pos: {
x: number;
y: number;
}) => RoomPosition;
export declare const getRangeTo: (from: RoomPosition, to: RoomPosition) => number;
export declare function posAtDirection(origin: RoomPosition, direction: DirectionConstant): RoomPosition;
/**
* Compress a path of adjacent RoomPositions to an origin and a list of directions
*/
export declare const compressPath: (path: RoomPosition[]) => string;
/**
* Decompress a path from an origin and list of directions
*/
export declare const decompressPath: (str: string) => RoomPosition[];
/**
* Pack a list of room names as compactly as possible
*/
export declare const packRoomNames: (roomNames: string[]) => string;
/**
* Unpack a list of room names as compactly as possible
*/
export declare const unpackRoomNames: (str: string) => string[];
/**
* Pack a single room name into two UTF-15 characters
*/
export declare const packRoomName: (roomName: string) => string;
/**
* Unpack a single room name from two UTF-15 characters
*/
export declare const unpackRoomName: (str: string) => string;