Beispiel #1
0
        private void RegisterAllComponentsOf(ThingWithComps parentThing)
        {
            CompPipeTrader comp = parentThing.GetComp <CompPipeTrader>();

            if (comp != null)
            {
                if (this.powerComps.Contains(comp))
                {
                    //Log.Error("PowerNet adding powerComp " + comp + " which it already has.", false);
                }
                else
                {
                    this.powerComps.Add(comp);
                }
            }
            CompPipeTank comp2 = parentThing.GetComp <CompPipeTank>();

            if (comp2 != null)
            {
                if (this.batteryComps.Contains(comp2))
                {
                    //Log.Error("PowerNet adding batteryComp " + comp2 + " which it already has.", false);
                }
                else
                {
                    this.batteryComps.Add(comp2);
                }
            }
        }
Beispiel #2
0
        private bool IsActivePowerSource(CompPipe cp)
        {
            CompPipeTank compPowerBattery = cp as CompPipeTank;

            if (compPowerBattery != null && compPowerBattery.StoredEnergy > 0f)
            {
                return(true);
            }
            CompPipeTrader compPowerTrader = cp as CompPipeTrader;

            return(compPowerTrader != null && compPowerTrader.PowerOutput > 0f);
        }
Beispiel #3
0
        private void DeregisterAllComponentsOf(ThingWithComps parentThing)
        {
            CompPipeTrader comp = parentThing.GetComp <CompPipeTrader>();

            if (comp != null)
            {
                this.powerComps.Remove(comp);
            }
            CompPipeTank comp2 = parentThing.GetComp <CompPipeTank>();

            if (comp2 != null)
            {
                this.batteryComps.Remove(comp2);
            }
        }
 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);
     }
 }
        public override void Draw()
        {
            base.Draw();
            CompPipeTank comp = base.GetComp <CompPipeTank>();

            GenDraw.FillableBarRequest r = default(GenDraw.FillableBarRequest);
            r.center      = this.DrawPos + Vector3.up * 0.1f;
            r.size        = Building_Tank.BarSize;
            r.fillPercent = comp.StoredEnergy / comp.Props.storedEnergyMax;
            r.filledMat   = Building_Tank.BatteryBarFilledMat;
            r.unfilledMat = Building_Tank.BatteryBarUnfilledMat;
            r.margin      = 0.15f;
            Rot4 rotation = base.Rotation;

            rotation.Rotate(RotationDirection.Clockwise);
            r.rotation = rotation;
            GenDraw.DrawFillableBar(r);
            if (this.ticksToExplode > 0 && base.Spawned)
            {
                base.Map.overlayDrawer.DrawOverlay(this, OverlayTypes.BurningWick);
            }
        }