Пример #1
0
        public override void CompTickRare()
        {
            base.CompTickRare();
            float num = 15f;

            if (this.parent.MapHeld != null)
            {
                num = GridsUtility.GetTemperature(this.parent.PositionHeld, this.parent.MapHeld);
            }
            CompEquippable comp = this.parent.GetComp <CompEquippable>();

            if (comp != null)
            {
                Pawn casterPawn = comp.PrimaryVerb.CasterPawn;
                if (casterPawn != null)
                {
                    num = GridsUtility.GetTemperature(casterPawn.PositionHeld, casterPawn.MapHeld);
                }
            }
            if (this.parent.Spawned)
            {
                List <Thing> thingList = GridsUtility.GetThingList(this.parent.PositionHeld, this.parent.MapHeld);
                for (int i = 0; i < thingList.Count; i++)
                {
                    bool flag4 = thingList[i] is Building_Refrigerator;
                    if (flag4)
                    {
                        Building_Refrigerator building_Refrigerator = thingList[i] as Building_Refrigerator;
                        num = building_Refrigerator.Temp;
                        break;
                    }
                }
            }
            this.Temp += (num - this.Temp) * 0.05f;
        }
Пример #2
0
        public override void CompTickRare()
        {
            base.CompTickRare();
            float num = 15f;

            if (parent.MapHeld != null)
            {
                num = GridsUtility.GetTemperature(parent.PositionHeld, parent.MapHeld);
            }
            CompEquippable comp = parent.GetComp <CompEquippable>();

            if (comp != null)
            {
                Pawn casterPawn = comp.PrimaryVerb.CasterPawn;
                if (casterPawn != null)
                {
                    num = GridsUtility.GetTemperature(casterPawn.PositionHeld, casterPawn.MapHeld);
                }
            }
            if (parent.Spawned)
            {
                List <Thing> thingList = GridsUtility.GetThingList(parent.PositionHeld, parent.MapHeld);
                for (int i = 0; i < thingList.Count; i++)
                {
                    CompRefrigerator fridge = ThingCompUtility.TryGetComp <CompRefrigerator>(thingList[i]);
                    if (fridge != null)
                    {
                        num = fridge.currentTemp;
                        break;
                    }
                }
            }
            temperature += (num - temperature) * 0.05f;
        }
