Esempio n. 1
0
 public float WindParamGet(string plugin, string param)
 {
     if (m_availableWindPlugins.ContainsKey(plugin))
     {
         IWindModelPlugin windPlugin = m_availableWindPlugins [plugin];
         return(windPlugin.WindParamGet(param));
     }
     throw new Exception(String.Format("Could not find plugin {0}", plugin));
 }
Esempio n. 2
0
        /// <summary>
        /// Called to change the active wind model plugin
        /// </summary>
        private void HandleConsoleBaseCommand(string module, string[] cmdparams)
        {
            ValidateConsole();

            if ((cmdparams.Length != 4) ||
                !cmdparams[1].Equals("base"))
            {
                MainConsole.Instance.Output(
                    "Invalid parameters to change parameters for Wind module base, usage: wind base <parameter> <value>");

                return;
            }

            switch (cmdparams[2])
            {
            case "wind_update_rate":
                int newRate = 1;

                if (int.TryParse(cmdparams[3], out newRate))
                {
                    m_frameUpdateRate = newRate;
                }
                else
                {
                    MainConsole.Instance.Output(
                        "Invalid value {0} specified for {1}", cmdparams[3], cmdparams[2]);

                    return;
                }

                break;

            case "wind_plugin":
                string desiredPlugin = cmdparams[3];

                if (desiredPlugin.Equals(m_activeWindPlugin.Name))
                {
                    MainConsole.Instance.Output("Wind model plugin {0} is already active", cmdparams[3]);

                    return;
                }

                if (m_availableWindPlugins.ContainsKey(desiredPlugin))
                {
                    m_activeWindPlugin = m_availableWindPlugins[cmdparams[3]];

                    MainConsole.Instance.Output("{0} wind model plugin now active", m_activeWindPlugin.Name);
                }
                else
                {
                    MainConsole.Instance.Output("Could not find wind model plugin {0}", desiredPlugin);
                }
                break;
            }
        }
Esempio n. 3
0
 public void WindParamSet(string plugin, string param, float value)
 {
     if (m_availableWindPlugins.ContainsKey(plugin))
     {
         IWindModelPlugin windPlugin = m_availableWindPlugins[plugin];
         windPlugin.WindParamSet(param, value);
     }
     else
     {
         throw new Exception(String.Format("Could not find plugin {0}", plugin));
     }
 }
Esempio n. 4
0
        public void RemoveRegion(IScene scene)
        {
            if (m_enabled)
            {
                m_ready = false;

                m_activeWindPlugin = null;

                m_availableWindPlugins.Clear();

                //  Remove our hooks
                m_scene.EventManager.OnFrame         -= WindUpdate;
                m_scene.EventManager.OnMakeRootAgent -= OnAgentEnteredRegion;
            }
        }
Esempio n. 5
0
        public void Close()
        {
            if (m_enabled)
            {
                m_ready = false;

                // REVIEW: If a region module is closed, is there a possibility that it'll re-open/initialize ??
                if (m_activeWindPlugin != null)
                {
                    m_activeWindPlugin.Dispose();
                    m_activeWindPlugin = null;
                }

                //  Remove our hooks
                m_scene.EventManager.OnFrame         -= WindUpdate;
                m_scene.EventManager.OnMakeRootAgent -= OnAgentEnteredRegion;
            }
        }
Esempio n. 6
0
        public void RemoveRegion(Scene scene)
        {
            if (m_enabled)
            {
                m_ready = false;

                m_activeWindPlugin = null;
                foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values)
                {
                    windPlugin.Dispose();
                }

                m_availableWindPlugins.Clear();

                //  Remove our hooks
                m_scene.EventManager.OnFrame         -= WindUpdate;
                m_scene.EventManager.OnMakeRootAgent -= OnAgentEnteredRegion;
            }
        }
Esempio n. 7
0
        public void Close()
        {
            if (m_enabled)
            {
                m_ready = false;

                // REVIEW: If a region module is closed, is there a possibility that it'll re-open/initialize ??
                m_activeWindPlugin = null;
                foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values)
                {
                    windPlugin.Dispose();
                }

                m_availableWindPlugins.Clear();

                //  Remove our hooks
                m_scene.EventManager.OnFrame         -= WindUpdate;
                m_scene.EventManager.OnMakeRootAgent -= OnAgentEnteredRegion;
            }
        }
