forked from Garethp/ScreepsAutocomplete
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRoom.js
158 lines (144 loc) · 5.85 KB
/
Room.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/**
* An object representing the room in which your creeps, spawns, and extensions are in. It can be used to look around,
* find paths, etc. Every object in the room contains its linked Room instance as the room property.
*
* @class
* @constructor
*/
Room = function () {
};
Room.prototype = {
/*
* One of the following constants:
* - Game.MODE_SIMULATION
* - Game.MODE_SURVIVAL
* - Game.MODE_WORLD
*/
mode: null,
/**
* The name of the room.
*
* @typs string
*/
name: "",
/**
* Create new Flag at the specified location.
*
* @param {Object} pos Can be a RoomPosition object or any object containing RoomPosition.
* @param {String} [name] The name of a new flag. It should be unique name, i.e. the Game.flags object should not
* contain another flag with the same name (hash key). If not defined, a random name will be generated.
* @param {String} [color] The color of a new flag. Should be one of the Game.COLOR_* constants. The default value is Game.COLOR_WHITE.
*/
createFlag: function (pos, name, color) {
},
/**
* Create new ConstructionSite at the specified location.
*
* @param {Object} pos Can be a RoomPosition object or any object containing RoomPosition.
* @param {Object} structureType One of the game structure constants
*/
createConstructionSite: function (pos, structureType) {
},
/**
* Find all objects of the specified type in the room.
* @param {number} type One of the Game Constants
* @param {Object} [opts] An object with additional options
* @param {Object|function|string} [opts.filter] The result list will be filtered using the Lodash.filter method.
* @return {Object[]} An array with the objects found.
*/
find: function (type, opts) {
},
/**
* Find an optimal path between fromPos and toPos using A* search algorithm.
*
* @param {RoomPosition} fromPos The start position.
* @param {RoomPosition} toPos The end position.
* @param {Object} [opts] An object containing additonal pathfinding flags:
* @param {Boolean} [opts.ignoreCreeps] Treat squares with creeps as walkable. Can be useful with too many moving
* creeps around or in some other cases. The default value is false.
* @param {Boolean} [opts.ignoreDestructibleStructures] Treat squares with destructible structures
* (constructed walls, ramparts, spawns, extensions) as walkable. Use this flag when you need to move through a
* territory blocked by hostile structures. If a creep with an ATTACK body part steps on such a square, it
* automatically attacks the structure. The default value is false.
* @param {Boolean} [opts.withinRampartsOnly] The path will be found only within the area of your ramparts. Use it to
* move your creeps safely. The default value is false.
* @param {RoomPosition|Object} [opts.ignore] An array of the room's objects or RoomPosition objects which should be
* treated as walkable tiles during the search.
* @param {RoomPosition|Object} [opts.avoid] An array of the room's objects or RoomPosition objects which should be
* treated as obstacles tiles during the search.
* @param {Number} [opts.maxOps] The maximum limit of possible pathfinding operations. The greater the value, the
* more accurate path will be found, but more CPU time could be used. The default value is 2000.
* @param {Number} [opts.heuristicWeight] Weight to apply to the heuristic to allow for suboptimal paths, in order to
* speed up the search. The less the value, the more accurate path will be found, but more CPU time could be used.
* The default value is 10.
*
* @return {PathStep[]}
*/
findPath: function (fromPos, toPos, opts) {
},
/**
* Get the list of objects at the specified room position.
*
* @param {Object|RoomPosition} pos target Can be a RoomPosition object or any object containing RoomPosition.
*/
lookAt: function (pos) {
},
/**
* Get the list of objects at the specified room area.
* This method is more CPU efficient in comparison to multiple lookAt calls.
*
* @param {Number} top The top Y boundary of the area.
* @param {Number} left The left X boundary of the area.
* @param {Number} bottom The bottom Y boundary of the area.
* @param {Number} right The right X boundary of the area.
*/
lookAtArea: function(top, left, bottom, right) {
},
/**
* Creates a RoomPosition object at the specified location.
*
* @param x {Number} The X position.
* @param y {Number} The Y position.
*
* @return RoomPosition
*/
getPositionAt: function (x, y) {
},
/**
* Create a room snapshot with all objects currently present in the room. Room snapshots are saved in your account
* so that you can later check out if something happened in the game when you were offline. Not available in the
* Simulation Room.
*
* @param {string} [description] The description message which will be attached to the snapshot.
*/
makeSnapshot: function (description) {
}
};
/**
* Create new Flag at the specified location.
*
* @param {Number} x The X position.
* @param {Number} y The Y position.
* @param {String} [name] The name of a new flag. It should be unique name, i.e. the Game.flags object should not
* contain another flag with the same name (hash key). If not defined, a random name will be generated.
* @param {String} [color] The color of a new flag. Should be one of the Game.COLOR_* constants. The default value is Game.COLOR_WHITE.
*/
Room.prototype.createFlag = function(x, y, name, color) {
};
/**
* Create new ConstructionSite at the specified location.
*
* @param {Number} x The X position.
* @param {Number} y The Y position.
* @param {Object} structureType One of the game structure constants
*/
Room.prototype.createConstructionSite = function(x, y, structureType) {
};
/**
* Get the list of objects at the specified room position.
*
* @param {Number} x X position in the room.
* @param {Number} y Y position in the room.
*/
Room.prototype.lookAt = function(x, y) {
};