private static void HandleMineRock(Creature c) { int currentFloor = c.CurrentFloor; Point worldIndex = c.WorldIndex; Block[] blocks = currentFloor >= 0 ? Program.WorldMap[worldIndex.X, worldIndex.Y].Dungeon.Floors[currentFloor].Blocks : Program.WorldMap[worldIndex.X, worldIndex.Y].Blocks; int width = Program.WorldMap.TileWidth, height = Program.WorldMap.TileHeight; Point closestStoneWall = blocks.GetClosestOfBlockTypeToPos(c.Position, new Point(width, height), BlockType.Wall, Material.Stone); bool nextToStoneWall = c.Position.NextToPoint(closestStoneWall); if (!nextToStoneWall) { PathToPoint(c, closestStoneWall); } else { for (int i = 0; i < c.Inventory.Count; i++) { Item I = c.Inventory[i]; if (I is Axe axe && axe.Name == "pickaxe") { c.Wield(i, true); } } if (c.Body.MainHand is MeleeWeapon mWeapon && (mWeapon is Axe || mWeapon is Sword)) { c.PickWall(( Wall)blocks[closestStoneWall.X * width + closestStoneWall.Y]); }
private static void HandleChopTree(Creature c) { int currentFloor = c.CurrentFloor; Point worldIndex = c.WorldIndex; Block[] blocks = currentFloor >= 0 ? Program.WorldMap[worldIndex.X, worldIndex.Y].Dungeon.Floors[currentFloor].Blocks : Program.WorldMap[worldIndex.X, worldIndex.Y].Blocks; int width = Program.WorldMap.TileWidth, height = Program.WorldMap.TileHeight; Point closestTree = blocks.GetClosestOfBlockTypeToPos(c.Position, new Point(width, height), BlockType.Tree); bool nextToTree = c.Position.NextToPoint(closestTree); if (!nextToTree) { PathToPoint(c, closestTree); } else { if (c.Body.MainHand != null && c.Body.MainHand is Axe == false) { for (int i = 0; i < c.Inventory.Count; i++) { Item I = c.Inventory[i]; if (I is Axe || I is Sword) { c.Wield(i, true); } } } c.ChopTree(closestTree); } }
// FUNCTIONS// public override void Activate(Creature user) { try { user.Wield(user.Inventory.FindIndex(i => i.Name == "recipe pouch"), true); } catch { Program.MsgConsole.WriteLine("You don't have a recipe pouch!"); } }