private void RegisterAllComponentsOf(ThingWithComps parentThing)
        {
            CompSteamTrader comp = parentThing.GetComp <CompSteamTrader>();

            if (comp != null)
            {
                if (this.SteamComps.Contains(comp))
                {
                    //Log.Error("SteamNet adding SteamComp " + comp + " which it already has.");
                }
                else
                {
                    this.SteamComps.Add(comp);
                }
            }
            CompSteamTank comp2 = parentThing.GetComp <CompSteamTank>();

            if (comp2 != null)
            {
                if (this.batteryComps.Contains(comp2))
                {
                    //Log.Error("SteamNet adding SteamTankComp " + comp2 + " which it already has.");
                }
                else
                {
                    this.batteryComps.Add(comp2);
                }
            }
        }
        private bool IsActiveSteamSource(CompSteam cp)
        {
            CompSteamTank CompSteamTank = cp as CompSteamTank;

            if (CompSteamTank != null && CompSteamTank.StoredSteam > 0f)
            {
                return(true);
            }
            CompSteamTrader compSteamTrader = cp as CompSteamTrader;

            return(compSteamTrader != null && compSteamTrader.SteamOutput > 0f);
        }
        private void DeregisterAllComponentsOf(ThingWithComps parentThing)
        {
            CompSteamTrader comp = parentThing.GetComp <CompSteamTrader>();

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

            if (comp2 != null)
            {
                this.batteryComps.Remove(comp2);
            }
        }
        public void SteamNetTick()
        {
            float num  = this.CurrentSteamGainRate();
            float num2 = this.CurrentStoredSteam();

            if (num2 + num >= -1E-07f && !this.Map.gameConditionManager.ConditionIsActive(GameConditionDefOf.SolarFlare))
            {
                float num3;
                if (this.batteryComps.Count > 0 && num2 >= 0.1f)
                {
                    num3 = num2 - 5f;
                }
                else
                {
                    num3 = num2;
                }
                if (UnityData.isDebugBuild)
                {
                    this.debugLastApparentStoredSteam = num3;
                    this.debugLastCreatedSteam        = num;
                    this.debugLastRawStoredSteam      = num2;
                }
                if (num3 + num >= 0f)
                {
                    SteamNet.partsWantingSteamOn.Clear();
                    for (int i = 0; i < this.SteamComps.Count; i++)
                    {
                        if (!this.SteamComps[i].SteamOn && FlickUtility.WantsToBeOn(this.SteamComps[i].parent) && !this.SteamComps[i].parent.IsBrokenDown())
                        {
                            SteamNet.partsWantingSteamOn.Add(this.SteamComps[i]);
                        }
                    }
                    if (SteamNet.partsWantingSteamOn.Count > 0)
                    {
                        int num4 = 200 / SteamNet.partsWantingSteamOn.Count;
                        if (num4 < 30)
                        {
                            num4 = 30;
                        }
                        if (Find.TickManager.TicksGame % num4 == 0)
                        {
                            int num5 = Mathf.Max(1, Mathf.RoundToInt((float)SteamNet.partsWantingSteamOn.Count * 0.05f));
                            for (int j = 0; j < num5; j++)
                            {
                                CompSteamTrader compSteamTrader = SteamNet.partsWantingSteamOn.RandomElement <CompSteamTrader>();
                                if (!compSteamTrader.SteamOn)
                                {
                                    if (num + num2 >= -(compSteamTrader.SteamOutputPerTick + 1E-07f))
                                    {
                                        compSteamTrader.SteamOn = true;
                                        num += compSteamTrader.SteamOutputPerTick;
                                    }
                                }
                            }
                        }
                    }
                }
                this.ChangeStoredSteam(num);
            }
            else if (Find.TickManager.TicksGame % 20 == 0)
            {
                SteamNet.potentialShutdownParts.Clear();
                for (int k = 0; k < this.SteamComps.Count; k++)
                {
                    if (this.SteamComps[k].SteamOn && this.SteamComps[k].SteamOutputPerTick < 0f)
                    {
                        SteamNet.potentialShutdownParts.Add(this.SteamComps[k]);
                    }
                }
                if (SteamNet.potentialShutdownParts.Count > 0)
                {
                    int num6 = Mathf.Max(1, Mathf.RoundToInt((float)SteamNet.potentialShutdownParts.Count * 0.05f));
                    for (int l = 0; l < num6; l++)
                    {
                        SteamNet.potentialShutdownParts.RandomElement <CompSteamTrader>().SteamOn = false;
                    }
                }
            }
        }