Exemplo n.º 1
0
        public TemperatureForecastForYear(int tileId, int ticks, int day)
        {
            Day = day;

            /*
             * Get min & max temperatures for the day
             */
            var tempsForHourOfDay = new List <float>(GenDate.HoursPerDay);

            for (var hour = 0; hour < GenDate.HoursPerDay; hour++)
            {
                var hourTicks = ticks + hour * GenDate.TicksPerHour;
                var temp      = Find.World.tileTemperatures.OutdoorTemperatureAt(tileId, hourTicks);
                tempsForHourOfDay.Add(temp);
            }

            // get min & max from list of temperatures for the day
            MinTemp = tempsForHourOfDay.Min();
            MaxTemp = tempsForHourOfDay.Max();

            // get number of ticks for the maximum temperature
            var ticksForMaxTemp = ticks + tempsForHourOfDay.IndexOf(MaxTemp) * GenDate.TicksPerHour;

            OffsetFromSeasonCycle = GenTemperature.OffsetFromSeasonCycle(ticksForMaxTemp, tileId);

            OffsetFromDailyRandomVariation =
                Find.World.tileTemperatures.OffsetFromDailyRandomVariation(tileId, ticksForMaxTemp);
        }
Exemplo n.º 2
0
        public static bool GetTemperatureFromSeasonAtTile(ref float __result, int absTick, int tile)
        {
            if (absTick == 0)
            {
                absTick = 1;
            }

            if (!tileAbsTickTemperature.TryGetValue(tile, out Dictionary <int, float> absTickTemperature))
            {
                absTickTemperature           = new Dictionary <int, float>();
                tileAbsTickTemperature[tile] = absTickTemperature;
            }
            if (!absTickTemperature.TryGetValue(absTick, out float temperature))
            {
                if (!tileTemperature.TryGetValue(tile, out float temperatureFromTile))
                {
                    temperatureFromTile   = Find.WorldGrid[tile].temperature;
                    tileTemperature[tile] = temperatureFromTile;
                }
                temperature = temperatureFromTile + GenTemperature.OffsetFromSeasonCycle(absTick, tile);
                lock (absTickTemperature)
                {
                    absTickTemperature.SetOrAdd(absTick, temperature);
                }
            }
            __result = temperature;
            return(false);
        }
Exemplo n.º 3
0
        public TemperatureForecastForDay(int tileId, int ticks, int hour)
        {
            TileId = tileId;
            Ticks  = ticks;
            Hour   = hour;

            var outdoorTemperature = Find.World.tileTemperatures.OutdoorTemperatureAt(tileId, Ticks);

            OutdoorTemperature = GenTemperature.CelsiusTo(outdoorTemperature, Prefs.TemperatureMode);

            var offsetFromSunCycle = GenTemperature.OffsetFromSunCycle(Ticks, TileId);

            // this is a temperature delta, so it's not a straight Celsius to another temperature unit. We use an extension method.
            OffsetFromSunCycle = TemperatureDisplayMode.Celsius.TempDelta(offsetFromSunCycle, Prefs.TemperatureMode);

            var offsetFromDailyRandomVariation =
                Find.World.tileTemperatures.OffsetFromDailyRandomVariation(TileId, Ticks);

            OffsetFromDailyRandomVariation =
                TemperatureDisplayMode.Celsius.TempDelta(offsetFromDailyRandomVariation, Prefs.TemperatureMode);

            var offsetFromSeasonCycle = GenTemperature.OffsetFromSeasonCycle(Ticks, tileId);

            OffsetFromSeasonCycle = TemperatureDisplayMode.Celsius.TempDelta(offsetFromSeasonCycle, Prefs.TemperatureMode);

            var dailyRandomVariation = Find.WorldGrid[TileId].temperature -
                                       (OffsetFromSeasonCycle + OffsetFromDailyRandomVariation + OffsetFromSunCycle);

            DailyRandomVariation = TemperatureDisplayMode.Celsius.TempDelta(dailyRandomVariation, Prefs.TemperatureMode);
        }
Exemplo n.º 4
0
        private void UpdateInfo()
        {
            int   tick = Find.TickManager.TicksGame;
            int   tile = map.Tile;
            float currentTemp, mint = 0, maxt = 0;

            //getting temp averages, computation optimization
            for (int i = 0; i < 24; ++i)
            {
                currentTemp = GenTemperature.OffsetFromSeasonCycle(tick + i * tempUpdateTicks, tile);
                if (currentTemp < mint)
                {
                    mint = currentTemp;
                }
                if (currentTemp > maxt)
                {
                    maxt = currentTemp;
                }
            }

            minTemperature = mint;
            maxTemperature = maxt;

            UpdateFIshInfo();

            LastUpdateTick = tick;
        }
            private float CalculateOutdoorTemperatureAtTile(int absTick, bool includeDailyVariations)
            {
                if (absTick == 0)
                {
                    absTick = 1;
                }
                float num = Find.WorldGrid[tile].temperature + GenTemperature.OffsetFromSeasonCycle(absTick, tile);

                if (includeDailyVariations)
                {
                    num += OffsetFromDailyRandomVariation(absTick) + GenTemperature.OffsetFromSunCycle(absTick, tile);
                }
                return(num);
            }
Exemplo n.º 6
0
        public TemperatureForecastForDay(int tileId, int ticks, int hour)
        {
            TileId = tileId;
            Ticks  = ticks;
            Hour   = hour;

            OutdoorTemperature             = Find.World.tileTemperatures.OutdoorTemperatureAt(tileId, Ticks);
            OffsetFromSunCycle             = GenTemperature.OffsetFromSunCycle(Ticks, TileId);
            OffsetFromDailyRandomVariation = Find.World.tileTemperatures.OffsetFromDailyRandomVariation(TileId,
                                                                                                        Ticks);
            OffsetFromSeasonCycle = GenTemperature.OffsetFromSeasonCycle(Ticks, tileId);

            var tile = Find.WorldGrid[TileId];

            DailyRandomVariation = tile.temperature -
                                   (OffsetFromSeasonCycle + OffsetFromDailyRandomVariation + OffsetFromSunCycle);
        }
Exemplo n.º 7
0
        public static bool GetTemperatureFromSeasonAtTile(ref float __result, int absTick, int tile)
        {
            WorldGrid newWorldGrid = Find.WorldGrid;

            if (worldGrid != newWorldGrid)
            {
                worldGrid = newWorldGrid;
                SeasonalShiftAmplitudeCache.Clear();
                tileAbsTickTemperature.Clear();
                tileTemperature.Clear();
#if DEBUG
                Log.Message("RimThreaded is rebuilding WorldGrid Temperature Cache");
#endif
            }
            if (absTick == 0)
            {
                absTick = 1;
            }

            if (!tileAbsTickTemperature.TryGetValue(tile, out Dictionary <int, float> absTickTemperature))
            {
                absTickTemperature           = new Dictionary <int, float>();
                tileAbsTickTemperature[tile] = absTickTemperature;
            }

            if (!absTickTemperature.TryGetValue(absTick, out float temperature))
            {
                if (!tileTemperature.TryGetValue(tile, out float temperatureFromTile))
                {
                    temperatureFromTile   = Find.WorldGrid[tile].temperature;
                    tileTemperature[tile] = temperatureFromTile;
                }
                temperature = temperatureFromTile + GenTemperature.OffsetFromSeasonCycle(absTick, tile);
                lock (absTickTemperature)
                {
                    absTickTemperature.SetOrAdd(absTick, temperature);
                }
            }
            __result = temperature;
            return(false);
        }