From 99cfcf405b6da42dac29d60141685e3852f41836 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Wed, 1 Apr 2009 14:50:18 +0000 Subject: Update svn properties. --- .../CoreModules/Resources/Wind.Models.addin.xml | 24 +- .../CoreModules/World/Wind/IWindModelPlugin.cs | 112 +++--- .../World/Wind/Plugins/ConfigurableWind.cs | 422 ++++++++++----------- .../World/Wind/Plugins/SimpleRandomWind.cs | 278 +++++++------- .../Scripting/Minimodule/IObjectAccessor.cs | 22 +- .../Scripting/Minimodule/ObjectAccessor.cs | 264 ++++++------- .../Scripting/Minimodule/SPAvatar.cs | 74 ++-- .../Scripting/Minimodule/Test/TestModule.cs | 34 +- 8 files changed, 615 insertions(+), 615 deletions(-) diff --git a/OpenSim/Region/CoreModules/Resources/Wind.Models.addin.xml b/OpenSim/Region/CoreModules/Resources/Wind.Models.addin.xml index 972f795..7735826 100644 --- a/OpenSim/Region/CoreModules/Resources/Wind.Models.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/Wind.Models.addin.xml @@ -1,12 +1,12 @@ - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/OpenSim/Region/CoreModules/World/Wind/IWindModelPlugin.cs b/OpenSim/Region/CoreModules/World/Wind/IWindModelPlugin.cs index 29b0ed5..6b495da 100644 --- a/OpenSim/Region/CoreModules/World/Wind/IWindModelPlugin.cs +++ b/OpenSim/Region/CoreModules/World/Wind/IWindModelPlugin.cs @@ -1,56 +1,56 @@ -using System; -using System.Collections.Generic; - -using Nini.Config; -using OpenSim.Framework; -using OpenMetaverse; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.CoreModules.World.Wind -{ - public interface IWindModelPlugin : IPlugin - { - /// - /// Brief description of this plugin's wind model - /// - string Description { get; } - - /// - /// Provides access to the wind configuration, if any. - /// - void WindConfig(Scene scene, IConfig windConfig); - - /// - /// Update wind. - /// - void WindUpdate(uint frame); - - /// - /// Returns the wind vector at the given local region coordinates. - /// - Vector3 WindSpeed(float x, float y, float z); - - /// - /// Generate a 16 x 16 Vector2 array of wind speeds for LL* based viewers - /// - /// Must return a Vector2[256] - Vector2[] WindLLClientArray(); - - /// - /// Retrieve a list of parameter/description pairs. - /// - /// - Dictionary WindParams(); - - /// - /// Set the specified parameter - /// - void WindParamSet(string param, float value); - - /// - /// Get the specified parameter - /// - float WindParamGet(string param); - - } -} +using System; +using System.Collections.Generic; + +using Nini.Config; +using OpenSim.Framework; +using OpenMetaverse; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.CoreModules.World.Wind +{ + public interface IWindModelPlugin : IPlugin + { + /// + /// Brief description of this plugin's wind model + /// + string Description { get; } + + /// + /// Provides access to the wind configuration, if any. + /// + void WindConfig(Scene scene, IConfig windConfig); + + /// + /// Update wind. + /// + void WindUpdate(uint frame); + + /// + /// Returns the wind vector at the given local region coordinates. + /// + Vector3 WindSpeed(float x, float y, float z); + + /// + /// Generate a 16 x 16 Vector2 array of wind speeds for LL* based viewers + /// + /// Must return a Vector2[256] + Vector2[] WindLLClientArray(); + + /// + /// Retrieve a list of parameter/description pairs. + /// + /// + Dictionary WindParams(); + + /// + /// Set the specified parameter + /// + void WindParamSet(string param, float value); + + /// + /// Get the specified parameter + /// + float WindParamGet(string param); + + } +} diff --git a/OpenSim/Region/CoreModules/World/Wind/Plugins/ConfigurableWind.cs b/OpenSim/Region/CoreModules/World/Wind/Plugins/ConfigurableWind.cs index 2f5cc31..2a0bb73 100644 --- a/OpenSim/Region/CoreModules/World/Wind/Plugins/ConfigurableWind.cs +++ b/OpenSim/Region/CoreModules/World/Wind/Plugins/ConfigurableWind.cs @@ -1,211 +1,211 @@ -using System; -using System.Collections.Generic; -using System.Reflection; - -using log4net; -using OpenMetaverse; - -using OpenSim.Region.CoreModules.World.Wind; - -namespace OpenSim.Region.CoreModules.World.Wind.Plugins -{ - class ConfigurableWind : Mono.Addins.TypeExtensionNode, IWindModelPlugin - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private Vector2[] m_windSpeeds = new Vector2[16 * 16]; - private Random m_rndnums = new Random(Environment.TickCount); - - private float m_avgStrength = 5.0f; // Average magnitude of the wind vector - private float m_avgDirection = 0.0f; // Average direction of the wind in degrees - private float m_varStrength = 5.0f; // Max Strength Variance - private float m_varDirection = 30.0f;// Max Direction Variance - private float m_rateChange = 1.0f; // - - private Vector2 m_curPredominateWind = new Vector2(); - - - - #region IPlugin Members - - public string Version - { - get { return "1.0.0.0"; } - } - - public string Name - { - get { return "ConfigurableWind"; } - } - - public void Initialise() - { - - } - - #endregion - - #region IDisposable Members - - public void Dispose() - { - m_windSpeeds = null; - } - - #endregion - - #region IWindModelPlugin Members - - public void WindConfig(OpenSim.Region.Framework.Scenes.Scene scene, Nini.Config.IConfig windConfig) - { - if( windConfig != null ) - { - // Uses strength value if avg_strength not specified - m_avgStrength = windConfig.GetFloat("strength", 5.0F); - m_avgStrength = windConfig.GetFloat("avg_strength", 5.0F); - - m_avgDirection = windConfig.GetFloat("avg_direction", 0.0F); - m_varStrength = windConfig.GetFloat("var_strength", 5.0F); - m_varDirection = windConfig.GetFloat("var_direction", 30.0F); - m_rateChange = windConfig.GetFloat("rate_change", 1.0F); - - LogSettings(); - } - } - - public void WindUpdate(uint frame) - { - double avgAng = m_avgDirection * (Math.PI/180.0f); - double varDir = m_varDirection * (Math.PI/180.0f); - - // Prevailing wind algorithm - // Inspired by Kanker Greenacre - - // TODO: - // * This should probably be based on in-world time. - // * should probably move all these local variables to class members and constants - double time = DateTime.Now.TimeOfDay.Seconds / 86400; - - double theta = time * (2 * Math.PI) * m_rateChange; - - double offset = Math.Sin(theta) * Math.Sin(theta*2) * Math.Sin(theta*9) * Math.Cos(theta*4); - - double windDir = avgAng + (varDir * offset); - - offset = Math.Sin(theta) * Math.Sin(theta*4) + (Math.Sin(theta*13) / 3); - double windSpeed = m_avgStrength + (m_varStrength * offset); - - if (windSpeed<0) - windSpeed=0; - - - - m_curPredominateWind.X = (float)Math.Cos(windDir); - m_curPredominateWind.Y = (float)Math.Sin(windDir); - - m_curPredominateWind.Normalize(); - m_curPredominateWind.X *= (float)windSpeed; - m_curPredominateWind.Y *= (float)windSpeed; - - for (int y = 0; y < 16; y++) - { - for (int x = 0; x < 16; x++) - { - m_windSpeeds[y * 16 + x] = m_curPredominateWind; - } - } - } - - public Vector3 WindSpeed(float fX, float fY, float fZ) - { - return new Vector3(m_curPredominateWind, 0.0f); - } - - public Vector2[] WindLLClientArray() - { - return m_windSpeeds; - } - - public string Description - { - get - { - return "Provides a predominate wind direction that can change within configured variances for direction and speed."; - } - } - - public System.Collections.Generic.Dictionary WindParams() - { - Dictionary Params = new Dictionary(); - - Params.Add("avgStrength", "average wind strength"); - Params.Add("avgDirection", "average wind direction in degrees"); - Params.Add("varStrength", "allowable variance in wind strength"); - Params.Add("varDirection", "allowable variance in wind direction in +/- degrees"); - Params.Add("rateChange", "rate of change"); - - return Params; - } - - public void WindParamSet(string param, float value) - { - switch (param) - { - case "avgStrength": - m_avgStrength = value; - break; - case "avgDirection": - m_avgDirection = value; - break; - case "varStrength": - m_varStrength = value; - break; - case "varDirection": - m_varDirection = value; - break; - case "rateChange": - m_rateChange = value; - break; - } - } - - public float WindParamGet(string param) - { - switch (param) - { - case "avgStrength": - return m_avgStrength; - case "avgDirection": - return m_avgDirection; - case "varStrength": - return m_varStrength; - case "varDirection": - return m_varDirection; - case "rateChange": - return m_rateChange; - default: - throw new Exception(String.Format("Unknown {0} parameter {1}", this.Name, param)); - - } - } - - - - #endregion - - - private void LogSettings() - { - m_log.InfoFormat("[ConfigurableWind] Average Strength : {0}", m_avgStrength); - m_log.InfoFormat("[ConfigurableWind] Average Direction : {0}", m_avgDirection); - m_log.InfoFormat("[ConfigurableWind] Varience Strength : {0}", m_varStrength); - m_log.InfoFormat("[ConfigurableWind] Varience Direction : {0}", m_varDirection); - m_log.InfoFormat("[ConfigurableWind] Rate Change : {0}", m_rateChange); - } - - #region IWindModelPlugin Members - - - #endregion - } -} +using System; +using System.Collections.Generic; +using System.Reflection; + +using log4net; +using OpenMetaverse; + +using OpenSim.Region.CoreModules.World.Wind; + +namespace OpenSim.Region.CoreModules.World.Wind.Plugins +{ + class ConfigurableWind : Mono.Addins.TypeExtensionNode, IWindModelPlugin + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private Vector2[] m_windSpeeds = new Vector2[16 * 16]; + private Random m_rndnums = new Random(Environment.TickCount); + + private float m_avgStrength = 5.0f; // Average magnitude of the wind vector + private float m_avgDirection = 0.0f; // Average direction of the wind in degrees + private float m_varStrength = 5.0f; // Max Strength Variance + private float m_varDirection = 30.0f;// Max Direction Variance + private float m_rateChange = 1.0f; // + + private Vector2 m_curPredominateWind = new Vector2(); + + + + #region IPlugin Members + + public string Version + { + get { return "1.0.0.0"; } + } + + public string Name + { + get { return "ConfigurableWind"; } + } + + public void Initialise() + { + + } + + #endregion + + #region IDisposable Members + + public void Dispose() + { + m_windSpeeds = null; + } + + #endregion + + #region IWindModelPlugin Members + + public void WindConfig(OpenSim.Region.Framework.Scenes.Scene scene, Nini.Config.IConfig windConfig) + { + if( windConfig != null ) + { + // Uses strength value if avg_strength not specified + m_avgStrength = windConfig.GetFloat("strength", 5.0F); + m_avgStrength = windConfig.GetFloat("avg_strength", 5.0F); + + m_avgDirection = windConfig.GetFloat("avg_direction", 0.0F); + m_varStrength = windConfig.GetFloat("var_strength", 5.0F); + m_varDirection = windConfig.GetFloat("var_direction", 30.0F); + m_rateChange = windConfig.GetFloat("rate_change", 1.0F); + + LogSettings(); + } + } + + public void WindUpdate(uint frame) + { + double avgAng = m_avgDirection * (Math.PI/180.0f); + double varDir = m_varDirection * (Math.PI/180.0f); + + // Prevailing wind algorithm + // Inspired by Kanker Greenacre + + // TODO: + // * This should probably be based on in-world time. + // * should probably move all these local variables to class members and constants + double time = DateTime.Now.TimeOfDay.Seconds / 86400; + + double theta = time * (2 * Math.PI) * m_rateChange; + + double offset = Math.Sin(theta) * Math.Sin(theta*2) * Math.Sin(theta*9) * Math.Cos(theta*4); + + double windDir = avgAng + (varDir * offset); + + offset = Math.Sin(theta) * Math.Sin(theta*4) + (Math.Sin(theta*13) / 3); + double windSpeed = m_avgStrength + (m_varStrength * offset); + + if (windSpeed<0) + windSpeed=0; + + + + m_curPredominateWind.X = (float)Math.Cos(windDir); + m_curPredominateWind.Y = (float)Math.Sin(windDir); + + m_curPredominateWind.Normalize(); + m_curPredominateWind.X *= (float)windSpeed; + m_curPredominateWind.Y *= (float)windSpeed; + + for (int y = 0; y < 16; y++) + { + for (int x = 0; x < 16; x++) + { + m_windSpeeds[y * 16 + x] = m_curPredominateWind; + } + } + } + + public Vector3 WindSpeed(float fX, float fY, float fZ) + { + return new Vector3(m_curPredominateWind, 0.0f); + } + + public Vector2[] WindLLClientArray() + { + return m_windSpeeds; + } + + public string Description + { + get + { + return "Provides a predominate wind direction that can change within configured variances for direction and speed."; + } + } + + public System.Collections.Generic.Dictionary WindParams() + { + Dictionary Params = new Dictionary(); + + Params.Add("avgStrength", "average wind strength"); + Params.Add("avgDirection", "average wind direction in degrees"); + Params.Add("varStrength", "allowable variance in wind strength"); + Params.Add("varDirection", "allowable variance in wind direction in +/- degrees"); + Params.Add("rateChange", "rate of change"); + + return Params; + } + + public void WindParamSet(string param, float value) + { + switch (param) + { + case "avgStrength": + m_avgStrength = value; + break; + case "avgDirection": + m_avgDirection = value; + break; + case "varStrength": + m_varStrength = value; + break; + case "varDirection": + m_varDirection = value; + break; + case "rateChange": + m_rateChange = value; + break; + } + } + + public float WindParamGet(string param) + { + switch (param) + { + case "avgStrength": + return m_avgStrength; + case "avgDirection": + return m_avgDirection; + case "varStrength": + return m_varStrength; + case "varDirection": + return m_varDirection; + case "rateChange": + return m_rateChange; + default: + throw new Exception(String.Format("Unknown {0} parameter {1}", this.Name, param)); + + } + } + + + + #endregion + + + private void LogSettings() + { + m_log.InfoFormat("[ConfigurableWind] Average Strength : {0}", m_avgStrength); + m_log.InfoFormat("[ConfigurableWind] Average Direction : {0}", m_avgDirection); + m_log.InfoFormat("[ConfigurableWind] Varience Strength : {0}", m_varStrength); + m_log.InfoFormat("[ConfigurableWind] Varience Direction : {0}", m_varDirection); + m_log.InfoFormat("[ConfigurableWind] Rate Change : {0}", m_rateChange); + } + + #region IWindModelPlugin Members + + + #endregion + } +} diff --git a/OpenSim/Region/CoreModules/World/Wind/Plugins/SimpleRandomWind.cs b/OpenSim/Region/CoreModules/World/Wind/Plugins/SimpleRandomWind.cs index 040a3c4..837d6e7 100644 --- a/OpenSim/Region/CoreModules/World/Wind/Plugins/SimpleRandomWind.cs +++ b/OpenSim/Region/CoreModules/World/Wind/Plugins/SimpleRandomWind.cs @@ -1,139 +1,139 @@ -using System; -using System.Collections.Generic; - -using OpenMetaverse; - - -namespace OpenSim.Region.CoreModules.World.Wind.Plugins -{ - class SimpleRandomWind : Mono.Addins.TypeExtensionNode, IWindModelPlugin - { - private Vector2[] m_windSpeeds = new Vector2[16 * 16]; - private float m_strength = 1.0f; - private Random m_rndnums = new Random(Environment.TickCount); - - - #region IPlugin Members - - public string Version - { - get { return "1.0.0.0"; } - } - - public string Name - { - get { return "SimpleRandomWind"; } - } - - public void Initialise() - { - - } - - #endregion - - #region IDisposable Members - - public void Dispose() - { - m_windSpeeds = null; - } - - #endregion - - #region IWindModelPlugin Members - - public void WindConfig(OpenSim.Region.Framework.Scenes.Scene scene, Nini.Config.IConfig windConfig) - { - if( windConfig != null ) - { - if( windConfig.Contains("strength") ) - { - m_strength = windConfig.GetFloat("strength", 1.0F); - } - } - } - - public void WindUpdate(uint frame) - { - for (int y = 0; y < 16; y++) - { - for (int x = 0; x < 16; x++) - { - m_windSpeeds[y * 16 + x].X = (float)(m_rndnums.NextDouble() * 2d - 1d); // -1 to 1 - m_windSpeeds[y * 16 + x].Y = (float)(m_rndnums.NextDouble() * 2d - 1d); // -1 to 1 - m_windSpeeds[y * 16 + x].X *= m_strength; - m_windSpeeds[y * 16 + x].Y *= m_strength; - } - } - } - - public Vector3 WindSpeed(float fX, float fY, float fZ) - { - Vector3 windVector = new Vector3(0.0f, 0.0f, 0.0f); - - int x = (int)fX / 16; - int y = (int)fY / 16; - - if (x < 0) x = 0; - if (x > 15) x = 15; - if (y < 0) y = 0; - if (y > 15) y = 15; - - if (m_windSpeeds != null) - { - windVector.X = m_windSpeeds[y * 16 + x].X; - windVector.Y = m_windSpeeds[y * 16 + x].Y; - } - - return windVector; - - } - - public Vector2[] WindLLClientArray() - { - return m_windSpeeds; - } - - public string Description - { - get - { - return "Provides a simple wind model that creates random wind of a given strength in 16m x 16m patches."; - } - } - - public System.Collections.Generic.Dictionary WindParams() - { - Dictionary Params = new Dictionary(); - - Params.Add("strength", "wind strength"); - - return Params; - } - - public void WindParamSet(string param, float value) - { - switch (param) - { - case "strength": - m_strength = value; - break; - } - } - - public float WindParamGet(string param) - { - switch (param) - { - case "strength": - return m_strength; - default: - throw new Exception(String.Format("Unknown {0} parameter {1}", this.Name, param)); - } - } - - #endregion - - } -} +using System; +using System.Collections.Generic; + +using OpenMetaverse; + + +namespace OpenSim.Region.CoreModules.World.Wind.Plugins +{ + class SimpleRandomWind : Mono.Addins.TypeExtensionNode, IWindModelPlugin + { + private Vector2[] m_windSpeeds = new Vector2[16 * 16]; + private float m_strength = 1.0f; + private Random m_rndnums = new Random(Environment.TickCount); + + + #region IPlugin Members + + public string Version + { + get { return "1.0.0.0"; } + } + + public string Name + { + get { return "SimpleRandomWind"; } + } + + public void Initialise() + { + + } + + #endregion + + #region IDisposable Members + + public void Dispose() + { + m_windSpeeds = null; + } + + #endregion + + #region IWindModelPlugin Members + + public void WindConfig(OpenSim.Region.Framework.Scenes.Scene scene, Nini.Config.IConfig windConfig) + { + if( windConfig != null ) + { + if( windConfig.Contains("strength") ) + { + m_strength = windConfig.GetFloat("strength", 1.0F); + } + } + } + + public void WindUpdate(uint frame) + { + for (int y = 0; y < 16; y++) + { + for (int x = 0; x < 16; x++) + { + m_windSpeeds[y * 16 + x].X = (float)(m_rndnums.NextDouble() * 2d - 1d); // -1 to 1 + m_windSpeeds[y * 16 + x].Y = (float)(m_rndnums.NextDouble() * 2d - 1d); // -1 to 1 + m_windSpeeds[y * 16 + x].X *= m_strength; + m_windSpeeds[y * 16 + x].Y *= m_strength; + } + } + } + + public Vector3 WindSpeed(float fX, float fY, float fZ) + { + Vector3 windVector = new Vector3(0.0f, 0.0f, 0.0f); + + int x = (int)fX / 16; + int y = (int)fY / 16; + + if (x < 0) x = 0; + if (x > 15) x = 15; + if (y < 0) y = 0; + if (y > 15) y = 15; + + if (m_windSpeeds != null) + { + windVector.X = m_windSpeeds[y * 16 + x].X; + windVector.Y = m_windSpeeds[y * 16 + x].Y; + } + + return windVector; + + } + + public Vector2[] WindLLClientArray() + { + return m_windSpeeds; + } + + public string Description + { + get + { + return "Provides a simple wind model that creates random wind of a given strength in 16m x 16m patches."; + } + } + + public System.Collections.Generic.Dictionary WindParams() + { + Dictionary Params = new Dictionary(); + + Params.Add("strength", "wind strength"); + + return Params; + } + + public void WindParamSet(string param, float value) + { + switch (param) + { + case "strength": + m_strength = value; + break; + } + } + + public float WindParamGet(string param) + { + switch (param) + { + case "strength": + return m_strength; + default: + throw new Exception(String.Format("Unknown {0} parameter {1}", this.Name, param)); + } + } + + #endregion + + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObjectAccessor.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObjectAccessor.cs index feddf67..9ad042e 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObjectAccessor.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObjectAccessor.cs @@ -1,12 +1,12 @@ -using System.Collections.Generic; -using OpenMetaverse; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public interface IObjectAccessor : ICollection - { - IObject this[int index] { get; } - IObject this[uint index] { get; } - IObject this[UUID index] { get; } - } +using System.Collections.Generic; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface IObjectAccessor : ICollection + { + IObject this[int index] { get; } + IObject this[uint index] { get; } + IObject this[UUID index] { get; } + } } \ No newline at end of file diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs index ad7182e..832050e 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs @@ -1,132 +1,132 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using OpenMetaverse; -using OpenSim.Region.Framework.Scenes; -using IEnumerable=System.Collections.IEnumerable; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - - internal class IObjEnum : IEnumerator - { - private readonly Scene m_scene; - private readonly IEnumerator m_sogEnum; - - public IObjEnum(Scene scene) - { - m_scene = scene; - m_sogEnum = m_scene.Entities.GetAllByType().GetEnumerator(); - } - - public void Dispose() - { - m_sogEnum.Dispose(); - } - - public bool MoveNext() - { - return m_sogEnum.MoveNext(); - } - - public void Reset() - { - m_sogEnum.Reset(); - } - - public IObject Current - { - get - { - return new SOPObject(m_scene, m_sogEnum.Current.LocalId); - } - } - - object IEnumerator.Current - { - get { return Current; } - } - } - - public class ObjectAccessor : IObjectAccessor - { - private readonly Scene m_scene; - - public ObjectAccessor(Scene scene) - { - m_scene = scene; - } - - public IObject this[int index] - { - get - { - return new SOPObject(m_scene, m_scene.Entities[(uint)index].LocalId); - } - } - - public IObject this[uint index] - { - get - { - return new SOPObject(m_scene, m_scene.Entities[index].LocalId); - } - } - - public IObject this[UUID index] - { - get - { - return new SOPObject(m_scene, m_scene.Entities[index].LocalId); - } - } - - public IEnumerator GetEnumerator() - { - return new IObjEnum(m_scene); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - public void Add(IObject item) - { - throw new NotSupportedException("Collection is read-only. This is an API TODO FIX, creation of objects is presently impossible."); - } - - public void Clear() - { - throw new NotSupportedException("Collection is read-only. TODO FIX."); - } - - public bool Contains(IObject item) - { - return m_scene.Entities.ContainsKey(item.LocalID); - } - - public void CopyTo(IObject[] array, int arrayIndex) - { - for (int i = arrayIndex; i < Count + arrayIndex; i++) - { - array[i] = this[i - arrayIndex]; - } - } - - public bool Remove(IObject item) - { - throw new NotSupportedException("Collection is read-only. TODO FIX."); - } - - public int Count - { - get { return m_scene.Entities.Count; } - } - - public bool IsReadOnly - { - get { return true; } - } - } -} +using System; +using System.Collections; +using System.Collections.Generic; +using OpenMetaverse; +using OpenSim.Region.Framework.Scenes; +using IEnumerable=System.Collections.IEnumerable; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + + internal class IObjEnum : IEnumerator + { + private readonly Scene m_scene; + private readonly IEnumerator m_sogEnum; + + public IObjEnum(Scene scene) + { + m_scene = scene; + m_sogEnum = m_scene.Entities.GetAllByType().GetEnumerator(); + } + + public void Dispose() + { + m_sogEnum.Dispose(); + } + + public bool MoveNext() + { + return m_sogEnum.MoveNext(); + } + + public void Reset() + { + m_sogEnum.Reset(); + } + + public IObject Current + { + get + { + return new SOPObject(m_scene, m_sogEnum.Current.LocalId); + } + } + + object IEnumerator.Current + { + get { return Current; } + } + } + + public class ObjectAccessor : IObjectAccessor + { + private readonly Scene m_scene; + + public ObjectAccessor(Scene scene) + { + m_scene = scene; + } + + public IObject this[int index] + { + get + { + return new SOPObject(m_scene, m_scene.Entities[(uint)index].LocalId); + } + } + + public IObject this[uint index] + { + get + { + return new SOPObject(m_scene, m_scene.Entities[index].LocalId); + } + } + + public IObject this[UUID index] + { + get + { + return new SOPObject(m_scene, m_scene.Entities[index].LocalId); + } + } + + public IEnumerator GetEnumerator() + { + return new IObjEnum(m_scene); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(IObject item) + { + throw new NotSupportedException("Collection is read-only. This is an API TODO FIX, creation of objects is presently impossible."); + } + + public void Clear() + { + throw new NotSupportedException("Collection is read-only. TODO FIX."); + } + + public bool Contains(IObject item) + { + return m_scene.Entities.ContainsKey(item.LocalID); + } + + public void CopyTo(IObject[] array, int arrayIndex) + { + for (int i = arrayIndex; i < Count + arrayIndex; i++) + { + array[i] = this[i - arrayIndex]; + } + } + + public bool Remove(IObject item) + { + throw new NotSupportedException("Collection is read-only. TODO FIX."); + } + + public int Count + { + get { return m_scene.Entities.Count; } + } + + public bool IsReadOnly + { + get { return true; } + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs index 6011e0b..03432bc 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs @@ -1,37 +1,37 @@ -using OpenMetaverse; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - class SPAvatar : IAvatar - { - private readonly Scene m_rootScene; - private readonly UUID m_ID; - - public SPAvatar(Scene scene, UUID ID) - { - m_rootScene = scene; - m_ID = ID; - } - - private ScenePresence GetSP() - { - return m_rootScene.GetScenePresence(m_ID); - } - - public string Name - { - get { return GetSP().Name; } - } - - public UUID GlobalID - { - get { return m_ID; } - } - - public Vector3 Position - { - get { return GetSP().AbsolutePosition; } - } - } -} +using OpenMetaverse; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + class SPAvatar : IAvatar + { + private readonly Scene m_rootScene; + private readonly UUID m_ID; + + public SPAvatar(Scene scene, UUID ID) + { + m_rootScene = scene; + m_ID = ID; + } + + private ScenePresence GetSP() + { + return m_rootScene.GetScenePresence(m_ID); + } + + public string Name + { + get { return GetSP().Name; } + } + + public UUID GlobalID + { + get { return m_ID; } + } + + public Vector3 Position + { + get { return GetSP().AbsolutePosition; } + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs index abbef0b..1e266ae 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs @@ -1,17 +1,17 @@ -using OpenSim.Region.OptionalModules.Scripting.Minimodule; - -namespace OpenSim -{ - class MiniModule : MRMBase - { - public override void Start() - { - Host.Console.Info("Hello World!"); - } - - public override void Stop() - { - - } - } -} +using OpenSim.Region.OptionalModules.Scripting.Minimodule; + +namespace OpenSim +{ + class MiniModule : MRMBase + { + public override void Start() + { + Host.Console.Info("Hello World!"); + } + + public override void Stop() + { + + } + } +} -- cgit v1.1