public static float OffsetFromSunCycle(int absTick, int tile)
        {
            float num = GenDate.DayPercent((long)absTick, Find.WorldGrid.LongLatOf(tile).x);
            float f   = 6.28318548f * (num + 0.32f);

            return(Mathf.Cos(f) * 7f);
        }
        public static float OffsetFromSunCycle(int absTick, int tile)
        {
            long    absTicks = absTick;
            Vector2 vector   = Find.WorldGrid.LongLatOf(tile);
            float   num      = GenDate.DayPercent(absTicks, vector.x);
            float   f        = (float)(6.2831854820251465 * (num + 0.31999999284744263));

            return((float)(Mathf.Cos(f) * 7.0));
        }
Ejemplo n.º 3
0
        public static float OffsetFromSunCycle(int absTick, int tile)
        {
            long    absTicks = absTick;
            Vector2 vector   = Find.WorldGrid.LongLatOf(tile);
            float   num      = GenDate.DayPercent(absTicks, vector.x);
            float   f        = 6.28318548f * (num + 0.32f);

            return(Mathf.Cos(f) * 7f);
        }
 // ReSharper disable once UnusedMember.Global
 public static bool Prefix(ref float __result, int absTick, int tile)
 {
     try
     {
         var num = GenDate.DayPercent(absTick, Find.WorldGrid.LongLatOf(tile).x);
         var f   = 6.28318548f * (num + 0.32f);
         __result = Main.BiomeSettings[Find.WorldGrid.tiles[tile].biome].CalculateTemp(f);
         return(false);
     }
     catch (Exception e)
     {
         Log.Error($"Error getting biome for tile {tile} on world grid due to {e} - {e.StackTrace}");
         return(true);
     }
 }
Ejemplo n.º 5
0
        public static float OffsetFromSunCycle(int absTick, int tile)
        {
            float num = GenDate.DayPercent(absTick, Find.WorldGrid.LongLatOf(tile).x);

            return(Mathf.Cos((float)Math.PI * 2f * (num + 0.32f)) * 7f);
        }
Ejemplo n.º 6
0
        public override void MapComponentTick()
        {
            if (this.map.Biome != Util_CaveBiome.CaveBiomeDef)
            {
                return;
            }

            if (Find.TickManager.TicksGame >= nextLightCheckTick)
            {
                nextLightCheckTick = Find.TickManager.TicksGame + lightCheckPeriodInTicks;
                float gamehour           = GenDate.HoursPerDay * GenDate.DayPercent(Find.TickManager.TicksAbs, Find.WorldGrid.LongLatOf(map.Tile).x); // TODO: could refine to accommodate axial tilt, such that high latitudes will have "midnight sun" growing areas... nifty.
                float caveWellBrightness = 0.0f;

                if (this.map.gameConditionManager.ConditionIsActive(GameConditionDefOf.Eclipse))
                {
                    // Shut down light when there is an eclipse.
                    caveWellBrightness = 0.0f;
                }
                else
                {
                    if (gamehour < sunriseBeginHour)
                    {
                        caveWellBrightness = brightnessCaveWellMin;
                    }
                    else if (gamehour < sunriseEndHour)
                    {
                        float sunriseProgress = Math.Max(0f, gamehour - sunriseBeginHour) / (sunriseEndHour - sunriseBeginHour);
                        caveWellBrightness = sunriseProgress * brightnessCaveWellMax;
                    }
                    else if (gamehour < sunsetBeginHour)
                    {
                        caveWellBrightness = brightnessCaveWellMax;
                    }
                    else if (gamehour < sunsetEndHour)
                    {
                        float sunsetProgress = Math.Max(0f, gamehour - sunsetBeginHour) / (sunsetEndHour - sunsetBeginHour);
                        caveWellBrightness = 1 - sunsetProgress * brightnessCaveWellMax;
                    }
                    else
                    {
                        caveWellBrightness = brightnessCaveWellMin;
                    }
                }

                currentGlowColor.r = (int)(caveWellBrightness * caveWellBrightness * baseGlowColor.r);
                currentGlowColor.g = (int)(caveWellBrightness * caveWellBrightness * baseGlowColor.g);
                currentGlowColor.b = (int)(caveWellBrightness * caveWellBrightness * baseGlowColor.b);

                List <Thing> caveWellsList = map.listerThings.ThingsOfDef(Util_CaveBiome.CaveWellDef);
                foreach (Thing caveWell in caveWellsList)
                {
                    SetCaveWellBrightness(caveWell, caveWellBrightness);
                }

                if ((MapComponent_CaveWellLight.plantsMessageHasBeenSent == false) &&
                    (gamehour >= sunriseBeginHour + 1))
                {
                    Find.LetterStack.ReceiveLetter("CaveBiome.LetterLabelCavePlants".Translate(), "CaveBiome.CavePlants".Translate(),
                                                   LetterDefOf.Good);
                    MapComponent_CaveWellLight.plantsMessageHasBeenSent = true;
                }
                if ((MapComponent_CaveWellLight.growingMessageHasBeenSent == false) &&
                    (gamehour >= sunriseBeginHour + 2))
                {
                    if (MapGenerator.PlayerStartSpot.IsValid &&
                        (MapGenerator.PlayerStartSpot != IntVec3.Zero))    // Checking PlayerStartSpot validity will still raise an error message if it is invalid.
                    {
                        Find.LetterStack.ReceiveLetter("CaveBiome.LetterLabelGrowingInCave".Translate(), "CaveBiome.GrowingInCave".Translate(),
                                                       LetterDefOf.Good, new RimWorld.Planet.GlobalTargetInfo(MapGenerator.PlayerStartSpot, this.map));
                    }
                    else
                    {
                        Find.LetterStack.ReceiveLetter("CaveBiome.LetterLabelGrowingInCave".Translate(), "CaveBiome.GrowingInCave".Translate(),
                                                       LetterDefOf.Good);
                    }
                    MapComponent_CaveWellLight.growingMessageHasBeenSent = true;
                }
            }
        }