Esempio n. 8
0
        public void AddRegion(IScene scene)
        {
            m_scene = scene;
            if (m_enabled)
            {
                //MainConsole.Instance.InfoFormat("[WIND] Enabled with an update rate of {0} frames.", m_frameUpdateRate);

                m_frame = 0;

                // Register all the Wind Model Plug-ins
                foreach (IWindModelPlugin windPlugin in WhiteCoreModuleLoader.PickupModules<IWindModelPlugin>())
                {
                    //MainConsole.Instance.InfoFormat("[WIND] Found Plugin: {0}", windPlugin.Name);
                    m_availableWindPlugins.Add(windPlugin.Name, windPlugin);
                }

                // Check for desired plugin
                if (m_availableWindPlugins.ContainsKey(desiredWindPlugin))
                {
                    m_activeWindPlugin = m_availableWindPlugins[desiredWindPlugin];

                    //MainConsole.Instance.InfoFormat("[WIND] {0} plugin found, initializing.", desiredWindPlugin);

                    if (windConfig != null)
                    {
                        m_activeWindPlugin.Initialise();
                        m_activeWindPlugin.WindConfig(m_scene, windConfig);
                    }
                }

                // if the plug-in wasn't found, default to no wind.
                if (m_activeWindPlugin == null)
                {
                    MainConsole.Instance.ErrorFormat("[WIND] Could not find specified wind plug-in: {0}",
                                                     desiredWindPlugin);
                    MainConsole.Instance.ErrorFormat("[WIND] Defaulting to no wind.");
                }

                if (MainConsole.Instance != null)
                {
                    // Get a list of the parameters for each plugin
                    foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values)
                    {
                        MainConsole.Instance.Commands.AddCommand(
                            String.Format("wind base wind_plugin {0}", windPlugin.Name),
                            String.Format("{0} - {1}", windPlugin.Name, windPlugin.Description), "",
                            HandleConsoleBaseCommand, true, false);
                        MainConsole.Instance.Commands.AddCommand(
                            String.Format("wind base wind_update_rate"), "Change the wind update rate.", "",
                            HandleConsoleBaseCommand, true, false);

                        foreach (KeyValuePair<string, string> kvp in windPlugin.WindParams())
                        {
                            MainConsole.Instance.Commands.AddCommand(
                                String.Format("wind {0} {1}", windPlugin.Name, kvp.Key),
                                String.Format("{0} : {1} - {2}", windPlugin.Name, kvp.Key, kvp.Value), "",
                                HandleConsoleParamCommand, true, false);
                        }
                    }
                }

                // Register event handlers for when Avatars enter the region, and frame ticks
                m_scene.EventManager.OnFrame += WindUpdate;
                m_scene.EventManager.OnMakeRootAgent += OnAgentEnteredRegion;

                // Register the wind module
                m_scene.RegisterModuleInterface<IWindModule>(this);

                // Generate initial wind values
                GenWindPos();

                // Mark Module Ready for duty
                m_ready = true;
            }
        }
