Esempio n. 1
0
        public void Update()
        {
            foreach (HeatPipe heatPipe in elements.Values)
            {
                Point16 check = TheOneLibrary.Utility.Utility.TileEntityTopLeft(heatPipe.position.X, heatPipe.position.Y);
                if (Main.tile[heatPipe.position.X, heatPipe.position.Y].liquidType() == Tile.Liquid_Lava)
                {
                    heatPipe.grid.heatStorage.ModifyHeatStored(Main.tile[heatPipe.position.X, heatPipe.position.Y].liquid);
                }

                if (TileEntity.ByPosition.ContainsKey(check))
                {
                    TileEntity   te   = TileEntity.ByPosition[check];
                    HeatPipeGrid grid = heatPipe.grid;

                    if (te is IHeatProvider)
                    {
                        IHeatProvider provider = (IHeatProvider)te;

                        provider.GetHeatStorage().ModifyHeatStored(
                            -grid.heatStorage.ReceiveHeat(TheOneLibrary.Utility.Utility.Min(grid.heatStorage.GetMaxReceive(), grid.heatStorage.GetCapacity() - grid.heatStorage.GetHeat(), provider.GetHeat())));
                    }
                    if (te is IHeatReceiver)
                    {
                        IHeatReceiver receiver = (IHeatReceiver)te;

                        receiver.GetHeatStorage().ModifyHeatStored(
                            grid.heatStorage.ExtractHeat(TheOneLibrary.Utility.Utility.Min(grid.heatStorage.GetMaxExtract(), grid.heatStorage.GetHeat(), receiver.GetCapacity() - receiver.GetHeat())));
                    }
                }
            }
        }
Esempio n. 2
0
 public void MergeGrids(HeatPipeGrid wireGrid)
 {
     for (int i = 0; i < wireGrid.tiles.Count; i++)
     {
         AddTile(wireGrid.tiles[i]);
     }
 }
Esempio n. 3
0
        public void ReformGrid()
        {
            for (int i = 0; i < tiles.Count; i++)
            {
                HeatPipeGrid newGrid = new HeatPipeGrid();
                newGrid.tiles.Add(tiles[i]);
                tiles[i].grid = newGrid;
            }

            for (int i = 0; i < tiles.Count; i++)
            {
                tiles[i].Merge();
            }
        }
Esempio n. 4
0
        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();
                        }
                    }
                }
            }
        }