Beispiel #1
0
        public void CreateWeather()
        {
            //set the begin and end time
            SDVTime stormStart = new SDVTime(1150 + (Dice.Next(0, 230)));

            stormStart.ClampToTenMinutes();

            BeginTime = new SDVTime(stormStart);

            stormStart.AddTime(Dice.Next(30, 190));
            stormStart.ClampToTenMinutes();
            ExpirTime = new SDVTime(stormStart);
        }
        protected internal static SDVTime GetTimeAtHourAngle(double angle, bool morning = true)
        {
            var    date      = SDate.Now();
            int    dayOfYear = date.DaysSinceStart % 112;
            double lat       = GeneralFunctions.DegreeToRadians(NightConfig.Latitude);

            double solarDeclination = .40927971 * Math.Sin((2 * Math.PI / 112) * (dayOfYear - 1));
            double noon             = 720 - 10 * Math.Sin(4 * (Math.PI / 112) * (dayOfYear - 1)) + 8 * Math.Sin(2 * (Math.PI / 112) * dayOfYear);
            double astroHA          = Math.Acos((Math.Sin(angle) - Math.Sin(lat) * Math.Sin(solarDeclination)) / (Math.Cos(lat) * Math.Cos(solarDeclination)));
            double minHA            = (astroHA / (2 * Math.PI)) * 1440;
            int    astroTwN         = 0;

            if (!morning)
            {
                astroTwN = (int)Math.Floor(noon + minHA);
            }
            else
            {
                astroTwN = (int)Math.Floor(noon - minHA);
            }

            //Conv to an SDV compat time, then clamp it.
            int     hr       = (int)Math.Floor(astroTwN / 60.0);
            int     min      = astroTwN - (hr * 60);
            SDVTime calcTime = new SDVTime(hr, min);

            calcTime.ClampToTenMinutes();
            return(calcTime);
        }
Beispiel #3
0
        protected internal static SDVTime GetTimeAtHourAngle(SDate day, double angle, bool morning = true)
        {
            int astroTwN;
            int dayOfYear = day.DaysSinceStart % 112;

            //handle lat changes
            float baseLat = NightConfig.Latitude;

            if (Game1.currentLocation != null && Game1.currentLocation is IslandLocation && NightConfig.IslandLatDifference != 0f)
            {
                baseLat = (NightConfig.Latitude > 0
                    ? NightConfig.Latitude - NightConfig.IslandLatDifference
                    : NightConfig.Latitude + NightConfig.IslandLatDifference);

                //sanity check it.
                if ((NightConfig.Latitude > 0 && baseLat < 0) || (NightConfig.Latitude < 0 && baseLat > 0))
                {
                    baseLat = 0;
                }
            }

            double lat = MathHelper.ToRadians(baseLat);
            //23.45 deg * sin(2pi / 112 * (dayOfYear - 1))
            double solarDeclination = .40927971 * Math.Sin((2 * Math.PI / 112) * (dayOfYear - 1));
            double noon             = 720 - 10 * Math.Sin(4 * (Math.PI / 112) * (dayOfYear - 1)) + 8 * Math.Sin(2 * (Math.PI / 112) * dayOfYear);
            double astroHA          = Math.Acos((Math.Sin(angle) - Math.Sin(lat) * Math.Sin(solarDeclination)) / (Math.Cos(lat) * Math.Cos(solarDeclination)));
            double minHA            = (astroHA / (2 * Math.PI)) * 1440;

            if (double.IsNaN(minHA))
            {
                minHA = noon;
            }

            if (!morning)
            {
                astroTwN = (int)Math.Floor(noon + minHA);
            }
            else
            {
                astroTwN = (int)Math.Floor(noon - minHA);
            }

            if (astroTwN < 0)
            {
                astroTwN = 0;
            }
            if (astroTwN > 1560)
            {
                astroTwN = 1560;
            }

            //Conv to an SDV compat time, then clamp it.
            int     hr       = (int)Math.Floor(astroTwN / 60.0);
            int     min      = astroTwN - (hr * 60);
            SDVTime calcTime = new SDVTime(hr, min);

            calcTime.ClampToTenMinutes();
            return(calcTime);
        }
