|
1 |
| -// Type definitions for Screeps 3.1.3 |
| 1 | +// Type definitions for Screeps 3.2.0 |
2 | 2 | // Project: https://github.com/screeps/screeps
|
3 | 3 | // Definitions by: Marko Sulamägi <https://github.com/MarkoSulamagi>
|
4 | 4 | // Nhan Ho <https://github.com/NhanHo>
|
@@ -2854,9 +2854,176 @@ interface GameMap {
|
2854 | 2854 | * @returns An object with the following properties {status: "normal" | "closed" | "novice" | "respawn", timestamp: number}
|
2855 | 2855 | */
|
2856 | 2856 | getRoomStatus(roomName: string): RoomStatus;
|
| 2857 | + |
| 2858 | + /** |
| 2859 | + * Map visuals provide a way to show various visual debug info on the game map. |
| 2860 | + * You can use the `Game.map.visual` object to draw simple shapes that are visible only to you. |
| 2861 | + * |
| 2862 | + * Map visuals are not stored in the database, their only purpose is to display something in your browser. |
| 2863 | + * All drawings will persist for one tick and will disappear if not updated. |
| 2864 | + * All `Game.map.visual` calls have no added CPU cost (their cost is natural and mostly related to simple JSON.serialize calls). |
| 2865 | + * However, there is a usage limit: you cannot post more than 1000 KB of serialized data. |
| 2866 | + * |
| 2867 | + * All draw coordinates are measured in global game coordinates (`RoomPosition`). |
| 2868 | + */ |
| 2869 | + visual: MapVisual; |
2857 | 2870 | }
|
2858 | 2871 |
|
2859 | 2872 | // No static is available
|
| 2873 | + |
| 2874 | +interface MapVisual { |
| 2875 | + /** |
| 2876 | + * Draw a line. |
| 2877 | + * @param pos1 The start position object. |
| 2878 | + * @param pos2 The finish position object. |
| 2879 | + * @param style The optional style |
| 2880 | + * @returns The MapVisual object, for chaining. |
| 2881 | + */ |
| 2882 | + line(pos1: RoomPosition, pos2: RoomPosition, style?: MapLineStyle): MapVisual; |
| 2883 | + |
| 2884 | + /** |
| 2885 | + * Draw a circle. |
| 2886 | + * @param pos The position object of the center. |
| 2887 | + * @param style The optional style |
| 2888 | + * @returns The MapVisual object, for chaining. |
| 2889 | + */ |
| 2890 | + circle(pos: RoomPosition, style?: MapCircleStyle): MapVisual; |
| 2891 | + |
| 2892 | + /** |
| 2893 | + * Draw a rectangle. |
| 2894 | + * @param topLeftPos The position object of the top-left corner. |
| 2895 | + * @param width The width of the rectangle. |
| 2896 | + * @param height The height of the rectangle. |
| 2897 | + * @param style The optional style |
| 2898 | + * @returns The MapVisual object, for chaining. |
| 2899 | + */ |
| 2900 | + rect(topLeftPos: RoomPosition, width: number, height: number, style?: MapPolyStyle): MapVisual; |
| 2901 | + |
| 2902 | + /** |
| 2903 | + * Draw a polyline. |
| 2904 | + * @param points An array of points. Every item should be a `RoomPosition` object. |
| 2905 | + * @param style The optional style |
| 2906 | + * @returns The MapVisual object, for chaining. |
| 2907 | + */ |
| 2908 | + poly(points: RoomPosition[], style?: MapPolyStyle): MapVisual; |
| 2909 | + |
| 2910 | + /** |
| 2911 | + * Draw a text label. You can use any valid Unicode characters, including emoji. |
| 2912 | + * @param text The text message. |
| 2913 | + * @param pos The position object of the label baseline. |
| 2914 | + * @param style The optional style |
| 2915 | + * @returns The MapVisual object, for chaining |
| 2916 | + */ |
| 2917 | + text(text: string, pos: RoomPosition, style?: MapTextStyle): MapVisual; |
| 2918 | + |
| 2919 | + /** |
| 2920 | + * Remove all visuals from the map. |
| 2921 | + * @returns The MapVisual object, for chaining |
| 2922 | + */ |
| 2923 | + clear(): MapVisual; |
| 2924 | + |
| 2925 | + /** |
| 2926 | + * Get the stored size of all visuals added on the map in the current tick. It must not exceed 1024,000 (1000 KB). |
| 2927 | + * @returns The size of the visuals in bytes. |
| 2928 | + */ |
| 2929 | + getSize(): number; |
| 2930 | +} |
| 2931 | + |
| 2932 | +interface MapLineStyle { |
| 2933 | + /** |
| 2934 | + * Line width, default is 0.1. |
| 2935 | + */ |
| 2936 | + width?: number; |
| 2937 | + /** |
| 2938 | + * Line color in the following format: #ffffff (hex triplet). Default is #ffffff. |
| 2939 | + */ |
| 2940 | + color?: string; |
| 2941 | + /** |
| 2942 | + * Opacity value, default is 0.5. |
| 2943 | + */ |
| 2944 | + opacity?: number; |
| 2945 | + /** |
| 2946 | + * Either undefined (solid line), dashed, or dotted. Default is undefined. |
| 2947 | + */ |
| 2948 | + lineStyle?: "dashed" | "dotted" | "solid"; |
| 2949 | +} |
| 2950 | + |
| 2951 | +interface MapPolyStyle { |
| 2952 | + /** |
| 2953 | + * Fill color in the following format: #ffffff (hex triplet). Default is #ffffff. |
| 2954 | + */ |
| 2955 | + fill?: string; |
| 2956 | + /** |
| 2957 | + * Opacity value, default is 0.5. |
| 2958 | + */ |
| 2959 | + opacity?: number; |
| 2960 | + /** |
| 2961 | + * Stroke color in the following format: #ffffff (hex triplet). Default is undefined (no stroke). |
| 2962 | + */ |
| 2963 | + stroke?: string | undefined; |
| 2964 | + /** |
| 2965 | + * Stroke line width, default is 0.5. |
| 2966 | + */ |
| 2967 | + strokeWidth?: number; |
| 2968 | + /** |
| 2969 | + * Either undefined (solid line), dashed, or dotted. Default is undefined. |
| 2970 | + */ |
| 2971 | + lineStyle?: "dashed" | "dotted" | "solid"; |
| 2972 | +} |
| 2973 | + |
| 2974 | +interface MapCircleStyle extends MapPolyStyle { |
| 2975 | + /** |
| 2976 | + * Circle radius, default is 10. |
| 2977 | + */ |
| 2978 | + radius?: number; |
| 2979 | +} |
| 2980 | + |
| 2981 | +interface MapTextStyle { |
| 2982 | + /** |
| 2983 | + * Font color in the following format: #ffffff (hex triplet). Default is #ffffff. |
| 2984 | + */ |
| 2985 | + color?: string; |
| 2986 | + /** |
| 2987 | + * The font family, default is sans-serif |
| 2988 | + */ |
| 2989 | + fontFamily?: string; |
| 2990 | + /** |
| 2991 | + * The font size in game coordinates, default is 10 |
| 2992 | + */ |
| 2993 | + fontSize?: number; |
| 2994 | + /** |
| 2995 | + * The font style ('normal', 'italic' or 'oblique') |
| 2996 | + */ |
| 2997 | + fontStyle?: string; |
| 2998 | + /** |
| 2999 | + * The font variant ('normal' or 'small-caps') |
| 3000 | + */ |
| 3001 | + fontVariant?: string; |
| 3002 | + /** |
| 3003 | + * Stroke color in the following format: #ffffff (hex triplet). Default is undefined (no stroke). |
| 3004 | + */ |
| 3005 | + stroke?: string; |
| 3006 | + /** |
| 3007 | + * Stroke width, default is 0.15. |
| 3008 | + */ |
| 3009 | + strokeWidth?: number; |
| 3010 | + /** |
| 3011 | + * Background color in the following format: #ffffff (hex triplet). Default is undefined (no background). When background is enabled, text vertical align is set to middle (default is baseline). |
| 3012 | + */ |
| 3013 | + backgroundColor?: string; |
| 3014 | + /** |
| 3015 | + * Background rectangle padding, default is 2. |
| 3016 | + */ |
| 3017 | + backgroundPadding?: number; |
| 3018 | + /** |
| 3019 | + * Text align, either center, left, or right. Default is center. |
| 3020 | + */ |
| 3021 | + align?: "center" | "left" | "right"; |
| 3022 | + /** |
| 3023 | + * Opacity value, default is 0.5. |
| 3024 | + */ |
| 3025 | + opacity?: number; |
| 3026 | +} |
2860 | 3027 | /**
|
2861 | 3028 | * A global object representing the in-game market. You can use this object to track resource transactions to/from your
|
2862 | 3029 | * terminals, and your buy/sell orders. The object is accessible via the singleton Game.market property.
|
|
0 commit comments