<commit_before>﻿using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using System.Timers;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using Nini.Config;
using log4net;
using Aurora.DataManager;
using Aurora.Framework;
using Mono.Addins;
using OpenMetaverse;

namespace Aurora.Modules
{
    [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
    public class WeatherModule : ISharedRegionModule
    {
        #region ISharedRegionModule Members
        private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

        private Timer timer = new Timer();
        private List<Scene> Scenes = new List<Scene>();
        private WeatherType CurrentWeather = WeatherType.Realistic;
        private bool Clouds = true;

        public void Initialise(IConfigSource source)
        {
            timer.Interval = 10000;
            timer.Enabled = true;
            timer.Elapsed += new ElapsedEventHandler(GenerateNewWindlightProfiles);
            timer.Start();
        }

        public void Close()
        {

        }

        public void AddRegion(Scene scene)
        {
            Scenes.Add(scene);
            scene.AddCommand(this, "change weather", "Changes weather", "Changes the weather in the current region", ConsoleChangeWeather);
        }

        public void RemoveRegion(Scene scene)
        {

        }

        public void RegionLoaded(Scene scene)
        {

        }

        public void ConsoleChangeWeather(string module, string[] cmdparams)
        {
            string WeatherType = "";
            string Region = "";
            while (true)
            {
                Region = MainConsole.Instance.CmdPrompt("Region", "None");
                if (Region == "None")
                    m_log.Info("No region selected. Please try again");
                else
                {
                    bool found = false;
                    foreach (Scene scene in Scenes)
                    {
                        if (scene.RegionInfo.RegionName == Region)
                        {
                            found = true;
                            break;
                        }
                    }
                    if (found) break;
                    m_log.Info("No region found. Please try again");
                }
            }
            WeatherType = MainConsole.Instance.CmdPrompt("Weather Type", "0");

            CurrentWeather = (WeatherType)int.Parse(WeatherType);
            GenerateNewWindlightProfiles();
        }



        private void GenerateNewWindlightProfiles()
        {
            if (CurrentWeather == WeatherType.AlwaysRandom)
            {
                
            }
        }

        void GenerateNewWindlightProfiles(object sender, ElapsedEventArgs e)
        {
            GenerateNewWindlightProfiles();
        }

        public void PostInitialise() { }

        public string Name
        {
            get { return "WeatherModule"; }
        }

        public Type ReplaceableInterface
        {
            get { return null; }
        }

        #endregion
    }

    private class WeatherInRegion
    {
        public bool CurrentlyCloudy = false;
        public bool CurrentlySunny = false;
        public bool NextCloudy = false;
        public bool NextSunny = false;
        public bool CurrentlyFoggy = false;
        public bool NextFoggy = false;
        public bool CurrentRainy = false;
        public bool NextRainy = false;
        //Temperary until I can get the wind from the wind module.
        public Vector2 CurrentWindDirection = Vector2.Zero;
        public Vector2 NextWindDirection = Vector2.Zero;

        public void Randomize()
        {
            Random random = new Random();

            int randomnum = random.Next(1);
            CurrentlyCloudy = randomnum == 1;

            randomnum = random.Next(1);
            CurrentlySunny = randomnum == 1;

            randomnum = random.Next(1);
            NextCloudy = randomnum == 1;

            randomnum = random.Next(1);
            NextSunny = randomnum == 1;

            randomnum = random.Next(1);
            CurrentlyFoggy = randomnum == 1;

            randomnum = random.Next(1);
            NextFoggy = randomnum == 1;

            randomnum = random.Next(1);
            CurrentRainy = randomnum == 1;

            randomnum = random.Next(1);
            NextRainy = randomnum == 1;
        }

        public void MakeRegionWindLightData(Scene scene, RegionLightShareData RLS)
        {
            Random random = new Random();
            if (NextSunny)
            {
                RLS.cloudCoverage -= .05f;
                if (random.Next(0, 1) == 1)
                    RLS.cloudScale += .025f;
                else
                    RLS.cloudScale -= .025f;
            }
            if (CurrentlySunny && !NextSunny)
            {
                RLS.cloudCoverage -= .05f;
            }

            #region Fog

            if (CurrentlyFoggy)
            {
                RLS.densityMultiplier += .1f;
                RLS.distanceMultiplier += 10;
            }
            if (CurrentlyFoggy && !NextFoggy)
            {
                RLS.distanceMultiplier -= 5;<commit_msg>Adds more sun pos, star, rain, and sunshine changes to the weather module.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using System.Timers;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using Nini.Config;
using log4net;
using Aurora.DataManager;
using Aurora.Framework;
using Mono.Addins;
using OpenMetaverse;

namespace Aurora.Modules
{
    [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
    public class WeatherModule : ISharedRegionModule
    {
        #region ISharedRegionModule Members
        private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

        private Timer timer = new Timer();
        private List<Scene> Scenes = new List<Scene>();
        private WeatherType CurrentWeather = WeatherType.Realistic;
        private bool Clouds = true;

        public void Initialise(IConfigSource source)
        {
            timer.Interval = 10000;
            timer.Enabled = true;
            timer.Elapsed += new ElapsedEventHandler(GenerateNewWindlightProfiles);
            timer.Start();
        }

        public void Close()
        {

        }

        public void AddRegion(Scene scene)
        {
            Scenes.Add(scene);
            scene.AddCommand(this, "change weather", "Changes weather", "Changes the weather in the current region", ConsoleChangeWeather);
        }

        public void RemoveRegion(Scene scene)
        {

        }

        public void RegionLoaded(Scene scene)
        {

        }

        public void ConsoleChangeWeather(string module, string[] cmdparams)
        {
            string WeatherType = "";
            string Region = "";
            while (true)
            {
                Region = MainConsole.Instance.CmdPrompt("Region", "None");
                if (Region == "None")
                    m_log.Info("No region selected. Please try again");
                else
                {
                    bool found = false;
                    foreach (Scene scene in Scenes)
                    {
                        if (scene.RegionInfo.RegionName == Region)
                        {
                            found = true;
                            break;
                        }
                    }
                    if (found) break;
                    m_log.Info("No region found. Please try again");
                }
            }
            WeatherType = MainConsole.Instance.CmdPrompt("Weather Type", "0");

            CurrentWeather = (WeatherType)int.Parse(WeatherType);
            GenerateNewWindlightProfiles();
        }



        private void GenerateNewWindlightProfiles()
        {
            if (CurrentWeather == WeatherType.AlwaysRandom)
            {
                
            }
        }

        void GenerateNewWindlightProfiles(object sender, ElapsedEventArgs e)
        {
            GenerateNewWindlightProfiles();
        }

        public void PostInitialise() { }

        public string Name
        {
            get { return "WeatherModule"; }
        }

        public Type ReplaceableInterface
        {
            get { return null; }
        }

        #endregion
    }

    private class WeatherInRegion
    {
        public bool CurrentlyCloudy = false;
        public bool CurrentlySunny = false;
        public bool NextCloudy = false;
        public bool NextSunny = false;
        public bool CurrentlyFoggy = false;
        public bool NextFoggy = false;
        public bool CurrentRainy = false;
        public bool NextRainy = false;
        //Temperary until I can get the wind from the wind module.
        public Vector2 CurrentWindDirection = Vector2.Zero;
        public Vector2 NextWindDirection = Vector2.Zero;

        public void Randomize()
        {
            Random random = new Random();

            int randomnum = random.Next(1);
            CurrentlyCloudy = randomnum == 1;

            randomnum = random.Next(1);
            CurrentlySunny = randomnum == 1;

            randomnum = random.Next(1);
            NextCloudy = randomnum == 1;

            randomnum = random.Next(1);
            NextSunny = randomnum == 1;

            randomnum = random.Next(1);
            CurrentlyFoggy = randomnum == 1;

            randomnum = random.Next(1);
            NextFoggy = randomnum == 1;

            randomnum = random.Next(1);
            CurrentRainy = randomnum == 1;

            randomnum = random.Next(1);
            NextRainy = randomnum == 1;
        }

        public void MakeRegionWindLightData(Scene scene, RegionLightShareData RLS)
        {
            #region Sun position and star brightness
            RLS.sunMoonPosition += .1f;
            if (RLS.sunMoonPosition > 1)
                RLS.sunMoonPosition = 0;
            if (RLS.sunMoonPosition > .5f)
                RLS.starBrightness += .5f;
            else
                RLS.starBrightness -= .5f;
            if (RLS.starBrightness > 2)
                RLS.starBrightness = 2;
            if (RLS.starBrightness < 0)
                RLS.starBrightness = 0;

            #endregion

            #region Sunny and clouds

            Random random = new Random();
            if (NextSunny)
            {
                RLS.cloudCoverage -= .05f;
                if (random.Next(0, 1) == 1)
                {
                    RLS.cloudScale += .025f;
                }
                else
                {
                    RLS.cloudScale -= .025f;
                }
            }
            if (CurrentlySunny && !NextSunny)
            {
                RLS.cloudCoverage += .05f;
            }
            if (CurrentlySunny && NextSunny)
            {
                //Clear ambient light changes.
                RLS.ambient.W = .4f;
            }
            
            #endregion

            #region Rain

            if (CurrentRainy)
            {
                RLS.ambient.W -= .1f;
                RLS.sceneGamma -= .05f;
            }
            if (NextSunny && CurrentRainy)
            {
                RLS.ambient.W += .1f;
                RLS.sceneGamma += .05f;
            }
            if (CurrentRainy && NextRainy)
            {
                RLS.ambient.W -= .05f;
            }

            #endregion

            #region Fog

            if (CurrentlyFoggy)
            {
                RLS.densityMultiplier += .1f;
                RLS.distanceMultiplier += 10;
            }
            if (CurrentlyFoggy && !NextFoggy)
            {
                RLS.distanceMultiplier -= 5;
{'fraction_non_alphanumeric': 0.08251945042211555, 'fraction_numerical': 0.008856149644098659, 'mean_word_length': 1.4297204906495073, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4901048', 'n_tokens_mistral': 3237, 'n_tokens_neox': 2992, 'n_words': 746}