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; } }