diff --git a/OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs b/OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs index 8061648221..a1261cbc87 100644 --- a/OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs +++ b/OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs @@ -48,7 +48,9 @@ namespace OpenSim.Region.Environment.Modules.World.TreePopulator public double m_tree_density = 50.0; // Aim for this many per region public double m_tree_updates = 1000.0; // MS between updates + private bool m_active_trees = false; private List m_trees; + Timer CalculateTrees; #region IRegionModule Members @@ -57,6 +59,7 @@ namespace OpenSim.Region.Environment.Modules.World.TreePopulator try { m_tree_density = config.Configs["Trees"].GetDouble("tree_density", m_tree_density); + m_active_trees = config.Configs["Trees"].GetBoolean("active_trees", m_active_trees); } catch (Exception) { @@ -67,9 +70,9 @@ namespace OpenSim.Region.Environment.Modules.World.TreePopulator m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; - Timer CalculateTrees = new Timer(m_tree_updates); - CalculateTrees.Elapsed += CalculateTrees_Elapsed; - CalculateTrees.Start(); + if (m_active_trees) + activeizeTreeze(true); + m_log.Debug("[TREES]: Initialised tree module"); } @@ -95,16 +98,61 @@ namespace OpenSim.Region.Environment.Modules.World.TreePopulator private void EventManager_OnPluginConsole(string[] args) { - if (args[0] == "tree") + if (args.Length == 1) { - UUID uuid = m_scene.RegionInfo.EstateSettings.EstateOwner; - if (uuid == UUID.Zero) - uuid = m_scene.RegionInfo.MasterAvatarAssignedUUID; - m_log.Debug("[TREES]: New tree planting"); - CreateTree(uuid, new Vector3(128.0f, 128.0f, 0.0f)); + if (args[0] == "tree") + { + UUID uuid = m_scene.RegionInfo.EstateSettings.EstateOwner; + if (uuid == UUID.Zero) + uuid = m_scene.RegionInfo.MasterAvatarAssignedUUID; + m_log.Debug("[TREES]: New tree planting"); + CreateTree(uuid, new Vector3(128.0f, 128.0f, 0.0f)); + + } } + + if (args.Length == 2 || args.Length == 3) + { + if (args[1] == "active") + { + if (args.Length >= 3) + { + if (args[2] == "true" && !m_active_trees) + { + m_active_trees = true; + activeizeTreeze(m_active_trees); + m_log.Info("[TREES]: Activizing Trees"); + } + if (args[2] == "false" && m_active_trees) + { + m_active_trees = false; + activeizeTreeze(m_active_trees); + m_log.Info("[TREES]: Trees no longer Active, for now..."); + } + } + else + { + m_log.Info("[TREES]: When setting the tree module active via the console, you must specify true or false"); + } + } + } + } + private void activeizeTreeze(bool activeYN) + { + if (activeYN) + { + CalculateTrees = new Timer(m_tree_updates); + CalculateTrees.Elapsed += CalculateTrees_Elapsed; + CalculateTrees.Start(); + } + else + { + CalculateTrees.Stop(); + } + } + private void growTrees() { foreach (UUID tree in m_trees) diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index f1f8f8b60c..f4734cb46e 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -981,3 +981,11 @@ InterregionComms = "RESTComms" ; {0} is replaced with the region's name ; {1} is replaced with the region's UUID broker = "http://broker.place.com/{1}" + +[Trees] + + ; Enable this to allow the tree module to manage your sim trees, including growing, reproducing and dying + active_trees = false + + ; Density of tree population + tree_density = 1000.0 \ No newline at end of file