Пример #3
0
        private new void CheckTemperatureMakeLeafless()
        {
            float num = 8f;

            if ((double)GridsUtility.GetTemperature(this.Position) >= (double)this.HashOffset() * 0.00999999977648258 % (double)num - (double)num - 2.0)
            {
                return;
            }
            this.MakeLeafless();
        }
        public override void TickRare()
        {
            if (this.CurrentTemp < -2000f)
            {
                this.CurrentTemp = GridsUtility.GetTemperature(base.Position, base.Map);
            }
            foreach (IntVec3 cell in this.AllSlotCells())
            {
                foreach (Thing thing in GridsUtility.GetThingList(cell, base.Map))
                {
                    CompRottable rottable = ThingCompUtility.TryGetComp <CompRottable>(thing);
                    if (rottable != null && !(rottable is CompBetterRottable))
                    {
                        ThingWithComps     thingWithComps     = thing as ThingWithComps;
                        CompBetterRottable compBetterRottable = new CompBetterRottable();
                        thingWithComps.AllComps.Remove(rottable);
                        thingWithComps.AllComps.Add(compBetterRottable);
                        compBetterRottable.props       = rottable.props;
                        compBetterRottable.parent      = thingWithComps;
                        compBetterRottable.RotProgress = rottable.RotProgress;
                    }

                    if (ThingCompUtility.TryGetComp <CompFrosty>(thing) == null && thing.def.defName == "Beer")
                    {
                        ThingWithComps thingWithComps = thing as ThingWithComps;
                        CompFrosty     compFrosty     = new CompFrosty();
                        thingWithComps.AllComps.Add(compFrosty);
                        compFrosty.props  = CompProperties_Frosty.Beer;
                        compFrosty.parent = thingWithComps;
                        ((TickList)typeof(TickManager).GetField("tickListRare", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(Find.TickManager)).RegisterThing(thingWithComps);
                    }
                }
            }

            float roomTemperature   = GridsUtility.GetTemperature(base.Position, base.Map);
            float changetemperature = (roomTemperature - this.CurrentTemp) * 0.01f;
            float changeEnergy      = -changetemperature;
            float powerMultiplier   = 0f;

            if (this.CurrentTemp + changetemperature > this.DesiredTemp)
            {
                float change = Mathf.Max(this.DesiredTemp - (this.CurrentTemp + changetemperature), -1f);
                if (this.powerComp != null && this.powerComp.PowerOn)
                {
                    changetemperature += change;
                    changeEnergy      -= change * 1.25f;
                }
                powerMultiplier = change * -1f;
            }
            this.CurrentTemp += changetemperature;
            IntVec3 pos = base.Position + IntVec3.North.RotatedBy(base.Rotation);

            GenTemperature.PushHeat(pos, base.Map, changeEnergy * 1.25f);
            this.powerComp.PowerOutput = -((CompProperties_Power)this.powerComp.props).basePowerConsumption * (powerMultiplier * 0.9f + 0.1f);
        }
Пример #5
0
    public static bool GrowthSeasonNowFrostPlant(IntVec3 c, Map map)
    {
        Room roomOrAdjacent = GridsUtility.GetRoomOrAdjacent(c, map, (RegionType)7);

        if (roomOrAdjacent == null)
        {
            return(false);
        }
        float temperature = GridsUtility.GetTemperature(c, map);

        return(temperature < 58f);
    }
Пример #6
0
        public override void CompTick()
        {
            base.CompTick();

            if (!Gen.IsHashIntervalTick(parent, 60))
            {
                return;
            }

            // If it has a comp power (which it should) and it's off, abort
            CompPowerTrader compPowerTrader = (parent as Building).PowerComp as CompPowerTrader;

            if ((compPowerTrader == null) ||
                (!compPowerTrader.PowerOn))
            {
                return;
            }

            // If it has a comp power idle (which it should) and it's idle, abort
            CompPowerLowIdleDraw compPowerLowIdleDraw = (parent as Building).TryGetComp <CompPowerLowIdleDraw>();

            if ((compPowerLowIdleDraw == null) ||
                (compPowerLowIdleDraw.isItIdle == true))
            {
                return;
            }

            // If the local temp is higher than the max heat pushed, abort
            if (GridsUtility.GetTemperature(parent.Position) >= props.heatPushMaxTemperature)
            {
                return;
            }

            // Push some heat
            GenTemperature.PushHeat(this.parent.Position, this.props.heatPerSecond);
        }
Пример #7
0
        public override void TickRare()
        {
            if (!compPowerTrader.PowerOn)
            {
                return;
            }

            IntVec3 intVec3_1 = Position + IntVec3Utility.RotatedBy(IntVec3.South, Rotation);
            IntVec3 intVec3_2 = Position + IntVec3Utility.RotatedBy(IntVec3.North, Rotation);
            bool    flag      = false;

            if (!GenGrid.Impassable(intVec3_2, Map) && !GenGrid.Impassable(intVec3_1, Map))
            {
                float temperature1 = GridsUtility.GetTemperature(intVec3_2, Map);
                float temperature2 = GridsUtility.GetTemperature(intVec3_1, Map);


                //Check for Mode
                bool _cooling = true;
                if (m_Mode == EnumCoolerMode.Cooling)
                {
                    _cooling = true;
                }
                else if (m_Mode == EnumCoolerMode.Heating)
                {
                    _cooling = false;
                }
                else if (m_Mode == EnumCoolerMode.Auto)
                {
                    if (temperature1 > compTempControl.targetTemperature)
                    {
                        //Log.Message("Auto Cooling");
                        _cooling = true;
                    }
                    else
                    {
                        //Log.Message("Auto Heating");
                        _cooling = false;
                    }
                }

                float a;
                float energyLimit;
                float _TemperatureDifferance;
                float num2;

                if (_cooling)
                {
                    //Log.Message("Cooling");
                    _TemperatureDifferance = temperature1 - temperature2;
                    if (temperature1 - TemperatureDiffThreshold > _TemperatureDifferance)
                    {
                        _TemperatureDifferance = temperature1 - TemperatureDiffThreshold;
                    }
                    num2 = 1.0f - _TemperatureDifferance * EfficiencyLossPerDegreeDifference;
                    if (num2 < 0.0f)
                    {
                        num2 = 0.0f;
                    }
                    energyLimit = (float)(compTempControl.Props.energyPerSecond * (double)num2 * UnknownConst_2);
                    a           = GenTemperature.ControlTemperatureTempChange(intVec3_1, Map, energyLimit, compTempControl.targetTemperature);
                    flag        = !Mathf.Approximately(a, 0.0f);
                }
                else
                {
                    //Log.Message("Heating");
                    _TemperatureDifferance = temperature1 - temperature2;
                    if (temperature1 + TemperatureDiffThreshold > _TemperatureDifferance)
                    {
                        _TemperatureDifferance = temperature1 + TemperatureDiffThreshold;
                    }
                    num2 = 1.0f - _TemperatureDifferance * EfficiencyLossPerDegreeDifference;
                    if (num2 < 0.0f)
                    {
                        num2 = 0.0f;
                    }
                    energyLimit = (float)(compTempControl.Props.energyPerSecond * -(double)num2 * UnknownConst_2);
                    a           = GenTemperature.ControlTemperatureTempChange(intVec3_1, Map, energyLimit, compTempControl.targetTemperature);
                    flag        = !Mathf.Approximately(a, 0.0f);
                }

                if (flag)
                {
                    GridsUtility.GetRoomGroup(intVec3_2, Map).Temperature -= a;
                    GenTemperature.PushHeat(intVec3_1, Map, (float)(+(double)energyLimit * HeatOutputMultiplier));
                }
            }


            CompProperties_Power props = compPowerTrader.Props;

            if (flag)
            {
                compPowerTrader.PowerOutput = -props.basePowerConsumption;
            }
            else
            {
                compPowerTrader.PowerOutput = -props.basePowerConsumption * compTempControl.Props.lowPowerConsumptionFactor;
            }

            compTempControl.operatingAtHighPower = flag;
        }
Пример #8
0
        // Token: 0x0600001C RID: 28 RVA: 0x000031E8 File Offset: 0x000013E8
        internal static float GetMiscFactor(Pawn target, Pawn seer, bool ActiveCamo)
        {
            float num  = 1f;
            bool  flag = StealthyBox.IsWearingStealthBox(target, out _);

            if (flag)
            {
                num *= 0.5f;
            }
            bool flag2;

            if (target == null)
            {
                flag2 = (null != null);
            }
            else
            {
                Pawn_StanceTracker stances = target.stances;
                flag2 = ((stances?.curStance) != null);
            }
            if (flag2)
            {
                if (!target.Downed)
                {
                    if (target.stances.curStance is Stance_Mobile)
                    {
                        if (flag)
                        {
                            num *= 1.5f;
                        }
                        else
                        {
                            num *= 1.1f;
                        }
                        if (CamoUtility.IsInsectoid(seer))
                        {
                            num *= 1.25f;
                        }
                    }
                    else if (target.stances.curStance is Stance_Cooldown || target.stances.curStance is Stance_Warmup)
                    {
                        num *= 0.95f;
                        if (CamoUtility.IsInsectoid(seer))
                        {
                            num *= 0.75f;
                        }
                    }
                }
                else
                {
                    num *= 0.5f;
                    if (CamoUtility.IsInsectoid(seer))
                    {
                        num *= 0.75f;
                    }
                }
            }
            if (Controller.Settings.DoCheckWeather && (target?.Map) != null)
            {
                float accuracyMultiplier = target.Map.weatherManager.curWeather.accuracyMultiplier;
                if (accuracyMultiplier != 1f)
                {
                    num *= accuracyMultiplier;
                }
            }
            if (Controller.Settings.DoCheckLight && !ActiveCamo)
            {
                PsychGlow psychGlow = target.Map.glowGrid.PsychGlowAt(target.Position);
                if (psychGlow == PsychGlow.Overlit)
                {
                    num *= 1.15f;
                }
                else
                {
                    num *= 0.8f;
                }
                PsychGlow psychGlow2 = seer.Map.glowGrid.PsychGlowAt(seer.Position);
                if (psychGlow2 == PsychGlow.Overlit)
                {
                    num *= 0.85f;
                }
                else
                {
                    num *= 1.2f;
                }
            }
            if (Controller.Settings.DoCheckTemp)
            {
                float temperature = GridsUtility.GetTemperature(target.Position, target.Map);
                float num2        = 21f;
                if (temperature > num2)
                {
                    num *= Mathf.Lerp(1f, 0.85f, (temperature - num2) / temperature);
                }
            }
            return(num);
        }
Пример #9
0
        public override void TickRare()
        {
            if (!this.compPowerTrader.PowerOn)
            {
                return;
            }

            IntVec3 intVec3_1 = this.Position + IntVec3.South.RotatedBy(this.Rotation);
            IntVec3 intVec3_2 = this.Position + IntVec3.North.RotatedBy(this.Rotation);
            bool    flag      = false;

            if (!intVec3_2.Impassable(this.Map) && !intVec3_1.Impassable(this.Map))
            {
                float temperature1 = GridsUtility.GetTemperature(intVec3_2, this.Map);
                float temperature2 = GridsUtility.GetTemperature(intVec3_1, this.Map);


                //Check for Mode
                bool _cooling = true;
                if (this.m_Mode == enumCoolerMode.Cooling)
                {
                    _cooling = true;
                }
                else if (this.m_Mode == enumCoolerMode.Heating)
                {
                    _cooling = false;
                }
                else if (this.m_Mode == enumCoolerMode.Auto)
                {
                    //Log.Message("T1: " + temperature1 + "T2: " + temperature2 + "TT: " + this.compTempControl.targetTemperature);
                    if (temperature1 > this.compTempControl.targetTemperature)
                    {
                        //Log.Message("Auto Cooling");
                        _cooling = true;
                    }
                    else
                    {
                        //Log.Message("Auto Heating");
                        _cooling = false;
                    }
                }

                float a           = 0.0f;
                float energyLimit = 0.0f;

                if (_cooling)
                {
                    //Log.Message("Cooling");
                    float _TemperatureDifferance = temperature1 - temperature2;
                    if ((double)temperature1 - 40.0 > (double)_TemperatureDifferance)
                    {
                        _TemperatureDifferance = temperature1 - 40f;
                    }
                    float num2 = (float)(1.0 - (double)_TemperatureDifferance * (1.0 / 130.0));
                    if ((double)num2 < 0.0)
                    {
                        num2 = 0.0f;
                    }
                    energyLimit = (float)((double)this.compTempControl.Props.energyPerSecond * (double)num2 * 4.16666650772095);
                    a           = GenTemperature.ControlTemperatureTempChange(intVec3_1, this.Map, energyLimit, this.compTempControl.targetTemperature);
                    flag        = !Mathf.Approximately(a, 0.0f);
                }
                else
                {
                    //Log.Message("Heating");
                    float _TemperatureDifferance = temperature1 - temperature2;
                    if ((double)temperature1 + 40.0 > (double)_TemperatureDifferance)
                    {
                        _TemperatureDifferance = temperature1 + 40f;
                    }
                    float num2 = (float)(1.0 - (double)_TemperatureDifferance * (1.0 / 130.0));
                    if ((double)num2 < 0.0)
                    {
                        num2 = 0.0f;
                    }
                    energyLimit = (float)((double)this.compTempControl.Props.energyPerSecond * -(double)num2 * 4.16666650772095);
                    //energyLimit = (float)((double)this.compTempControl.Props.energyPerSecond * 4.16666650772095 * -1);
                    a    = GenTemperature.ControlTemperatureTempChange(intVec3_1, this.Map, energyLimit, this.compTempControl.targetTemperature);
                    flag = !Mathf.Approximately(a, 0.0f);
                    //Log.Message("TempDiff: " + _TemperatureDifferance + " num2: " + num2 + " EnergyLimit: " + energyLimit + " a: " + a);
                }

                if (flag)
                {
                    GridsUtility.GetRoomGroup(intVec3_2, this.Map).Temperature -= a;
                    GenTemperature.PushHeat(intVec3_1, this.Map, (float)(+(double)energyLimit * 1.25));
                }
            }


            CompProperties_Power props = this.compPowerTrader.Props;

            if (flag)
            {
                this.compPowerTrader.PowerOutput = -props.basePowerConsumption;
            }
            else
            {
                this.compPowerTrader.PowerOutput = -props.basePowerConsumption * this.compTempControl.Props.lowPowerConsumptionFactor;
            }
            this.compTempControl.operatingAtHighPower = flag;
        }