Beispiel #4
0
        public static void Postfix(ref int __result)
        {
            SDVTime calcTime = DynamicNightTime.GetSunset();

            calcTime.ClampToTenMinutes();

            __result = calcTime.ReturnIntTime();
        }
        public void CreateWeather()
        {
            //set the begin and end time
            SDVTime stormStart = new SDVTime(1150 + (ClimatesOfFerngill.Dice.Next(0, 230)));

            stormStart.ClampToTenMinutes();

            BeginTime = new SDVTime(stormStart);

            //control for more variance
            if (ClimatesOfFerngill.Dice.NextDouble() < ClimatesOfFerngill.WeatherOpt.MoreSevereThunderFrenzyOdds)
            {
                stormStart.AddTime(ClimatesOfFerngill.Dice.Next(240, 380));
            }
            else
            {
                stormStart.AddTime(ClimatesOfFerngill.Dice.Next(30, 190));
            }

            stormStart.ClampToTenMinutes();
            ExpirTime = new SDVTime(stormStart);
        }
Beispiel #6
0
        internal void SetEveningFog()
        {
            SDVTime STime, ETime;

            STime = new SDVTime(Game1.getStartingToGetDarkTime());
            STime.AddTime(Dice.Next(-25, 80));

            ETime = new SDVTime(STime);
            ETime.AddTime(Dice.Next(120, 310));

            STime.ClampToTenMinutes();
            ETime.ClampToTenMinutes();
            this.SetWeatherTime(STime, ETime);
        }
        protected internal static SDVTime GetSolarNoon()
        {
            var    date      = SDate.Now();
            int    dayOfYear = date.DaysSinceStart % 112;
            double noon      = 720 - 10 * Math.Sin(2 * (Math.PI / 112) * (dayOfYear)) + 8 * Math.Sin((Math.PI / 112) * dayOfYear);

            int noonTime = (int)Math.Floor(noon);

            int     hr       = (int)Math.Floor(noonTime / 60.0);
            SDVTime calcTime = new SDVTime(hr, noonTime - (hr * 60));

            calcTime.ClampToTenMinutes();
            return(calcTime);
        }
Beispiel #8
0
        internal void SetEveningFog()
        {
            var sTime = new SDVTime(Game1.getStartingToGetDarkTime());

            sTime.AddTime(ClimatesOfFerngill.Dice.Next(-25, 80));

            var eTime = new SDVTime(sTime);

            eTime.AddTime(ClimatesOfFerngill.Dice.Next(120, 310));

            sTime.ClampToTenMinutes();
            eTime.ClampToTenMinutes();
            SetWeatherTime(sTime, eTime);
        }
        protected internal static SDVTime GetBeginningOfLateAfternoon()
        {
            SDVTime Noon   = GetSolarNoon();
            SDVTime Sunset = GetSunset();

            int numMinutes    = Sunset.GetNumberOfMinutesFromMidnight() - Noon.GetNumberOfMinutesFromMidnight();
            int lateAfternoon = (int)Math.Floor(numMinutes * .62);

            SDVTime LateAfternoon = new SDVTime(Noon);

            LateAfternoon.AddTime(lateAfternoon);
            LateAfternoon.ClampToTenMinutes();

            return(LateAfternoon);
        }
        protected internal static SDVTime GetEndOfEarlyMorning()
        {
            SDVTime Noon    = GetSolarNoon();
            SDVTime Sunrise = GetSunrise();

            int numMinutes        = Noon.GetNumberOfMinutesFromMidnight() - Sunrise.GetNumberOfMinutesFromMidnight();
            int endOfEarlyMorning = (int)Math.Floor(numMinutes * .38);

            SDVTime EndOfEarlyMorning = new SDVTime(Sunrise);

            EndOfEarlyMorning.AddTime(endOfEarlyMorning);
            EndOfEarlyMorning.ClampToTenMinutes();

            return(EndOfEarlyMorning);
        }