Esempio n. 9
0
        public void AddRegion(Scene scene)
        {
            if (!m_enabled)
            {
                return;
            }

            m_scene = scene;
            m_frame = 0;
            // Register all the Wind Model Plug-ins
            foreach (IWindModelPlugin windPlugin in AddinManager.GetExtensionObjects("/OpenSim/WindModule", false))
            {
                m_log.InfoFormat("[WIND] Found Plugin: {0}", windPlugin.Name);
                m_availableWindPlugins.Add(windPlugin.Name, windPlugin);
            }

            // Check for desired plugin
            if (m_availableWindPlugins.ContainsKey(m_dWindPluginName))
            {
                m_activeWindPlugin = m_availableWindPlugins[m_dWindPluginName];

                m_log.InfoFormat("[WIND] {0} plugin found, initializing.", m_dWindPluginName);

                if (m_windConfig != null)
                {
                    m_activeWindPlugin.Initialise();
                    m_activeWindPlugin.WindConfig(m_scene, m_windConfig);
                }
            }

            // if the plug-in wasn't found, default to no wind.
            if (m_activeWindPlugin == null)
            {
                m_log.ErrorFormat("[WIND] Could not find specified wind plug-in: {0}", m_dWindPluginName);
                m_log.ErrorFormat("[WIND] Defaulting to no wind.");
            }

            // This one puts an entry in the main help screen
            //                m_scene.AddCommand("Regions", this, "wind", "wind", "Usage: wind <plugin> <param> [value] - Get or Update Wind paramaters", null);

            // This one enables the ability to type just the base command without any parameters
            //                m_scene.AddCommand("Regions", this, "wind", "", "", HandleConsoleCommand);

            // Get a list of the parameters for each plugin
            foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values)
            {
                //                    m_scene.AddCommand("Regions", this, String.Format("wind base wind_plugin {0}", windPlugin.Name), String.Format("{0} - {1}", windPlugin.Name, windPlugin.Description), "", HandleConsoleBaseCommand);
                m_scene.AddCommand(
                    "Regions",
                    this,
                    "wind base wind_update_rate",
                    "wind base wind_update_rate [<value>]",
                    "Get or set the wind update rate.",
                    "",
                    HandleConsoleBaseCommand);

                foreach (KeyValuePair <string, string> kvp in windPlugin.WindParams())
                {
                    string windCommand = String.Format("wind {0} {1}", windPlugin.Name, kvp.Key);
                    m_scene.AddCommand("Regions", this, windCommand, string.Format("{0} [<value>]", windCommand), kvp.Value, "", HandleConsoleParamCommand);
                }
            }

            // Register event handlers for when Avatars enter the region, and frame ticks
            m_scene.EventManager.OnFrame += WindUpdate;

            // Register the wind module
            m_scene.RegisterModuleInterface <IWindModule>(this);

            // Generate initial wind values
            GenWind();
            // hopefully this will not be the same for all regions on same instance
            m_dataVersion = m_scene.AllocateIntId();
            // Mark Module Ready for duty
            m_ready = true;
        }
