Пример #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);
                }
            }
        }
Пример #2
0
        public static void NotLitIfNoGas(ref bool __result, ref CompGlower __instance)

        {
            CompPipeTrader compPipeTrader = __instance.parent.TryGetComp <CompPipeTrader>();

            if (compPipeTrader != null && !compPipeTrader.PowerOn)
            {
                __result = false;
            }
        }
Пример #3
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);
        }
Пример #4
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);
            }
        }
Пример #5
0
 public static void DisconnectAllFromTransmitterAndSetWantConnect(CompPipe deadPc, Map map)
 {
     if (deadPc.connectChildren == null)
     {
         return;
     }
     for (int i = 0; i < deadPc.connectChildren.Count; i++)
     {
         CompPipe compPipe = deadPc.connectChildren[i];
         compPipe.connectParent = null;
         CompPipeTrader compPipeTrader = compPipe as CompPipeTrader;
         if (compPipeTrader != null)
         {
             compPipeTrader.PowerOn = false;
         }
         map.GetComponent <PipeMapComponent>().Notify_ConnectorWantsConnect(compPipe);
     }
 }
        public override bool ShouldSkip(Pawn pawn, bool forced = false)
        {
            List <Building> allBuildingsColonist = pawn.Map.listerBuildings.allBuildingsColonist;

            for (int i = 0; i < allBuildingsColonist.Count; i++)
            {
                Building building = allBuildingsColonist[i];
                if (building.def == ThingDef.Named("VPE_GasDrill"))
                {
                    CompPipeTrader comp = building.GetComp <CompPipeTrader>();
                    if ((comp == null || comp.PowerOn) && building.Map.designationManager.DesignationOn(building, DesignationDefOf.Uninstall) == null)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Пример #7
0
        public override void TickRare()
        {
            CompPipeTrader compPipeTrader = this.GetComp <CompPipeTrader>();

            if (compPipeTrader.PowerOn)
            {
                float ambientTemperature = base.AmbientTemperature;
                float num;
                if (ambientTemperature < 20f)
                {
                    num = 1f;
                }
                else if (ambientTemperature > 120f)
                {
                    num = 0f;
                }
                else
                {
                    num = Mathf.InverseLerp(120f, 20f, ambientTemperature);
                }
                float energyLimit         = this.compTempControl.Props.energyPerSecond * num * 4.16666651f;
                float num2                = GenTemperature.ControlTemperatureTempChange(base.Position, base.Map, energyLimit, this.compTempControl.targetTemperature);
                bool  flag                = !Mathf.Approximately(num2, 0f);
                CompProperties_Pipe props = compPipeTrader.Props;
                if (flag)
                {
                    this.GetRoomGroup().Temperature += num2;
                    compPipeTrader.PowerOutput       = -props.basePowerConsumption;
                }
                else
                {
                    compPipeTrader.PowerOutput = -props.basePowerConsumption * this.compTempControl.Props.lowPowerConsumptionFactor;
                }
                this.compTempControl.operatingAtHighPower = flag;
            }
        }
Пример #8
0
        public void PowerNetTick()
        {
            float num  = this.CurrentEnergyGainRate();
            float num2 = this.CurrentStoredEnergy();

            if (num2 + num >= -1E-07f)
            {
                float num3;
                if (this.batteryComps.Count > 0 && num2 >= 0.1f)
                {
                    num3 = num2 - 5f;
                }
                else
                {
                    num3 = num2;
                }

                if (num3 + num >= 0f)
                {
                    partsWantingPowerOn.Clear();
                    for (int i = 0; i < this.powerComps.Count; i++)
                    {
                        if (!this.powerComps[i].PowerOn && FlickUtility.WantsToBeOn(this.powerComps[i].parent) && !this.powerComps[i].parent.IsBrokenDown())
                        {
                            partsWantingPowerOn.Add(this.powerComps[i]);
                        }
                    }
                    if (partsWantingPowerOn.Count > 0)
                    {
                        int num4 = 200 / partsWantingPowerOn.Count;
                        if (num4 < 30)
                        {
                            num4 = 30;
                        }
                        if (Find.TickManager.TicksGame % num4 == 0)
                        {
                            int num5 = Mathf.Max(1, Mathf.RoundToInt((float)partsWantingPowerOn.Count * 0.05f));
                            for (int j = 0; j < num5; j++)
                            {
                                CompPipeTrader compPowerTrader = partsWantingPowerOn.RandomElement <CompPipeTrader>();
                                if (!compPowerTrader.PowerOn)
                                {
                                    if (num + num2 >= -(compPowerTrader.EnergyOutputPerTick + 1E-07f))
                                    {
                                        compPowerTrader.PowerOn = true;
                                        num += compPowerTrader.EnergyOutputPerTick;
                                    }
                                }
                            }
                        }
                    }
                }
                this.ChangeStoredEnergy(num);
            }
            else if (Find.TickManager.TicksGame % 20 == 0)
            {
                potentialShutdownParts.Clear();
                for (int k = 0; k < this.powerComps.Count; k++)
                {
                    if (this.powerComps[k].PowerOn && this.powerComps[k].EnergyOutputPerTick < 0f)
                    {
                        potentialShutdownParts.Add(this.powerComps[k]);
                    }
                }
                if (potentialShutdownParts.Count > 0)
                {
                    int num6 = Mathf.Max(1, Mathf.RoundToInt((float)potentialShutdownParts.Count * 0.05f));
                    for (int l = 0; l < num6; l++)
                    {
                        potentialShutdownParts.RandomElement <CompPipeTrader>().PowerOn = false;
                    }
                }
            }
        }