Beispiel #11
0
        protected internal static SDVTime GetSolarNoon()
        {
            var    date      = SDate.Now();
            int    dayOfYear = date.DaysSinceStart % 112;
            double lat       = GeneralFunctions.DegreeToRadians(NightConfig.Latitude);

            double solarDeclination = .40927971 * Math.Sin((2 * Math.PI / 112) * (dayOfYear - 1));
            double noon             = 720 - 10 * Math.Sin(4 * (Math.PI / 112) * (dayOfYear - 1)) + 8 * Math.Sin(2 * (Math.PI / 112) * dayOfYear);

            int     noonTime = (int)Math.Floor(noon);
            int     hr       = (int)Math.Floor(noonTime / 60.0);
            SDVTime calcTime = new SDVTime(hr, noonTime - (hr * 60));

            calcTime.ClampToTenMinutes();
            return(calcTime);
        }
        internal void ForceEveningFog()
        {
            //Get fog instance
            List<ISDVWeather> fogWeather = this.GetWeatherMatchingType("Fog");
            foreach (ISDVWeather weat in fogWeather)
            {
                SDVTime BeginTime, ExpirTime;
                BeginTime = new SDVTime(Game1.getStartingToGetDarkTime());
                BeginTime.AddTime(Dice.Next(-15, 90));

                ExpirTime = new SDVTime(BeginTime);
                ExpirTime.AddTime(Dice.Next(120, 310));

                BeginTime.ClampToTenMinutes();
                ExpirTime.ClampToTenMinutes();
                weat.SetWeatherTime(BeginTime, ExpirTime);
            }
        }
        protected internal static SDVTime GetTimeAtHourAngle(double angle, bool morning = true)
        {
            int    astroTwN;
            int    dayOfYear = SDate.Now().DaysSinceStart % 112;
            double lat       = MathHelper.ToRadians((float)NightConfig.Latitude);
            //23.45 deg * sin(2pi / 112 * (dayOfYear - 1))
            double solarDeclination = .40927971 * Math.Sin((2 * Math.PI / 112) * (dayOfYear - 1));
            double noon             = 720 - 10 * Math.Sin(4 * (Math.PI / 112) * (dayOfYear - 1)) + 8 * Math.Sin(2 * (Math.PI / 112) * dayOfYear);
            double astroHA          = Math.Acos((Math.Sin(angle) - Math.Sin(lat) * Math.Sin(solarDeclination)) / (Math.Cos(lat) * Math.Cos(solarDeclination)));
            double minHA            = (astroHA / (2 * Math.PI)) * 1440;

            if (double.IsNaN(minHA))
            {
                minHA = noon;
            }

            if (!morning)
            {
                astroTwN = (int)Math.Floor(noon + minHA);
            }
            else
            {
                astroTwN = (int)Math.Floor(noon - minHA);
            }

            if (astroTwN < 0)
            {
                astroTwN = 0;
            }
            if (astroTwN > 1560)
            {
                astroTwN = 1560;
            }

            //Conv to an SDV compat time, then clamp it.
            int     hr       = (int)Math.Floor(astroTwN / 60.0);
            int     min      = astroTwN - (hr * 60);
            SDVTime calcTime = new SDVTime(hr, min);

            calcTime.ClampToTenMinutes();
            return(calcTime);
        }