Esempio n. 10
0
        public void AddRegion(IScene scene)
        {
            m_scene = scene;
            if (m_enabled)
            {
                //MainConsole.Instance.InfoFormat("[WIND] Enabled with an update rate of {0} frames.", m_frameUpdateRate);

                m_frame = 0;

                // Register all the Wind Model Plug-ins
                foreach (IWindModelPlugin windPlugin in AuroraModuleLoader.PickupModules <IWindModelPlugin>())
                {
                    //MainConsole.Instance.InfoFormat("[WIND] Found Plugin: {0}", windPlugin.Name);
                    m_availableWindPlugins.Add(windPlugin.Name, windPlugin);
                }

                // Check for desired plugin
                if (m_availableWindPlugins.ContainsKey(desiredWindPlugin))
                {
                    m_activeWindPlugin = m_availableWindPlugins[desiredWindPlugin];

                    //MainConsole.Instance.InfoFormat("[WIND] {0} plugin found, initializing.", desiredWindPlugin);

                    if (windConfig != null)
                    {
                        m_activeWindPlugin.Initialise();
                        m_activeWindPlugin.WindConfig(m_scene, windConfig);
                    }
                }


                // if the plug-in wasn't found, default to no wind.
                if (m_activeWindPlugin == null)
                {
                    MainConsole.Instance.ErrorFormat("[WIND] Could not find specified wind plug-in: {0}",
                                                     desiredWindPlugin);
                    MainConsole.Instance.ErrorFormat("[WIND] Defaulting to no wind.");
                }

                if (MainConsole.Instance != null)
                {
                    // Get a list of the parameters for each plugin
                    foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values)
                    {
                        MainConsole.Instance.Commands.AddCommand(
                            String.Format("wind base wind_plugin {0}", windPlugin.Name),
                            String.Format("{0} - {1}", windPlugin.Name, windPlugin.Description), "",
                            HandleConsoleBaseCommand);
                        MainConsole.Instance.Commands.AddCommand(
                            String.Format("wind base wind_update_rate"), "Change the wind update rate.", "",
                            HandleConsoleBaseCommand);

                        foreach (KeyValuePair <string, string> kvp in windPlugin.WindParams())
                        {
                            MainConsole.Instance.Commands.AddCommand(
                                String.Format("wind {0} {1}", windPlugin.Name, kvp.Key),
                                String.Format("{0} : {1} - {2}", windPlugin.Name, kvp.Key, kvp.Value), "",
                                HandleConsoleParamCommand);
                        }
                    }
                }


                // Register event handlers for when Avatars enter the region, and frame ticks
                m_scene.EventManager.OnFrame         += WindUpdate;
                m_scene.EventManager.OnMakeRootAgent += OnAgentEnteredRegion;

                // Register the wind module
                m_scene.RegisterModuleInterface <IWindModule>(this);

                // Generate initial wind values
                GenWindPos();

                // Mark Module Ready for duty
                m_ready = true;
            }
        }
        public void Initialise(Scene scene, IConfigSource config)
        {
            string desiredWindPlugin = DEFAULT_WIND_PLUGIN;

            IConfig windConfig = config.Configs["Wind"];
            if (windConfig != null)
            {
                m_enabled = windConfig.GetBoolean("enabled", true);
                m_frameUpdateRate = windConfig.GetInt("wind_update_rate", 150);

                // Determine which wind model plugin is desired
                if (windConfig.Contains("wind_plugin"))
                    desiredWindPlugin = windConfig.GetString("wind_plugin");
            }

            if (m_enabled)
            {
                m_log.InfoFormat("[WIND] Enabled with an update rate of {0} frames.", m_frameUpdateRate);

                m_scene = scene;
                m_frame = 0;

                if (windConfig != null)
                {
                    CompositionContainer moduleContainer = scene.ModuleContainer;
                    IEnumerable<Lazy<object, object>> exportEnumerable = moduleContainer.GetExports(typeof(IPlugin), null, null);

                    foreach (Lazy<object, object> lazyExport in exportEnumerable)
                    {
                        IDictionary<string, object> metadata = (IDictionary<string, object>)lazyExport.Metadata;
                        object nameObj;
                        if (metadata.TryGetValue("Name", out nameObj))
                        {
                            string name = (string)nameObj;
                            if (name.Equals(desiredWindPlugin, StringComparison.InvariantCultureIgnoreCase) && lazyExport.Value is IWindModelPlugin)
                            {
                                m_log.InfoFormat("[WIND] {0} plugin found, initializing.", desiredWindPlugin);

                                m_activeWindPlugin = (IWindModelPlugin)lazyExport.Value;
                                m_activeWindPlugin.Initialise();
                                m_activeWindPlugin.WindConfig(m_scene, windConfig);
                                break;
                            }
                        }
                    }
                }

                // if the plug-in wasn't found, default to no wind.
                if (m_activeWindPlugin == null)
                {
                    m_log.ErrorFormat("[WIND] Could not find specified wind plug-in: {0}", desiredWindPlugin);
                    m_log.ErrorFormat("[WIND] Defaulting to no wind.");
                }

                // This one puts an entry in the main help screen
                m_scene.AddCommand(this, String.Empty, "wind", "Usage: wind <param> [value] - Get or Update Wind paramaters", null);
                
                // This one enables the ability to type just the base command without any parameters
                m_scene.AddCommand(this, "wind", "", "", HandleConsoleCommand);

                // Get a list of the parameters for the plugin
                if (m_activeWindPlugin != null)
                {
                    m_scene.AddCommand(this, String.Format("wind wind_update_rate"), "Change the wind update rate.", "", HandleConsoleBaseCommand);

                    foreach (KeyValuePair<string, string> kvp in m_activeWindPlugin.WindParams())
                    {
                        m_scene.AddCommand(this, String.Format("wind {0} {1}", m_activeWindPlugin.Name, kvp.Key),
                            String.Format("{0} : {1} - {2}", m_activeWindPlugin.Name, kvp.Key, kvp.Value), "", HandleConsoleParamCommand);
                    }
                }

                // Register event handlers for when Avatars enter the region, and frame ticks
                m_scene.EventManager.OnFrame += WindUpdate;
                m_scene.EventManager.OnMakeRootAgent += OnAgentEnteredRegion;

                // Register the wind module 
                m_scene.RegisterModuleInterface<IWindModule>(this);

                // Generate initial wind values
                GenWindPos();

                // Mark Module Ready for duty
                m_ready = true;
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Called to change the active wind model plugin
        /// </summary>
        private void HandleConsoleBaseCommand(string module, string[] cmdparams)
        {
            ValidateConsole();

            if ((cmdparams.Length != 4)
                || !cmdparams[1].Equals("base"))
            {
                m_log.Info("[WIND] Invalid parameters to change parameters for Wind module base, usage: wind base <parameter> <value>");
                return;
            }

            switch (cmdparams[2])
            {
                case "wind_update_rate":
                    int newRate = 1;

                    if (int.TryParse(cmdparams[3], out newRate))
                    {
                        m_frameUpdateRate = newRate;
                    }
                    else
                    {
                        m_log.InfoFormat("[WIND] Invalid value {0} specified for {1}", cmdparams[3], cmdparams[2]);
                        return;
                    }

                    break;
                case "wind_plugin":
                    string desiredPlugin = cmdparams[3];

                    if (desiredPlugin.Equals(m_activeWindPlugin.Name))
                    {
                        m_log.InfoFormat("[WIND] Wind model plugin {0} is already active", cmdparams[3]);
                        return;
                    }

                    if (m_availableWindPlugins.ContainsKey(desiredPlugin))
                    {
                        m_activeWindPlugin = m_availableWindPlugins[cmdparams[3]];
                        m_log.InfoFormat("[WIND] {0} wind model plugin now active", m_activeWindPlugin.Name);
                    }
                    else
                    {
                        m_log.InfoFormat("[WIND] Could not find wind model plugin {0}", desiredPlugin);
                    }
                    break;
            }

        }
Esempio n. 13
0
        public void AddRegion(Scene scene)
        {
            if (!m_enabled)
                return;

            m_scene = scene;
            m_frame = 0;

            // Register all the Wind Model Plug-ins
            foreach (IWindModelPlugin windPlugin in AddinManager.GetExtensionObjects("/OpenSim/WindModule", false))
            {
                m_log.InfoFormat("[WIND] Found Plugin: {0}", windPlugin.Name);
                m_availableWindPlugins.Add(windPlugin.Name, windPlugin);
            }

            // Check for desired plugin
            if (m_availableWindPlugins.ContainsKey(m_dWindPluginName))
            {
                m_activeWindPlugin = m_availableWindPlugins[m_dWindPluginName];

                m_log.InfoFormat("[WIND] {0} plugin found, initializing.", m_dWindPluginName);

                if (m_windConfig != null)
                {
                    m_activeWindPlugin.Initialise();
                    m_activeWindPlugin.WindConfig(m_scene, m_windConfig);
                }
            }


            // if the plug-in wasn't found, default to no wind.
            if (m_activeWindPlugin == null)
            {
                m_log.ErrorFormat("[WIND] Could not find specified wind plug-in: {0}", m_dWindPluginName);
                m_log.ErrorFormat("[WIND] Defaulting to no wind.");
            }

            // This one puts an entry in the main help screen
            //                m_scene.AddCommand("Regions", this, "wind", "wind", "Usage: wind <plugin> <param> [value] - Get or Update Wind paramaters", null);

            // This one enables the ability to type just the base command without any parameters
            //                m_scene.AddCommand("Regions", this, "wind", "", "", HandleConsoleCommand);

            // Get a list of the parameters for each plugin
            foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values)
            {
                //                    m_scene.AddCommand("Regions", this, String.Format("wind base wind_plugin {0}", windPlugin.Name), String.Format("{0} - {1}", windPlugin.Name, windPlugin.Description), "", HandleConsoleBaseCommand);
                m_scene.AddCommand(
                    "Regions",
                    this,
                    "wind base wind_update_rate",
                    "wind base wind_update_rate [<value>]",
                    "Get or set the wind update rate.",
                    "",
                    HandleConsoleBaseCommand);

                foreach (KeyValuePair<string, string> kvp in windPlugin.WindParams())
                {
                    string windCommand = String.Format("wind {0} {1}", windPlugin.Name, kvp.Key);
                    m_scene.AddCommand("Regions", this, windCommand, string.Format("{0} [<value>]", windCommand), kvp.Value, "", HandleConsoleParamCommand);
                }
            }

            // Register event handlers for when Avatars enter the region, and frame ticks
            m_scene.EventManager.OnFrame += WindUpdate;
            m_scene.EventManager.OnMakeRootAgent += OnAgentEnteredRegion;

            // Register the wind module 
            m_scene.RegisterModuleInterface<IWindModule>(this);

            // Generate initial wind values
            GenWindPos();

            // Mark Module Ready for duty
            m_ready = true;
        }
Esempio n. 14
0
        public void Initialise(Scene scene, IConfigSource config)
        {
            string desiredWindPlugin = DEFAULT_WIND_PLUGIN;

            IConfig windConfig = config.Configs["Wind"];

            if (windConfig != null)
            {
                m_enabled         = windConfig.GetBoolean("enabled", true);
                m_frameUpdateRate = windConfig.GetInt("wind_update_rate", 150);

                // Determine which wind model plugin is desired
                if (windConfig.Contains("wind_plugin"))
                {
                    desiredWindPlugin = windConfig.GetString("wind_plugin");
                }
            }

            if (m_enabled)
            {
                m_log.InfoFormat("[WIND] Enabled with an update rate of {0} frames.", m_frameUpdateRate);

                m_scene = scene;
                m_frame = 0;

                if (windConfig != null)
                {
                    CompositionContainer moduleContainer = scene.ModuleContainer;
                    IEnumerable <Lazy <object, object> > exportEnumerable = moduleContainer.GetExports(typeof(IPlugin), null, null);

                    foreach (Lazy <object, object> lazyExport in exportEnumerable)
                    {
                        IDictionary <string, object> metadata = (IDictionary <string, object>)lazyExport.Metadata;
                        object nameObj;
                        if (metadata.TryGetValue("Name", out nameObj))
                        {
                            string name = (string)nameObj;
                            if (name.Equals(desiredWindPlugin, StringComparison.InvariantCultureIgnoreCase) && lazyExport.Value is IWindModelPlugin)
                            {
                                m_log.InfoFormat("[WIND] {0} plugin found, initializing.", desiredWindPlugin);

                                m_activeWindPlugin = (IWindModelPlugin)lazyExport.Value;
                                m_activeWindPlugin.Initialise();
                                m_activeWindPlugin.WindConfig(m_scene, windConfig);
                                break;
                            }
                        }
                    }
                }

                // if the plug-in wasn't found, default to no wind.
                if (m_activeWindPlugin == null)
                {
                    m_log.ErrorFormat("[WIND] Could not find specified wind plug-in: {0}", desiredWindPlugin);
                    m_log.ErrorFormat("[WIND] Defaulting to no wind.");
                }

                // This one puts an entry in the main help screen
                m_scene.AddCommand(this, String.Empty, "wind", "Usage: wind <param> [value] - Get or Update Wind paramaters", null);

                // This one enables the ability to type just the base command without any parameters
                m_scene.AddCommand(this, "wind", "", "", HandleConsoleCommand);

                // Get a list of the parameters for the plugin
                if (m_activeWindPlugin != null)
                {
                    m_scene.AddCommand(this, String.Format("wind wind_update_rate"), "Change the wind update rate.", "", HandleConsoleBaseCommand);

                    foreach (KeyValuePair <string, string> kvp in m_activeWindPlugin.WindParams())
                    {
                        m_scene.AddCommand(this, String.Format("wind {0} {1}", m_activeWindPlugin.Name, kvp.Key),
                                           String.Format("{0} : {1} - {2}", m_activeWindPlugin.Name, kvp.Key, kvp.Value), "", HandleConsoleParamCommand);
                    }
                }

                // Register event handlers for when Avatars enter the region, and frame ticks
                m_scene.EventManager.OnFrame         += WindUpdate;
                m_scene.EventManager.OnMakeRootAgent += OnAgentEnteredRegion;

                // Register the wind module
                m_scene.RegisterModuleInterface <IWindModule>(this);

                // Generate initial wind values
                GenWindPos();

                // Mark Module Ready for duty
                m_ready = true;
            }
        }
Esempio n. 15
0
        public void RemoveRegion(Scene scene)
        {
            if (m_enabled)
            {
                m_ready = false;

                m_activeWindPlugin = null;
                foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values)
                {
                    windPlugin.Dispose();
                }

                m_availableWindPlugins.Clear();

                //  Remove our hooks
                m_scene.EventManager.OnFrame -= WindUpdate;
                m_scene.EventManager.OnMakeRootAgent -= OnAgentEnteredRegion;
            }
        }
