From f8a6ef2d50e85b8d5383147895830bc5aa95551d Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Tue, 26 Feb 2008 15:21:47 +0000 Subject: * Hooked up replacment TerrainModule, raising land will now be weird as both modules are technically active. Beta software, yada yada yada. Will disable one of them by the end of the day. --- .../Environment/Modules/Terrain/TerrainModule.cs | 92 ++++++++++++++++++++-- 1 file changed, 87 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs') diff --git a/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs index 4f8b377..24b3f50 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs @@ -49,6 +49,11 @@ namespace OpenSim.Region.Environment.Modules.Terrain void FloodEffect(ITerrainChannel map, Boolean[,] fillArea, double strength); } + public interface ITerrainEffect + { + void RunEffect(ITerrainChannel map, double strength); + } + /// /// A new version of the old Channel class, simplified /// @@ -103,16 +108,97 @@ namespace OpenSim.Region.Environment.Modules.Terrain } } + public enum StandardTerrainEffects : byte + { + Flatten = 0, + Raise = 1, + Lower = 2, + Smooth = 3, + Noise = 4, + Revert = 5 + } + public class TerrainModule : IRegionModule { - Scene m_scene; + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private Dictionary m_painteffects = + new Dictionary(); + private Dictionary m_floodeffects = + new Dictionary(); + Scene m_scene; + ITerrainChannel m_channel; private IConfigSource m_gConfig; + private void InstallDefaultEffects() + { + m_painteffects[StandardTerrainEffects.Raise] = new PaintBrushes.RaiseSphere(); + m_floodeffects[StandardTerrainEffects.Raise] = new FloodBrushes.RaiseArea(); + } + public void Initialise(Scene scene, IConfigSource config) { m_scene = scene; m_gConfig = config; + + m_channel = new TerrainChannel(); + m_scene.EventManager.OnNewClient += EventManager_OnNewClient; + } + + void EventManager_OnNewClient(IClientAPI client) + { + client.OnModifyTerrain += client_OnModifyTerrain; + } + + void client_OnModifyTerrain(float height, float seconds, byte size, byte action, float north, float west, float south, float east, IClientAPI remoteClient) + { + // Not a good permissions check, if in area mode, need to check the entire area. + if (m_scene.PermissionsMngr.CanTerraform(remoteClient.AgentId, new LLVector3(north, west, 0))) + { + + if (north == south && east == west) + { + if (m_painteffects.ContainsKey((StandardTerrainEffects)action)) + { + m_painteffects[(StandardTerrainEffects)action].PaintEffect( + m_channel, west, south, Math.Pow(size, 2.0)); + } + else + { + m_log.Debug("Unknown terrain brush type " + action.ToString()); + } + } + else + { + if (m_floodeffects.ContainsKey((StandardTerrainEffects)action)) + { + bool[,] fillArea = new bool[m_channel.Width, m_channel.Height]; + + fillArea.Initialize(); + + int x, y; + for (x = 0; x < m_channel.Width; x++) + { + for (y = 0; y < m_channel.Height; y++) + { + fillArea[x, y] = true; + } + } + + m_floodeffects[(StandardTerrainEffects)action].FloodEffect( + m_channel, fillArea, Math.Pow(size, 2.0)); + } + else + { + m_log.Debug("Unknown terrain flood type " + action.ToString()); + } + } + } + } + + public void PostInitialise() + { + InstallDefaultEffects(); } public void Close() @@ -128,9 +214,5 @@ namespace OpenSim.Region.Environment.Modules.Terrain { get { return false; } } - - public void PostInitialise() - { - } } } -- cgit v1.1