Beispiel #14
0
        /// <summary>This function creates the fog </summary>
        public void CreateWeather()
        {
            this.FogAlpha = 1f;
            //First, let's determine the type.
            //... I am a dumb foxgirl. A really dumb one.
            if (Dice.NextDoublePositive() < ModConfig.DarkFogChance && SDate.Now().Day != 1 && SDate.Now().Year != 1 && SDate.Now().Season != "spring")
            {
                CurrentFogType = FogType.Dark;
            }
            else if (Dice.NextDoublePositive() <= .001)
            {
                CurrentFogType = FogType.Blinding;
            }
            else
            {
                CurrentFogType = FogType.Normal;
            }

            //now determine the fog expiration time
            double FogChance = Dice.NextDoublePositive();

            /*
             * So we should rarely have full day fog, and it should on average burn off around 9am.
             * So, the strongest odds should be 820 to 930, with sharply falling off odds until 1200. And then
             * so, extremely rare odds for until 7pm and even rarer than midnight.
             */

            if (FogTimeSpan == SDVTimePeriods.Morning)
            {
                BeginTime = new SDVTime(0600);
                if (FogChance > 0 && FogChance < .25)
                {
                    this.ExpirTime = new SDVTime(830);
                }
                else if (FogChance >= .25 && FogChance < .32)
                {
                    this.ExpirTime = new SDVTime(900);
                }
                else if (FogChance >= .32 && FogChance < .41)
                {
                    this.ExpirTime = new SDVTime(930);
                }
                else if (FogChance >= .41 && FogChance < .55)
                {
                    this.ExpirTime = new SDVTime(950);
                }
                else if (FogChance >= .55 && FogChance < .7)
                {
                    this.ExpirTime = new SDVTime(1040);
                }
                else if (FogChance >= .7 && FogChance < .8)
                {
                    this.ExpirTime = new SDVTime(1120);
                }
                else if (FogChance >= .8 && FogChance < .9)
                {
                    this.ExpirTime = new SDVTime(1200);
                }
                else if (FogChance >= .9 && FogChance < .95)
                {
                    this.ExpirTime = new SDVTime(1220);
                }
                else if (FogChance >= .95 && FogChance < .98)
                {
                    this.ExpirTime = new SDVTime(1300);
                }
                else if (FogChance >= .98 && FogChance < .99)
                {
                    this.ExpirTime = new SDVTime(1910);
                }
                else if (FogChance >= .99)
                {
                    this.ExpirTime = new SDVTime(2400);
                }
            }
            else
            {
                BeginTime = new SDVTime(Game1.getStartingToGetDarkTime());
                BeginTime.AddTime(Dice.Next(-15, 90));

                ExpirTime = new SDVTime(BeginTime);
                ExpirTime.AddTime(Dice.Next(120, 310));

                BeginTime.ClampToTenMinutes();
                ExpirTime.ClampToTenMinutes();
            }

            if (SDVTime.CurrentTime >= BeginTime)
            {
                UpdateStatus(WeatherType, true);
            }
        }
Beispiel #15
0
        /// <summary>This function creates the fog </summary>
        public void CreateWeather()
        {
            SetFogTargetAlpha();
            this.FogAlpha  = this.FogTargetAlpha;
            CurrentFogType = FogType.Normal;

            //now determine the fog expiration time
            double FogChance = ClimatesOfFerngill.Dice.NextDoublePositive();

            /*
             * So we should rarely have full day fog, and it should on average burn off around 9am.
             * So, the strongest odds should be 820 to 930, with sharply falling off odds until 1200. And then
             * so, extremely rare odds for until 7pm and even rarer than midnight.
             */

            if (FogTimeSpan == SDVTimePeriods.Morning)
            {
                BeginTime = new SDVTime(0600);
                if (FogChance > 0 && FogChance < .25)
                {
                    this.ExpirTime = new SDVTime(830);
                }
                else if (FogChance >= .25 && FogChance < .32)
                {
                    this.ExpirTime = new SDVTime(900);
                }
                else if (FogChance >= .32 && FogChance < .41)
                {
                    this.ExpirTime = new SDVTime(930);
                }
                else if (FogChance >= .41 && FogChance < .55)
                {
                    this.ExpirTime = new SDVTime(950);
                }
                else if (FogChance >= .55 && FogChance < .7)
                {
                    this.ExpirTime = new SDVTime(1040);
                }
                else if (FogChance >= .7 && FogChance < .8)
                {
                    this.ExpirTime = new SDVTime(1120);
                }
                else if (FogChance >= .8 && FogChance < .9)
                {
                    this.ExpirTime = new SDVTime(1200);
                }
                else if (FogChance >= .9 && FogChance < .95)
                {
                    this.ExpirTime = new SDVTime(1220);
                }
                else if (FogChance >= .95 && FogChance < .98)
                {
                    this.ExpirTime = new SDVTime(1300);
                }
                else if (FogChance >= .98 && FogChance < .99)
                {
                    this.ExpirTime = new SDVTime(1910);
                }
                else if (FogChance >= .99)
                {
                    this.ExpirTime = new SDVTime(2400);
                }
            }
            else
            {
                BeginTime = new SDVTime(Game1.getModeratelyDarkTime());
                BeginTime.AddTime(ClimatesOfFerngill.Dice.Next(-15, 90));

                ExpirTime = new SDVTime(BeginTime);
                ExpirTime.AddTime(ClimatesOfFerngill.Dice.Next(120, 310));

                BeginTime.ClampToTenMinutes();
                ExpirTime.ClampToTenMinutes();
            }

            if (SDVTime.CurrentTime >= BeginTime)
            {
                UpdateStatus(WeatherType, true);
            }
        }