Esempio n. 16
0
        public void RemoveRegion(IScene scene)
        {
            if (m_enabled)
            {
                m_ready = false;

                m_activeWindPlugin = null;

                m_availableWindPlugins.Clear();

                //  Remove our hooks
                m_scene.EventManager.OnFrame -= WindUpdate;
                m_scene.EventManager.OnMakeRootAgent -= OnAgentEnteredRegion;
            }
        }
Esempio n. 17
0
        public void Close()
        {
            if (m_enabled)
            {
                m_ready = false;

                // REVIEW: If a region module is closed, is there a possibility that it'll re-open/initialize ??
                m_activeWindPlugin = null;
                foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values)
                {
                    windPlugin.Dispose();
                }

                m_availableWindPlugins.Clear();

                //  Remove our hooks
                m_scene.EventManager.OnFrame -= WindUpdate;
                m_scene.EventManager.OnMakeRootAgent -= OnAgentEnteredRegion;
            }
        }
Esempio n. 18
0
        public void Initialize(Scene scene, IConfigSource config)
        {
            IConfig windConfig        = config.Configs["Wind"];
            string  desiredWindPlugin = m_dWindPluginName;

            if (windConfig != null)
            {
                m_enabled = windConfig.GetBoolean("enabled", true);

                m_frameUpdateRate = windConfig.GetInt("wind_update_rate", 150);

                // Determine which wind model plugin is desired
                if (windConfig.Contains("wind_plugin"))
                {
                    desiredWindPlugin = windConfig.GetString("wind_plugin");
                }
            }

            if (m_enabled)
            {
                m_log.InfoFormat("[WIND] Enabled with an update rate of {0} frames.", m_frameUpdateRate);

                m_scene = scene;
                m_frame = 0;

                // Register all the Wind Model Plug-ins
                foreach (IWindModelPlugin windPlugin in AddinManager.GetExtensionObjects("/OpenSim/WindModule", false))
                {
                    m_log.InfoFormat("[WIND] Found Plugin: {0}", windPlugin.Name);
                    m_availableWindPlugins.Add(windPlugin.Name, windPlugin);
                }

                // Check for desired plugin
                if (m_availableWindPlugins.ContainsKey(desiredWindPlugin))
                {
                    m_activeWindPlugin = m_availableWindPlugins[desiredWindPlugin];

                    m_log.InfoFormat("[WIND] {0} plugin found, initializing.", desiredWindPlugin);

                    if (windConfig != null)
                    {
                        m_activeWindPlugin.Initialize();
                        m_activeWindPlugin.WindConfig(m_scene, windConfig);
                    }
                }


                // if the plug-in wasn't found, default to no wind.
                if (m_activeWindPlugin == null)
                {
                    m_log.ErrorFormat("[WIND] Could not find specified wind plug-in: {0}", desiredWindPlugin);
                    m_log.ErrorFormat("[WIND] Defaulting to no wind.");
                }

                // This one puts an entry in the main help screen
                m_scene.AddCommand(this, String.Empty, "wind", "Usage: wind <plugin> <param> [value] - Get or Update Wind paramaters", null);

                // This one enables the ability to type just the base command without any parameters
                m_scene.AddCommand(this, "wind", String.Empty, String.Empty, HandleConsoleCommand);

                // Get a list of the parameters for each plugin
                foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values)
                {
                    m_scene.AddCommand(this, String.Format("wind base wind_plugin {0}", windPlugin.Name), String.Format("{0} - {1}", windPlugin.Name, windPlugin.Description), String.Empty, HandleConsoleBaseCommand);
                    m_scene.AddCommand(this, String.Format("wind base wind_update_rate"), "Change the wind update rate.", String.Empty, HandleConsoleBaseCommand);

                    foreach (KeyValuePair <string, string> kvp in windPlugin.WindParams())
                    {
                        m_scene.AddCommand(this, String.Format("wind {0} {1}", windPlugin.Name, kvp.Key), String.Format("{0} : {1} - {2}", windPlugin.Name, kvp.Key, kvp.Value), String.Empty, HandleConsoleParamCommand);
                    }
                }


                // Register event handlers for when Avatars enter the region, and frame ticks
                m_scene.EventManager.OnFrame         += WindUpdate;
                m_scene.EventManager.OnMakeRootAgent += OnAgentEnteredRegion;

                // Register the wind module
                m_scene.RegisterModuleInterface <IWindModule>(this);

                // Generate initial wind values
                GenWindPos();

                // Mark Module Ready for duty
                m_ready = true;
            }
        }
