예제 #1
0
        public static float GetCurrentWinterMovementDifficultyOffset(int tile, int?ticksAbs = null, StringBuilder explanation = null)
        {
            if (!ticksAbs.HasValue)
            {
                ticksAbs = GenTicks.TicksAbs;
            }
            Vector2 vector = Find.WorldGrid.LongLatOf(tile);

            SeasonUtility.GetSeason(GenDate.YearPercent(ticksAbs.Value, vector.x), vector.y, out var _, out var _, out var _, out var winter, out var _, out var permanentWinter);
            float num = winter + permanentWinter;

            num *= Mathf.InverseLerp(5f, 0f, GenTemperature.GetTemperatureFromSeasonAtTile(ticksAbs.Value, tile));
            if (num > 0.01f)
            {
                float num2 = 2f * num;
                if (explanation != null)
                {
                    explanation.AppendLine();
                    explanation.Append("Winter".Translate());
                    if (num < 0.999f)
                    {
                        explanation.Append(" (" + num.ToStringPercent("F0") + ")");
                    }
                    explanation.Append(": ");
                    explanation.Append(num2.ToStringWithSign("0.#"));
                }
                return(num2);
            }
            return(0f);
        }
예제 #2
0
        public static float GetCurrentWinterMovementDifficultyOffset(int tile, VehicleDef vehicleDef, int?ticksAbs = null, StringBuilder explanation = null)
        {
            if (ticksAbs == null)
            {
                ticksAbs = new int?(GenTicks.TicksAbs);
            }
            Vector2 vector = Find.WorldGrid.LongLatOf(tile);

            SeasonUtility.GetSeason(GenDate.YearPercent(ticksAbs.Value, vector.x), vector.y, out float num, out float num2, out float num3, out float num4, out float num5, out float num6);
            float num7 = num4 + num6;

            num7 *= Mathf.InverseLerp(MaxTempForWinterOffset, 0f, GenTemperature.GetTemperatureFromSeasonAtTile(ticksAbs.Value, tile));
            if (num7 > 0.01f)
            {
                float num8 = WinterMovementDifficultyOffset * num7;
                if (explanation != null)
                {
                    explanation.AppendLine();
                    explanation.Append("Winter".Translate());
                    if (num7 < 0.999f)
                    {
                        explanation.Append(" (" + num7.ToStringPercent("F0") + ")");
                    }
                    explanation.Append(": ");
                    explanation.Append(num8.ToStringWithSign("0.#"));                     //REDO - Add translated text for winter path cost multiplier
                }
                return(num8 * vehicleDef.properties.winterPathCostMultiplier);
            }
            return(0f);
        }
예제 #3
0
        public int ApproxTicksUntilRotWhenAtTempOfTile(int tile, int ticksAbs)
        {
            //Note that we ignore local map temperature offsets even if there's a map at this tile
            float temp = GenTemperature.GetTemperatureFromSeasonAtTile(ticksAbs, tile);

            return(TicksUntilRotAtTemp(temp));
        }
 public static bool EnvironmentAllowsEatingVirtualPlantsAt(int tile, int ticksAbs)
 {
     if (!Find.WorldGrid[tile].biome.hasVirtualPlants)
     {
         return(false);
     }
     if (GenTemperature.GetTemperatureFromSeasonAtTile(ticksAbs, tile) < 0f)
     {
         return(false);
     }
     return(true);
 }
        public static bool EnvironmentAllowsEatingVirtualPlantsAt(int tile, int ticksAbs)
        {
            BiomeDef biome = Find.WorldGrid[tile].biome;

            if (!biome.hasVirtualPlants)
            {
                return(false);
            }
            float temperatureFromSeasonAtTile = GenTemperature.GetTemperatureFromSeasonAtTile(ticksAbs, tile);

            return(temperatureFromSeasonAtTile >= 0f);
        }
예제 #6
0
        public static bool WillWinterEverAffectMovementDifficulty(int tile)
        {
            int ticksAbs = GenTicks.TicksAbs;

            for (int i = 0; i < 3600000; i += 60000)
            {
                if (GenTemperature.GetTemperatureFromSeasonAtTile(ticksAbs + i, tile) < 5f)
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #7
0
        public static float GetCurrentWinterMovementDifficultyOffset(int tile, int?ticksAbs = null, StringBuilder explanation = null)
        {
            if (ticksAbs == null)
            {
                ticksAbs = new int?(GenTicks.TicksAbs);
            }
            Vector2 vector  = Find.WorldGrid.LongLatOf(tile);
            float   yearPct = GenDate.YearPercent((long)ticksAbs.Value, vector.x);
            float   num;
            float   num2;
            float   num3;
            float   num4;
            float   num5;
            float   num6;

            SeasonUtility.GetSeason(yearPct, vector.y, out num, out num2, out num3, out num4, out num5, out num6);
            float num7 = num4 + num6;

            num7 *= Mathf.InverseLerp(5f, 0f, GenTemperature.GetTemperatureFromSeasonAtTile(ticksAbs.Value, tile));
            float result;

            if (num7 > 0.01f)
            {
                float num8 = 2f * num7;
                if (explanation != null)
                {
                    explanation.AppendLine();
                    explanation.Append("Winter".Translate());
                    if (num7 < 0.999f)
                    {
                        explanation.Append(" (" + num7.ToStringPercent("F0") + ")");
                    }
                    explanation.Append(": ");
                    explanation.Append(num8.ToStringWithSign("0.#"));
                }
                result = num8;
            }
            else
            {
                result = 0f;
            }
            return(result);
        }
            public static void GetOutdoorTemp(ref float __result, Map ___map)
            {
                MapParent_PocketDimension mapParent = ___map.info.parent as MapParent_PocketDimension;

                if (mapParent != null)
                {
                    Building_PocketDimensionEntranceBase box = PocketDimensionUtility.GetBox(mapParent.dimensionSeed);
                    if (box != null)
                    {
                        __result = 21.0f;

                        if (box.Spawned)
                        {
                            __result = GenTemperature.GetTemperatureForCell(box.Position, box.Map);
                        }
                        else if (box.ParentHolder != null)
                        {
                            for (IThingHolder parentHolder = box.ParentHolder; parentHolder != null; parentHolder = parentHolder.ParentHolder)
                            {
                                if (ThingOwnerUtility.TryGetFixedTemperature(parentHolder, box, out __result))
                                {
                                    return;// false;
                                }
                            }
                        }
                        else if (box.SpawnedOrAnyParentSpawned)
                        {
                            __result = GenTemperature.GetTemperatureForCell(box.PositionHeld, box.MapHeld);
                        }
                        else if (box.Tile >= 0)
                        {
                            __result = GenTemperature.GetTemperatureFromSeasonAtTile(GenTicks.TicksAbs, box.Tile);
                        }

                        // Above logic derived from the following function call. Can't call it here due to an edge case which results in infinite loop
                        //__result = box.AmbientTemperature;
                        return;// false;
                    }
                }

                //return true;
            }
        public int ApproxTicksUntilRotWhenAtTempOfTile(int tile, int ticksAbs)
        {
            float temperatureFromSeasonAtTile = GenTemperature.GetTemperatureFromSeasonAtTile(ticksAbs, tile);

            return(this.TicksUntilRotAtTemp(temperatureFromSeasonAtTile));
        }