public override void Update(Bot bot, Stopwatch currentRedTime, BlockPos pos) { enabled = false; lock (bot.playerList) { foreach (var p in bot.playerList) { if (p.Value.blockX == pos.x && p.Value.blockY == pos.y) { enabled = true; break; } } } if (!enabled) { if (bot.room.getBlock(pos.l, pos.x, pos.y).blockId == 301/*sand white*/) { bot.room.DrawBlock(Block.CreateBlock(pos.l, pos.x, pos.y, 311/*cloud bottom*/, -2)); } } else if (bot.room.getBlock(pos.l, pos.x, pos.y).blockId == 311/*cloud bottom*/) { bot.room.DrawBlock(Block.CreateBlock(pos.l, pos.x, pos.y, 301/*sand white*/, -2)); } }
public override void Update(Bot bot, System.Diagnostics.Stopwatch currentRedTime, BlockPos pos) { if (enabled) { if (bot.room.getBlock(pos.l, pos.x, pos.y).blockId == 86/*scifi gray*/) { bot.room.DrawBlock(Block.CreateBlock(pos.l, pos.x, pos.y, 243/*secrets nonsolid*/, -2)); } } else if (bot.room.getBlock(pos.l, pos.x, pos.y).blockId == 243/*secrets nonsolid*/) { bot.room.DrawBlock(Block.CreateBlock(pos.l, pos.x, pos.y, 86/*scifi gray*/, -2)); } enabled = false; }
public override void Update(Bot bot, System.Diagnostics.Stopwatch currentRedTime, BlockPos pos) { if (enabled) { if (bot.room.getBlock(pos.l, pos.x, pos.y).blockId == 33/*glossy black special*/) { bot.room.DrawBlock(Block.CreateBlock(pos.l, pos.x, pos.y, 143/*cloud white*/, -2)); } } else if (bot.room.getBlock(pos.l, pos.x, pos.y).blockId == 143/*cloud white*/) { bot.room.DrawBlock(Block.CreateBlock(pos.l, pos.x, pos.y, 33/*glossy black special*/, -2)); } enabled = false; base.Update(bot, currentRedTime, pos); }
public virtual void Update(Bot bot, Stopwatch currentRedTime, BlockPos pos) { }
public override void Update(Bot bot, System.Diagnostics.Stopwatch currentRedTime, BlockPos pos) { enabled = willEnable; willEnable = true; base.Update(bot, currentRedTime, pos); }
public Wire(BlockPos position, float resistance) { this.position = position; this.resistance = resistance; }
public override void onCommand(object sender, string text, string[] args, Player player, bool isBotMod, Bot bot) { if (isBotMod) { switch (args[0]) { case "genmaze": { Stack<BlockPos> points = new Stack<BlockPos>(); points.Push(new BlockPos(0, player.blockX & 0xFFFE, player.blockY & 0xFFFE)); points.Push(new BlockPos(0, player.blockX & 0xFFFE, player.blockY & 0xFFFE)); int maxLength; if (args.Count() >= 1) int.TryParse(args[1], out maxLength); else maxLength = 1; if (maxLength < 1) maxLength = 1; while (points.Count > 0) { BlockPos point = points.Pop(); BlockPos wallPoint = points.Pop(); if (point.x > 0 && point.x < bot.room.Width - 1 && point.y > 0 && point.y < bot.room.Height - 1) { Block block = bot.room.getBotBlock(0, point.x, point.y); if (block.blockId > 8 && block.blockId < 226) { bot.room.DrawBlock(Block.CreateBlock(0, point.x, point.y, 4, -1)); bot.room.DrawBlock(Block.CreateBlock(0, wallPoint.x, wallPoint.y, 4, -1)); List<BlockPos> namnpriblem = new List<BlockPos>(); for (int i = 0; i < moves.Length; i++) namnpriblem.Add(moves[i]); while(namnpriblem.Count > 0) { int index = random.Next(namnpriblem.Count); BlockPos newPoint = new BlockPos(0, point.x + namnpriblem[index].x * 2, point.y + namnpriblem[index].y * 2); BlockPos newWallPoint = new BlockPos(0, point.x + namnpriblem[index].x, point.y + namnpriblem[index].y); namnpriblem.RemoveAt(index); //BlockPos newWallPoint = new BlockPos(0, point.x + newPoint.x, point.y + newPoint.y); points.Push(newWallPoint); points.Push(newPoint); } } } } } break; case "genemaze2": { int maxLength; if (args.Count() >= 1) int.TryParse(args[1], out maxLength); else maxLength = 1; if (maxLength < 1) maxLength = 1; List<BlockPos> points = new List<BlockPos>(); points.Add(new BlockPos(0, player.blockX & 0xFFFE, player.blockY & 0xFFFE)); bot.room.DrawBlock(Block.CreateBlock(0, points[0].x, points[0].y, 4, -1)); while (points.Count > 0) { int i = random.Next(points.Count); BlockPos p = moves[random.Next(moves.Count())]; { BlockPos pointA, pointB; pointA = new BlockPos(0, points[i].x + p.x, points[i].y + p.y); // is between the previous point nad pointB pointB = new BlockPos(0, points[i].x, points[i].y); //"destination" for (int j = 0; j < random.Next(1,maxLength); j++) { pointB = new BlockPos(0, pointB.x + p.x * 2, pointB.y + p.y * 2); //pointB.y = p.y * 2; //pointB.x //BlockPos pointA = new BlockPos(0, points[i].x + p.x * 2, points[i].y + p.y * 2); //BlockPos pointB = new BlockPos(0, points[i].x + p.x * 2, points[i].y + p.y * 2); Block b = bot.room.getBotBlock(0, pointB.x, pointB.y); Block b2 = bot.room.getBotBlock(0, pointA.x, pointA.y); if (b.blockId > 8 && b.blockId < 218 && b2.blockId > 8 && b2.blockId < 218 && b.x > 1 && b.y > 1 && b.x < bot.room.Width-1 && b.y < bot.room.Height-1) { bot.room.DrawBlock(Block.CreateBlock(0, pointA.x, pointA.y, 4, -1)); bot.room.DrawBlock(Block.CreateBlock(0, pointB.x, pointB.y, 4, -1)); points.Add(pointB); pointA = new BlockPos(0, pointA.x + p.x * 2, pointA.y + p.y * 2); //pointA.x += p.x * 2; //pointA.y += p.y * 2; } else { break; } } } bool noWay = false; foreach (var m in moves) { BlockPos a = new BlockPos(0, points[i].x + m.x, points[i].y + m.y); BlockPos b = new BlockPos(0, points[i].x + m.x, points[i].y + m.y); Block bl = bot.room.getBotBlock(0, b.x, b.y); Block bl2 = bot.room.getBotBlock(0, a.x, a.y); if (!(bl.blockId > 8 && bl.blockId < 218 && bl2.blockId > 8 && bl2.blockId < 218 && bl.x > 1 && bl.y > 1 && bl.x < bot.room.Width - 1 && bl.y < bot.room.Height - 1)) { noWay = true; break; } } if (noWay) { points.RemoveAt(i); } } } break; } } }
/// <summary> /// Resets the wires from a power source. /// </summary> /// <param name="powerSourceKeyValuePair">Resets the wires from this power source.</param> private void ResetPowerSourceWires(KeyValuePair<BlockPos, PowerSource> powerSourceKeyValuePair) { //RemoveWiresFromPowerSource(powerSourceKeyValuePair); BlockPos pos = powerSourceKeyValuePair.Key; BlockPos newPos; float[, ,] redMap = new float[bot.room.Width, bot.room.Height, 2]; Queue<BlockPos> blockQueue = new Queue<BlockPos>(); redMap[pos.x, pos.y, pos.l] = 1.0F; blockQueue.Enqueue(pos); while (blockQueue.Count > 0) { pos = blockQueue.Dequeue(); for (int i = 0; i < 4; i++) { float power = redMap[pos.x, pos.y, pos.l]; newPos = new BlockPos(pos.x, pos.y, pos.l); for (int j = 0; j < 2; j++) { if (j == 1) { if (pos.x == powerSourceKeyValuePair.Key.x && pos.y == powerSourceKeyValuePair.Key.y) break; } if (i % 2 == 0) newPos.x += (i > 1) ? 1 : -1; else newPos.y += (i > 1) ? 1 : -1; if (newPos.x <= 1 || newPos.x >= bot.room.Width - 2 || newPos.y <= 1 || newPos.y >= bot.room.Height - 2) break; power -= 0.01F; if (power > redMap[newPos.x, newPos.y, newPos.l]) redMap[newPos.x, newPos.y, newPos.l] = power; else break; Block block = bot.room.getBlock(newPos.l, newPos.x, newPos.y); if (wireTypes.ContainsKey(block.blockId)) { blockQueue.Enqueue(newPos); break; } else if (layerSwitches.Contains(block.blockId)) { blockQueue.Enqueue(new BlockPos(newPos.x, newPos.y, newPos.l ^ 1)); redMap[newPos.x, newPos.y, newPos.l ^ 1] = power; break; } else if (destinationTypes.ContainsKey(block.blockId)) { if (!wires.ContainsKey(powerSourceKeyValuePair.Key)) wires.Add(powerSourceKeyValuePair.Key, new Dictionary<BlockPos, float>()); if (wires[powerSourceKeyValuePair.Key].ContainsKey(newPos)) wires[powerSourceKeyValuePair.Key][newPos] = 1.0F - power;//wires[powerSourceKeyValuePair.Key].Remove(newPos); else wires[powerSourceKeyValuePair.Key].Add(newPos, 1.0F - power); break; } else if (powerSourceTypes.ContainsKey(block.blockId)) { if (j == 0) continue; if (!wires.ContainsKey(powerSourceKeyValuePair.Key)) wires.Add(powerSourceKeyValuePair.Key, new Dictionary<BlockPos, float>()); if (wires[powerSourceKeyValuePair.Key].ContainsKey(newPos)) wires[powerSourceKeyValuePair.Key][newPos] = 1.0F - power; else //wires[powerSourceKeyValuePair.Key].Remove(newPos); wires[powerSourceKeyValuePair.Key].Add(newPos, 1.0F - power); break; } else if ((block.blockId < 9 || block.blockId > 15) && (block.blockId < 500 || block.blockId > 507)) { break; } } } } }
public override void onMessage(object sender, PlayerIOClient.Message m, Bot bot) { switch (m.Type) { case "init": { ResetRed(); } break; case "b": { Block block = new Block(m); Block oldBlock = bot.room.getBlock(block.layer, block.x, block.y, 1); BlockPos position = new BlockPos(block.x, block.y, block.layer); if (wireTypes.ContainsKey(oldBlock.blockId) || (block.blockId >= 9 && block.blockId <= 15)) { if (!wireTypes.ContainsKey(block.blockId)) { lock (this) ResetPowerSources(); break; } } else if (powerSourceTypes.ContainsKey(oldBlock.blockId)) { if (!powerSourceTypes.ContainsKey(block.blockId)) { lock (this) { RemoveWiresFromPowerSource(new KeyValuePair<BlockPos, PowerSource>( position, powerSourceTypes[oldBlock.blockId])); powerSources.Remove(position); } } } else if (destinationTypes.ContainsKey(oldBlock.blockId)) { if (!destinationTypes.ContainsKey(block.blockId)) { lock (this) { if (destinations.ContainsKey(position)) { destinations.Remove(position); ResetPowerSources(); } } break; /*lock (this) RemoveWiresFromDestination(new KeyValuePair<BlockPos, Destination>( new BlockPos(block.x, block.y, block.layer), destinationTypes[oldBlock.blockId]));*/ } } if (wireTypes.ContainsKey(block.blockId)) { lock (this) ResetPowerSources(); } else if (powerSourceTypes.ContainsKey(block.blockId)) { lock (this) { if (!powerSources.ContainsKey(new BlockPos(block.x, block.y, block.layer))) { KeyValuePair<BlockPos, PowerSource> powerSourceKeyValuePair = new KeyValuePair<BlockPos, PowerSource>(new BlockPos(block.x, block.y, block.layer), powerSourceTypes[block.blockId].Clone() as PowerSource); powerSources.Add(powerSourceKeyValuePair.Key, powerSourceKeyValuePair.Value); ResetPowerSources();//ResetPowerSourceWires(powerSourceKeyValuePair); } } } else if (destinationTypes.ContainsKey(block.blockId)) { lock (this) { if (!destinations.ContainsKey(new BlockPos(block.x, block.y, block.layer))) { destinations.Add(new BlockPos(block.x, block.y, block.layer), destinationTypes[block.blockId].Clone() as Destination); ResetPowerSources(); } } } } break; } }