Esempio n. 19
0
        public void Initialise(Scene scene, IConfigSource config)
        {
            IConfig windConfig = config.Configs["Wind"];
            string desiredWindPlugin = m_dWindPluginName;

            if (windConfig != null)
            {
                m_enabled = windConfig.GetBoolean("enabled", true);

                m_frameUpdateRate = windConfig.GetInt("wind_update_rate", 150);

                // Determine which wind model plugin is desired
                if (windConfig.Contains("wind_plugin"))
                {
                    desiredWindPlugin = windConfig.GetString("wind_plugin");
                }
            }

            if (m_enabled)
            {
                m_log.InfoFormat("[WIND] Enabled with an update rate of {0} frames.", m_frameUpdateRate);

                m_scene = scene;
                m_frame = 0;

                // Register all the Wind Model Plug-ins
                foreach (IWindModelPlugin windPlugin in AddinManager.GetExtensionObjects("/OpenSim/WindModule", false))
                {
                    m_log.InfoFormat("[WIND] Found Plugin: {0}", windPlugin.Name);
                    m_availableWindPlugins.Add(windPlugin.Name, windPlugin);
                }

                // Check for desired plugin
                if (m_availableWindPlugins.ContainsKey(desiredWindPlugin))
                {
                    m_activeWindPlugin = m_availableWindPlugins[desiredWindPlugin];

                    m_log.InfoFormat("[WIND] {0} plugin found, initializing.", desiredWindPlugin);

                    if (windConfig != null)
                    {
                        m_activeWindPlugin.Initialise();
                        m_activeWindPlugin.WindConfig(m_scene, windConfig);
                    }
                } 


                // if the plug-in wasn't found, default to no wind.
                if (m_activeWindPlugin == null)
                {
                    m_log.ErrorFormat("[WIND] Could not find specified wind plug-in: {0}", desiredWindPlugin);
                    m_log.ErrorFormat("[WIND] Defaulting to no wind.");
                }

                // This one puts an entry in the main help screen
                m_scene.AddCommand(this, String.Empty, "wind", "Usage: wind <plugin> <param> [value] - Get or Update Wind paramaters", null);
                
                // This one enables the ability to type just the base command without any parameters
                m_scene.AddCommand(this, "wind", "", "", HandleConsoleCommand);

                // Get a list of the parameters for each plugin
                foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values)
                {
                    m_scene.AddCommand(this, String.Format("wind base wind_plugin {0}", windPlugin.Name), String.Format("{0} - {1}", windPlugin.Name, windPlugin.Description), "", HandleConsoleBaseCommand);
                    m_scene.AddCommand(this, String.Format("wind base wind_update_rate"), "Change the wind update rate.", "", HandleConsoleBaseCommand);
                    
                    foreach (KeyValuePair<string, string> kvp in windPlugin.WindParams())
                    {
                        m_scene.AddCommand(this, String.Format("wind {0} {1}", windPlugin.Name, kvp.Key), String.Format("{0} : {1} - {2}", windPlugin.Name, kvp.Key, kvp.Value), "", HandleConsoleParamCommand);
                    }
                }


                // Register event handlers for when Avatars enter the region, and frame ticks
                m_scene.EventManager.OnFrame += WindUpdate;
                m_scene.EventManager.OnMakeRootAgent += OnAgentEnteredRegion;

                // Register the wind module 
                m_scene.RegisterModuleInterface<IWindModule>(this);

                // Generate initial wind values
                GenWindPos();

                // Mark Module Ready for duty
                m_ready = true;

            }

        }
        public void Close()
        {
            if (m_enabled)
            {
                m_ready = false;

                // REVIEW: If a region module is closed, is there a possibility that it'll re-open/initialize ??
                if (m_activeWindPlugin != null)
                {
                    m_activeWindPlugin.Dispose();
                    m_activeWindPlugin = null;
                }

                //  Remove our hooks
                m_scene.EventManager.OnFrame -= WindUpdate;
                m_scene.EventManager.OnMakeRootAgent -= OnAgentEnteredRegion;
            }
        }