public void Info(Point16 mouse) { HeatPipe heatPipe = elements[mouse]; Main.NewText("Tiles: " + heatPipe.grid.tiles.Count); Main.NewText("Current heat: " + heatPipe.grid.heatStorage.GetHeat()); }
public void Merge() { CustomDictionary <HeatPipe> heatPipes = DawnOfIndustryCore.Instance.GetModWorld <DoIWorld>().heatPipes.elements; foreach (Point16 check in TheOneLibrary.Utility.Utility.CheckNeighbours()) { Point16 point = new Point16(position.X + check.X, position.Y + check.Y); HeatPipe wire = heatPipes.ContainsKey(point) ? heatPipes[point] : null; if (wire != null) { if (check.X == -1) { grid.MergeGrids(wire.grid); } else if (check.X == 1) { grid.MergeGrids(wire.grid); } if (check.Y == -1) { grid.MergeGrids(wire.grid); } else if (check.Y == 1) { grid.MergeGrids(wire.grid); } } } }
public void AddTile(HeatPipe tile) { if (!tiles.Contains(tile)) { tile.grid = this; tiles.Add(tile); } }
public void Draw() { Vector2 zero = new Vector2(Main.offScreenRange, Main.offScreenRange); if (Main.drawToScreen) { zero = Vector2.Zero; } int num4 = (int)((Main.screenPosition.X - zero.X) / 16f - 1f); int num5 = (int)((Main.screenPosition.X + Main.screenWidth + zero.X) / 16f) + 2; int num6 = (int)((Main.screenPosition.Y - zero.Y) / 16f - 1f); int num7 = (int)((Main.screenPosition.Y + Main.screenHeight + zero.Y) / 16f) + 5; if (num4 < 4) { num4 = 4; } if (num5 > Main.maxTilesX - 4) { num5 = Main.maxTilesX - 4; } if (num6 < 4) { num6 = 4; } if (num7 > Main.maxTilesY - 4) { num7 = Main.maxTilesY - 4; } for (int i = num4 - 2; i < num5 + 2; i++) { for (int j = num6; j < num7 + 4; j++) { if (elements.ContainsKey(i, j)) { Vector2 position = -Main.screenPosition + new Vector2(i, j) * 16; HeatPipe wire = elements[i, j]; if (GetInfo().Draw) { wire.Draw(Main.spriteBatch, position); } } } } }
public void Remove(Point16 mouse, Player player) { HeatPipe heatPipe = elements[mouse]; elements.Remove(mouse); heatPipe.grid.tiles.Remove(heatPipe); heatPipe.grid.ReformGrid(); foreach (Point16 check in TheOneLibrary.Utility.Utility.CheckNeighbours()) { if (elements.ContainsKey(mouse + check) && elements[mouse + check].type == heatPipe.type) { elements[mouse + check].Frame(); } } player.PutItemInInventory(heatPipe.type); }
public void Place(Point16 mouse, Player player) { if (Main.LocalPlayer.inventory.Any(x => x.modItem is Items.Wires.HeatPipe)) { int type = player.inventory.First(x => x.modItem is Items.Wires.HeatPipe).type; Item item = player.inventory.First(x => x.type == type); item.stack--; if (item.stack <= 0) { item.TurnToAir(); } HeatPipe heatPipe = new HeatPipe(); heatPipe.SetDefaults(type); heatPipe.position = mouse; elements.Add(mouse, heatPipe); HeatPipeGrid grid = new HeatPipeGrid(); grid.tiles.Add(heatPipe); heatPipe.grid = grid; heatPipe.Merge(); heatPipe.Frame(); foreach (Point16 add in TheOneLibrary.Utility.Utility.CheckNeighbours()) { if (elements.ContainsKey(mouse.X + add.X, mouse.Y + add.Y)) { HeatPipe merge = elements[mouse + add]; if (merge.type == type) { merge.Frame(); } } } } }
public void Modify(Point16 mouse) { HeatPipe heatPipe = elements[mouse]; int x = (int)Main.MouseWorld.X - mouse.X * 16; int y = (int)Main.MouseWorld.Y - mouse.Y * 16; Rectangle io = new Rectangle(4, 4, 8, 8); if (!io.Contains(x, y)) { if (TheOneLibrary.Utility.Utility.PointInTriangle(new Point(x, y), new Point(0, 0), new Point(8, 8), new Point(0, 16))) { heatPipe.connections[TheOneLibrary.Utility.Utility.Facing.Left] = !heatPipe.connections[TheOneLibrary.Utility.Utility.Facing.Left]; heatPipe.Frame(); Main.NewText(heatPipe.grid.tiles.Count.ToString()); if (!heatPipe.connections[TheOneLibrary.Utility.Utility.Facing.Left]) { heatPipe.grid.ReformGrid(); } if (elements.ContainsKey(mouse.X - 1, mouse.Y)) { HeatPipe other = elements[mouse.X - 1, mouse.Y]; other.connections[TheOneLibrary.Utility.Utility.Facing.Right] = !other.connections[TheOneLibrary.Utility.Utility.Facing.Right]; if (heatPipe.connections[TheOneLibrary.Utility.Utility.Facing.Left]) { heatPipe.grid.MergeGrids(other.grid); } other.Frame(); } } else if (TheOneLibrary.Utility.Utility.PointInTriangle(new Point(x, y), new Point(16, 0), new Point(16, 16), new Point(8, 8))) { heatPipe.connections[TheOneLibrary.Utility.Utility.Facing.Right] = !heatPipe.connections[TheOneLibrary.Utility.Utility.Facing.Right]; heatPipe.Frame(); if (!heatPipe.connections[TheOneLibrary.Utility.Utility.Facing.Right]) { heatPipe.grid.ReformGrid(); } if (elements.ContainsKey(mouse.X + 1, mouse.Y)) { HeatPipe other = elements[mouse.X + 1, mouse.Y]; other.connections[TheOneLibrary.Utility.Utility.Facing.Left] = !elements[mouse.X + 1, mouse.Y].connections[TheOneLibrary.Utility.Utility.Facing.Left]; if (heatPipe.connections[TheOneLibrary.Utility.Utility.Facing.Right]) { heatPipe.grid.MergeGrids(elements[mouse.X + 1, mouse.Y].grid); } elements[mouse.X + 1, mouse.Y].Frame(); } } else if (TheOneLibrary.Utility.Utility.PointInTriangle(new Point(x, y), new Point(0, 0), new Point(16, 0), new Point(8, 8))) { heatPipe.connections[TheOneLibrary.Utility.Utility.Facing.Up] = !heatPipe.connections[TheOneLibrary.Utility.Utility.Facing.Up]; heatPipe.Frame(); if (!heatPipe.connections[TheOneLibrary.Utility.Utility.Facing.Up]) { heatPipe.grid.ReformGrid(); } if (elements.ContainsKey(mouse.X, mouse.Y - 1)) { HeatPipe other = elements[mouse.X, mouse.Y - 1]; other.connections[TheOneLibrary.Utility.Utility.Facing.Down] = !other.connections[TheOneLibrary.Utility.Utility.Facing.Down]; if (heatPipe.connections[TheOneLibrary.Utility.Utility.Facing.Up]) { heatPipe.grid.MergeGrids(other.grid); } other.Frame(); } } else if (TheOneLibrary.Utility.Utility.PointInTriangle(new Point(x, y), new Point(0, 16), new Point(8, 8), new Point(16, 16))) { heatPipe.connections[TheOneLibrary.Utility.Utility.Facing.Down] = !heatPipe.connections[TheOneLibrary.Utility.Utility.Facing.Down]; heatPipe.Frame(); if (!heatPipe.connections[TheOneLibrary.Utility.Utility.Facing.Down]) { heatPipe.grid.ReformGrid(); } if (elements.ContainsKey(mouse.X, mouse.Y + 1)) { HeatPipe other = elements[mouse.X, mouse.Y + 1]; other.connections[TheOneLibrary.Utility.Utility.Facing.Up] = !other.connections[TheOneLibrary.Utility.Utility.Facing.Up]; if (heatPipe.connections[TheOneLibrary.Utility.Utility.Facing.Down]) { heatPipe.grid.MergeGrids(other.grid); } other.Frame(); } } } }