path-info.js
// Use flags to visualize a path
Use flags to visualize a path
Use flags to visualize a path
draw() {
		let flags = Memory.debugFlags || (Memory.debugFlags = []);
		let flagIndex = {};
		flags.forEach(function(flag, ii) {
			flagIndex[flag.pos] = ii;
		});
		let ii = 0;
		if (flags.length !== 0) {
			ii = flags[flags.length - 1].ii + 1;
		}
		for (let pos of this.path) {
			let rp = pos.toRoomPosition();
			if (Game.rooms.sim) {
				rp.roomName = 'sim';
			}
			let index = flagIndex[pos.serialize()];
			if (index !== undefined) {
				flags[index].time = Game.time + 5;
				continue;
			}
			let room = Game.rooms[rp.roomName];
			if (room) {
				let name = 'd'+ ii.toString(36);
				flags.push({
					ii: ii,
					time: Game.time + 5,
					flag: name,
					pos: pos.serialize(),
				});
				++ii;
				room.createFlag(rp, name, COLOR_GREY);
			}
		}
	}
draw ( ) { let flags = Memory . debugFlags || ( Memory . debugFlags = [ ] ) ; let flagIndex = { } ; flags . forEach ( function ( flag , ii ) { flagIndex [ flag . pos ] = ii ; } ) ; let ii = 0 ; if ( flags . length !== 0 ) { ii = flags [ flags . length - 1 ] . ii + 1 ; } for ( let pos of this . path ) { let rp = pos . toRoomPosition ( ) ; if ( Game . rooms . sim ) { rp . roomName = 'sim' ; } let index = flagIndex [ pos . serialize ( ) ] ; if ( index !== undefined ) { flags [ index ] . time = Game . time + 5 ; continue ; } let room = Game . rooms [ rp . roomName ] ; if ( room ) { let name = 'd' + ii . toString ( 36 ) ; flags . push ( { ii : ii , time : Game . time + 5 , flag : name , pos : pos . serialize ( ) , } ) ; ++ ii ; room . createFlag ( rp , name , COLOR_GREY ) ; } } }
Use flags to visualize a path
Use flags to visualize a path