예제 #1
0
        public static Twelfth PreviousTwelfth(this Twelfth twelfth)
        {
            Twelfth result;

            if (twelfth == Twelfth.Undefined)
            {
                result = Twelfth.Undefined;
            }
            else
            {
                int num = (int)(twelfth - Twelfth.Second);
                if (num == -1)
                {
                    num = 11;
                }
                result = (Twelfth)num;
            }
            return(result);
        }
예제 #2
0
        public static NeededWarmth CalculateNeededWarmth(Pawn pawn, int tile, Twelfth twelfth)
        {
            float        num = GenTemperature.AverageTemperatureAtTileForTwelfth(tile, twelfth);
            NeededWarmth result;

            if (num < pawn.def.GetStatValueAbstract(StatDefOf.ComfyTemperatureMin, null) - 4f)
            {
                result = NeededWarmth.Warm;
            }
            else if (num > pawn.def.GetStatValueAbstract(StatDefOf.ComfyTemperatureMin, null) + 4f)
            {
                result = NeededWarmth.Cool;
            }
            else
            {
                result = NeededWarmth.Any;
            }
            return(result);
        }
예제 #3
0
        public static Twelfth GetRightMostTwelfth(List <Twelfth> twelfths, Twelfth rootTwelfth)
        {
            if (twelfths.Count >= 12)
            {
                return(Twelfth.Undefined);
            }
            Twelfth m;

            while (true)
            {
                m           = rootTwelfth;
                rootTwelfth = TwelfthUtility.TwelfthAfter(rootTwelfth);
                if (!twelfths.Contains(rootTwelfth))
                {
                    break;
                }
            }
            return(TwelfthUtility.TwelfthAfter(m));
        }
예제 #4
0
        public static Twelfth GetRightMostTwelfth(List <Twelfth> twelfths, Twelfth rootTwelfth)
        {
            Twelfth result;

            if (twelfths.Count >= 12)
            {
                result = Twelfth.Undefined;
            }
            else
            {
                Twelfth m;
                do
                {
                    m           = rootTwelfth;
                    rootTwelfth = TwelfthUtility.TwelfthAfter(rootTwelfth);
                }while (twelfths.Contains(rootTwelfth));
                result = TwelfthUtility.TwelfthAfter(m);
            }
            return(result);
        }
예제 #5
0
        private static string SeasonsContinuousRangeLabel(List <Twelfth> twelfths, Twelfth rootTwelfth, Vector2 longLat)
        {
            Twelfth leftMostTwelfth  = TwelfthUtility.GetLeftMostTwelfth(twelfths, rootTwelfth);
            Twelfth rightMostTwelfth = TwelfthUtility.GetRightMostTwelfth(twelfths, rootTwelfth);
            Twelfth twelfth          = leftMostTwelfth;

            while (twelfth != rightMostTwelfth)
            {
                if (twelfths.Contains(twelfth))
                {
                    twelfths.Remove(twelfth);
                    twelfth = TwelfthUtility.TwelfthAfter(twelfth);
                    continue;
                }
                Log.Error("Twelfths doesn't contain " + twelfth + " (" + leftMostTwelfth + ".." + rightMostTwelfth + ")");
                break;
            }
            twelfths.Remove(rightMostTwelfth);
            return(GenDate.SeasonDateStringAt(leftMostTwelfth, longLat) + " - " + GenDate.SeasonDateStringAt(rightMostTwelfth, longLat));
        }
예제 #6
0
        public static Twelfth GetLeftMostTwelfth(List <Twelfth> twelfths, Twelfth rootTwelfth)
        {
            Twelfth result;

            if (twelfths.Count >= 12)
            {
                result = Twelfth.Undefined;
            }
            else
            {
                Twelfth twelfth;
                do
                {
                    twelfth     = rootTwelfth;
                    rootTwelfth = TwelfthUtility.TwelfthBefore(rootTwelfth);
                }while (twelfths.Contains(rootTwelfth));
                result = twelfth;
            }
            return(result);
        }
