private static void DrainBatteriesAndCauseExplosion(GasPipeNet net, Building culprit, out float totalEnergy, out float explosionRadius)
 {
     totalEnergy = 0f;
     for (int i = 0; i < net.batteryComps.Count; i++)
     {
         CompPipeTank compTank = net.batteryComps[i];
         totalEnergy += compTank.StoredEnergy;
         compTank.DrawPower(compTank.StoredEnergy);
     }
     explosionRadius = Mathf.Sqrt(totalEnergy) * 0.05f;
     explosionRadius = Mathf.Clamp(explosionRadius, 1.5f, 14.9f);
     GenExplosion.DoExplosion(culprit.Position, net.Map, explosionRadius, DamageDefOf.Flame, null, -1, -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false, null, null);
     if (explosionRadius > 3.5f)
     {
         GenExplosion.DoExplosion(culprit.Position, net.Map, explosionRadius * 0.3f, DamageDefOf.Bomb, null, -1, -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false, null, null);
     }
 }
 private void TryCreateNetAt(IntVec3 cell)
 {
     if (!cell.InBounds(this.map))
     {
         return;
     }
     if (this.map.GetComponent <PipeNetGrid>().TransmittedPowerNetAt(cell) == null)
     {
         Building transmitter = GetPipeTransmitter(cell, this.map);
         //Log.Message(transmitter.ToString());
         if (transmitter != null && GetPipeTransmission(transmitter))
         {
             GasPipeNet pipeNet = PipeNetMaker.NewPowerNetStartingFrom(transmitter);
             this.RegisterPowerNet(pipeNet);
             for (int i = 0; i < pipeNet.transmitters.Count; i++)
             {
                 PipeConnectionMaker.ConnectAllConnectorsToTransmitter(pipeNet.transmitters[i]);
             }
         }
     }
 }
示例#3
0
        public void Notify_PowerNetCreated(GasPipeNet newNet)
        {
            if (this.powerNetCells.ContainsKey(newNet))
            {
                Log.Warning("Net " + newNet + " is already registered in PowerNetGrid.", false);
                this.powerNetCells.Remove(newNet);
            }
            List <IntVec3> list = new List <IntVec3>();

            this.powerNetCells.Add(newNet, list);
            for (int i = 0; i < newNet.transmitters.Count; i++)
            {
                CellRect cellRect = newNet.transmitters[i].parent.OccupiedRect();
                for (int j = cellRect.minZ; j <= cellRect.maxZ; j++)
                {
                    for (int k = cellRect.minX; k <= cellRect.maxX; k++)
                    {
                        int num = this.map.cellIndices.CellToIndex(k, j);
                        if (this.netGrid[num] != null)
                        {
                            /*Log.Warning(string.Concat(new object[]
                             * {
                             *  "Two power nets on the same cell (",
                             *  k,
                             *  ", ",
                             *  j,
                             *  "). First transmitters: ",
                             *  newNet.transmitters[0].parent.LabelCap,
                             *  " and ",
                             *  (!this.netGrid[num].transmitters.NullOrEmpty<CompPipe>()) ? this.netGrid[num].transmitters[0].parent.LabelCap : "[none]",
                             *  "."
                             * }), false);*/
                        }
                        this.netGrid[num] = newNet;
                        list.Add(new IntVec3(k, 0, j));
                    }
                }
            }
        }
示例#4
0
        public void Notify_PowerNetDeleted(GasPipeNet deadNet)
        {
            List <IntVec3> list;

            if (!this.powerNetCells.TryGetValue(deadNet, out list))
            {
                Log.Warning("Net " + deadNet + " does not exist in PowerNetGrid's dictionary.", false);
                return;
            }
            for (int i = 0; i < list.Count; i++)
            {
                int num = this.map.cellIndices.CellToIndex(list[i]);
                if (this.netGrid[num] == deadNet)
                {
                    this.netGrid[num] = null;
                }
                else
                {
                    //Log.Warning("Multiple nets on the same cell " + list[i] + ". This is probably a result of an earlier error.", false);
                }
            }
            this.powerNetCells.Remove(deadNet);
        }
 public void DeletePowerNet(GasPipeNet oldNet)
 {
     this.allNets.Remove(oldNet);
     this.map.GetComponent <PipeNetGrid>().Notify_PowerNetDeleted(oldNet);
 }
 public static void UpdateVisualLinkagesFor(GasPipeNet net)
 {
 }