예제 #7
0
        private static NeededWarmth ApparelWarmthNeededNow(Pawn pawn, PawnGenerationRequest request, out float mapTemperature)
        {
            int tile = request.Tile;

            if (tile == -1)
            {
                Map anyPlayerHomeMap = Find.AnyPlayerHomeMap;
                if (anyPlayerHomeMap != null)
                {
                    tile = anyPlayerHomeMap.Tile;
                }
            }
            if (tile == -1)
            {
                mapTemperature = 21f;
                return(NeededWarmth.Any);
            }
            NeededWarmth neededWarmth = NeededWarmth.Any;
            Twelfth      twelfth      = GenLocalDate.Twelfth(tile);

            mapTemperature = GenTemperature.AverageTemperatureAtTileForTwelfth(tile, twelfth);
            for (int i = 0; i < 2; i++)
            {
                NeededWarmth neededWarmth2 = CalculateNeededWarmth(pawn, tile, twelfth);
                if (neededWarmth2 != 0)
                {
                    neededWarmth = neededWarmth2;
                    break;
                }
                twelfth = twelfth.NextTwelfth();
            }
            if (pawn.kindDef.apparelIgnoreSeasons)
            {
                if (request.ForceAddFreeWarmLayerIfNeeded && neededWarmth == NeededWarmth.Warm)
                {
                    return(neededWarmth);
                }
                return(NeededWarmth.Any);
            }
            return(neededWarmth);
        }
        public static List <Twelfth> TwelfthsInAverageTemperatureRange(int tile, float minTemp, float maxTemp)
        {
            List <Twelfth> twelfths = new List <Twelfth>();

            for (int i = 0; i < 12; i++)
            {
                float num = GenTemperature.AverageTemperatureAtTileForTwelfth(tile, (Twelfth)i);
                if (num >= minTemp && num <= maxTemp)
                {
                    twelfths.Add((Twelfth)i);
                }
            }
            if (twelfths.Count <= 1 || twelfths.Count == 12)
            {
                return(twelfths);
            }
            if (twelfths.Contains(Twelfth.Twelfth) && twelfths.Contains(Twelfth.First))
            {
                Twelfth        twelfth = twelfths.First((Twelfth m) => !twelfths.Contains((Twelfth)(m - Twelfth.Second)));
                List <Twelfth> list    = new List <Twelfth>();
                for (int j = (int)twelfth; j < 12; j++)
                {
                    if (!twelfths.Contains((Twelfth)j))
                    {
                        break;
                    }
                    list.Add((Twelfth)j);
                }
                for (int k = 0; k < 12; k++)
                {
                    if (!twelfths.Contains((Twelfth)k))
                    {
                        break;
                    }
                    list.Add((Twelfth)k);
                }
            }
            return(twelfths);
        }
예제 #9
0
 private float GetTemperature(Twelfth twelfth, [NotNull] Map map)
 {
     return(GenTemperature.AverageTemperatureAtTileForTwelfth(map.Tile, twelfth));
 }
예제 #10
0
 public float AverageTemperatureForTwelfth(int tile, Twelfth twelfth)
 {
     return(this.RetrieveCachedData(tile).AverageTemperatureForTwelfth(twelfth));
 }
예제 #11
0
 public float AverageTemperatureForTwelfth(Twelfth twelfth)
 {
     return(this.twelfthlyTempAverages[(int)twelfth]);
 }
예제 #12
0
 public static string SeasonDateStringAt(Twelfth twelfth, Vector2 longLat)
 {
     return(SeasonDateStringAt((int)twelfth * 300000 + 1, longLat));
 }
예제 #13
0
 public static string QuadrumDateStringAt(Twelfth twelfth)
 {
     return(QuadrumDateStringAt((int)twelfth * 300000 + 1, 0f));
 }
예제 #14
0
        public static Quadrum Quadrum(long absTicks, float longitude)
        {
            Twelfth twelfth = GenDate.Twelfth(absTicks, longitude);

            return(twelfth.GetQuadrum());
        }
예제 #15
0
 public static string QuadrumDateStringAt(Twelfth twelfth)
 {
     return(GenDate.QuadrumDateStringAt((long)((int)twelfth * 300000 + 1), 0f));
 }
예제 #16
0
 static void Postfix(int tile, Twelfth twelfth, ref float __result)
 {
     if (averageTileTemps.TryGetValue(tile, out float[] arr) && !float.IsNaN(arr[(int)twelfth]))
예제 #17
0
 static bool Prefix(int tile, Twelfth twelfth)
 {
     return(!averageTileTemps.TryGetValue(tile, out float[] arr) || float.IsNaN(arr[(int)twelfth]));
 }
 internal bool <> m__0(Twelfth m)
 {
     return(!this.twelfths.Contains((Twelfth)(m - Twelfth.Second)));
 }
예제 #19
0
 public static int ToGrowingDays(this Twelfth thisTwelfth)
 {
     return(((int)thisTwelfth + 1 % 13) * 5);
 }
예제 #20
0
 public static float GetBeginningYearPct(this Twelfth twelfth)
 {
     return((float)(int)twelfth / 12f);
 }
예제 #21
0
 public static float GetMiddleYearPct(this Twelfth twelfth)
 {
     return(((float)(int)twelfth + 0.5f) / 12f);
 }
예제 #22
0
 public static bool AverageTemperatureForTwelfth(TileTemperaturesComp __instance, ref float __result, int tile, Twelfth twelfth)
 {
     __result = RetrieveCachedData2(__instance, tile).AverageTemperatureForTwelfth(twelfth);
     return(false);
 }