From 3538eeafa200f035b67a833c11b5050360479463 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 4 Mar 2009 01:38:22 +0000 Subject: * Implementing some interfaces for aformentioned script engine. Ignore this. --- .../Scripting/Minimodule/IHeightmap.cs | 14 ++++ .../Scripting/Minimodule/IObject.cs | 96 ++++++++++++++++++++++ .../OptionalModules/Scripting/Minimodule/IWorld.cs | 11 +++ 3 files changed, 121 insertions(+) create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs new file mode 100644 index 0000000..fd1cc3d --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + interface IHeightmap + { + int Height { get; } + int Width { get; } + double Get(int x, int y); + void Set(int x, int y, double val); + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs new file mode 100644 index 0000000..04d36a5 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs @@ -0,0 +1,96 @@ +using System; +using System.Drawing; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + interface IObject + { + bool Exists { get; } + uint LocalID { get; } + UUID GlobalID { get; } + + IObject[] Children { get; } + + /// + /// Equals 'this' if we have no parent. Ergo, Root.Children.Count will always return the total number of items in the linkset. + /// + IObject Root { get; } + + IObjectFace[] Faces { get; } + + Vector3 Scale { get; set; } + Quaternion Rotation { get; set; } + + Vector3 SitTarget { get; set; } + String SitTargetText { get; set; } + + String TouchText { get; set; } + + String Text { get; set; } + + bool IsPhysical { get; set; } // SetStatus(PHYSICS) + bool IsPhantom { get; set; } // SetStatus(PHANTOM) + bool IsRotationLockedX { get; set; } // SetStatus(!ROTATE_X) + bool IsRotationLockedY { get; set; } // SetStatus(!ROTATE_Y) + bool IsRotationLockedZ { get; set; } // SetStatus(!ROTATE_Z) + bool IsSandboxed { get; set; } // SetStatus(SANDBOX) + bool IsImmotile { get; set; } // SetStatus(BLOCK_GRAB) + bool IsAlwaysReturned { get; set; } // SetStatus(!DIE_AT_EDGE) + bool IsTemporary { get; set; } // TEMP_ON_REZ + + bool IsFlexible { get; set; } + + PrimType PrimShape { get; set; } + // TODO: + // PrimHole + // Repeats, Offsets, Cut/Dimple/ProfileCut + // Hollow, Twist, HoleSize, + // Taper[A+B], Shear[A+B], Revolutions, + // RadiusOffset, Skew + + Material Material { get; set; } + } + + public enum Material + { + Default, + Glass, + Metal, + Plastic, + Wood, + Rubber, + Stone, + Flesh + } + + public enum PrimType + { + NotPrimitive, + Box, + Cylinder, + Prism, + Sphere, + Torus, + Tube, + Ring, + Sculpt + } + + public enum TextureMapping + { + Default, + Planar + } + + interface IObjectFace + { + Color Color { get; set; } + UUID Texture { get; set; } + TextureMapping Mapping { get; set; } // SetPrimParms(PRIM_TEXGEN) + bool Bright { get; set; } // SetPrimParms(FULLBRIGHT) + double Bloom { get; set; } // SetPrimParms(GLOW) + bool Shiny { get; set; } // SetPrimParms(SHINY) + bool BumpMap { get; set; } // SetPrimParms(BUMPMAP) [DEPRECIATE IN FAVOUR OF UUID?] + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs new file mode 100644 index 0000000..3ce7020 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + interface IWorld + { + + } +} -- cgit v1.1 From 915b0f2448e6785c4031f664b98ea67ef1a90380 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 4 Mar 2009 02:29:51 +0000 Subject: * More work on MiniRegionModule module. --- .../Scripting/Minimodule/Heightmap.cs | 34 +++++ .../Scripting/Minimodule/IHeightmap.cs | 2 +- .../Scripting/Minimodule/IObject.cs | 2 +- .../OptionalModules/Scripting/Minimodule/IWorld.cs | 3 +- .../Scripting/Minimodule/SOPObject.cs | 166 +++++++++++++++++++++ .../OptionalModules/Scripting/Minimodule/World.cs | 39 +++++ 6 files changed, 243 insertions(+), 3 deletions(-) create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/Heightmap.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Heightmap.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Heightmap.cs new file mode 100644 index 0000000..c75c6e7 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Heightmap.cs @@ -0,0 +1,34 @@ +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public class Heightmap : IHeightmap + { + private Scene m_scene; + + public Heightmap(Scene scene) + { + m_scene = scene; + } + + public int Height + { + get { return m_scene.Heightmap.Height; } + } + + public int Width + { + get { return m_scene.Heightmap.Width; } + } + + public double Get(int x, int y) + { + return m_scene.Heightmap[x, y]; + } + + public void Set(int x, int y, double val) + { + m_scene.Heightmap[x, y] = val; + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs index fd1cc3d..b4502a4 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs @@ -4,7 +4,7 @@ using System.Text; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - interface IHeightmap + public interface IHeightmap { int Height { get; } int Width { get; } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs index 04d36a5..30b08b0 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs @@ -4,7 +4,7 @@ using OpenMetaverse; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - interface IObject + public interface IObject { bool Exists { get; } uint LocalID { get; } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs index 3ce7020..087f94f 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs @@ -6,6 +6,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { interface IWorld { - + IObject[] Objects { get; } + IHeightmap Terrain { get; } } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs new file mode 100644 index 0000000..55b9767 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -0,0 +1,166 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + class SOPObject : IObject + { + private readonly Scene m_rootScene; + private readonly uint m_localID; + + public SOPObject(Scene rootScene, uint localID) + { + m_rootScene = rootScene; + m_localID = localID; + } + + private SceneObjectPart GetSOP() + { + if (m_rootScene.Entities.ContainsKey(m_localID)) + return ((SceneObjectGroup) m_rootScene.Entities[m_localID]).RootPart; + + return null; + } + + public bool Exists + { + get { return GetSOP() != null; } + } + + public uint LocalID + { + get { return m_localID; } + } + + public UUID GlobalID + { + get { return GetSOP().UUID; } + } + + public IObject[] Children + { + get { throw new System.NotImplementedException(); } + } + + public IObject Root + { + get { return new SOPObject(m_rootScene, GetSOP().ParentGroup.RootPart.LocalId); } + } + + public IObjectFace[] Faces + { + get { throw new System.NotImplementedException(); } + } + + public Vector3 Scale + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public Quaternion Rotation + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public Vector3 SitTarget + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public string SitTargetText + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public string TouchText + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public string Text + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public bool IsPhysical + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public bool IsPhantom + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public bool IsRotationLockedX + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public bool IsRotationLockedY + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public bool IsRotationLockedZ + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public bool IsSandboxed + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public bool IsImmotile + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public bool IsAlwaysReturned + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public bool IsTemporary + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public bool IsFlexible + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public PrimType PrimShape + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public Material Material + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs new file mode 100644 index 0000000..6c7f854 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs @@ -0,0 +1,39 @@ +using System.Collections.Generic; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public class World : IWorld + { + private readonly Scene m_internalScene; + private readonly Heightmap m_heights; + + public World(Scene internalScene) + { + m_internalScene = internalScene; + m_heights = new Heightmap(m_internalScene); + } + + public IObject[] Objects + { + get + { + List ents = m_internalScene.Entities.GetAllByType(); + IObject[] rets = new IObject[ents.Count]; + + for (int i = 0; i < ents.Count; i++) + { + EntityBase ent = ents[i]; + rets[i] = new SOPObject(m_internalScene, ent.LocalId); + } + + return rets; + } + } + + public IHeightmap Terrain + { + get { return m_heights; } + } + } +} -- cgit v1.1 From b2135c2029087c3949204e5e929af92ec2dfbac2 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Wed, 4 Mar 2009 03:58:11 +0000 Subject: IObjectFace needs to be public to compile. --- OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs index 30b08b0..3456258 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs @@ -83,7 +83,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule Planar } - interface IObjectFace + public interface IObjectFace { Color Color { get; set; } UUID Texture { get; set; } -- cgit v1.1 From ea9bb2f7416eb9f298fec168fa78f13baf6fa871 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 4 Mar 2009 20:28:11 +0000 Subject: * More work on MiniRegionModule module. --- .../OptionalModules/Scripting/Minimodule/Host.cs | 21 +++ .../Scripting/Minimodule/IAvatar.cs | 14 ++ .../OptionalModules/Scripting/Minimodule/IHost.cs | 11 ++ .../Scripting/Minimodule/MiniModule.cs | 202 +++++++++++++++++++++ .../Scripting/Minimodule/MiniModuleBase.cs | 27 +++ 5 files changed, 275 insertions(+) create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModule.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModuleBase.cs (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs new file mode 100644 index 0000000..41d368d --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + class Host : IHost + { + private readonly IObject m_obj; + + public Host(IObject m_obj) + { + this.m_obj = m_obj; + } + + public IObject Object + { + get { return m_obj; } + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs new file mode 100644 index 0000000..ba92c64 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + interface IAvatar + { + string Name { get; } + UUID GlobalID { get; } + Vector3 Position { get; } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs new file mode 100644 index 0000000..e47a278 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + interface IHost + { + IObject Object { get; } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModule.cs new file mode 100644 index 0000000..eb98215 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModule.cs @@ -0,0 +1,202 @@ +using System; +using System.CodeDom.Compiler; +using System.IO; +using System.Reflection; +using System.Text; +using log4net; +using Microsoft.CSharp; +using Nini.Config; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + class MiniModule : IRegionModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private Scene m_scene; + + + private static readonly CSharpCodeProvider CScodeProvider = new CSharpCodeProvider(); + + public void Initialise(Scene scene, IConfigSource source) + { + m_scene = scene; + scene.EventManager.OnRezScript += EventManager_OnRezScript; + } + + void EventManager_OnRezScript(uint localID, OpenMetaverse.UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) + { + if(engine == "MiniMod") + { + if(script.StartsWith("//MiniMod:C#")) + { + IWorld m_world = new World(m_scene); + IHost m_host = new Host(new SOPObject(m_scene, localID)); + + MiniModuleBase mmb = (MiniModuleBase) AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap( + CompileFromDotNetText(script, itemID.ToString()), + "OpenSim.MiniModule"); + mmb.InitMiniModule(m_world, m_host); + } + } + } + + public void PostInitialise() + { + + } + + public void Close() + { + + } + + public string Name + { + get { return "MiniScriptModule"; } + } + + public bool IsSharedModule + { + get { return false; } + } + + /// + /// Stolen from ScriptEngine Common + /// + /// + /// Unique ID for this module + /// + internal string CompileFromDotNetText(string Script, string uuid) + { + const string ext = ".cs"; + const string FilePrefix = "MiniModule"; + + // Output assembly name + string OutFile = Path.Combine("MiniModules", Path.Combine( + m_scene.RegionInfo.RegionID.ToString(), + FilePrefix + "_compiled_" + uuid + ".dll")); + try + { + File.Delete(OutFile); + } + catch (IOException e) + { + throw new Exception("Unable to delete old existing " + + "script-file before writing new. Compile aborted: " + + e); + } + + // DEBUG - write source to disk + string srcFileName = FilePrefix + "_source_" + + Path.GetFileNameWithoutExtension(OutFile) + ext; + try + { + File.WriteAllText(Path.Combine(Path.Combine( + "MiniModules", + m_scene.RegionInfo.RegionID.ToString()), + srcFileName), Script); + } + catch (Exception ex) //NOTLEGIT - Should be just FileIOException + { + m_log.Error("[Compiler]: Exception while " + + "trying to write script source to file \"" + + srcFileName + "\": " + ex.ToString()); + } + + // Do actual compile + CompilerParameters parameters = new CompilerParameters(); + + parameters.IncludeDebugInformation = true; + + string rootPath = + Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); + + + // TODO: Add Libraries + parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, + "OpenSim.Region.OptionalModules.dll")); + + + parameters.GenerateExecutable = false; + parameters.OutputAssembly = OutFile; + parameters.IncludeDebugInformation = true; + parameters.TreatWarningsAsErrors = false; + + CompilerResults results = CScodeProvider.CompileAssemblyFromSource( + parameters, Script); + + int display = 5; + if (results.Errors.Count > 0) + { + string errtext = String.Empty; + foreach (CompilerError CompErr in results.Errors) + { + // Show 5 errors max + // + if (display <= 0) + break; + display--; + + string severity = "Error"; + if (CompErr.IsWarning) + { + severity = "Warning"; + } + + string text = CompErr.ErrorText; + + // The Second Life viewer's script editor begins + // countingn lines and columns at 0, so we subtract 1. + errtext += String.Format("Line ({0},{1}): {4} {2}: {3}\n", + CompErr.Line - 1, CompErr.Column - 1, + CompErr.ErrorNumber, text, severity); + } + + if (!File.Exists(OutFile)) + { + throw new Exception(errtext); + } + } + + if (!File.Exists(OutFile)) + { + string errtext = String.Empty; + errtext += "No compile error. But not able to locate compiled file."; + throw new Exception(errtext); + } + + FileInfo fi = new FileInfo(OutFile); + + Byte[] data = new Byte[fi.Length]; + + try + { + FileStream fs = File.Open(OutFile, FileMode.Open, FileAccess.Read); + fs.Read(data, 0, data.Length); + fs.Close(); + } + catch (IOException) + { + string errtext = String.Empty; + errtext += "No compile error. But not able to open file."; + throw new Exception(errtext); + } + + // Convert to base64 + // + string filetext = Convert.ToBase64String(data); + + ASCIIEncoding enc = new ASCIIEncoding(); + + Byte[] buf = enc.GetBytes(filetext); + + FileStream sfs = File.Create(OutFile + ".cil.b64"); + sfs.Write(buf, 0, buf.Length); + sfs.Close(); + + return OutFile; + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModuleBase.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModuleBase.cs new file mode 100644 index 0000000..a886158 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModuleBase.cs @@ -0,0 +1,27 @@ +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + abstract class MiniModuleBase + { + private IWorld m_world; + private IHost m_host; + + public void InitMiniModule(IWorld world, IHost host) + { + m_world = world; + m_host = host; + } + + protected IWorld World + { + get { return m_world; } + } + + protected IHost Host + { + get { return m_host; } + } + + protected abstract void Start(); + protected abstract void Stop(); + } +} -- cgit v1.1 From e57ac6e0bfc4b9d95a171a9c3df016f207e0902d Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 4 Mar 2009 20:29:50 +0000 Subject: * Whoops. Left MiniModule enabled to anyone. (potential security risk). Disabled - edit code to load. --- OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModule.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModule.cs index eb98215..2e91142 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModule.cs @@ -27,6 +27,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule void EventManager_OnRezScript(uint localID, OpenMetaverse.UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) { + if(true) + return; + if(engine == "MiniMod") { if(script.StartsWith("//MiniMod:C#")) -- cgit v1.1 From f3aac0fa4af4b503e9fdffe866ca7c179d41f6aa Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 4 Mar 2009 22:14:40 +0000 Subject: * Fleshed out the MRM Module a little. * Please don't use this yet, it represents a very heavy security risk if you enable it. --- .../OptionalModules/Scripting/Minimodule/Host.cs | 8 ++ .../OptionalModules/Scripting/Minimodule/IHost.cs | 4 +- .../OptionalModules/Scripting/Minimodule/IWorld.cs | 2 +- .../Scripting/Minimodule/MiniModule.cs | 108 +++++++++++++-------- .../Scripting/Minimodule/MiniModuleBase.cs | 6 +- 5 files changed, 84 insertions(+), 44 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs index 41d368d..dcb70b4 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs @@ -1,12 +1,15 @@ using System; using System.Collections.Generic; +using System.Reflection; using System.Text; +using log4net; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { class Host : IHost { private readonly IObject m_obj; + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public Host(IObject m_obj) { @@ -17,5 +20,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { get { return m_obj; } } + + public ILog Console + { + get { return m_log; } + } } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs index e47a278..8f95ba7 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs @@ -1,11 +1,13 @@ using System; using System.Collections.Generic; using System.Text; +using log4net; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - interface IHost + public interface IHost { IObject Object { get; } + ILog Console { get; } } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs index 087f94f..2f1388e 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs @@ -4,7 +4,7 @@ using System.Text; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - interface IWorld + public interface IWorld { IObject[] Objects { get; } IHeightmap Terrain { get; } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModule.cs index 2e91142..ae8d632 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModule.cs @@ -1,47 +1,65 @@ using System; using System.CodeDom.Compiler; +using System.Collections.Generic; using System.IO; using System.Reflection; using System.Text; using log4net; using Microsoft.CSharp; using Nini.Config; +using OpenMetaverse; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - class MiniModule : IRegionModule + public class MiniModule : IRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_scene; + private readonly Dictionary m_scripts = new Dictionary(); private static readonly CSharpCodeProvider CScodeProvider = new CSharpCodeProvider(); public void Initialise(Scene scene, IConfigSource source) { - m_scene = scene; - scene.EventManager.OnRezScript += EventManager_OnRezScript; + if (source.Configs["MRM"] != null) + { + if (source.Configs["MRM"].GetBoolean("Enabled", false)) + { + m_log.Info("[MRM] Enabling MRM Module"); + m_scene = scene; + scene.EventManager.OnRezScript += EventManager_OnRezScript; + } + else + { + m_log.Info("[MRM] Disabled MRM Module (Express)"); + } + } + else + { + m_log.Info("[MRM] Disabled MRM Module (Omission)"); + } } - void EventManager_OnRezScript(uint localID, OpenMetaverse.UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) + void EventManager_OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) { - if(true) - return; - - if(engine == "MiniMod") + if (script.StartsWith("//MiniMod:C#")) { - if(script.StartsWith("//MiniMod:C#")) - { - IWorld m_world = new World(m_scene); - IHost m_host = new Host(new SOPObject(m_scene, localID)); - - MiniModuleBase mmb = (MiniModuleBase) AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap( - CompileFromDotNetText(script, itemID.ToString()), - "OpenSim.MiniModule"); - mmb.InitMiniModule(m_world, m_host); - } + m_log.Info("[MRM] Found C# MRM"); + IWorld m_world = new World(m_scene); + IHost m_host = new Host(new SOPObject(m_scene, localID)); + + MiniModuleBase mmb = (MiniModuleBase) AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap( + CompileFromDotNetText(script, itemID.ToString()), + "OpenSim.MiniModule"); + m_log.Info("[MRM] Created MRM Instance"); + mmb.InitMiniModule(m_world, m_host); + m_scripts[itemID] = mmb; + + m_log.Info("[MRM] Starting MRM"); + mmb.Start(); } } @@ -52,7 +70,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public void Close() { - + foreach (KeyValuePair pair in m_scripts) + { + pair.Value.Stop(); + } } public string Name @@ -78,8 +99,16 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule // Output assembly name string OutFile = Path.Combine("MiniModules", Path.Combine( - m_scene.RegionInfo.RegionID.ToString(), - FilePrefix + "_compiled_" + uuid + ".dll")); + m_scene.RegionInfo.RegionID.ToString(), + FilePrefix + "_compiled_" + uuid + ".dll")); + + // Create Directories for Assemblies + if (!Directory.Exists("MiniModules")) + Directory.CreateDirectory("MiniModules"); + string tmp = Path.Combine("MiniModules", m_scene.RegionInfo.RegionID.ToString()); + if (!Directory.Exists(tmp)) + Directory.CreateDirectory(tmp); + try { File.Delete(OutFile); @@ -87,26 +116,26 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule catch (IOException e) { throw new Exception("Unable to delete old existing " + - "script-file before writing new. Compile aborted: " + - e); + "script-file before writing new. Compile aborted: " + + e); } // DEBUG - write source to disk - string srcFileName = FilePrefix + "_source_" + - Path.GetFileNameWithoutExtension(OutFile) + ext; - try - { - File.WriteAllText(Path.Combine(Path.Combine( - "MiniModules", - m_scene.RegionInfo.RegionID.ToString()), - srcFileName), Script); - } - catch (Exception ex) //NOTLEGIT - Should be just FileIOException - { - m_log.Error("[Compiler]: Exception while " + - "trying to write script source to file \"" + - srcFileName + "\": " + ex.ToString()); - } + string srcFileName = FilePrefix + "_source_" + + Path.GetFileNameWithoutExtension(OutFile) + ext; + try + { + File.WriteAllText(Path.Combine(Path.Combine( + "MiniModules", + m_scene.RegionInfo.RegionID.ToString()), + srcFileName), Script); + } + catch (Exception ex) //NOTLEGIT - Should be just FileIOException + { + m_log.Error("[Compiler]: Exception while " + + "trying to write script source to file \"" + + srcFileName + "\": " + ex.ToString()); + } // Do actual compile CompilerParameters parameters = new CompilerParameters(); @@ -120,7 +149,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule // TODO: Add Libraries parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.OptionalModules.dll")); - + parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, + "log4net.dll")); parameters.GenerateExecutable = false; parameters.OutputAssembly = OutFile; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModuleBase.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModuleBase.cs index a886158..9ce4506 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModuleBase.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModuleBase.cs @@ -1,6 +1,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - abstract class MiniModuleBase + public abstract class MiniModuleBase { private IWorld m_world; private IHost m_host; @@ -21,7 +21,7 @@ get { return m_host; } } - protected abstract void Start(); - protected abstract void Stop(); + public abstract void Start(); + public abstract void Stop(); } } -- cgit v1.1 From 0e7e2eba14cd9a5302f6f14e57b7247a5199a65e Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 5 Mar 2009 00:16:06 +0000 Subject: * Implements a number of members on SOGObject for use with the MRM Script Engine API. * It's lag-tacular! :D --- .../Scripting/Minimodule/IObject.cs | 18 +-- .../Scripting/Minimodule/SOPObject.cs | 163 ++++++++++++++++++++- 2 files changed, 166 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs index 3456258..ef442d4 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs @@ -66,15 +66,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public enum PrimType { - NotPrimitive, - Box, - Cylinder, - Prism, - Sphere, - Torus, - Tube, - Ring, - Sculpt + NotPrimitive = 255, + Box = 0, + Cylinder = 1, + Prism = 2, + Sphere = 3, + Torus = 4, + Tube = 5, + Ring = 6, + Sculpt = 7 } public enum TextureMapping diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 55b9767..cf59cba 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -1,7 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Text; +using System.Collections.Generic; using OpenMetaverse; +using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule @@ -17,6 +16,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule m_localID = localID; } + /// + /// This needs to run very, very quickly. + /// It is utilized in nearly every property and method. + /// + /// private SceneObjectPart GetSOP() { if (m_rootScene.Entities.ContainsKey(m_localID)) @@ -42,7 +46,21 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public IObject[] Children { - get { throw new System.NotImplementedException(); } + get + { + SceneObjectPart my = GetSOP(); + int total = my.ParentGroup.Children.Count; + + IObject[] rets = new IObject[total]; + + int i = 0; + foreach (KeyValuePair pair in my.ParentGroup.Children) + { + rets[i++] = new SOPObject(m_rootScene, pair.Value.LocalId); + } + + return rets; + } } public IObject Root @@ -52,7 +70,18 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public IObjectFace[] Faces { - get { throw new System.NotImplementedException(); } + get + { + SceneObjectPart sop = GetSOP(); + IObjectFace[] rets = new IObjectFace[getNumberOfSides(sop)]; + + for (int i = 0; i < rets.Length;i++ ) + { + //rets[i] = new ObjectFace + } + + return rets; + } } public Vector3 Scale @@ -153,7 +182,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public PrimType PrimShape { - get { throw new System.NotImplementedException(); } + get { return (PrimType) getScriptPrimType(GetSOP().Shape); } set { throw new System.NotImplementedException(); } } @@ -162,5 +191,127 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule get { throw new System.NotImplementedException(); } set { throw new System.NotImplementedException(); } } + + + #region Supporting Functions + + // Helper functions to understand if object has cut, hollow, dimple, and other affecting number of faces + private static void hasCutHollowDimpleProfileCut(int primType, PrimitiveBaseShape shape, out bool hasCut, out bool hasHollow, + out bool hasDimple, out bool hasProfileCut) + { + if (primType == (int)PrimType.Box + || + primType == (int)PrimType.Cylinder + || + primType == (int)PrimType.Prism) + + hasCut = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); + else + hasCut = (shape.PathBegin > 0) || (shape.PathEnd > 0); + + hasHollow = shape.ProfileHollow > 0; + hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); // taken from llSetPrimitiveParms + hasProfileCut = hasDimple; // is it the same thing? + + } + + private static int getScriptPrimType(PrimitiveBaseShape primShape) + { + if (primShape.SculptEntry) + return (int) PrimType.Sculpt; + if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.Square) + { + if (primShape.PathCurve == (byte) Extrusion.Straight) + return (int) PrimType.Box; + if (primShape.PathCurve == (byte) Extrusion.Curve1) + return (int) PrimType.Tube; + } + else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.Circle) + { + if (primShape.PathCurve == (byte) Extrusion.Straight) + return (int) PrimType.Cylinder; + if (primShape.PathCurve == (byte) Extrusion.Curve1) + return (int) PrimType.Torus; + } + else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.HalfCircle) + { + if (primShape.PathCurve == (byte) Extrusion.Curve1 || primShape.PathCurve == (byte) Extrusion.Curve2) + return (int) PrimType.Sphere; + } + else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.EquilateralTriangle) + { + if (primShape.PathCurve == (byte) Extrusion.Straight) + return (int) PrimType.Prism; + if (primShape.PathCurve == (byte) Extrusion.Curve1) + return (int) PrimType.Ring; + } + return (int) PrimType.NotPrimitive; + } + + private static int getNumberOfSides(SceneObjectPart part) + { + int ret; + bool hasCut; + bool hasHollow; + bool hasDimple; + bool hasProfileCut; + + int primType = getScriptPrimType(part.Shape); + hasCutHollowDimpleProfileCut(primType, part.Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut); + + switch (primType) + { + default: + case (int) PrimType.Box: + ret = 6; + if (hasCut) ret += 2; + if (hasHollow) ret += 1; + break; + case (int) PrimType.Cylinder: + ret = 3; + if (hasCut) ret += 2; + if (hasHollow) ret += 1; + break; + case (int) PrimType.Prism: + ret = 5; + if (hasCut) ret += 2; + if (hasHollow) ret += 1; + break; + case (int) PrimType.Sphere: + ret = 1; + if (hasCut) ret += 2; + if (hasDimple) ret += 2; + if (hasHollow) + ret += 1; // GOTCHA: LSL shows 2 additional sides here. + // This has been fixed, but may cause porting issues. + break; + case (int) PrimType.Torus: + ret = 1; + if (hasCut) ret += 2; + if (hasProfileCut) ret += 2; + if (hasHollow) ret += 1; + break; + case (int) PrimType.Tube: + ret = 4; + if (hasCut) ret += 2; + if (hasProfileCut) ret += 2; + if (hasHollow) ret += 1; + break; + case (int) PrimType.Ring: + ret = 3; + if (hasCut) ret += 2; + if (hasProfileCut) ret += 2; + if (hasHollow) ret += 1; + break; + case (int) PrimType.Sculpt: + ret = 1; + break; + } + return ret; + } + + + #endregion + } } -- cgit v1.1 From 65990de3905a4b117e5fef2c535fcc9d920be6c5 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 5 Mar 2009 00:52:59 +0000 Subject: MRM Scripting Changes * Renames MiniRegionModule to MRMModule to make it more distinct from the actual Mini Region Module[s] executed in Scene. * Renames MiniRegionModuleBase to MRMBase for convenience. MRM's need to be adjusted to inherit from MRMBase. --- .../Scripting/Minimodule/MRMBase.cs | 27 +++ .../Scripting/Minimodule/MRMModule.cs | 235 +++++++++++++++++++++ .../Scripting/Minimodule/MiniModule.cs | 235 --------------------- .../Scripting/Minimodule/MiniModuleBase.cs | 27 --- .../Scripting/Minimodule/SOPObject.cs | 4 +- 5 files changed, 264 insertions(+), 264 deletions(-) create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMBase.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs delete mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModule.cs delete mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModuleBase.cs (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMBase.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMBase.cs new file mode 100644 index 0000000..b2e6d2e --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMBase.cs @@ -0,0 +1,27 @@ +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public abstract class MRMBase + { + private IWorld m_world; + private IHost m_host; + + public void InitMiniModule(IWorld world, IHost host) + { + m_world = world; + m_host = host; + } + + protected IWorld World + { + get { return m_world; } + } + + protected IHost Host + { + get { return m_host; } + } + + public abstract void Start(); + public abstract void Stop(); + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs new file mode 100644 index 0000000..86a3240 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -0,0 +1,235 @@ +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Text; +using log4net; +using Microsoft.CSharp; +using Nini.Config; +using OpenMetaverse; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public class MRMModule : IRegionModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private Scene m_scene; + + private readonly Dictionary m_scripts = new Dictionary(); + + private static readonly CSharpCodeProvider CScodeProvider = new CSharpCodeProvider(); + + public void Initialise(Scene scene, IConfigSource source) + { + if (source.Configs["MRM"] != null) + { + if (source.Configs["MRM"].GetBoolean("Enabled", false)) + { + m_log.Info("[MRM] Enabling MRM Module"); + m_scene = scene; + scene.EventManager.OnRezScript += EventManager_OnRezScript; + } + else + { + m_log.Info("[MRM] Disabled MRM Module (Express)"); + } + } + else + { + m_log.Info("[MRM] Disabled MRM Module (Omission)"); + } + } + + void EventManager_OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) + { + if (script.StartsWith("//MiniMod:C#")) + { + m_log.Info("[MRM] Found C# MRM"); + IWorld m_world = new World(m_scene); + IHost m_host = new Host(new SOPObject(m_scene, localID)); + + MRMBase mmb = (MRMBase) AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap( + CompileFromDotNetText(script, itemID.ToString()), + "OpenSim.MiniModule"); + m_log.Info("[MRM] Created MRM Instance"); + mmb.InitMiniModule(m_world, m_host); + m_scripts[itemID] = mmb; + + m_log.Info("[MRM] Starting MRM"); + mmb.Start(); + } + } + + public void PostInitialise() + { + + } + + public void Close() + { + foreach (KeyValuePair pair in m_scripts) + { + pair.Value.Stop(); + } + } + + public string Name + { + get { return "MiniRegionModule"; } + } + + public bool IsSharedModule + { + get { return false; } + } + + /// + /// Stolen from ScriptEngine Common + /// + /// + /// Unique ID for this module + /// + internal string CompileFromDotNetText(string Script, string uuid) + { + const string ext = ".cs"; + const string FilePrefix = "MiniModule"; + + // Output assembly name + string OutFile = Path.Combine("MiniModules", Path.Combine( + m_scene.RegionInfo.RegionID.ToString(), + FilePrefix + "_compiled_" + uuid + ".dll")); + + // Create Directories for Assemblies + if (!Directory.Exists("MiniModules")) + Directory.CreateDirectory("MiniModules"); + string tmp = Path.Combine("MiniModules", m_scene.RegionInfo.RegionID.ToString()); + if (!Directory.Exists(tmp)) + Directory.CreateDirectory(tmp); + + try + { + File.Delete(OutFile); + } + catch (IOException e) + { + throw new Exception("Unable to delete old existing " + + "script-file before writing new. Compile aborted: " + + e); + } + + // DEBUG - write source to disk + string srcFileName = FilePrefix + "_source_" + + Path.GetFileNameWithoutExtension(OutFile) + ext; + try + { + File.WriteAllText(Path.Combine(Path.Combine( + "MiniModules", + m_scene.RegionInfo.RegionID.ToString()), + srcFileName), Script); + } + catch (Exception ex) //NOTLEGIT - Should be just FileIOException + { + m_log.Error("[Compiler]: Exception while " + + "trying to write script source to file \"" + + srcFileName + "\": " + ex.ToString()); + } + + // Do actual compile + CompilerParameters parameters = new CompilerParameters(); + + parameters.IncludeDebugInformation = true; + + string rootPath = + Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); + + + // TODO: Add Libraries + parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, + "OpenSim.Region.OptionalModules.dll")); + parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, + "log4net.dll")); + + parameters.GenerateExecutable = false; + parameters.OutputAssembly = OutFile; + parameters.IncludeDebugInformation = true; + parameters.TreatWarningsAsErrors = false; + + CompilerResults results = CScodeProvider.CompileAssemblyFromSource( + parameters, Script); + + int display = 5; + if (results.Errors.Count > 0) + { + string errtext = String.Empty; + foreach (CompilerError CompErr in results.Errors) + { + // Show 5 errors max + // + if (display <= 0) + break; + display--; + + string severity = "Error"; + if (CompErr.IsWarning) + { + severity = "Warning"; + } + + string text = CompErr.ErrorText; + + // The Second Life viewer's script editor begins + // countingn lines and columns at 0, so we subtract 1. + errtext += String.Format("Line ({0},{1}): {4} {2}: {3}\n", + CompErr.Line - 1, CompErr.Column - 1, + CompErr.ErrorNumber, text, severity); + } + + if (!File.Exists(OutFile)) + { + throw new Exception(errtext); + } + } + + if (!File.Exists(OutFile)) + { + string errtext = String.Empty; + errtext += "No compile error. But not able to locate compiled file."; + throw new Exception(errtext); + } + + FileInfo fi = new FileInfo(OutFile); + + Byte[] data = new Byte[fi.Length]; + + try + { + FileStream fs = File.Open(OutFile, FileMode.Open, FileAccess.Read); + fs.Read(data, 0, data.Length); + fs.Close(); + } + catch (IOException) + { + string errtext = String.Empty; + errtext += "No compile error. But not able to open file."; + throw new Exception(errtext); + } + + // Convert to base64 + // + string filetext = Convert.ToBase64String(data); + + ASCIIEncoding enc = new ASCIIEncoding(); + + Byte[] buf = enc.GetBytes(filetext); + + FileStream sfs = File.Create(OutFile + ".cil.b64"); + sfs.Write(buf, 0, buf.Length); + sfs.Close(); + + return OutFile; + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModule.cs deleted file mode 100644 index ae8d632..0000000 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModule.cs +++ /dev/null @@ -1,235 +0,0 @@ -using System; -using System.CodeDom.Compiler; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Text; -using log4net; -using Microsoft.CSharp; -using Nini.Config; -using OpenMetaverse; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public class MiniModule : IRegionModule - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private Scene m_scene; - - private readonly Dictionary m_scripts = new Dictionary(); - - private static readonly CSharpCodeProvider CScodeProvider = new CSharpCodeProvider(); - - public void Initialise(Scene scene, IConfigSource source) - { - if (source.Configs["MRM"] != null) - { - if (source.Configs["MRM"].GetBoolean("Enabled", false)) - { - m_log.Info("[MRM] Enabling MRM Module"); - m_scene = scene; - scene.EventManager.OnRezScript += EventManager_OnRezScript; - } - else - { - m_log.Info("[MRM] Disabled MRM Module (Express)"); - } - } - else - { - m_log.Info("[MRM] Disabled MRM Module (Omission)"); - } - } - - void EventManager_OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) - { - if (script.StartsWith("//MiniMod:C#")) - { - m_log.Info("[MRM] Found C# MRM"); - IWorld m_world = new World(m_scene); - IHost m_host = new Host(new SOPObject(m_scene, localID)); - - MiniModuleBase mmb = (MiniModuleBase) AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap( - CompileFromDotNetText(script, itemID.ToString()), - "OpenSim.MiniModule"); - m_log.Info("[MRM] Created MRM Instance"); - mmb.InitMiniModule(m_world, m_host); - m_scripts[itemID] = mmb; - - m_log.Info("[MRM] Starting MRM"); - mmb.Start(); - } - } - - public void PostInitialise() - { - - } - - public void Close() - { - foreach (KeyValuePair pair in m_scripts) - { - pair.Value.Stop(); - } - } - - public string Name - { - get { return "MiniScriptModule"; } - } - - public bool IsSharedModule - { - get { return false; } - } - - /// - /// Stolen from ScriptEngine Common - /// - /// - /// Unique ID for this module - /// - internal string CompileFromDotNetText(string Script, string uuid) - { - const string ext = ".cs"; - const string FilePrefix = "MiniModule"; - - // Output assembly name - string OutFile = Path.Combine("MiniModules", Path.Combine( - m_scene.RegionInfo.RegionID.ToString(), - FilePrefix + "_compiled_" + uuid + ".dll")); - - // Create Directories for Assemblies - if (!Directory.Exists("MiniModules")) - Directory.CreateDirectory("MiniModules"); - string tmp = Path.Combine("MiniModules", m_scene.RegionInfo.RegionID.ToString()); - if (!Directory.Exists(tmp)) - Directory.CreateDirectory(tmp); - - try - { - File.Delete(OutFile); - } - catch (IOException e) - { - throw new Exception("Unable to delete old existing " + - "script-file before writing new. Compile aborted: " + - e); - } - - // DEBUG - write source to disk - string srcFileName = FilePrefix + "_source_" + - Path.GetFileNameWithoutExtension(OutFile) + ext; - try - { - File.WriteAllText(Path.Combine(Path.Combine( - "MiniModules", - m_scene.RegionInfo.RegionID.ToString()), - srcFileName), Script); - } - catch (Exception ex) //NOTLEGIT - Should be just FileIOException - { - m_log.Error("[Compiler]: Exception while " + - "trying to write script source to file \"" + - srcFileName + "\": " + ex.ToString()); - } - - // Do actual compile - CompilerParameters parameters = new CompilerParameters(); - - parameters.IncludeDebugInformation = true; - - string rootPath = - Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); - - - // TODO: Add Libraries - parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, - "OpenSim.Region.OptionalModules.dll")); - parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, - "log4net.dll")); - - parameters.GenerateExecutable = false; - parameters.OutputAssembly = OutFile; - parameters.IncludeDebugInformation = true; - parameters.TreatWarningsAsErrors = false; - - CompilerResults results = CScodeProvider.CompileAssemblyFromSource( - parameters, Script); - - int display = 5; - if (results.Errors.Count > 0) - { - string errtext = String.Empty; - foreach (CompilerError CompErr in results.Errors) - { - // Show 5 errors max - // - if (display <= 0) - break; - display--; - - string severity = "Error"; - if (CompErr.IsWarning) - { - severity = "Warning"; - } - - string text = CompErr.ErrorText; - - // The Second Life viewer's script editor begins - // countingn lines and columns at 0, so we subtract 1. - errtext += String.Format("Line ({0},{1}): {4} {2}: {3}\n", - CompErr.Line - 1, CompErr.Column - 1, - CompErr.ErrorNumber, text, severity); - } - - if (!File.Exists(OutFile)) - { - throw new Exception(errtext); - } - } - - if (!File.Exists(OutFile)) - { - string errtext = String.Empty; - errtext += "No compile error. But not able to locate compiled file."; - throw new Exception(errtext); - } - - FileInfo fi = new FileInfo(OutFile); - - Byte[] data = new Byte[fi.Length]; - - try - { - FileStream fs = File.Open(OutFile, FileMode.Open, FileAccess.Read); - fs.Read(data, 0, data.Length); - fs.Close(); - } - catch (IOException) - { - string errtext = String.Empty; - errtext += "No compile error. But not able to open file."; - throw new Exception(errtext); - } - - // Convert to base64 - // - string filetext = Convert.ToBase64String(data); - - ASCIIEncoding enc = new ASCIIEncoding(); - - Byte[] buf = enc.GetBytes(filetext); - - FileStream sfs = File.Create(OutFile + ".cil.b64"); - sfs.Write(buf, 0, buf.Length); - sfs.Close(); - - return OutFile; - } - } -} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModuleBase.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModuleBase.cs deleted file mode 100644 index 9ce4506..0000000 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MiniModuleBase.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public abstract class MiniModuleBase - { - private IWorld m_world; - private IHost m_host; - - public void InitMiniModule(IWorld world, IHost host) - { - m_world = world; - m_host = host; - } - - protected IWorld World - { - get { return m_world; } - } - - protected IHost Host - { - get { return m_host; } - } - - public abstract void Start(); - public abstract void Stop(); - } -} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index cf59cba..d939e85 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -86,8 +86,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public Vector3 Scale { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } + get { return GetSOP().Scale; } + set { GetSOP().Scale = value; } } public Quaternion Rotation -- cgit v1.1 From e1f68145be8b0cfc48c7fe6920ae8db1bfa049f5 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sat, 7 Mar 2009 02:00:18 +0000 Subject: Update svn properties. --- .../Scripting/Minimodule/Heightmap.cs | 68 +-- .../OptionalModules/Scripting/Minimodule/Host.cs | 58 +- .../Scripting/Minimodule/IAvatar.cs | 28 +- .../Scripting/Minimodule/IHeightmap.cs | 28 +- .../OptionalModules/Scripting/Minimodule/IHost.cs | 26 +- .../Scripting/Minimodule/IObject.cs | 192 +++---- .../OptionalModules/Scripting/Minimodule/IWorld.cs | 24 +- .../Scripting/Minimodule/MRMBase.cs | 54 +- .../Scripting/Minimodule/MRMModule.cs | 470 +++++++-------- .../Scripting/Minimodule/SOPObject.cs | 634 ++++++++++----------- .../OptionalModules/Scripting/Minimodule/World.cs | 78 +-- 11 files changed, 830 insertions(+), 830 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Heightmap.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Heightmap.cs index c75c6e7..6fa6ebe 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Heightmap.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Heightmap.cs @@ -1,34 +1,34 @@ -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public class Heightmap : IHeightmap - { - private Scene m_scene; - - public Heightmap(Scene scene) - { - m_scene = scene; - } - - public int Height - { - get { return m_scene.Heightmap.Height; } - } - - public int Width - { - get { return m_scene.Heightmap.Width; } - } - - public double Get(int x, int y) - { - return m_scene.Heightmap[x, y]; - } - - public void Set(int x, int y, double val) - { - m_scene.Heightmap[x, y] = val; - } - } -} +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public class Heightmap : IHeightmap + { + private Scene m_scene; + + public Heightmap(Scene scene) + { + m_scene = scene; + } + + public int Height + { + get { return m_scene.Heightmap.Height; } + } + + public int Width + { + get { return m_scene.Heightmap.Width; } + } + + public double Get(int x, int y) + { + return m_scene.Heightmap[x, y]; + } + + public void Set(int x, int y, double val) + { + m_scene.Heightmap[x, y] = val; + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs index dcb70b4..c8b51b6 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs @@ -1,29 +1,29 @@ -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Text; -using log4net; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - class Host : IHost - { - private readonly IObject m_obj; - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - public Host(IObject m_obj) - { - this.m_obj = m_obj; - } - - public IObject Object - { - get { return m_obj; } - } - - public ILog Console - { - get { return m_log; } - } - } -} +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Text; +using log4net; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + class Host : IHost + { + private readonly IObject m_obj; + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public Host(IObject m_obj) + { + this.m_obj = m_obj; + } + + public IObject Object + { + get { return m_obj; } + } + + public ILog Console + { + get { return m_log; } + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs index ba92c64..270ed89 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs @@ -1,14 +1,14 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenMetaverse; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - interface IAvatar - { - string Name { get; } - UUID GlobalID { get; } - Vector3 Position { get; } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + interface IAvatar + { + string Name { get; } + UUID GlobalID { get; } + Vector3 Position { get; } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs index b4502a4..84d602a 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs @@ -1,14 +1,14 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public interface IHeightmap - { - int Height { get; } - int Width { get; } - double Get(int x, int y); - void Set(int x, int y, double val); - } -} +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface IHeightmap + { + int Height { get; } + int Width { get; } + double Get(int x, int y); + void Set(int x, int y, double val); + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs index 8f95ba7..123fa38 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs @@ -1,13 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Text; -using log4net; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public interface IHost - { - IObject Object { get; } - ILog Console { get; } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using log4net; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface IHost + { + IObject Object { get; } + ILog Console { get; } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs index ef442d4..0c7bfc0 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs @@ -1,96 +1,96 @@ -using System; -using System.Drawing; -using OpenMetaverse; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public interface IObject - { - bool Exists { get; } - uint LocalID { get; } - UUID GlobalID { get; } - - IObject[] Children { get; } - - /// - /// Equals 'this' if we have no parent. Ergo, Root.Children.Count will always return the total number of items in the linkset. - /// - IObject Root { get; } - - IObjectFace[] Faces { get; } - - Vector3 Scale { get; set; } - Quaternion Rotation { get; set; } - - Vector3 SitTarget { get; set; } - String SitTargetText { get; set; } - - String TouchText { get; set; } - - String Text { get; set; } - - bool IsPhysical { get; set; } // SetStatus(PHYSICS) - bool IsPhantom { get; set; } // SetStatus(PHANTOM) - bool IsRotationLockedX { get; set; } // SetStatus(!ROTATE_X) - bool IsRotationLockedY { get; set; } // SetStatus(!ROTATE_Y) - bool IsRotationLockedZ { get; set; } // SetStatus(!ROTATE_Z) - bool IsSandboxed { get; set; } // SetStatus(SANDBOX) - bool IsImmotile { get; set; } // SetStatus(BLOCK_GRAB) - bool IsAlwaysReturned { get; set; } // SetStatus(!DIE_AT_EDGE) - bool IsTemporary { get; set; } // TEMP_ON_REZ - - bool IsFlexible { get; set; } - - PrimType PrimShape { get; set; } - // TODO: - // PrimHole - // Repeats, Offsets, Cut/Dimple/ProfileCut - // Hollow, Twist, HoleSize, - // Taper[A+B], Shear[A+B], Revolutions, - // RadiusOffset, Skew - - Material Material { get; set; } - } - - public enum Material - { - Default, - Glass, - Metal, - Plastic, - Wood, - Rubber, - Stone, - Flesh - } - - public enum PrimType - { - NotPrimitive = 255, - Box = 0, - Cylinder = 1, - Prism = 2, - Sphere = 3, - Torus = 4, - Tube = 5, - Ring = 6, - Sculpt = 7 - } - - public enum TextureMapping - { - Default, - Planar - } - - public interface IObjectFace - { - Color Color { get; set; } - UUID Texture { get; set; } - TextureMapping Mapping { get; set; } // SetPrimParms(PRIM_TEXGEN) - bool Bright { get; set; } // SetPrimParms(FULLBRIGHT) - double Bloom { get; set; } // SetPrimParms(GLOW) - bool Shiny { get; set; } // SetPrimParms(SHINY) - bool BumpMap { get; set; } // SetPrimParms(BUMPMAP) [DEPRECIATE IN FAVOUR OF UUID?] - } -} +using System; +using System.Drawing; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface IObject + { + bool Exists { get; } + uint LocalID { get; } + UUID GlobalID { get; } + + IObject[] Children { get; } + + /// + /// Equals 'this' if we have no parent. Ergo, Root.Children.Count will always return the total number of items in the linkset. + /// + IObject Root { get; } + + IObjectFace[] Faces { get; } + + Vector3 Scale { get; set; } + Quaternion Rotation { get; set; } + + Vector3 SitTarget { get; set; } + String SitTargetText { get; set; } + + String TouchText { get; set; } + + String Text { get; set; } + + bool IsPhysical { get; set; } // SetStatus(PHYSICS) + bool IsPhantom { get; set; } // SetStatus(PHANTOM) + bool IsRotationLockedX { get; set; } // SetStatus(!ROTATE_X) + bool IsRotationLockedY { get; set; } // SetStatus(!ROTATE_Y) + bool IsRotationLockedZ { get; set; } // SetStatus(!ROTATE_Z) + bool IsSandboxed { get; set; } // SetStatus(SANDBOX) + bool IsImmotile { get; set; } // SetStatus(BLOCK_GRAB) + bool IsAlwaysReturned { get; set; } // SetStatus(!DIE_AT_EDGE) + bool IsTemporary { get; set; } // TEMP_ON_REZ + + bool IsFlexible { get; set; } + + PrimType PrimShape { get; set; } + // TODO: + // PrimHole + // Repeats, Offsets, Cut/Dimple/ProfileCut + // Hollow, Twist, HoleSize, + // Taper[A+B], Shear[A+B], Revolutions, + // RadiusOffset, Skew + + Material Material { get; set; } + } + + public enum Material + { + Default, + Glass, + Metal, + Plastic, + Wood, + Rubber, + Stone, + Flesh + } + + public enum PrimType + { + NotPrimitive = 255, + Box = 0, + Cylinder = 1, + Prism = 2, + Sphere = 3, + Torus = 4, + Tube = 5, + Ring = 6, + Sculpt = 7 + } + + public enum TextureMapping + { + Default, + Planar + } + + public interface IObjectFace + { + Color Color { get; set; } + UUID Texture { get; set; } + TextureMapping Mapping { get; set; } // SetPrimParms(PRIM_TEXGEN) + bool Bright { get; set; } // SetPrimParms(FULLBRIGHT) + double Bloom { get; set; } // SetPrimParms(GLOW) + bool Shiny { get; set; } // SetPrimParms(SHINY) + bool BumpMap { get; set; } // SetPrimParms(BUMPMAP) [DEPRECIATE IN FAVOUR OF UUID?] + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs index 2f1388e..ea74524 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs @@ -1,12 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public interface IWorld - { - IObject[] Objects { get; } - IHeightmap Terrain { get; } - } -} +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface IWorld + { + IObject[] Objects { get; } + IHeightmap Terrain { get; } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMBase.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMBase.cs index b2e6d2e..cbef1ca 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMBase.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMBase.cs @@ -1,27 +1,27 @@ -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public abstract class MRMBase - { - private IWorld m_world; - private IHost m_host; - - public void InitMiniModule(IWorld world, IHost host) - { - m_world = world; - m_host = host; - } - - protected IWorld World - { - get { return m_world; } - } - - protected IHost Host - { - get { return m_host; } - } - - public abstract void Start(); - public abstract void Stop(); - } -} +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public abstract class MRMBase + { + private IWorld m_world; + private IHost m_host; + + public void InitMiniModule(IWorld world, IHost host) + { + m_world = world; + m_host = host; + } + + protected IWorld World + { + get { return m_world; } + } + + protected IHost Host + { + get { return m_host; } + } + + public abstract void Start(); + public abstract void Stop(); + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 86a3240..1536445 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -1,235 +1,235 @@ -using System; -using System.CodeDom.Compiler; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Text; -using log4net; -using Microsoft.CSharp; -using Nini.Config; -using OpenMetaverse; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public class MRMModule : IRegionModule - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private Scene m_scene; - - private readonly Dictionary m_scripts = new Dictionary(); - - private static readonly CSharpCodeProvider CScodeProvider = new CSharpCodeProvider(); - - public void Initialise(Scene scene, IConfigSource source) - { - if (source.Configs["MRM"] != null) - { - if (source.Configs["MRM"].GetBoolean("Enabled", false)) - { - m_log.Info("[MRM] Enabling MRM Module"); - m_scene = scene; - scene.EventManager.OnRezScript += EventManager_OnRezScript; - } - else - { - m_log.Info("[MRM] Disabled MRM Module (Express)"); - } - } - else - { - m_log.Info("[MRM] Disabled MRM Module (Omission)"); - } - } - - void EventManager_OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) - { - if (script.StartsWith("//MiniMod:C#")) - { - m_log.Info("[MRM] Found C# MRM"); - IWorld m_world = new World(m_scene); - IHost m_host = new Host(new SOPObject(m_scene, localID)); - - MRMBase mmb = (MRMBase) AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap( - CompileFromDotNetText(script, itemID.ToString()), - "OpenSim.MiniModule"); - m_log.Info("[MRM] Created MRM Instance"); - mmb.InitMiniModule(m_world, m_host); - m_scripts[itemID] = mmb; - - m_log.Info("[MRM] Starting MRM"); - mmb.Start(); - } - } - - public void PostInitialise() - { - - } - - public void Close() - { - foreach (KeyValuePair pair in m_scripts) - { - pair.Value.Stop(); - } - } - - public string Name - { - get { return "MiniRegionModule"; } - } - - public bool IsSharedModule - { - get { return false; } - } - - /// - /// Stolen from ScriptEngine Common - /// - /// - /// Unique ID for this module - /// - internal string CompileFromDotNetText(string Script, string uuid) - { - const string ext = ".cs"; - const string FilePrefix = "MiniModule"; - - // Output assembly name - string OutFile = Path.Combine("MiniModules", Path.Combine( - m_scene.RegionInfo.RegionID.ToString(), - FilePrefix + "_compiled_" + uuid + ".dll")); - - // Create Directories for Assemblies - if (!Directory.Exists("MiniModules")) - Directory.CreateDirectory("MiniModules"); - string tmp = Path.Combine("MiniModules", m_scene.RegionInfo.RegionID.ToString()); - if (!Directory.Exists(tmp)) - Directory.CreateDirectory(tmp); - - try - { - File.Delete(OutFile); - } - catch (IOException e) - { - throw new Exception("Unable to delete old existing " + - "script-file before writing new. Compile aborted: " + - e); - } - - // DEBUG - write source to disk - string srcFileName = FilePrefix + "_source_" + - Path.GetFileNameWithoutExtension(OutFile) + ext; - try - { - File.WriteAllText(Path.Combine(Path.Combine( - "MiniModules", - m_scene.RegionInfo.RegionID.ToString()), - srcFileName), Script); - } - catch (Exception ex) //NOTLEGIT - Should be just FileIOException - { - m_log.Error("[Compiler]: Exception while " + - "trying to write script source to file \"" + - srcFileName + "\": " + ex.ToString()); - } - - // Do actual compile - CompilerParameters parameters = new CompilerParameters(); - - parameters.IncludeDebugInformation = true; - - string rootPath = - Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); - - - // TODO: Add Libraries - parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, - "OpenSim.Region.OptionalModules.dll")); - parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, - "log4net.dll")); - - parameters.GenerateExecutable = false; - parameters.OutputAssembly = OutFile; - parameters.IncludeDebugInformation = true; - parameters.TreatWarningsAsErrors = false; - - CompilerResults results = CScodeProvider.CompileAssemblyFromSource( - parameters, Script); - - int display = 5; - if (results.Errors.Count > 0) - { - string errtext = String.Empty; - foreach (CompilerError CompErr in results.Errors) - { - // Show 5 errors max - // - if (display <= 0) - break; - display--; - - string severity = "Error"; - if (CompErr.IsWarning) - { - severity = "Warning"; - } - - string text = CompErr.ErrorText; - - // The Second Life viewer's script editor begins - // countingn lines and columns at 0, so we subtract 1. - errtext += String.Format("Line ({0},{1}): {4} {2}: {3}\n", - CompErr.Line - 1, CompErr.Column - 1, - CompErr.ErrorNumber, text, severity); - } - - if (!File.Exists(OutFile)) - { - throw new Exception(errtext); - } - } - - if (!File.Exists(OutFile)) - { - string errtext = String.Empty; - errtext += "No compile error. But not able to locate compiled file."; - throw new Exception(errtext); - } - - FileInfo fi = new FileInfo(OutFile); - - Byte[] data = new Byte[fi.Length]; - - try - { - FileStream fs = File.Open(OutFile, FileMode.Open, FileAccess.Read); - fs.Read(data, 0, data.Length); - fs.Close(); - } - catch (IOException) - { - string errtext = String.Empty; - errtext += "No compile error. But not able to open file."; - throw new Exception(errtext); - } - - // Convert to base64 - // - string filetext = Convert.ToBase64String(data); - - ASCIIEncoding enc = new ASCIIEncoding(); - - Byte[] buf = enc.GetBytes(filetext); - - FileStream sfs = File.Create(OutFile + ".cil.b64"); - sfs.Write(buf, 0, buf.Length); - sfs.Close(); - - return OutFile; - } - } -} +using System; +using System.CodeDom.Compiler; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Text; +using log4net; +using Microsoft.CSharp; +using Nini.Config; +using OpenMetaverse; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public class MRMModule : IRegionModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private Scene m_scene; + + private readonly Dictionary m_scripts = new Dictionary(); + + private static readonly CSharpCodeProvider CScodeProvider = new CSharpCodeProvider(); + + public void Initialise(Scene scene, IConfigSource source) + { + if (source.Configs["MRM"] != null) + { + if (source.Configs["MRM"].GetBoolean("Enabled", false)) + { + m_log.Info("[MRM] Enabling MRM Module"); + m_scene = scene; + scene.EventManager.OnRezScript += EventManager_OnRezScript; + } + else + { + m_log.Info("[MRM] Disabled MRM Module (Express)"); + } + } + else + { + m_log.Info("[MRM] Disabled MRM Module (Omission)"); + } + } + + void EventManager_OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) + { + if (script.StartsWith("//MiniMod:C#")) + { + m_log.Info("[MRM] Found C# MRM"); + IWorld m_world = new World(m_scene); + IHost m_host = new Host(new SOPObject(m_scene, localID)); + + MRMBase mmb = (MRMBase) AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap( + CompileFromDotNetText(script, itemID.ToString()), + "OpenSim.MiniModule"); + m_log.Info("[MRM] Created MRM Instance"); + mmb.InitMiniModule(m_world, m_host); + m_scripts[itemID] = mmb; + + m_log.Info("[MRM] Starting MRM"); + mmb.Start(); + } + } + + public void PostInitialise() + { + + } + + public void Close() + { + foreach (KeyValuePair pair in m_scripts) + { + pair.Value.Stop(); + } + } + + public string Name + { + get { return "MiniRegionModule"; } + } + + public bool IsSharedModule + { + get { return false; } + } + + /// + /// Stolen from ScriptEngine Common + /// + /// + /// Unique ID for this module + /// + internal string CompileFromDotNetText(string Script, string uuid) + { + const string ext = ".cs"; + const string FilePrefix = "MiniModule"; + + // Output assembly name + string OutFile = Path.Combine("MiniModules", Path.Combine( + m_scene.RegionInfo.RegionID.ToString(), + FilePrefix + "_compiled_" + uuid + ".dll")); + + // Create Directories for Assemblies + if (!Directory.Exists("MiniModules")) + Directory.CreateDirectory("MiniModules"); + string tmp = Path.Combine("MiniModules", m_scene.RegionInfo.RegionID.ToString()); + if (!Directory.Exists(tmp)) + Directory.CreateDirectory(tmp); + + try + { + File.Delete(OutFile); + } + catch (IOException e) + { + throw new Exception("Unable to delete old existing " + + "script-file before writing new. Compile aborted: " + + e); + } + + // DEBUG - write source to disk + string srcFileName = FilePrefix + "_source_" + + Path.GetFileNameWithoutExtension(OutFile) + ext; + try + { + File.WriteAllText(Path.Combine(Path.Combine( + "MiniModules", + m_scene.RegionInfo.RegionID.ToString()), + srcFileName), Script); + } + catch (Exception ex) //NOTLEGIT - Should be just FileIOException + { + m_log.Error("[Compiler]: Exception while " + + "trying to write script source to file \"" + + srcFileName + "\": " + ex.ToString()); + } + + // Do actual compile + CompilerParameters parameters = new CompilerParameters(); + + parameters.IncludeDebugInformation = true; + + string rootPath = + Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); + + + // TODO: Add Libraries + parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, + "OpenSim.Region.OptionalModules.dll")); + parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, + "log4net.dll")); + + parameters.GenerateExecutable = false; + parameters.OutputAssembly = OutFile; + parameters.IncludeDebugInformation = true; + parameters.TreatWarningsAsErrors = false; + + CompilerResults results = CScodeProvider.CompileAssemblyFromSource( + parameters, Script); + + int display = 5; + if (results.Errors.Count > 0) + { + string errtext = String.Empty; + foreach (CompilerError CompErr in results.Errors) + { + // Show 5 errors max + // + if (display <= 0) + break; + display--; + + string severity = "Error"; + if (CompErr.IsWarning) + { + severity = "Warning"; + } + + string text = CompErr.ErrorText; + + // The Second Life viewer's script editor begins + // countingn lines and columns at 0, so we subtract 1. + errtext += String.Format("Line ({0},{1}): {4} {2}: {3}\n", + CompErr.Line - 1, CompErr.Column - 1, + CompErr.ErrorNumber, text, severity); + } + + if (!File.Exists(OutFile)) + { + throw new Exception(errtext); + } + } + + if (!File.Exists(OutFile)) + { + string errtext = String.Empty; + errtext += "No compile error. But not able to locate compiled file."; + throw new Exception(errtext); + } + + FileInfo fi = new FileInfo(OutFile); + + Byte[] data = new Byte[fi.Length]; + + try + { + FileStream fs = File.Open(OutFile, FileMode.Open, FileAccess.Read); + fs.Read(data, 0, data.Length); + fs.Close(); + } + catch (IOException) + { + string errtext = String.Empty; + errtext += "No compile error. But not able to open file."; + throw new Exception(errtext); + } + + // Convert to base64 + // + string filetext = Convert.ToBase64String(data); + + ASCIIEncoding enc = new ASCIIEncoding(); + + Byte[] buf = enc.GetBytes(filetext); + + FileStream sfs = File.Create(OutFile + ".cil.b64"); + sfs.Write(buf, 0, buf.Length); + sfs.Close(); + + return OutFile; + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index d939e85..e154b79 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -1,317 +1,317 @@ -using System.Collections.Generic; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - class SOPObject : IObject - { - private readonly Scene m_rootScene; - private readonly uint m_localID; - - public SOPObject(Scene rootScene, uint localID) - { - m_rootScene = rootScene; - m_localID = localID; - } - - /// - /// This needs to run very, very quickly. - /// It is utilized in nearly every property and method. - /// - /// - private SceneObjectPart GetSOP() - { - if (m_rootScene.Entities.ContainsKey(m_localID)) - return ((SceneObjectGroup) m_rootScene.Entities[m_localID]).RootPart; - - return null; - } - - public bool Exists - { - get { return GetSOP() != null; } - } - - public uint LocalID - { - get { return m_localID; } - } - - public UUID GlobalID - { - get { return GetSOP().UUID; } - } - - public IObject[] Children - { - get - { - SceneObjectPart my = GetSOP(); - int total = my.ParentGroup.Children.Count; - - IObject[] rets = new IObject[total]; - - int i = 0; - foreach (KeyValuePair pair in my.ParentGroup.Children) - { - rets[i++] = new SOPObject(m_rootScene, pair.Value.LocalId); - } - - return rets; - } - } - - public IObject Root - { - get { return new SOPObject(m_rootScene, GetSOP().ParentGroup.RootPart.LocalId); } - } - - public IObjectFace[] Faces - { - get - { - SceneObjectPart sop = GetSOP(); - IObjectFace[] rets = new IObjectFace[getNumberOfSides(sop)]; - - for (int i = 0; i < rets.Length;i++ ) - { - //rets[i] = new ObjectFace - } - - return rets; - } - } - - public Vector3 Scale - { - get { return GetSOP().Scale; } - set { GetSOP().Scale = value; } - } - - public Quaternion Rotation - { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } - } - - public Vector3 SitTarget - { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } - } - - public string SitTargetText - { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } - } - - public string TouchText - { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } - } - - public string Text - { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } - } - - public bool IsPhysical - { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } - } - - public bool IsPhantom - { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } - } - - public bool IsRotationLockedX - { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } - } - - public bool IsRotationLockedY - { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } - } - - public bool IsRotationLockedZ - { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } - } - - public bool IsSandboxed - { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } - } - - public bool IsImmotile - { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } - } - - public bool IsAlwaysReturned - { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } - } - - public bool IsTemporary - { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } - } - - public bool IsFlexible - { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } - } - - public PrimType PrimShape - { - get { return (PrimType) getScriptPrimType(GetSOP().Shape); } - set { throw new System.NotImplementedException(); } - } - - public Material Material - { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } - } - - - #region Supporting Functions - - // Helper functions to understand if object has cut, hollow, dimple, and other affecting number of faces - private static void hasCutHollowDimpleProfileCut(int primType, PrimitiveBaseShape shape, out bool hasCut, out bool hasHollow, - out bool hasDimple, out bool hasProfileCut) - { - if (primType == (int)PrimType.Box - || - primType == (int)PrimType.Cylinder - || - primType == (int)PrimType.Prism) - - hasCut = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); - else - hasCut = (shape.PathBegin > 0) || (shape.PathEnd > 0); - - hasHollow = shape.ProfileHollow > 0; - hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); // taken from llSetPrimitiveParms - hasProfileCut = hasDimple; // is it the same thing? - - } - - private static int getScriptPrimType(PrimitiveBaseShape primShape) - { - if (primShape.SculptEntry) - return (int) PrimType.Sculpt; - if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.Square) - { - if (primShape.PathCurve == (byte) Extrusion.Straight) - return (int) PrimType.Box; - if (primShape.PathCurve == (byte) Extrusion.Curve1) - return (int) PrimType.Tube; - } - else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.Circle) - { - if (primShape.PathCurve == (byte) Extrusion.Straight) - return (int) PrimType.Cylinder; - if (primShape.PathCurve == (byte) Extrusion.Curve1) - return (int) PrimType.Torus; - } - else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.HalfCircle) - { - if (primShape.PathCurve == (byte) Extrusion.Curve1 || primShape.PathCurve == (byte) Extrusion.Curve2) - return (int) PrimType.Sphere; - } - else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.EquilateralTriangle) - { - if (primShape.PathCurve == (byte) Extrusion.Straight) - return (int) PrimType.Prism; - if (primShape.PathCurve == (byte) Extrusion.Curve1) - return (int) PrimType.Ring; - } - return (int) PrimType.NotPrimitive; - } - - private static int getNumberOfSides(SceneObjectPart part) - { - int ret; - bool hasCut; - bool hasHollow; - bool hasDimple; - bool hasProfileCut; - - int primType = getScriptPrimType(part.Shape); - hasCutHollowDimpleProfileCut(primType, part.Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut); - - switch (primType) - { - default: - case (int) PrimType.Box: - ret = 6; - if (hasCut) ret += 2; - if (hasHollow) ret += 1; - break; - case (int) PrimType.Cylinder: - ret = 3; - if (hasCut) ret += 2; - if (hasHollow) ret += 1; - break; - case (int) PrimType.Prism: - ret = 5; - if (hasCut) ret += 2; - if (hasHollow) ret += 1; - break; - case (int) PrimType.Sphere: - ret = 1; - if (hasCut) ret += 2; - if (hasDimple) ret += 2; - if (hasHollow) - ret += 1; // GOTCHA: LSL shows 2 additional sides here. - // This has been fixed, but may cause porting issues. - break; - case (int) PrimType.Torus: - ret = 1; - if (hasCut) ret += 2; - if (hasProfileCut) ret += 2; - if (hasHollow) ret += 1; - break; - case (int) PrimType.Tube: - ret = 4; - if (hasCut) ret += 2; - if (hasProfileCut) ret += 2; - if (hasHollow) ret += 1; - break; - case (int) PrimType.Ring: - ret = 3; - if (hasCut) ret += 2; - if (hasProfileCut) ret += 2; - if (hasHollow) ret += 1; - break; - case (int) PrimType.Sculpt: - ret = 1; - break; - } - return ret; - } - - - #endregion - - } -} +using System.Collections.Generic; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + class SOPObject : IObject + { + private readonly Scene m_rootScene; + private readonly uint m_localID; + + public SOPObject(Scene rootScene, uint localID) + { + m_rootScene = rootScene; + m_localID = localID; + } + + /// + /// This needs to run very, very quickly. + /// It is utilized in nearly every property and method. + /// + /// + private SceneObjectPart GetSOP() + { + if (m_rootScene.Entities.ContainsKey(m_localID)) + return ((SceneObjectGroup) m_rootScene.Entities[m_localID]).RootPart; + + return null; + } + + public bool Exists + { + get { return GetSOP() != null; } + } + + public uint LocalID + { + get { return m_localID; } + } + + public UUID GlobalID + { + get { return GetSOP().UUID; } + } + + public IObject[] Children + { + get + { + SceneObjectPart my = GetSOP(); + int total = my.ParentGroup.Children.Count; + + IObject[] rets = new IObject[total]; + + int i = 0; + foreach (KeyValuePair pair in my.ParentGroup.Children) + { + rets[i++] = new SOPObject(m_rootScene, pair.Value.LocalId); + } + + return rets; + } + } + + public IObject Root + { + get { return new SOPObject(m_rootScene, GetSOP().ParentGroup.RootPart.LocalId); } + } + + public IObjectFace[] Faces + { + get + { + SceneObjectPart sop = GetSOP(); + IObjectFace[] rets = new IObjectFace[getNumberOfSides(sop)]; + + for (int i = 0; i < rets.Length;i++ ) + { + //rets[i] = new ObjectFace + } + + return rets; + } + } + + public Vector3 Scale + { + get { return GetSOP().Scale; } + set { GetSOP().Scale = value; } + } + + public Quaternion Rotation + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public Vector3 SitTarget + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public string SitTargetText + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public string TouchText + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public string Text + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public bool IsPhysical + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public bool IsPhantom + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public bool IsRotationLockedX + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public bool IsRotationLockedY + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public bool IsRotationLockedZ + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public bool IsSandboxed + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public bool IsImmotile + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public bool IsAlwaysReturned + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public bool IsTemporary + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public bool IsFlexible + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public PrimType PrimShape + { + get { return (PrimType) getScriptPrimType(GetSOP().Shape); } + set { throw new System.NotImplementedException(); } + } + + public Material Material + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + + #region Supporting Functions + + // Helper functions to understand if object has cut, hollow, dimple, and other affecting number of faces + private static void hasCutHollowDimpleProfileCut(int primType, PrimitiveBaseShape shape, out bool hasCut, out bool hasHollow, + out bool hasDimple, out bool hasProfileCut) + { + if (primType == (int)PrimType.Box + || + primType == (int)PrimType.Cylinder + || + primType == (int)PrimType.Prism) + + hasCut = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); + else + hasCut = (shape.PathBegin > 0) || (shape.PathEnd > 0); + + hasHollow = shape.ProfileHollow > 0; + hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); // taken from llSetPrimitiveParms + hasProfileCut = hasDimple; // is it the same thing? + + } + + private static int getScriptPrimType(PrimitiveBaseShape primShape) + { + if (primShape.SculptEntry) + return (int) PrimType.Sculpt; + if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.Square) + { + if (primShape.PathCurve == (byte) Extrusion.Straight) + return (int) PrimType.Box; + if (primShape.PathCurve == (byte) Extrusion.Curve1) + return (int) PrimType.Tube; + } + else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.Circle) + { + if (primShape.PathCurve == (byte) Extrusion.Straight) + return (int) PrimType.Cylinder; + if (primShape.PathCurve == (byte) Extrusion.Curve1) + return (int) PrimType.Torus; + } + else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.HalfCircle) + { + if (primShape.PathCurve == (byte) Extrusion.Curve1 || primShape.PathCurve == (byte) Extrusion.Curve2) + return (int) PrimType.Sphere; + } + else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.EquilateralTriangle) + { + if (primShape.PathCurve == (byte) Extrusion.Straight) + return (int) PrimType.Prism; + if (primShape.PathCurve == (byte) Extrusion.Curve1) + return (int) PrimType.Ring; + } + return (int) PrimType.NotPrimitive; + } + + private static int getNumberOfSides(SceneObjectPart part) + { + int ret; + bool hasCut; + bool hasHollow; + bool hasDimple; + bool hasProfileCut; + + int primType = getScriptPrimType(part.Shape); + hasCutHollowDimpleProfileCut(primType, part.Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut); + + switch (primType) + { + default: + case (int) PrimType.Box: + ret = 6; + if (hasCut) ret += 2; + if (hasHollow) ret += 1; + break; + case (int) PrimType.Cylinder: + ret = 3; + if (hasCut) ret += 2; + if (hasHollow) ret += 1; + break; + case (int) PrimType.Prism: + ret = 5; + if (hasCut) ret += 2; + if (hasHollow) ret += 1; + break; + case (int) PrimType.Sphere: + ret = 1; + if (hasCut) ret += 2; + if (hasDimple) ret += 2; + if (hasHollow) + ret += 1; // GOTCHA: LSL shows 2 additional sides here. + // This has been fixed, but may cause porting issues. + break; + case (int) PrimType.Torus: + ret = 1; + if (hasCut) ret += 2; + if (hasProfileCut) ret += 2; + if (hasHollow) ret += 1; + break; + case (int) PrimType.Tube: + ret = 4; + if (hasCut) ret += 2; + if (hasProfileCut) ret += 2; + if (hasHollow) ret += 1; + break; + case (int) PrimType.Ring: + ret = 3; + if (hasCut) ret += 2; + if (hasProfileCut) ret += 2; + if (hasHollow) ret += 1; + break; + case (int) PrimType.Sculpt: + ret = 1; + break; + } + return ret; + } + + + #endregion + + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index 6c7f854..b1a4394 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs @@ -1,39 +1,39 @@ -using System.Collections.Generic; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public class World : IWorld - { - private readonly Scene m_internalScene; - private readonly Heightmap m_heights; - - public World(Scene internalScene) - { - m_internalScene = internalScene; - m_heights = new Heightmap(m_internalScene); - } - - public IObject[] Objects - { - get - { - List ents = m_internalScene.Entities.GetAllByType(); - IObject[] rets = new IObject[ents.Count]; - - for (int i = 0; i < ents.Count; i++) - { - EntityBase ent = ents[i]; - rets[i] = new SOPObject(m_internalScene, ent.LocalId); - } - - return rets; - } - } - - public IHeightmap Terrain - { - get { return m_heights; } - } - } -} +using System.Collections.Generic; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public class World : IWorld + { + private readonly Scene m_internalScene; + private readonly Heightmap m_heights; + + public World(Scene internalScene) + { + m_internalScene = internalScene; + m_heights = new Heightmap(m_internalScene); + } + + public IObject[] Objects + { + get + { + List ents = m_internalScene.Entities.GetAllByType(); + IObject[] rets = new IObject[ents.Count]; + + for (int i = 0; i < ents.Count; i++) + { + EntityBase ent = ents[i]; + rets[i] = new SOPObject(m_internalScene, ent.LocalId); + } + + return rets; + } + } + + public IHeightmap Terrain + { + get { return m_heights; } + } + } +} -- cgit v1.1 From 3fe42386e488026b7211b18c3d8cff029ce1c61f Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sat, 7 Mar 2009 02:11:50 +0000 Subject: Add copyright headers. --- .../Scripting/Minimodule/Heightmap.cs | 29 +++++++++++++++++++++- .../OptionalModules/Scripting/Minimodule/Host.cs | 29 +++++++++++++++++++++- .../Scripting/Minimodule/IAvatar.cs | 29 +++++++++++++++++++++- .../Scripting/Minimodule/IHeightmap.cs | 29 +++++++++++++++++++++- .../OptionalModules/Scripting/Minimodule/IHost.cs | 29 +++++++++++++++++++++- .../Scripting/Minimodule/IObject.cs | 29 +++++++++++++++++++++- .../OptionalModules/Scripting/Minimodule/IWorld.cs | 29 +++++++++++++++++++++- .../Scripting/Minimodule/MRMBase.cs | 29 +++++++++++++++++++++- .../Scripting/Minimodule/MRMModule.cs | 29 +++++++++++++++++++++- .../Scripting/Minimodule/SOPObject.cs | 29 +++++++++++++++++++++- .../OptionalModules/Scripting/Minimodule/World.cs | 29 +++++++++++++++++++++- 11 files changed, 308 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Heightmap.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Heightmap.cs index 6fa6ebe..2f6c204 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Heightmap.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Heightmap.cs @@ -1,4 +1,31 @@ -using OpenSim.Region.Framework.Scenes; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs index c8b51b6..5a3690f 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; using System.Collections.Generic; using System.Reflection; using System.Text; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs index 270ed89..e979378 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; using System.Collections.Generic; using System.Text; using OpenMetaverse; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs index 84d602a..37cf8ae 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; using System.Collections.Generic; using System.Text; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs index 123fa38..deb7c57 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; using System.Collections.Generic; using System.Text; using log4net; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs index 0c7bfc0..1ccc8a4 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; using System.Drawing; using OpenMetaverse; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs index ea74524..63fdc74 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; using System.Collections.Generic; using System.Text; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMBase.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMBase.cs index cbef1ca..b98bb95 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMBase.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMBase.cs @@ -1,4 +1,31 @@ -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { public abstract class MRMBase { diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 1536445..7c87756 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.IO; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index e154b79..e1b9f3e 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -1,4 +1,31 @@ -using System.Collections.Generic; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Collections.Generic; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index b1a4394..cdefe16 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs @@ -1,4 +1,31 @@ -using System.Collections.Generic; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Collections.Generic; using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -- cgit v1.1 From 5225e40f9e2cfdbc5a14099f45e794ed208838f5 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 1 Apr 2009 05:58:07 +0000 Subject: * Removes some hard-coded magic numbers relating to RegionSize. We now use Constants.RegionSize as expected. (Working towards enlarged or smaller regionsizes that arent multiples of 256m) * Adds minor functionality to MRM Scripting. --- .../Scripting/Minimodule/IObject.cs | 6 ++- .../Scripting/Minimodule/SOPObject.cs | 51 ++++++++++------------ 2 files changed, 28 insertions(+), 29 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs index 1ccc8a4..c7f9569 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -37,6 +37,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule uint LocalID { get; } UUID GlobalID { get; } + String Name { get; set; } + String Description { get; set; } + IObject[] Children { get; } /// @@ -48,6 +51,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule Vector3 Scale { get; set; } Quaternion Rotation { get; set; } + Vector3 Position { get; set; } Vector3 SitTarget { get; set; } String SitTargetText { get; set; } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index e1b9f3e..538a496 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -1,31 +1,4 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System.Collections.Generic; +using System.Collections.Generic; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; @@ -71,6 +44,18 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule get { return GetSOP().UUID; } } + public string Name + { + get { return GetSOP().Name; } + set { GetSOP().Name = value; } + } + + public string Description + { + get { return GetSOP().Description; } + set { GetSOP().Description = value; } + } + public IObject[] Children { get @@ -123,6 +108,16 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule set { throw new System.NotImplementedException(); } } + public Vector3 Position + { + get { return GetSOP().AbsolutePosition; } + set + { + SceneObjectPart pos = GetSOP(); + pos.UpdateOffSet(value - pos.AbsolutePosition); + } + } + public Vector3 SitTarget { get { throw new System.NotImplementedException(); } -- cgit v1.1 From 7eccad05c9623d9fe80c29d3e30a6511caf00531 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 1 Apr 2009 06:55:39 +0000 Subject: * Adds World.Avatars[] to MRM Scripting. Contains an enumerable array containing IAvatar instances for each avatar in the region. * Adds Test/TestModule.cs which demonstrates a very quick and simple MRM Test. --- .../Scripting/Minimodule/IAvatar.cs | 2 +- .../OptionalModules/Scripting/Minimodule/IWorld.cs | 1 + .../Scripting/Minimodule/SPAvatar.cs | 37 ++++++++++++++++++++++ .../Scripting/Minimodule/Test/TestModule.cs | 17 ++++++++++ .../OptionalModules/Scripting/Minimodule/World.cs | 17 ++++++++++ 5 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs index e979378..a500154 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs @@ -32,7 +32,7 @@ using OpenMetaverse; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - interface IAvatar + public interface IAvatar { string Name { get; } UUID GlobalID { get; } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs index 63fdc74..bfa6b65 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs @@ -34,6 +34,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public interface IWorld { IObject[] Objects { get; } + IAvatar[] Avatars { get; } IHeightmap Terrain { get; } } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs new file mode 100644 index 0000000..6011e0b --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs @@ -0,0 +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; } + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs new file mode 100644 index 0000000..abbef0b --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs @@ -0,0 +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() + { + + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index cdefe16..4ba6778 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs @@ -58,6 +58,23 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule } } + public IAvatar[] Avatars + { + get + { + List ents = m_internalScene.Entities.GetAllByType(); + IAvatar[] rets = new IAvatar[ents.Count]; + + for (int i = 0; i < ents.Count; i++) + { + EntityBase ent = ents[i]; + rets[i] = new SPAvatar(m_internalScene, ent.UUID); + } + + return rets; + } + } + public IHeightmap Terrain { get { return m_heights; } -- cgit v1.1 From 5cd70a8c0e3786712fa7dc3be8c947829be060c7 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 1 Apr 2009 09:31:40 +0000 Subject: * MRM Adjustments * Changes World.Objects from Array IObject[] to IObjectAccessor. * Syntactically identical in most behaviour, however the indexer is now ranges not from 0..Count, but any valid internal LocalID. Additional indexers have been added for UUID. * Example: for(int i=0;i + { + 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/IWorld.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs index bfa6b65..1b1ce92 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs @@ -33,7 +33,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { public interface IWorld { - IObject[] Objects { get; } + IObjectAccessor Objects { get; } IAvatar[] Avatars { get; } IHeightmap Terrain { get; } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs new file mode 100644 index 0000000..ad7182e --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs @@ -0,0 +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; } + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index 4ba6778..987868a 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs @@ -35,27 +35,18 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule private readonly Scene m_internalScene; private readonly Heightmap m_heights; + private ObjectAccessor m_objs; + public World(Scene internalScene) { m_internalScene = internalScene; m_heights = new Heightmap(m_internalScene); + m_objs = new ObjectAccessor(m_internalScene); } - public IObject[] Objects + public IObjectAccessor Objects { - get - { - List ents = m_internalScene.Entities.GetAllByType(); - IObject[] rets = new IObject[ents.Count]; - - for (int i = 0; i < ents.Count; i++) - { - EntityBase ent = ents[i]; - rets[i] = new SOPObject(m_internalScene, ent.LocalId); - } - - return rets; - } + get { return m_objs; } } public IAvatar[] Avatars -- cgit v1.1 From 1a25969096834e104d1ea69a26cab9c5b0a061eb Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 1 Apr 2009 11:03:42 +0000 Subject: * MRM Adjustments * Renamed 'Material' to PhysicsMaterial (Wood, Glass, Metal, etc.). May want to place in subclass with other physics specific properties. (We however need to support these features in ODE/etc first.) * Renamed Faces to Materials. IObjectFace to IObjectMaterial - this is for clarity for those coming from a 3D Programming background (it also makes more sense if/when we support Meshes in core). Properties and members remain identical. * Added XMLDoc comments to IObject to assist people writing MRMs in XMLDoc aware editors. --- .../Scripting/Minimodule/IObject.cs | 34 ++++++++++++++++++---- .../OptionalModules/Scripting/Minimodule/IWorld.cs | 4 --- .../Scripting/Minimodule/SOPObject.cs | 6 ++-- .../OptionalModules/Scripting/Minimodule/World.cs | 2 +- 4 files changed, 32 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs index c7f9569..da8fce5 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs @@ -40,19 +40,41 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule String Name { get; set; } String Description { get; set; } - IObject[] Children { get; } + /// - /// Equals 'this' if we have no parent. Ergo, Root.Children.Count will always return the total number of items in the linkset. + /// Returns the root object of a linkset. If this object is the root, it will return itself. /// IObject Root { get; } - IObjectFace[] Faces { get; } + /// + /// Returns a collection of objects which are linked to the current object. Does not include the root object. + /// + IObject[] Children { get; } + + /// + /// Returns a list of materials attached to this object. Each may contain unique texture + /// and other visual information. For primitive based objects, this correlates with + /// Object Faces. For mesh based objects, this correlates with Materials. + /// + IObjectMaterial[] Materials { get; } + /// + /// The bounding box of the object. Primitive and Mesh objects alike are scaled to fit within these bounds. + /// Vector3 Scale { get; set; } + + /// + /// The rotation of the object relative to the Scene + /// Quaternion Rotation { get; set; } + + /// + /// The position of the object relative to the Scene + /// Vector3 Position { get; set; } + Vector3 SitTarget { get; set; } String SitTargetText { get; set; } @@ -80,10 +102,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule // Taper[A+B], Shear[A+B], Revolutions, // RadiusOffset, Skew - Material Material { get; set; } + PhysicsMaterial PhysicsMaterial { get; set; } } - public enum Material + public enum PhysicsMaterial { Default, Glass, @@ -114,7 +136,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule Planar } - public interface IObjectFace + public interface IObjectMaterial { Color Color { get; set; } UUID Texture { get; set; } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs index 1b1ce92..f06f57a 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs @@ -25,10 +25,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { public interface IWorld diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 538a496..8b7b470 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -80,12 +80,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule get { return new SOPObject(m_rootScene, GetSOP().ParentGroup.RootPart.LocalId); } } - public IObjectFace[] Faces + public IObjectMaterial[] Materials { get { SceneObjectPart sop = GetSOP(); - IObjectFace[] rets = new IObjectFace[getNumberOfSides(sop)]; + IObjectMaterial[] rets = new IObjectMaterial[getNumberOfSides(sop)]; for (int i = 0; i < rets.Length;i++ ) { @@ -208,7 +208,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule set { throw new System.NotImplementedException(); } } - public Material Material + public PhysicsMaterial PhysicsMaterial { get { throw new System.NotImplementedException(); } set { throw new System.NotImplementedException(); } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index 987868a..c798cc8 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs @@ -35,7 +35,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule private readonly Scene m_internalScene; private readonly Heightmap m_heights; - private ObjectAccessor m_objs; + private readonly ObjectAccessor m_objs; public World(Scene internalScene) { -- cgit v1.1 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. --- .../Scripting/Minimodule/IObjectAccessor.cs | 22 +- .../Scripting/Minimodule/ObjectAccessor.cs | 264 ++++++++++----------- .../Scripting/Minimodule/SPAvatar.cs | 74 +++--- .../Scripting/Minimodule/Test/TestModule.cs | 34 +-- 4 files changed, 197 insertions(+), 197 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') 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 From 7e91f41535e27d992cf85a46bed25b781367dcf1 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Fri, 3 Apr 2009 09:22:34 +0000 Subject: * Implements "ID" semi-global within MRM scripts. This is tied to the 'state ID' for MRMs. * Implements IPersistence interface, allows simple KeyValue access for MRM scripts to a more permanent datastore. --- .../OptionalModules/Scripting/Minimodule/Host.cs | 3 --- .../Scripting/Minimodule/IPersistence.cs | 31 ++++++++++++++++++++++ .../Scripting/Minimodule/MRMBase.cs | 11 +++++++- .../Scripting/Minimodule/MRMModule.cs | 2 +- .../Scripting/Minimodule/SOPObject.cs | 5 ++-- 5 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs index 5a3690f..394e024 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs @@ -25,10 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using System; -using System.Collections.Generic; using System.Reflection; -using System.Text; using log4net; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs new file mode 100644 index 0000000..6020a7a --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + interface IPersistence + { + Object Get(MRMBase state, Guid storageID); + Object Get(MRMBase state); + + /// + /// Stores 'data' into the persistence system + /// associated with this object, however saved + /// under the ID 'storageID'. This data may + /// be accessed by other scripts however. + /// + /// + /// + /// + void Put(MRMBase state, Guid storageID, Object data); + + /// + /// Stores 'data' into the persistence system + /// using the default ID for this script. + /// + /// + /// + void Put(MRMBase state, Object data); + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMBase.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMBase.cs index b98bb95..c47e592 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMBase.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMBase.cs @@ -25,17 +25,21 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using OpenMetaverse; + namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { public abstract class MRMBase { private IWorld m_world; private IHost m_host; + private UUID m_id; - public void InitMiniModule(IWorld world, IHost host) + public void InitMiniModule(IWorld world, IHost host, UUID uniqueID) { m_world = world; m_host = host; + m_id = uniqueID; } protected IWorld World @@ -48,6 +52,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule get { return m_host; } } + public UUID ID + { + get { return m_id; } + } + public abstract void Start(); public abstract void Stop(); } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 7c87756..3e53bc5 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -82,7 +82,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule CompileFromDotNetText(script, itemID.ToString()), "OpenSim.MiniModule"); m_log.Info("[MRM] Created MRM Instance"); - mmb.InitMiniModule(m_world, m_host); + mmb.InitMiniModule(m_world, m_host, itemID); m_scripts[itemID] = mmb; m_log.Info("[MRM] Starting MRM"); diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 8b7b470..5010a34 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -1,11 +1,12 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - class SOPObject : IObject + class SOPObject : MarshalByRefObject, IObject { private readonly Scene m_rootScene; private readonly uint m_localID; -- cgit v1.1 From 36bc485e7e622301a900663320b52e136e4181f3 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Fri, 3 Apr 2009 10:30:51 +0000 Subject: * MRM Scripts will now no longer disconnect the client if there was an error in compilation or script initialisation. * Clarified some debug text for MRM Enabling --- .../Scripting/Minimodule/MRMModule.cs | 42 ++++++++++++++-------- 1 file changed, 27 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 3e53bc5..6fa8a24 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -35,6 +35,7 @@ using log4net; using Microsoft.CSharp; using Nini.Config; using OpenMetaverse; +using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -61,12 +62,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule } else { - m_log.Info("[MRM] Disabled MRM Module (Express)"); + m_log.Info("[MRM] Disabled MRM Module (Disabled in ini)"); } } else { - m_log.Info("[MRM] Disabled MRM Module (Omission)"); + m_log.Info("[MRM] Disabled MRM Module (Default disabled)"); } } @@ -74,19 +75,30 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { if (script.StartsWith("//MiniMod:C#")) { - m_log.Info("[MRM] Found C# MRM"); - IWorld m_world = new World(m_scene); - IHost m_host = new Host(new SOPObject(m_scene, localID)); - - MRMBase mmb = (MRMBase) AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap( - CompileFromDotNetText(script, itemID.ToString()), - "OpenSim.MiniModule"); - m_log.Info("[MRM] Created MRM Instance"); - mmb.InitMiniModule(m_world, m_host, itemID); - m_scripts[itemID] = mmb; - - m_log.Info("[MRM] Starting MRM"); - mmb.Start(); + try + { + m_log.Info("[MRM] Found C# MRM"); + IWorld m_world = new World(m_scene); + IHost m_host = new Host(new SOPObject(m_scene, localID)); + + MRMBase mmb = (MRMBase)AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap( + CompileFromDotNetText(script, itemID.ToString()), + "OpenSim.MiniModule"); + m_log.Info("[MRM] Created MRM Instance"); + mmb.InitMiniModule(m_world, m_host, itemID); + m_scripts[itemID] = mmb; + + m_log.Info("[MRM] Starting MRM"); + mmb.Start(); + } + catch (Exception e) + { + m_scene.Broadcast(delegate(IClientAPI user) + { + user.SendAlertMessage( + "MiniRegionModule Compilation and Initialisation failed: " + e); + }); + } } } -- cgit v1.1 From 254d3099f03dde79a4e689bcb99e4d67d91f6300 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Fri, 3 Apr 2009 10:40:14 +0000 Subject: * Implements Scene.SimChat(string,...) rather than byte[]. We should probably mark byte[] as obsolete. * Implements SOPObject.Say for MRM. (Note, not IObject yet) --- .../Region/OptionalModules/Scripting/Minimodule/SOPObject.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 5010a34..12d996a 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -215,6 +215,17 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule set { throw new System.NotImplementedException(); } } + #region Public Functions + + public void Say(string msg) + { + SceneObjectPart sop = GetSOP(); + + m_rootScene.SimChat(msg, ChatTypeEnum.Say, sop.AbsolutePosition, sop.Name, sop.UUID, false); + } + + #endregion + #region Supporting Functions -- cgit v1.1 From 084ffc74c659c0c6ba86167590b0d146408aa56b Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Fri, 3 Apr 2009 10:42:39 +0000 Subject: * Implements MRM IObject.Say - this is equivilent to llSay Example: public override void Start() { Host.Object.Say("Hello World!"); } --- OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs index da8fce5..21efc6d 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs @@ -103,6 +103,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule // RadiusOffset, Skew PhysicsMaterial PhysicsMaterial { get; set; } + + /// + /// Causes the object to speak to its surroundings, + /// equivilent to LSL/OSSL llSay + /// + /// The message to send to the user + void Say(string msg); + } public enum PhysicsMaterial -- cgit v1.1 From fcbe7b9ed63eb4a64a241113421125c3ecf844b8 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 4 Apr 2009 05:51:26 +0000 Subject: * Drops Heightmap.Get/Heightmap.Set from IHeightmap interface. * Adds Heightmap[x,y] to interface. * MRM Scripts should utilize World.Heightmap[x,y] = 0.0; to replace set, and Val = World.Heightmap[x,y] to get. --- .../Scripting/Minimodule/Heightmap.cs | 12 +++++++++--- .../Scripting/Minimodule/IHeightmap.cs | 21 +++++++++++++++++++-- 2 files changed, 28 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Heightmap.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Heightmap.cs index 2f6c204..875de50 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Heightmap.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Heightmap.cs @@ -31,13 +31,19 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { public class Heightmap : IHeightmap { - private Scene m_scene; + private readonly Scene m_scene; public Heightmap(Scene scene) { m_scene = scene; } + public double this[int x, int y] + { + get { return Get(x, y); } + set { Set(x, y, value); } + } + public int Height { get { return m_scene.Heightmap.Height; } @@ -48,12 +54,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule get { return m_scene.Heightmap.Width; } } - public double Get(int x, int y) + protected double Get(int x, int y) { return m_scene.Heightmap[x, y]; } - public void Set(int x, int y, double val) + protected void Set(int x, int y, double val) { m_scene.Heightmap[x, y] = val; } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs index 37cf8ae..afea12b 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs @@ -33,9 +33,26 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { public interface IHeightmap { + /// + /// Returns [or sets] the heightmap value at specified coordinates. + /// + /// X Coordinate + /// Y Coordinate + /// A value in meters representing height. Can be negative. Value correlates with Z parameter in world coordinates + double this[int x, int y] + { + get; + set; + } + + /// + /// The maximum height of the region (Y axis), exclusive. (eg Height = 256, max Y = 255). Minimum is always 0 inclusive. + /// int Height { get; } + + /// + /// The maximum width of the region (X axis), exclusive. (eg Width = 256, max X = 255). Minimum is always 0 inclusive. + /// int Width { get; } - double Get(int x, int y); - void Set(int x, int y, double val); } } -- cgit v1.1 From c3e1756a48049664a4381cb8b2497415719d8d5c Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 4 Apr 2009 06:28:55 +0000 Subject: * Removes IObject.Position, IObject.Rotation from IObject * Adds IObject.WorldPosition and IObject.OffsetPosition - this is equivilent to AbsolutePosition and OffsetPosition in SOP respectively. * Adds IObject.WorldRotation and IObject.OffsetRotation - as above. --- .../Scripting/Minimodule/IObject.cs | 45 ++++++++++++++++++++-- .../Scripting/Minimodule/SOPObject.cs | 16 +++++++- 2 files changed, 55 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs index 21efc6d..d3eeffb 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs @@ -33,14 +33,35 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { public interface IObject { + /// + /// Returns whether or not this object is still in the world. + /// Eg, if you store an IObject reference, however the object + /// is deleted before you use it, it will throw a NullReference + /// exception. 'Exists' allows you to check the object is still + /// in play before utilizing it. + /// bool Exists { get; } + + /// + /// The local region-unique ID for this object. + /// uint LocalID { get; } + + /// + /// The global 'world-unique' ID for this object. + /// (Note, may not actually be world unique) + /// UUID GlobalID { get; } + /// + /// The name of this Object. + /// String Name { get; set; } - String Description { get; set; } - + /// + /// The description assigned to this object. + /// + String Description { get; set; } /// /// Returns the root object of a linkset. If this object is the root, it will return itself. @@ -67,19 +88,35 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule /// /// The rotation of the object relative to the Scene /// - Quaternion Rotation { get; set; } + Quaternion WorldRotation { get; set; } + + /// + /// The rotation of the object relative to a parent object + /// If root, works the same as WorldRotation + /// + Quaternion OffsetRotation { get; set; } /// /// The position of the object relative to the Scene /// - Vector3 Position { get; set; } + Vector3 WorldPosition { get; set; } + /// + /// The position of the object relative to a parent object + /// If root, works the same as WorldPosition + /// + Vector3 OffsetPosition { get; set; } Vector3 SitTarget { get; set; } String SitTargetText { get; set; } String TouchText { get; set; } + /// + /// Text to be associated with this object, in the + /// Second Life(r) viewer, this is shown above the + /// object. + /// String Text { get; set; } bool IsPhysical { get; set; } // SetStatus(PHYSICS) diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 12d996a..f53a7df 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -103,13 +103,19 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule set { GetSOP().Scale = value; } } - public Quaternion Rotation + public Quaternion WorldRotation { get { throw new System.NotImplementedException(); } set { throw new System.NotImplementedException(); } } - public Vector3 Position + public Quaternion OffsetRotation + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public Vector3 WorldPosition { get { return GetSOP().AbsolutePosition; } set @@ -119,6 +125,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule } } + public Vector3 OffsetPosition + { + get { return GetSOP().OffsetPosition; } + set { GetSOP().OffsetPosition = value; } + } + public Vector3 SitTarget { get { throw new System.NotImplementedException(); } -- cgit v1.1 From 5cf7b784cec3bd8b3bdf643b05b27b1f10e10417 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sat, 4 Apr 2009 07:32:41 +0000 Subject: Add copyright headers, formatting cleanup. --- .../Scripting/Minimodule/IObject.cs | 2 +- .../Scripting/Minimodule/IObjectAccessor.cs | 27 ++++++++++++++++++++ .../Scripting/Minimodule/ObjectAccessor.cs | 29 +++++++++++++++++++++- .../Scripting/Minimodule/SOPObject.cs | 29 +++++++++++++++++++++- .../Scripting/Minimodule/SPAvatar.cs | 29 +++++++++++++++++++++- .../Scripting/Minimodule/Test/TestModule.cs | 29 +++++++++++++++++++++- 6 files changed, 140 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs index d3eeffb..223d764 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObjectAccessor.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObjectAccessor.cs index 9ad042e..7aed41b 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObjectAccessor.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObjectAccessor.cs @@ -1,3 +1,30 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + using System.Collections.Generic; using OpenMetaverse; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs index 832050e..2bd2e29 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; using System.Collections; using System.Collections.Generic; using OpenMetaverse; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index f53a7df..c0a838b 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; using System.Collections.Generic; using OpenMetaverse; using OpenSim.Framework; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs index 03432bc..25b547c 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs @@ -1,4 +1,31 @@ -using OpenMetaverse; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using OpenMetaverse; using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs index 1e266ae..e56d5eb 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs @@ -1,4 +1,31 @@ -using OpenSim.Region.OptionalModules.Scripting.Minimodule; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using OpenSim.Region.OptionalModules.Scripting.Minimodule; namespace OpenSim { -- cgit v1.1 From 4e9403e6ef4d87235af639af7515a512a595b5ec Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 4 Apr 2009 08:33:58 +0000 Subject: * Renamed Heightmap.Height to Heightmap.Length to avoid confusion about axis. * Added XMLDOC to MRM API code, this means we have usable programming docs being produced here: http://docs.opensimulator.org/namespaceOpenSim_1_1Region_1_1OptionalModules_1_1Scripting_1_1Minimodule.html (eg IObject, IHeightmap, etc) --- .../Scripting/Minimodule/Heightmap.cs | 2 +- .../Scripting/Minimodule/IHeightmap.cs | 15 +++++++++++++-- .../OptionalModules/Scripting/Minimodule/IObject.cs | 21 +++++++++++++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Heightmap.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Heightmap.cs index 875de50..9b9d686 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Heightmap.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Heightmap.cs @@ -44,7 +44,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule set { Set(x, y, value); } } - public int Height + public int Length { get { return m_scene.Heightmap.Height; } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs index afea12b..93cbc5b 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs @@ -39,6 +39,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule /// X Coordinate /// Y Coordinate /// A value in meters representing height. Can be negative. Value correlates with Z parameter in world coordinates + /// + /// double heightVal = World.Heightmap[128,128]; + /// World.Heightmap[128,128] *= 5.0; + /// World.Heightmap[128,128] = 25; + /// double this[int x, int y] { get; @@ -46,13 +51,19 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule } /// - /// The maximum height of the region (Y axis), exclusive. (eg Height = 256, max Y = 255). Minimum is always 0 inclusive. + /// The maximum length of the region (Y axis), exclusive. (eg Height = 256, max Y = 255). Minimum is always 0 inclusive. /// - int Height { get; } + /// + /// Host.Console.Info("The terrain length of this region is " + World.Heightmap.Length); + /// + int Length { get; } /// /// The maximum width of the region (X axis), exclusive. (eg Width = 256, max X = 255). Minimum is always 0 inclusive. /// + /// + /// Host.Console.Info("The terrain width of this region is " + World.Heightmap.Width); + /// int Width { get; } } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs index 223d764..0308079 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs @@ -40,6 +40,27 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule /// exception. 'Exists' allows you to check the object is still /// in play before utilizing it. /// + /// + /// IObject deleteMe = World.Objects[0]; + /// + /// if(deleteMe.Exists) { + /// deleteMe.Say("Hello, I still exist!"); + /// } + /// + /// World.Objects.Remove(deleteMe); + /// + /// if(!deleteMe.Exists) { + /// Host.Console.Info("I was deleted"); + /// } + /// + /// + /// Objects should be near-guarunteed to exist for any event which + /// passes them as an argument. Storing an object for a longer period + /// of time however will limit their reliability. + /// + /// It is a good practice to use Try/Catch blocks handling for + /// NullReferenceException, when accessing remote objects. + /// bool Exists { get; } /// -- cgit v1.1 From 23193ab5380e67d3b623db255ee98e84f09cccad Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 4 Apr 2009 08:36:45 +0000 Subject: * Changed IPersistence interface so that passing the MRMBase is unessecary. --- OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs | 2 +- .../OptionalModules/Scripting/Minimodule/IPersistence.cs | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs index 0308079..0b8fc37 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs index 6020a7a..b6d79d4 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs @@ -6,8 +6,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { interface IPersistence { - Object Get(MRMBase state, Guid storageID); - Object Get(MRMBase state); + Object Get(Guid storageID); + Object Get(); /// /// Stores 'data' into the persistence system @@ -15,17 +15,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule /// under the ID 'storageID'. This data may /// be accessed by other scripts however. /// - /// /// /// - void Put(MRMBase state, Guid storageID, Object data); + void Put(Guid storageID, Object data); /// /// Stores 'data' into the persistence system /// using the default ID for this script. /// - /// /// - void Put(MRMBase state, Object data); + void Put(Object data); } } -- cgit v1.1 From d758753d7c47846258abb12d605eeddfa9d1ef24 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 4 Apr 2009 22:57:53 +0000 Subject: * More fiddling with MRM IPersistence, now stores instead of Object. --- .../Region/OptionalModules/Scripting/Minimodule/IPersistence.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs index b6d79d4..5ca4f59 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs @@ -6,8 +6,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { interface IPersistence { - Object Get(Guid storageID); - Object Get(); + + T Get(Guid storageID); + T Get(); /// /// Stores 'data' into the persistence system @@ -17,13 +18,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule /// /// /// - void Put(Guid storageID, Object data); + void Put(Guid storageID, T data); /// /// Stores 'data' into the persistence system /// using the default ID for this script. /// /// - void Put(Object data); + void Put(T data); } } -- cgit v1.1 From 39c3ccb93a62de270c2f625d396daf18c805bf51 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 4 Apr 2009 23:16:19 +0000 Subject: * Implements IObjectPhysics, this collects Physics attributes into one interface, will be referenced on IObject as IObject.Physics.* * Eg; IObject.Physics.Torque = new Vector3(30.0,0.4,0.5); * Maps loosely to internal PhysicsActor class. --- .../Scripting/Minimodule/Object/IObjectPhysics.cs | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectPhysics.cs (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectPhysics.cs new file mode 100644 index 0000000..aaa95e5 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectPhysics.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object +{ + interface IObjectPhysics + { + bool Enabled { get; set; } + bool Phantom { get; set; } + bool PhantomCollisions { get; set; } + + double Density { get; set; } + double Mass { get; set; } + + double Buoyancy { get; set; } + + Vector3 GeometricCenter { get; } + Vector3 CenterOfMass { get; } + Vector3 Velocity { get; set; } + Vector3 Torque { get; set; } + + Vector3 Acceleration { get; } + Quaternion Orientation { get; set; } + Vector3 RotationalVelocity { get; set; } + + void AddForce(Vector3 force, bool pushforce); + void AddAngularForce(Vector3 force, bool pushforce); + void SetMomentum(Vector3 momentum); + } +} -- cgit v1.1 From 746729b6cefce7093d346e21909b35440dd88569 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 4 Apr 2009 23:23:24 +0000 Subject: * Implements IObjectPhysics on SOPObject partially. * Eg, IObject.Physics.* is now valid syntax and compiles (but will throw NotSupported at runtime) --- .../Scripting/Minimodule/IObject.cs | 5 +- .../Scripting/Minimodule/Object/IObjectPhysics.cs | 12 ++- .../Scripting/Minimodule/SOPObject.cs | 106 ++++++++++++++++++++- 3 files changed, 116 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs index 0b8fc37..36d016e 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs @@ -28,6 +28,7 @@ using System; using System.Drawing; using OpenMetaverse; +using OpenSim.Region.OptionalModules.Scripting.Minimodule.Object; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { @@ -140,7 +141,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule /// String Text { get; set; } - bool IsPhysical { get; set; } // SetStatus(PHYSICS) bool IsPhantom { get; set; } // SetStatus(PHANTOM) bool IsRotationLockedX { get; set; } // SetStatus(!ROTATE_X) bool IsRotationLockedY { get; set; } // SetStatus(!ROTATE_Y) @@ -162,6 +162,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule PhysicsMaterial PhysicsMaterial { get; set; } + IObjectPhysics Physics { get; } + + /// /// Causes the object to speak to its surroundings, /// equivilent to LSL/OSSL llSay diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectPhysics.cs index aaa95e5..9035db9 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectPhysics.cs @@ -5,25 +5,27 @@ using OpenMetaverse; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object { - interface IObjectPhysics + public interface IObjectPhysics { bool Enabled { get; set; } + bool Phantom { get; set; } bool PhantomCollisions { get; set; } double Density { get; set; } double Mass { get; set; } - double Buoyancy { get; set; } Vector3 GeometricCenter { get; } Vector3 CenterOfMass { get; } + + Vector3 RotationalVelocity { get; set; } Vector3 Velocity { get; set; } Vector3 Torque { get; set; } - Vector3 Acceleration { get; } - Quaternion Orientation { get; set; } - Vector3 RotationalVelocity { get; set; } + Vector3 Force { get; set; } + + bool FloatOnWater { set; } void AddForce(Vector3 force, bool pushforce); void AddAngularForce(Vector3 force, bool pushforce); diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index c0a838b..2e93673 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -30,10 +30,11 @@ using System.Collections.Generic; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.OptionalModules.Scripting.Minimodule.Object; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - class SOPObject : MarshalByRefObject, IObject + class SOPObject : MarshalByRefObject, IObject, IObjectPhysics { private readonly Scene m_rootScene; private readonly uint m_localID; @@ -254,6 +255,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule set { throw new System.NotImplementedException(); } } + public IObjectPhysics Physics + { + get { return this; } + } + #region Public Functions public void Say(string msg) @@ -386,5 +392,103 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule #endregion + #region IObjectPhysics + + public bool Enabled + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public bool Phantom + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public bool PhantomCollisions + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public double Density + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public double Mass + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public double Buoyancy + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public Vector3 GeometricCenter + { + get { throw new System.NotImplementedException(); } + } + + public Vector3 CenterOfMass + { + get { throw new System.NotImplementedException(); } + } + + public Vector3 RotationalVelocity + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public Vector3 Velocity + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public Vector3 Torque + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public Vector3 Acceleration + { + get { throw new System.NotImplementedException(); } + } + + public Vector3 Force + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public bool FloatOnWater + { + set { throw new System.NotImplementedException(); } + } + + public void AddForce(Vector3 force, bool pushforce) + { + throw new System.NotImplementedException(); + } + + public void AddAngularForce(Vector3 force, bool pushforce) + { + throw new System.NotImplementedException(); + } + + public void SetMomentum(Vector3 momentum) + { + throw new System.NotImplementedException(); + } + + #endregion } } -- cgit v1.1 From e120876bd018c1c184955df7037fd87f576bb42a Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 4 Apr 2009 23:32:37 +0000 Subject: Implements on IObjectPhysics: * SetMomentum * AddAngularForce * AddForce * FloatOnWater * Force * Acceleration * Torque * Velocity * RotationalVelocity * CenterOfMass * GeometricCenter * Buoyancy * Mass (Partial) * Density (Partial) --- .../Scripting/Minimodule/SOPObject.cs | 83 ++++++++++++++++------ 1 file changed, 62 insertions(+), 21 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 2e93673..e62f795 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -31,6 +31,7 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.OptionalModules.Scripting.Minimodule.Object; +using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { @@ -414,79 +415,119 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public double Density { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } + get { return (GetSOP().PhysActor.Mass/Scale.X*Scale.Y/Scale.Z); } + set { throw new NotImplementedException(); } } public double Mass { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } + get { return GetSOP().PhysActor.Mass; } + set { throw new NotImplementedException(); } } public double Buoyancy { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } + get { return GetSOP().PhysActor.Buoyancy; } + set { GetSOP().PhysActor.Buoyancy = (float)value; } } public Vector3 GeometricCenter { - get { throw new System.NotImplementedException(); } + get + { + PhysicsVector tmp = GetSOP().PhysActor.GeometricCenter; + return new Vector3(tmp.X, tmp.Y, tmp.Z); + } } public Vector3 CenterOfMass { - get { throw new System.NotImplementedException(); } + get + { + PhysicsVector tmp = GetSOP().PhysActor.CenterOfMass; + return new Vector3(tmp.X, tmp.Y, tmp.Z); + } } public Vector3 RotationalVelocity { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } + get + { + PhysicsVector tmp = GetSOP().PhysActor.RotationalVelocity; + return new Vector3(tmp.X, tmp.Y, tmp.Z); + } + set + { + GetSOP().PhysActor.RotationalVelocity = new PhysicsVector(value.X, value.Y, value.Z); + } } public Vector3 Velocity { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } + get + { + PhysicsVector tmp = GetSOP().PhysActor.Velocity; + return new Vector3(tmp.X, tmp.Y, tmp.Z); + } + set + { + GetSOP().PhysActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z); + } } public Vector3 Torque { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } + get + { + PhysicsVector tmp = GetSOP().PhysActor.Torque; + return new Vector3(tmp.X, tmp.Y, tmp.Z); + } + set + { + GetSOP().PhysActor.Torque = new PhysicsVector(value.X, value.Y, value.Z); + } } public Vector3 Acceleration { - get { throw new System.NotImplementedException(); } + get + { + PhysicsVector tmp = GetSOP().PhysActor.Acceleration; + return new Vector3(tmp.X, tmp.Y, tmp.Z); + } } public Vector3 Force { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } + get + { + PhysicsVector tmp = GetSOP().PhysActor.Force; + return new Vector3(tmp.X, tmp.Y, tmp.Z); + } + set + { + GetSOP().PhysActor.Force = new PhysicsVector(value.X, value.Y, value.Z); + } } public bool FloatOnWater { - set { throw new System.NotImplementedException(); } + set { GetSOP().PhysActor.FloatOnWater = value; } } public void AddForce(Vector3 force, bool pushforce) { - throw new System.NotImplementedException(); + GetSOP().PhysActor.AddForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce); } public void AddAngularForce(Vector3 force, bool pushforce) { - throw new System.NotImplementedException(); + GetSOP().PhysActor.AddAngularForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce); } public void SetMomentum(Vector3 momentum) { - throw new System.NotImplementedException(); + GetSOP().PhysActor.SetMomentum(new PhysicsVector(momentum.X, momentum.Y, momentum.Z)); } #endregion -- cgit v1.1 From 2e1646d368dc1318c9ed35be6682a875b45c0acc Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 4 Apr 2009 23:44:37 +0000 Subject: * Removes IsPhysical, IsPhantom from IObject, since this is now represented in IObject.Physics.Enabled / IObject.Physics.Phantom instead. --- .../Region/OptionalModules/Scripting/Minimodule/IObject.cs | 1 - .../Region/OptionalModules/Scripting/Minimodule/SOPObject.cs | 12 ------------ 2 files changed, 13 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs index 36d016e..3636544 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs @@ -141,7 +141,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule /// String Text { get; set; } - bool IsPhantom { get; set; } // SetStatus(PHANTOM) bool IsRotationLockedX { get; set; } // SetStatus(!ROTATE_X) bool IsRotationLockedY { get; set; } // SetStatus(!ROTATE_Y) bool IsRotationLockedZ { get; set; } // SetStatus(!ROTATE_Z) diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index e62f795..48cae2f 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -184,18 +184,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule set { throw new System.NotImplementedException(); } } - public bool IsPhysical - { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } - } - - public bool IsPhantom - { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } - } - public bool IsRotationLockedX { get { throw new System.NotImplementedException(); } -- cgit v1.1 From f094847c43821cf4922f8e2156cacb7f6078c379 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 5 Apr 2009 01:28:23 +0000 Subject: * Implements ISocialEntity - this represents the class of "user-like" objects such as Users, Groups, etc. Destined to be used as the return value of any "Owner" properties. * Implements basic "SEUser" class which implements Avatar/Agent SE functions (primitive). --- .../Scripting/Minimodule/IPersistence.cs | 1 - .../Scripting/Minimodule/ISocialEntity.cs | 14 +++++++++ .../OptionalModules/Scripting/Minimodule/SEUser.cs | 34 ++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/ISocialEntity.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/SEUser.cs (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs index 5ca4f59..e433c11 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs @@ -6,7 +6,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { interface IPersistence { - T Get(Guid storageID); T Get(); diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISocialEntity.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISocialEntity.cs new file mode 100644 index 0000000..fe4826a --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISocialEntity.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + interface ISocialEntity + { + UUID GlobalID { get; } + string Name { get; } + bool IsUser { get; } + } +} \ No newline at end of file diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SEUser.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SEUser.cs new file mode 100644 index 0000000..1fc1c55 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SEUser.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + class SEUser : ISocialEntity + { + private readonly UUID m_uuid; + private readonly string m_name; + + public SIUser(UUID uuid, string name) + { + this.m_uuid = uuid; + this.m_name = name; + } + + public UUID GlobalID + { + get { return m_uuid; } + } + + public string Name + { + get { return m_name; } + } + + public bool IsUser + { + get { return true; } + } + } +} -- cgit v1.1 From dc967b16a43a3a89bc9631f27a85fa9b94a9c9e0 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 5 Apr 2009 01:29:58 +0000 Subject: * Typo in constructor during class rename (whoops!) * OpenSim is now over 9000. --- OpenSim/Region/OptionalModules/Scripting/Minimodule/SEUser.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SEUser.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SEUser.cs index 1fc1c55..baab999 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SEUser.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SEUser.cs @@ -10,7 +10,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule private readonly UUID m_uuid; private readonly string m_name; - public SIUser(UUID uuid, string name) + public SEUser(UUID uuid, string name) { this.m_uuid = uuid; this.m_name = name; -- cgit v1.1 From 51419d21e4afb1ffbaef3bf537ed981f9da49f00 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 5 Apr 2009 01:36:30 +0000 Subject: * Minor cosmetic change to SEUser to get Bamboo to initiate another build. (grr) * Adds basic IParcel interface. Soon to live on World.Parcels{[id],[x,y]} --- .../Region/OptionalModules/Scripting/Minimodule/IParcel.cs | 14 ++++++++++++++ .../Region/OptionalModules/Scripting/Minimodule/SEUser.cs | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/IParcel.cs (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IParcel.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IParcel.cs new file mode 100644 index 0000000..ae0f85e --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IParcel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + interface IParcel + { + string Name { get; set; } + string Description { get; set; } + ISocialEntity Owner { get; set; } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SEUser.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SEUser.cs index baab999..a35e051 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SEUser.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SEUser.cs @@ -12,8 +12,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public SEUser(UUID uuid, string name) { - this.m_uuid = uuid; - this.m_name = name; + m_uuid = uuid; + m_name = name; } public UUID GlobalID -- cgit v1.1 From 9a4192d14e3cd6940c12928181d5ca363abece64 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 5 Apr 2009 02:51:10 +0000 Subject: * Fixed copyright headers on HyperGrid source files. (Now match the rest of OpenSim, license text is unchanged) * Added Bitmap[,] to IParcel for MRM --- OpenSim/Region/OptionalModules/Scripting/Minimodule/IParcel.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IParcel.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IParcel.cs index ae0f85e..7c3fe86 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IParcel.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IParcel.cs @@ -10,5 +10,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule string Name { get; set; } string Description { get; set; } ISocialEntity Owner { get; set; } + bool[,] Bitmap { get; set; } } } -- cgit v1.1 From 918c46688189cc0e6f237f9f2d2ee8892506d56d Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Mon, 6 Apr 2009 04:17:55 +0000 Subject: * Adds AutoOAR module, this will automatically OAR your regions every 20 minutes to a directory called "autooar", if enabled. Default disabled. Use [autooar] Enabled=true in OpenSim.ini to enable. * Adds some MRM XMLDOC --- .../OptionalModules/Scripting/Minimodule/Object/IObjectPhysics.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectPhysics.cs index 9035db9..6ca4e5f 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectPhysics.cs @@ -5,6 +5,11 @@ using OpenMetaverse; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object { + /// + /// This implements an interface similar to that provided by physics engines to OpenSim internally. + /// Eg, PhysicsActor. It is capable of setting and getting properties related to the current + /// physics scene representation of this object. + /// public interface IObjectPhysics { bool Enabled { get; set; } -- cgit v1.1 From 9e51c2db95fd43aa18e66d359c15349bdc9ad8f0 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Mon, 6 Apr 2009 07:17:23 +0000 Subject: * Implements World.Parcels[] array for MRM scripting. --- .../Scripting/Minimodule/IParcel.cs | 4 +- .../Scripting/Minimodule/ISocialEntity.cs | 2 +- .../OptionalModules/Scripting/Minimodule/IWorld.cs | 1 + .../Scripting/Minimodule/LOParcel.cs | 45 ++++++++++++++++++++++ .../OptionalModules/Scripting/Minimodule/World.cs | 18 +++++++++ 5 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IParcel.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IParcel.cs index 7c3fe86..2a973a9 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IParcel.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IParcel.cs @@ -5,11 +5,11 @@ using OpenMetaverse; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - interface IParcel + public interface IParcel { string Name { get; set; } string Description { get; set; } ISocialEntity Owner { get; set; } - bool[,] Bitmap { get; set; } + bool[,] Bitmap { get; } } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISocialEntity.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISocialEntity.cs index fe4826a..0833ffd 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISocialEntity.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISocialEntity.cs @@ -5,7 +5,7 @@ using OpenMetaverse; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - interface ISocialEntity + public interface ISocialEntity { UUID GlobalID { get; } string Name { get; } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs index f06f57a..b35b57d 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs @@ -31,6 +31,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { IObjectAccessor Objects { get; } IAvatar[] Avatars { get; } + IParcel[] Parcels { get; } IHeightmap Terrain { get; } } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs new file mode 100644 index 0000000..aceeacc --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs @@ -0,0 +1,45 @@ +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + class LOParcel : IParcel + { + private readonly Scene m_scene; + private readonly int m_parcelID; + + public LOParcel(Scene m_scene, int m_parcelID) + { + this.m_scene = m_scene; + this.m_parcelID = m_parcelID; + } + + private ILandObject GetLO() + { + return m_scene.LandChannel.GetLandObject(m_parcelID); + } + + public string Name + { + get { return GetLO().landData.Name; } + set { GetLO().landData.Name = value; } + } + + public string Description + { + get { return GetLO().landData.Description; } + set { GetLO().landData.Description = value; } + } + + public ISocialEntity Owner + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public bool[,] Bitmap + { + get { return GetLO().landBitmap; } + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index c798cc8..05a6a84 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs @@ -26,6 +26,7 @@ */ using System.Collections.Generic; +using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule @@ -49,6 +50,23 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule get { return m_objs; } } + public IParcel[] Parcels + { + get + { + List m_los = m_internalScene.LandChannel.AllParcels(); + List m_parcels = new List(m_los.Count); + + foreach (ILandObject landObject in m_los) + { + m_parcels.Add(new LOParcel(m_internalScene, landObject.landData.LocalID)); + } + + return m_parcels.ToArray(); + } + } + + public IAvatar[] Avatars { get -- cgit v1.1 From 5f34bd73fbca765064c4b3811d1f67da36cbf5ae Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 6 Apr 2009 14:24:13 +0000 Subject: Update svn properties. --- .../Scripting/Minimodule/IParcel.cs | 30 ++++---- .../Scripting/Minimodule/IPersistence.cs | 58 +++++++------- .../Scripting/Minimodule/ISocialEntity.cs | 26 +++---- .../Scripting/Minimodule/LOParcel.cs | 90 +++++++++++----------- .../Scripting/Minimodule/Object/IObjectPhysics.cs | 78 +++++++++---------- .../OptionalModules/Scripting/Minimodule/SEUser.cs | 68 ++++++++-------- 6 files changed, 175 insertions(+), 175 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IParcel.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IParcel.cs index 2a973a9..2849f16 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IParcel.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IParcel.cs @@ -1,15 +1,15 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenMetaverse; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public interface IParcel - { - string Name { get; set; } - string Description { get; set; } - ISocialEntity Owner { get; set; } - bool[,] Bitmap { get; } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface IParcel + { + string Name { get; set; } + string Description { get; set; } + ISocialEntity Owner { get; set; } + bool[,] Bitmap { get; } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs index e433c11..c093880 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs @@ -1,29 +1,29 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - interface IPersistence - { - T Get(Guid storageID); - T Get(); - - /// - /// Stores 'data' into the persistence system - /// associated with this object, however saved - /// under the ID 'storageID'. This data may - /// be accessed by other scripts however. - /// - /// - /// - void Put(Guid storageID, T data); - - /// - /// Stores 'data' into the persistence system - /// using the default ID for this script. - /// - /// - void Put(T data); - } -} +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + interface IPersistence + { + T Get(Guid storageID); + T Get(); + + /// + /// Stores 'data' into the persistence system + /// associated with this object, however saved + /// under the ID 'storageID'. This data may + /// be accessed by other scripts however. + /// + /// + /// + void Put(Guid storageID, T data); + + /// + /// Stores 'data' into the persistence system + /// using the default ID for this script. + /// + /// + void Put(T data); + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISocialEntity.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISocialEntity.cs index 0833ffd..cc664eb 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISocialEntity.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISocialEntity.cs @@ -1,14 +1,14 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenMetaverse; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public interface ISocialEntity - { - UUID GlobalID { get; } - string Name { get; } - bool IsUser { get; } - } +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface ISocialEntity + { + UUID GlobalID { get; } + string Name { get; } + bool IsUser { get; } + } } \ No newline at end of file diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs index aceeacc..8ab1a56 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs @@ -1,45 +1,45 @@ -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - class LOParcel : IParcel - { - private readonly Scene m_scene; - private readonly int m_parcelID; - - public LOParcel(Scene m_scene, int m_parcelID) - { - this.m_scene = m_scene; - this.m_parcelID = m_parcelID; - } - - private ILandObject GetLO() - { - return m_scene.LandChannel.GetLandObject(m_parcelID); - } - - public string Name - { - get { return GetLO().landData.Name; } - set { GetLO().landData.Name = value; } - } - - public string Description - { - get { return GetLO().landData.Description; } - set { GetLO().landData.Description = value; } - } - - public ISocialEntity Owner - { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } - } - - public bool[,] Bitmap - { - get { return GetLO().landBitmap; } - } - } -} +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + class LOParcel : IParcel + { + private readonly Scene m_scene; + private readonly int m_parcelID; + + public LOParcel(Scene m_scene, int m_parcelID) + { + this.m_scene = m_scene; + this.m_parcelID = m_parcelID; + } + + private ILandObject GetLO() + { + return m_scene.LandChannel.GetLandObject(m_parcelID); + } + + public string Name + { + get { return GetLO().landData.Name; } + set { GetLO().landData.Name = value; } + } + + public string Description + { + get { return GetLO().landData.Description; } + set { GetLO().landData.Description = value; } + } + + public ISocialEntity Owner + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public bool[,] Bitmap + { + get { return GetLO().landBitmap; } + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectPhysics.cs index 6ca4e5f..3682e9b 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectPhysics.cs @@ -1,39 +1,39 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenMetaverse; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object -{ - /// - /// This implements an interface similar to that provided by physics engines to OpenSim internally. - /// Eg, PhysicsActor. It is capable of setting and getting properties related to the current - /// physics scene representation of this object. - /// - public interface IObjectPhysics - { - bool Enabled { get; set; } - - bool Phantom { get; set; } - bool PhantomCollisions { get; set; } - - double Density { get; set; } - double Mass { get; set; } - double Buoyancy { get; set; } - - Vector3 GeometricCenter { get; } - Vector3 CenterOfMass { get; } - - Vector3 RotationalVelocity { get; set; } - Vector3 Velocity { get; set; } - Vector3 Torque { get; set; } - Vector3 Acceleration { get; } - Vector3 Force { get; set; } - - bool FloatOnWater { set; } - - void AddForce(Vector3 force, bool pushforce); - void AddAngularForce(Vector3 force, bool pushforce); - void SetMomentum(Vector3 momentum); - } -} +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object +{ + /// + /// This implements an interface similar to that provided by physics engines to OpenSim internally. + /// Eg, PhysicsActor. It is capable of setting and getting properties related to the current + /// physics scene representation of this object. + /// + public interface IObjectPhysics + { + bool Enabled { get; set; } + + bool Phantom { get; set; } + bool PhantomCollisions { get; set; } + + double Density { get; set; } + double Mass { get; set; } + double Buoyancy { get; set; } + + Vector3 GeometricCenter { get; } + Vector3 CenterOfMass { get; } + + Vector3 RotationalVelocity { get; set; } + Vector3 Velocity { get; set; } + Vector3 Torque { get; set; } + Vector3 Acceleration { get; } + Vector3 Force { get; set; } + + bool FloatOnWater { set; } + + void AddForce(Vector3 force, bool pushforce); + void AddAngularForce(Vector3 force, bool pushforce); + void SetMomentum(Vector3 momentum); + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SEUser.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SEUser.cs index a35e051..a7da114 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SEUser.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SEUser.cs @@ -1,34 +1,34 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenMetaverse; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - class SEUser : ISocialEntity - { - private readonly UUID m_uuid; - private readonly string m_name; - - public SEUser(UUID uuid, string name) - { - m_uuid = uuid; - m_name = name; - } - - public UUID GlobalID - { - get { return m_uuid; } - } - - public string Name - { - get { return m_name; } - } - - public bool IsUser - { - get { return true; } - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + class SEUser : ISocialEntity + { + private readonly UUID m_uuid; + private readonly string m_name; + + public SEUser(UUID uuid, string name) + { + m_uuid = uuid; + m_name = name; + } + + public UUID GlobalID + { + get { return m_uuid; } + } + + public string Name + { + get { return m_name; } + } + + public bool IsUser + { + get { return true; } + } + } +} -- cgit v1.1 From 465f1df5923e82c0471aac6b771fb4b7f76d3cac Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 6 Apr 2009 14:36:44 +0000 Subject: Add copyright headers, formatting cleanup. --- .../Scripting/Minimodule/IObject.cs | 6 ++--- .../Scripting/Minimodule/IParcel.cs | 29 +++++++++++++++++++++- .../Scripting/Minimodule/IPersistence.cs | 29 +++++++++++++++++++++- .../Scripting/Minimodule/ISocialEntity.cs | 29 +++++++++++++++++++++- .../Scripting/Minimodule/LOParcel.cs | 29 +++++++++++++++++++++- .../Scripting/Minimodule/Object/IObjectPhysics.cs | 29 +++++++++++++++++++++- .../OptionalModules/Scripting/Minimodule/SEUser.cs | 29 +++++++++++++++++++++- 7 files changed, 171 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs index 3636544..20d8e54 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -44,13 +44,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule /// /// IObject deleteMe = World.Objects[0]; /// - /// if(deleteMe.Exists) { + /// if (deleteMe.Exists) { /// deleteMe.Say("Hello, I still exist!"); /// } /// /// World.Objects.Remove(deleteMe); /// - /// if(!deleteMe.Exists) { + /// if (!deleteMe.Exists) { /// Host.Console.Info("I was deleted"); /// } /// diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IParcel.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IParcel.cs index 2849f16..759b26d 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IParcel.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IParcel.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; using System.Collections.Generic; using System.Text; using OpenMetaverse; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs index c093880..17bb6e7 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; using System.Collections.Generic; using System.Text; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISocialEntity.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISocialEntity.cs index cc664eb..400367f 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISocialEntity.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISocialEntity.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; using System.Collections.Generic; using System.Text; using OpenMetaverse; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs index 8ab1a56..d2f3121 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs @@ -1,4 +1,31 @@ -using OpenSim.Region.Framework.Interfaces; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectPhysics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectPhysics.cs index 3682e9b..45bf25e 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectPhysics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectPhysics.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; using System.Collections.Generic; using System.Text; using OpenMetaverse; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SEUser.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SEUser.cs index a7da114..ebf68b1 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SEUser.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SEUser.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; using System.Collections.Generic; using System.Text; using OpenMetaverse; -- cgit v1.1 From 232241ab25ccd9e3184a2eeda0e80f7af15e1641 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 9 Apr 2009 07:46:05 +0000 Subject: * Implements IObject.OnTouch += delegate(IObject sender, TouchEventArgs e) * This is equivalent to LSL 'touch(int senders)' --- .../Scripting/Minimodule/IObject.cs | 22 ++++++++++ .../Scripting/Minimodule/SOPObject.cs | 51 ++++++++++++++++++++++ 2 files changed, 73 insertions(+) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs index 20d8e54..fd62328 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs @@ -32,8 +32,30 @@ using OpenSim.Region.OptionalModules.Scripting.Minimodule.Object; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { + public class TouchEventArgs : EventArgs + { + public IAvatar Avatar; + + public Vector3 TouchBiNormal; + public Vector3 TouchNormal; + public Vector3 TouchPosition; + + public Vector2 TouchUV; + public Vector2 TouchST; + + public int TouchMaterialIndex; + } + + public delegate void OnTouchDelegate(IObject sender, TouchEventArgs e); + public interface IObject { + #region Events + + event OnTouchDelegate OnTouch; + + #endregion + /// /// Returns whether or not this object is still in the world. /// Eg, if you store an IObject reference, however the object diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 48cae2f..4734fa9 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -59,6 +59,57 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule return null; } + #region OnTouch + + private event OnTouchDelegate _OnTouch; + private bool _OnTouchActive = false; + + public event OnTouchDelegate OnTouch + { + add + { + if(!_OnTouchActive) + { + _OnTouchActive = true; + m_rootScene.EventManager.OnObjectGrab += EventManager_OnObjectGrab; + } + + _OnTouch += value; + } + remove + { + _OnTouch -= value; + + if (_OnTouch == null) + { + _OnTouchActive = false; + m_rootScene.EventManager.OnObjectGrab -= EventManager_OnObjectGrab; + } + } + } + + void EventManager_OnObjectGrab(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) + { + if (_OnTouchActive && m_localID == localID) + { + TouchEventArgs e = new TouchEventArgs(); + e.Avatar = new SPAvatar(m_rootScene, remoteClient.AgentId); + e.TouchBiNormal = surfaceArgs.Binormal; + e.TouchMaterialIndex = surfaceArgs.FaceIndex; + e.TouchNormal = surfaceArgs.Normal; + e.TouchPosition = surfaceArgs.Position; + e.TouchST = new Vector2(surfaceArgs.STCoord.X, surfaceArgs.STCoord.Y); + e.TouchUV = new Vector2(surfaceArgs.UVCoord.X, surfaceArgs.UVCoord.Y); + + IObject sender = this; + + if (_OnTouch != null) + _OnTouch(sender, e); + } + } + + #endregion + public bool Exists { get { return GetSOP() != null; } -- cgit v1.1 From 1b56fff7c8ca3a3e14e576ecb0137d9d34997205 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 9 Apr 2009 10:07:40 +0000 Subject: * Implements retrieving child primitives via World.Objects[id] (MRM) * Optimizes SceneGraph - fetches on primitives via "GetGroupByPrim" wont search the entire list if the primitive is infact the root. (Core) * Updates Test MRM. --- .../OptionalModules/Scripting/Minimodule/SOPObject.cs | 5 +---- .../OptionalModules/Scripting/Minimodule/Test/TestModule.cs | 13 ++++++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 4734fa9..75ec33a 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -53,10 +53,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule /// private SceneObjectPart GetSOP() { - if (m_rootScene.Entities.ContainsKey(m_localID)) - return ((SceneObjectGroup) m_rootScene.Entities[m_localID]).RootPart; - - return null; + return m_rootScene.GetSceneObjectPart(m_localID); } #region OnTouch diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs index e56d5eb..702ac74 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs @@ -33,7 +33,18 @@ namespace OpenSim { public override void Start() { - Host.Console.Info("Hello World!"); + // Say Hello + Host.Object.Say("Hello, Avatar!"); + + // Register ourselves to listen + // for touch events. + Host.Object.OnTouch += OnTouched; + } + + // This is our touch event handler + void OnTouched(IObject sender, TouchEventArgs e) + { + Host.Object.Say("Touched."); } public override void Stop() -- cgit v1.1 From b529750548b74ae16c5b2e0f5393e2ef87626d50 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 9 Apr 2009 11:09:24 +0000 Subject: * Moves Name, GlobalID and WorldPosition into new IEntity interface. * Avatar and Object now inherit from IEntity. * Avatar.Position is now Avatar.WorldPosition to match IObject property. * Implements event World.OnChat += delegate(IWorld sender, ChatEventArgs e); --- .../Scripting/Minimodule/IAvatar.cs | 6 +- .../Scripting/Minimodule/IObject.cs | 18 +---- .../OptionalModules/Scripting/Minimodule/IWorld.cs | 12 ++++ .../Scripting/Minimodule/SPAvatar.cs | 5 +- .../OptionalModules/Scripting/Minimodule/World.cs | 79 ++++++++++++++++++++++ 5 files changed, 98 insertions(+), 22 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs index a500154..fef85dd 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs @@ -32,10 +32,8 @@ using OpenMetaverse; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - public interface IAvatar + public interface IAvatar : IEntity { - string Name { get; } - UUID GlobalID { get; } - Vector3 Position { get; } + } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs index fd62328..dc2e3fa 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs @@ -48,7 +48,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public delegate void OnTouchDelegate(IObject sender, TouchEventArgs e); - public interface IObject + public interface IObject : IEntity { #region Events @@ -92,17 +92,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule uint LocalID { get; } /// - /// The global 'world-unique' ID for this object. - /// (Note, may not actually be world unique) - /// - UUID GlobalID { get; } - - /// - /// The name of this Object. - /// - String Name { get; set; } - - /// /// The description assigned to this object. /// String Description { get; set; } @@ -141,11 +130,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule Quaternion OffsetRotation { get; set; } /// - /// The position of the object relative to the Scene - /// - Vector3 WorldPosition { get; set; } - - /// /// The position of the object relative to a parent object /// If root, works the same as WorldPosition /// diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs index b35b57d..e7d9024 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs @@ -25,13 +25,25 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; + namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { + public class ChatEventArgs : EventArgs + { + public string Text; + public IEntity Sender; + } + + public delegate void OnChatDelegate(IWorld sender, ChatEventArgs e); + public interface IWorld { IObjectAccessor Objects { get; } IAvatar[] Avatars { get; } IParcel[] Parcels { get; } IHeightmap Terrain { get; } + + event OnChatDelegate OnChat; } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs index 25b547c..41074c3 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; using OpenMetaverse; using OpenSim.Region.Framework.Scenes; @@ -49,6 +50,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public string Name { get { return GetSP().Name; } + set { throw new InvalidOperationException("Avatar Names are a read-only property."); } } public UUID GlobalID @@ -56,9 +58,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule get { return m_ID; } } - public Vector3 Position + public Vector3 WorldPosition { get { return GetSP().AbsolutePosition; } + set { GetSP().AbsolutePosition = value; } } } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index 05a6a84..e3553bf 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs @@ -26,6 +26,7 @@ */ using System.Collections.Generic; +using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -45,6 +46,84 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule m_objs = new ObjectAccessor(m_internalScene); } + #region Events + + #region OnChat + private event OnChatDelegate _OnChat; + private bool _OnChatActive; + + public event OnChatDelegate OnChat + { + add + { + if (!_OnChatActive) + { + _OnChatActive = true; + m_internalScene.EventManager.OnChatFromClient += EventManager_OnChatFromClient; + m_internalScene.EventManager.OnChatFromWorld += EventManager_OnChatFromWorld; + } + + _OnChat += value; + } + remove + { + _OnChat -= value; + + if (_OnChat == null) + { + _OnChatActive = false; + m_internalScene.EventManager.OnChatFromClient -= EventManager_OnChatFromClient; + m_internalScene.EventManager.OnChatFromWorld -= EventManager_OnChatFromWorld; + } + } + } + + void EventManager_OnChatFromWorld(object sender, OpenSim.Framework.OSChatMessage chat) + { + if (_OnChat != null) + { + HandleChatPacket(chat); + return; + } + } + + private void HandleChatPacket(OSChatMessage chat) + { + // Object? + if (chat.Sender == null && chat.SenderObject != null) + { + ChatEventArgs e = new ChatEventArgs(); + e.Sender = new SOPObject(m_internalScene, ((SceneObjectPart) chat.SenderObject).LocalId); + e.Text = chat.Message; + + _OnChat(this, e); + return; + } + // Avatar? + if (chat.SenderObject != null && chat.SenderObject == null) + { + ChatEventArgs e = new ChatEventArgs(); + e.Sender = new SPAvatar(m_internalScene, chat.SenderUUID); + e.Text = chat.Message; + + _OnChat(this, e); + return; + } + // Skip if other + } + + void EventManager_OnChatFromClient(object sender, OpenSim.Framework.OSChatMessage chat) + { + if (_OnChat != null) + { + HandleChatPacket(chat); + return; + } + } + #endregion + + #endregion + public IObjectAccessor Objects { get { return m_objs; } -- cgit v1.1 From 0af0399198f6b12cc8f7728ecf5dbf59ec66d0b3 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 9 Apr 2009 11:25:50 +0000 Subject: * Forgot to commit IEntity in last commit. * Added "DrunkenTextAppreciationModule" Demo MRM - behaves very similarly to the sobriety filter in WoW. ;) --- .../Scripting/Minimodule/IEntity.cs | 14 ++++++ .../Test/DrunkenTextAppreciationModule.cs | 53 ++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/IEntity.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/DrunkenTextAppreciationModule.cs (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IEntity.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IEntity.cs new file mode 100644 index 0000000..94c53e3 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IEntity.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface IEntity + { + string Name { get; set; } + UUID GlobalID { get; } + Vector3 WorldPosition { get; set; } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/DrunkenTextAppreciationModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/DrunkenTextAppreciationModule.cs new file mode 100644 index 0000000..5b1841d --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/DrunkenTextAppreciationModule.cs @@ -0,0 +1,53 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using OpenSim.Region.OptionalModules.Scripting.Minimodule; + +namespace OpenSim +{ + class DrunkenTextAppreciationModule : MRMBase + { + public override void Start() + { + World.OnChat += World_OnChat; + } + + void World_OnChat(IWorld sender, ChatEventArgs e) + { + e.Text.Replace("s", "sh"); + e.Text.Replace("S", "Sh"); + e.Text += " ...hic!"; + + Host.Object.Say(e.Text); + } + + public override void Stop() + { + + } + } +} \ No newline at end of file -- cgit v1.1 From 03984e7304df152f5b415e38c314e39b7a551dc7 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 9 Apr 2009 13:03:27 +0000 Subject: * Added additional debug testing info to Scene * Corrected issue with MRMs where it would attempt to overwrite an already loaded DLL. (and thus fail with cryptic UnauthorizedAccessException.) * Made DrunkenTextAppreciationModule.cs MRM not crash with StackOverflowException * Added some temporary logging to MRM World.* --- .../Scripting/Minimodule/MRMModule.cs | 44 +++++++++++++++++++++- .../Test/DrunkenTextAppreciationModule.cs | 11 ++++-- .../OptionalModules/Scripting/Minimodule/World.cs | 7 +++- 3 files changed, 56 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 6fa8a24..71077f2 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -91,8 +91,23 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule m_log.Info("[MRM] Starting MRM"); mmb.Start(); } + catch (UnauthorizedAccessException e) + { + m_log.Error("[MRM] UAE " + e.Message); + m_log.Error("[MRM] " + e.StackTrace); + + if (e.InnerException != null) + m_log.Error("[MRM] " + e.InnerException); + + m_scene.Broadcast(delegate(IClientAPI user) + { + user.SendAlertMessage( + "MRM UnAuthorizedAccess: " + e); + }); + } catch (Exception e) { + m_log.Info("[MRM] Error: " + e); m_scene.Broadcast(delegate(IClientAPI user) { user.SendAlertMessage( @@ -133,13 +148,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule /// internal string CompileFromDotNetText(string Script, string uuid) { + m_log.Info("MRM 1"); const string ext = ".cs"; const string FilePrefix = "MiniModule"; // Output assembly name string OutFile = Path.Combine("MiniModules", Path.Combine( m_scene.RegionInfo.RegionID.ToString(), - FilePrefix + "_compiled_" + uuid + ".dll")); + FilePrefix + "_compiled_" + uuid + "_" + + Util.RandomClass.Next(9000) + ".dll")); // Create Directories for Assemblies if (!Directory.Exists("MiniModules")) @@ -148,10 +165,19 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule if (!Directory.Exists(tmp)) Directory.CreateDirectory(tmp); + + m_log.Info("MRM 2"); + try { File.Delete(OutFile); } + catch (UnauthorizedAccessException e) + { + throw new Exception("Unable to delete old existing " + + "script-file before writing new. Compile aborted: " + + e); + } catch (IOException e) { throw new Exception("Unable to delete old existing " + @@ -159,6 +185,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule e); } + m_log.Info("MRM 3"); + // DEBUG - write source to disk string srcFileName = FilePrefix + "_source_" + Path.GetFileNameWithoutExtension(OutFile) + ext; @@ -176,6 +204,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule srcFileName + "\": " + ex.ToString()); } + m_log.Info("MRM 4"); + // Do actual compile CompilerParameters parameters = new CompilerParameters(); @@ -196,9 +226,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule parameters.IncludeDebugInformation = true; parameters.TreatWarningsAsErrors = false; + m_log.Info("MRM 5"); + CompilerResults results = CScodeProvider.CompileAssemblyFromSource( parameters, Script); + m_log.Info("MRM 6"); + int display = 5; if (results.Errors.Count > 0) { @@ -232,6 +266,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule } } + m_log.Info("MRM 7"); + if (!File.Exists(OutFile)) { string errtext = String.Empty; @@ -256,6 +292,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule throw new Exception(errtext); } + m_log.Info("MRM 8"); + // Convert to base64 // string filetext = Convert.ToBase64String(data); @@ -264,10 +302,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule Byte[] buf = enc.GetBytes(filetext); + m_log.Info("MRM 9"); + FileStream sfs = File.Create(OutFile + ".cil.b64"); sfs.Write(buf, 0, buf.Length); sfs.Close(); + m_log.Info("MRM 10"); + return OutFile; } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/DrunkenTextAppreciationModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/DrunkenTextAppreciationModule.cs index 5b1841d..7e8db9c 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/DrunkenTextAppreciationModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/DrunkenTextAppreciationModule.cs @@ -38,11 +38,14 @@ namespace OpenSim void World_OnChat(IWorld sender, ChatEventArgs e) { - e.Text.Replace("s", "sh"); - e.Text.Replace("S", "Sh"); - e.Text += " ...hic!"; + if(!e.Text.Contains("hic!")) + { + e.Text = e.Text.Replace("s", "sh"); + e.Text = e.Text.Replace("S", "Sh"); + e.Text += " ...hic!"; - Host.Object.Say(e.Text); + Host.Object.Say(e.Text); + } } public override void Stop() diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index e3553bf..802d984 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs @@ -26,7 +26,10 @@ */ using System.Collections.Generic; +using System.Reflection; +using log4net; using OpenSim.Framework; +using OpenSim.Framework.Client; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -34,6 +37,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { public class World : IWorld { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private readonly Scene m_internalScene; private readonly Heightmap m_heights; @@ -100,7 +105,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule return; } // Avatar? - if (chat.SenderObject != null && chat.SenderObject == null) + if (chat.Sender != null && chat.SenderObject == null) { ChatEventArgs e = new ChatEventArgs(); e.Sender = new SPAvatar(m_internalScene, chat.SenderUUID); -- cgit v1.1 From 162dd5c65cf94ded47d3cf55ad4160b590413e98 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 9 Apr 2009 13:05:01 +0000 Subject: * World.OnChat no longer fires if there is no chat text (prevents the typing animation packet from firing OnChat) --- OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index 802d984..34f66d8 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs @@ -37,8 +37,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { public class World : IWorld { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private readonly Scene m_internalScene; private readonly Heightmap m_heights; @@ -94,6 +92,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule private void HandleChatPacket(OSChatMessage chat) { + if(string.IsNullOrEmpty(chat.Message)) + return; + // Object? if (chat.Sender == null && chat.SenderObject != null) { -- cgit v1.1 From c91c24441bb114502f0d49d026cfce0b47045c40 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 9 Apr 2009 13:14:25 +0000 Subject: * Limits MRM scripting to Region Master Avatar only. * This makes MRM scripting ever so slightly more secure. If you have enforced Object Permissions enabled, it may be acceptable to enable MRM within your regions. * Security bug reports on this feature are much appreciated (eg: anyone finding ways around this to execute a MRM as a basic user). --- OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 71077f2..910ddea 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -73,8 +73,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule void EventManager_OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) { - if (script.StartsWith("//MiniMod:C#")) + if (script.StartsWith("//MRM:C#")) { + if(m_scene.GetSceneObjectPart(localID).OwnerID != m_scene.RegionInfo.MasterAvatarAssignedUUID) + return; + try { m_log.Info("[MRM] Found C# MRM"); -- cgit v1.1 From 98eda9ebdb168957725c0476abc12cca4dcccd88 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 9 Apr 2009 13:22:27 +0000 Subject: * Adds World.OnNewUser += delegate(IWorld sender, NewUserEventArgs e); * This event fires when a new avatar is created within the Scene. (Internally corresponds to EventManager.OnNewPresence) --- .../OptionalModules/Scripting/Minimodule/IWorld.cs | 8 ++++ .../OptionalModules/Scripting/Minimodule/World.cs | 43 +++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs index e7d9024..acb569f 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs @@ -29,6 +29,13 @@ using System; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { + public class NewUserEventArgs : EventArgs + { + public IAvatar Avatar; + } + + public delegate void OnNewUserDelegate(IWorld sender, NewUserEventArgs e); + public class ChatEventArgs : EventArgs { public string Text; @@ -45,5 +52,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule IHeightmap Terrain { get; } event OnChatDelegate OnChat; + event OnNewUserDelegate OnNewUser; } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index 34f66d8..2280022 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs @@ -51,6 +51,47 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule #region Events + #region OnNewUser + + private event OnNewUserDelegate _OnNewUser; + private bool _OnNewUserActive; + + public event OnNewUserDelegate OnNewUser + { + add + { + if (!_OnNewUserActive) + { + _OnNewUserActive = true; + m_internalScene.EventManager.OnNewPresence += EventManager_OnNewPresence; + } + + _OnNewUser += value; + } + remove + { + _OnNewUser -= value; + + if (_OnNewUser == null) + { + _OnNewUserActive = false; + m_internalScene.EventManager.OnNewPresence -= EventManager_OnNewPresence; + } + } + } + + void EventManager_OnNewPresence(ScenePresence presence) + { + if (_OnNewUser != null) + { + NewUserEventArgs e = new NewUserEventArgs(); + e.Avatar = new SPAvatar(m_internalScene, presence.UUID); + _OnNewUser(this, e); + } + } + + #endregion + #region OnChat private event OnChatDelegate _OnChat; private bool _OnChatActive; @@ -81,7 +122,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule } } - void EventManager_OnChatFromWorld(object sender, OpenSim.Framework.OSChatMessage chat) + void EventManager_OnChatFromWorld(object sender, OSChatMessage chat) { if (_OnChat != null) { -- cgit v1.1 From c77e7fce9ebbdb0a7a5baee316fcf940bf641416 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 9 Apr 2009 14:19:49 +0000 Subject: * Implements IGraphics interface for MRM Scripting. * This allows you to utilize System.Drawing tools on textures within the region. * Example: use System.Drawing.Bitmap to make your texture, then use Host.Graphics.SaveBitmap to make an asset from it in JPEG2K. You can edit (but not overwrite) existing textures using Host.Graphics.LoadBitmap. --- .../Scripting/Minimodule/Graphics.cs | 48 ++++++++++++++++++++++ .../OptionalModules/Scripting/Minimodule/Host.cs | 13 +++++- .../Scripting/Minimodule/IGraphics.cs | 12 ++++++ .../OptionalModules/Scripting/Minimodule/IHost.cs | 1 + .../Scripting/Minimodule/MRMModule.cs | 2 +- .../OptionalModules/Scripting/Minimodule/World.cs | 5 +-- 6 files changed, 75 insertions(+), 6 deletions(-) create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/IGraphics.cs (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs new file mode 100644 index 0000000..4de249f --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs @@ -0,0 +1,48 @@ +using System.Drawing; +using OpenMetaverse; +using OpenMetaverse.Imaging; +using OpenSim.Framework; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + class Graphics : IGraphics + { + private readonly Scene m_scene; + + public Graphics(Scene m_scene) + { + this.m_scene = m_scene; + } + + public UUID SaveBitmap(Bitmap data) + { + return SaveBitmap(data, false, true); + } + + public UUID SaveBitmap(Bitmap data, bool lossless, bool temporary) + { + AssetBase asset = new AssetBase(); + asset.FullID = UUID.Random(); + asset.Data = OpenJPEG.EncodeFromImage(data, lossless); + asset.Name = "MRMDynamicImage" + Util.RandomClass.Next(1, 10000); + asset.Type = 0; + asset.Description = "MRM Image"; + asset.Local = false; + asset.Temporary = temporary; + m_scene.CommsManager.AssetCache.AddAsset(asset); + + return asset.FullID; + } + + public Bitmap LoadBitmap(UUID assetID) + { + AssetBase bmp = m_scene.CommsManager.AssetCache.GetAsset(assetID, true); + ManagedImage outimg; + Image img; + OpenJPEG.DecodeToImage(bmp.Data, out outimg, out img); + + return new Bitmap(img); + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs index 394e024..f5953d0 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs @@ -27,6 +27,7 @@ using System.Reflection; using log4net; +using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { @@ -34,10 +35,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { private readonly IObject m_obj; private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private readonly IGraphics m_graphics; + private Scene m_scene; - public Host(IObject m_obj) + public Host(IObject m_obj, Scene m_scene) { this.m_obj = m_obj; + this.m_scene = m_scene; + + m_graphics = new Graphics(m_scene); } public IObject Object @@ -49,5 +55,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { get { return m_log; } } + + public IGraphics Graphics + { + get { return m_graphics; } + } } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IGraphics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IGraphics.cs new file mode 100644 index 0000000..f4bc12e --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IGraphics.cs @@ -0,0 +1,12 @@ +using System.Drawing; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface IGraphics + { + UUID SaveBitmap(Bitmap data); + UUID SaveBitmap(Bitmap data, bool lossless, bool temporary); + Bitmap LoadBitmap(UUID assetID); + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs index deb7c57..6c76919 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs @@ -36,5 +36,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { IObject Object { get; } ILog Console { get; } + IGraphics Graphics { get; } } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 910ddea..b978d7c 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -82,7 +82,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { m_log.Info("[MRM] Found C# MRM"); IWorld m_world = new World(m_scene); - IHost m_host = new Host(new SOPObject(m_scene, localID)); + IHost m_host = new Host(new SOPObject(m_scene, localID), m_scene); MRMBase mmb = (MRMBase)AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap( CompileFromDotNetText(script, itemID.ToString()), diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index 2280022..f2b3e81 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs @@ -26,10 +26,7 @@ */ using System.Collections.Generic; -using System.Reflection; -using log4net; using OpenSim.Framework; -using OpenSim.Framework.Client; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -159,7 +156,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule // Skip if other } - void EventManager_OnChatFromClient(object sender, OpenSim.Framework.OSChatMessage chat) + void EventManager_OnChatFromClient(object sender, OSChatMessage chat) { if (_OnChat != null) { -- cgit v1.1 From 8ee81f98ea093d6bae70ba493a9d11a4ce576622 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 9 Apr 2009 14:51:18 +0000 Subject: * Implements IObject.Materials[].* * This lets you do things like IObject.Materials[0].Texture = new UUID("0000-..."); --- .../Scripting/Minimodule/Graphics.cs | 2 +- .../Scripting/Minimodule/SOPObject.cs | 2 +- .../Scripting/Minimodule/SOPObjectMaterial.cs | 91 ++++++++++++++++++++++ 3 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs index 4de249f..44bae5c 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs @@ -25,7 +25,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule AssetBase asset = new AssetBase(); asset.FullID = UUID.Random(); asset.Data = OpenJPEG.EncodeFromImage(data, lossless); - asset.Name = "MRMDynamicImage" + Util.RandomClass.Next(1, 10000); + asset.Name = "MRMDynamicImage"; asset.Type = 0; asset.Description = "MRM Image"; asset.Local = false; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 75ec33a..d6c3f7f 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -167,7 +167,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule for (int i = 0; i < rets.Length;i++ ) { - //rets[i] = new ObjectFace + rets[i] = new SOPObjectMaterial(i, sop); } return rets; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs new file mode 100644 index 0000000..94de09e --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Text; +using OpenMetaverse; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + class SOPObjectMaterial : IObjectMaterial + { + private readonly int m_face; + private readonly SceneObjectPart m_parent; + + public SOPObjectMaterial(int m_face, SceneObjectPart m_parent) + { + this.m_face = m_face; + this.m_parent = m_parent; + } + + public Color Color + { + get + { + Color4 res = GetTexface().RGBA; + return Color.FromArgb((int) (res.A*255), (int) (res.R*255), (int) (res.G*255), (int) (res.B*255)); + } + set + { + Primitive.TextureEntry tex = m_parent.Shape.Textures; + Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); + texface.RGBA = new Color4(value.R,value.G,value.B,value.A); + tex.FaceTextures[m_face] = texface; + m_parent.UpdateTexture(tex); + } + } + + public UUID Texture + { + get + { + Primitive.TextureEntryFace texface = GetTexface(); + return texface.TextureID; + } + set + { + Primitive.TextureEntry tex = m_parent.Shape.Textures; + Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); + texface.TextureID = value; + tex.FaceTextures[m_face] = texface; + m_parent.UpdateTexture(tex); + } + } + + private Primitive.TextureEntryFace GetTexface() + { + Primitive.TextureEntry tex = m_parent.Shape.Textures; + return tex.GetFace((uint)m_face); + } + + public TextureMapping Mapping + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public bool Bright + { + get { return GetTexface().Fullbright; } + set { throw new System.NotImplementedException(); } + } + + public double Bloom + { + get { return GetTexface().Glow; } + set { throw new System.NotImplementedException(); } + } + + public bool Shiny + { + get { return GetTexface().Shiny != Shininess.None; } + set { throw new System.NotImplementedException(); } + } + + public bool BumpMap + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + } +} -- cgit v1.1 From f44694c28eee8bf3593f23a39607fb62e9299309 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 9 Apr 2009 15:46:02 +0000 Subject: * Allows MRMs to import libraries in the OpenSim bin directory. * Syntax: //@DEPENDS:library.dll --- .../Scripting/Minimodule/MRMModule.cs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index b978d7c..5c249b9 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -217,12 +217,23 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule string rootPath = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); + List libraries = new List(); + string[] lines = Script.Split(new string[] {"\n"}, StringSplitOptions.RemoveEmptyEntries); + foreach (string s in lines) + { + if(s.StartsWith("//@DEPENDS:")) + { + libraries.Add(s.Replace("//@DEPENDS:", "")); + } + } - // TODO: Add Libraries - parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, - "OpenSim.Region.OptionalModules.dll")); - parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, - "log4net.dll")); + libraries.Add("OpenSim.Region.OptionalModules.dll"); + libraries.Add("log4net.dll"); + + foreach (string library in libraries) + { + parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, library)); + } parameters.GenerateExecutable = false; parameters.OutputAssembly = OutFile; -- cgit v1.1 From 601fa22185a64d2fa378ccc3c0b55638bc77dc37 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 9 Apr 2009 20:06:30 +0000 Subject: * minor: remove some mono compiler warnings --- OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs index f5953d0..b7f67dd 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs @@ -36,12 +36,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule private readonly IObject m_obj; private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private readonly IGraphics m_graphics; - private Scene m_scene; + //private Scene m_scene; public Host(IObject m_obj, Scene m_scene) { this.m_obj = m_obj; - this.m_scene = m_scene; + //this.m_scene = m_scene; m_graphics = new Graphics(m_scene); } -- cgit v1.1 From b664566b8f2384e68362c008b147be72db04f8ff Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Fri, 10 Apr 2009 05:13:02 +0000 Subject: * Fixes a bug in MRM scripting whereby the Touch flag is never enabled for OnTouch capable scripts. --- OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index d6c3f7f..d726de7 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -67,6 +67,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { if(!_OnTouchActive) { + GetSOP().Flags |= PrimFlags.Touch; _OnTouchActive = true; m_rootScene.EventManager.OnObjectGrab += EventManager_OnObjectGrab; } @@ -79,6 +80,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule if (_OnTouch == null) { + GetSOP().Flags &= ~PrimFlags.Touch; _OnTouchActive = false; m_rootScene.EventManager.OnObjectGrab -= EventManager_OnObjectGrab; } -- cgit v1.1 From b8619386eb31a2bf3f460e464d0237f6bee5f56f Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 11 Apr 2009 10:21:04 +0000 Subject: * Minor MRM Cleanup * Interfaces now live in Interfaces subdirectory. * Namespace does not yet reflect this change. * Final namespace for MRMs will probably sit somewhere around OpenSim.Extend.MRM[?] --- .../Scripting/Minimodule/IAvatar.cs | 39 ---- .../Scripting/Minimodule/IEntity.cs | 14 -- .../Scripting/Minimodule/IGraphics.cs | 12 -- .../Scripting/Minimodule/IHeightmap.cs | 69 ------- .../OptionalModules/Scripting/Minimodule/IHost.cs | 41 ---- .../Scripting/Minimodule/IObject.cs | 223 --------------------- .../Scripting/Minimodule/IObjectAccessor.cs | 39 ---- .../Scripting/Minimodule/IParcel.cs | 42 ---- .../Scripting/Minimodule/IPersistence.cs | 56 ------ .../Scripting/Minimodule/ISocialEntity.cs | 41 ---- .../OptionalModules/Scripting/Minimodule/IWorld.cs | 57 ------ .../Scripting/Minimodule/Interfaces/IAvatar.cs | 39 ++++ .../Scripting/Minimodule/Interfaces/IEntity.cs | 14 ++ .../Scripting/Minimodule/Interfaces/IGraphics.cs | 12 ++ .../Scripting/Minimodule/Interfaces/IHeightmap.cs | 69 +++++++ .../Scripting/Minimodule/Interfaces/IHost.cs | 41 ++++ .../Scripting/Minimodule/Interfaces/IObject.cs | 223 +++++++++++++++++++++ .../Minimodule/Interfaces/IObjectAccessor.cs | 39 ++++ .../Scripting/Minimodule/Interfaces/IParcel.cs | 42 ++++ .../Minimodule/Interfaces/IPersistence.cs | 56 ++++++ .../Scripting/Minimodule/Interfaces/IScheduler.cs | 43 ++++ .../Minimodule/Interfaces/ISocialEntity.cs | 41 ++++ .../Scripting/Minimodule/Interfaces/IWorld.cs | 57 ++++++ .../Scripting/Minimodule/SOPObjectMaterial.cs | 5 +- .../Test/DrunkenTextAppreciationModule.cs | 18 +- 25 files changed, 690 insertions(+), 642 deletions(-) delete mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs delete mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/IEntity.cs delete mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/IGraphics.cs delete mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs delete mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs delete mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs delete mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/IObjectAccessor.cs delete mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/IParcel.cs delete mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs delete mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/ISocialEntity.cs delete mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IEntity.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IGraphics.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IHeightmap.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IHost.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObjectAccessor.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IParcel.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IPersistence.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IScheduler.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/ISocialEntity.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IWorld.cs (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs deleted file mode 100644 index fef85dd..0000000 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IAvatar.cs +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Text; -using OpenMetaverse; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public interface IAvatar : IEntity - { - - } -} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IEntity.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IEntity.cs deleted file mode 100644 index 94c53e3..0000000 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IEntity.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenMetaverse; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public interface IEntity - { - string Name { get; set; } - UUID GlobalID { get; } - Vector3 WorldPosition { get; set; } - } -} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IGraphics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IGraphics.cs deleted file mode 100644 index f4bc12e..0000000 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IGraphics.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Drawing; -using OpenMetaverse; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public interface IGraphics - { - UUID SaveBitmap(Bitmap data); - UUID SaveBitmap(Bitmap data, bool lossless, bool temporary); - Bitmap LoadBitmap(UUID assetID); - } -} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs deleted file mode 100644 index 93cbc5b..0000000 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHeightmap.cs +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public interface IHeightmap - { - /// - /// Returns [or sets] the heightmap value at specified coordinates. - /// - /// X Coordinate - /// Y Coordinate - /// A value in meters representing height. Can be negative. Value correlates with Z parameter in world coordinates - /// - /// double heightVal = World.Heightmap[128,128]; - /// World.Heightmap[128,128] *= 5.0; - /// World.Heightmap[128,128] = 25; - /// - double this[int x, int y] - { - get; - set; - } - - /// - /// The maximum length of the region (Y axis), exclusive. (eg Height = 256, max Y = 255). Minimum is always 0 inclusive. - /// - /// - /// Host.Console.Info("The terrain length of this region is " + World.Heightmap.Length); - /// - int Length { get; } - - /// - /// The maximum width of the region (X axis), exclusive. (eg Width = 256, max X = 255). Minimum is always 0 inclusive. - /// - /// - /// Host.Console.Info("The terrain width of this region is " + World.Heightmap.Width); - /// - int Width { get; } - } -} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs deleted file mode 100644 index 6c76919..0000000 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Text; -using log4net; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public interface IHost - { - IObject Object { get; } - ILog Console { get; } - IGraphics Graphics { get; } - } -} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs deleted file mode 100644 index dc2e3fa..0000000 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Drawing; -using OpenMetaverse; -using OpenSim.Region.OptionalModules.Scripting.Minimodule.Object; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public class TouchEventArgs : EventArgs - { - public IAvatar Avatar; - - public Vector3 TouchBiNormal; - public Vector3 TouchNormal; - public Vector3 TouchPosition; - - public Vector2 TouchUV; - public Vector2 TouchST; - - public int TouchMaterialIndex; - } - - public delegate void OnTouchDelegate(IObject sender, TouchEventArgs e); - - public interface IObject : IEntity - { - #region Events - - event OnTouchDelegate OnTouch; - - #endregion - - /// - /// Returns whether or not this object is still in the world. - /// Eg, if you store an IObject reference, however the object - /// is deleted before you use it, it will throw a NullReference - /// exception. 'Exists' allows you to check the object is still - /// in play before utilizing it. - /// - /// - /// IObject deleteMe = World.Objects[0]; - /// - /// if (deleteMe.Exists) { - /// deleteMe.Say("Hello, I still exist!"); - /// } - /// - /// World.Objects.Remove(deleteMe); - /// - /// if (!deleteMe.Exists) { - /// Host.Console.Info("I was deleted"); - /// } - /// - /// - /// Objects should be near-guarunteed to exist for any event which - /// passes them as an argument. Storing an object for a longer period - /// of time however will limit their reliability. - /// - /// It is a good practice to use Try/Catch blocks handling for - /// NullReferenceException, when accessing remote objects. - /// - bool Exists { get; } - - /// - /// The local region-unique ID for this object. - /// - uint LocalID { get; } - - /// - /// The description assigned to this object. - /// - String Description { get; set; } - - /// - /// Returns the root object of a linkset. If this object is the root, it will return itself. - /// - IObject Root { get; } - - /// - /// Returns a collection of objects which are linked to the current object. Does not include the root object. - /// - IObject[] Children { get; } - - /// - /// Returns a list of materials attached to this object. Each may contain unique texture - /// and other visual information. For primitive based objects, this correlates with - /// Object Faces. For mesh based objects, this correlates with Materials. - /// - IObjectMaterial[] Materials { get; } - - /// - /// The bounding box of the object. Primitive and Mesh objects alike are scaled to fit within these bounds. - /// - Vector3 Scale { get; set; } - - /// - /// The rotation of the object relative to the Scene - /// - Quaternion WorldRotation { get; set; } - - /// - /// The rotation of the object relative to a parent object - /// If root, works the same as WorldRotation - /// - Quaternion OffsetRotation { get; set; } - - /// - /// The position of the object relative to a parent object - /// If root, works the same as WorldPosition - /// - Vector3 OffsetPosition { get; set; } - - Vector3 SitTarget { get; set; } - String SitTargetText { get; set; } - - String TouchText { get; set; } - - /// - /// Text to be associated with this object, in the - /// Second Life(r) viewer, this is shown above the - /// object. - /// - String Text { get; set; } - - bool IsRotationLockedX { get; set; } // SetStatus(!ROTATE_X) - bool IsRotationLockedY { get; set; } // SetStatus(!ROTATE_Y) - bool IsRotationLockedZ { get; set; } // SetStatus(!ROTATE_Z) - bool IsSandboxed { get; set; } // SetStatus(SANDBOX) - bool IsImmotile { get; set; } // SetStatus(BLOCK_GRAB) - bool IsAlwaysReturned { get; set; } // SetStatus(!DIE_AT_EDGE) - bool IsTemporary { get; set; } // TEMP_ON_REZ - - bool IsFlexible { get; set; } - - PrimType PrimShape { get; set; } - // TODO: - // PrimHole - // Repeats, Offsets, Cut/Dimple/ProfileCut - // Hollow, Twist, HoleSize, - // Taper[A+B], Shear[A+B], Revolutions, - // RadiusOffset, Skew - - PhysicsMaterial PhysicsMaterial { get; set; } - - IObjectPhysics Physics { get; } - - - /// - /// Causes the object to speak to its surroundings, - /// equivilent to LSL/OSSL llSay - /// - /// The message to send to the user - void Say(string msg); - - } - - public enum PhysicsMaterial - { - Default, - Glass, - Metal, - Plastic, - Wood, - Rubber, - Stone, - Flesh - } - - public enum PrimType - { - NotPrimitive = 255, - Box = 0, - Cylinder = 1, - Prism = 2, - Sphere = 3, - Torus = 4, - Tube = 5, - Ring = 6, - Sculpt = 7 - } - - public enum TextureMapping - { - Default, - Planar - } - - public interface IObjectMaterial - { - Color Color { get; set; } - UUID Texture { get; set; } - TextureMapping Mapping { get; set; } // SetPrimParms(PRIM_TEXGEN) - bool Bright { get; set; } // SetPrimParms(FULLBRIGHT) - double Bloom { get; set; } // SetPrimParms(GLOW) - bool Shiny { get; set; } // SetPrimParms(SHINY) - bool BumpMap { get; set; } // SetPrimParms(BUMPMAP) [DEPRECIATE IN FAVOUR OF UUID?] - } -} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObjectAccessor.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObjectAccessor.cs deleted file mode 100644 index 7aed41b..0000000 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObjectAccessor.cs +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -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/IParcel.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IParcel.cs deleted file mode 100644 index 759b26d..0000000 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IParcel.cs +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Text; -using OpenMetaverse; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public interface IParcel - { - string Name { get; set; } - string Description { get; set; } - ISocialEntity Owner { get; set; } - bool[,] Bitmap { get; } - } -} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs deleted file mode 100644 index 17bb6e7..0000000 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IPersistence.cs +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - interface IPersistence - { - T Get(Guid storageID); - T Get(); - - /// - /// Stores 'data' into the persistence system - /// associated with this object, however saved - /// under the ID 'storageID'. This data may - /// be accessed by other scripts however. - /// - /// - /// - void Put(Guid storageID, T data); - - /// - /// Stores 'data' into the persistence system - /// using the default ID for this script. - /// - /// - void Put(T data); - } -} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISocialEntity.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISocialEntity.cs deleted file mode 100644 index 400367f..0000000 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISocialEntity.cs +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Text; -using OpenMetaverse; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public interface ISocialEntity - { - UUID GlobalID { get; } - string Name { get; } - bool IsUser { get; } - } -} \ No newline at end of file diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs deleted file mode 100644 index acb569f..0000000 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IWorld.cs +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public class NewUserEventArgs : EventArgs - { - public IAvatar Avatar; - } - - public delegate void OnNewUserDelegate(IWorld sender, NewUserEventArgs e); - - public class ChatEventArgs : EventArgs - { - public string Text; - public IEntity Sender; - } - - public delegate void OnChatDelegate(IWorld sender, ChatEventArgs e); - - public interface IWorld - { - IObjectAccessor Objects { get; } - IAvatar[] Avatars { get; } - IParcel[] Parcels { get; } - IHeightmap Terrain { get; } - - event OnChatDelegate OnChat; - event OnNewUserDelegate OnNewUser; - } -} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs new file mode 100644 index 0000000..92ef490 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs @@ -0,0 +1,39 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface IAvatar : IEntity + { + + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IEntity.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IEntity.cs new file mode 100644 index 0000000..94c53e3 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IEntity.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface IEntity + { + string Name { get; set; } + UUID GlobalID { get; } + Vector3 WorldPosition { get; set; } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IGraphics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IGraphics.cs new file mode 100644 index 0000000..f4bc12e --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IGraphics.cs @@ -0,0 +1,12 @@ +using System.Drawing; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface IGraphics + { + UUID SaveBitmap(Bitmap data); + UUID SaveBitmap(Bitmap data, bool lossless, bool temporary); + Bitmap LoadBitmap(UUID assetID); + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IHeightmap.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IHeightmap.cs new file mode 100644 index 0000000..eea1baf --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IHeightmap.cs @@ -0,0 +1,69 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface IHeightmap + { + /// + /// Returns [or sets] the heightmap value at specified coordinates. + /// + /// X Coordinate + /// Y Coordinate + /// A value in meters representing height. Can be negative. Value correlates with Z parameter in world coordinates + /// + /// double heightVal = World.Heightmap[128,128]; + /// World.Heightmap[128,128] *= 5.0; + /// World.Heightmap[128,128] = 25; + /// + double this[int x, int y] + { + get; + set; + } + + /// + /// The maximum length of the region (Y axis), exclusive. (eg Height = 256, max Y = 255). Minimum is always 0 inclusive. + /// + /// + /// Host.Console.Info("The terrain length of this region is " + World.Heightmap.Length); + /// + int Length { get; } + + /// + /// The maximum width of the region (X axis), exclusive. (eg Width = 256, max X = 255). Minimum is always 0 inclusive. + /// + /// + /// Host.Console.Info("The terrain width of this region is " + World.Heightmap.Width); + /// + int Width { get; } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IHost.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IHost.cs new file mode 100644 index 0000000..8980b8f --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IHost.cs @@ -0,0 +1,41 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Text; +using log4net; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface IHost + { + IObject Object { get; } + ILog Console { get; } + IGraphics Graphics { get; } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs new file mode 100644 index 0000000..e17b716 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs @@ -0,0 +1,223 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Drawing; +using OpenMetaverse; +using OpenSim.Region.OptionalModules.Scripting.Minimodule.Object; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public class TouchEventArgs : EventArgs + { + public IAvatar Avatar; + + public Vector3 TouchBiNormal; + public Vector3 TouchNormal; + public Vector3 TouchPosition; + + public Vector2 TouchUV; + public Vector2 TouchST; + + public int TouchMaterialIndex; + } + + public delegate void OnTouchDelegate(IObject sender, TouchEventArgs e); + + public interface IObject : IEntity + { + #region Events + + event OnTouchDelegate OnTouch; + + #endregion + + /// + /// Returns whether or not this object is still in the world. + /// Eg, if you store an IObject reference, however the object + /// is deleted before you use it, it will throw a NullReference + /// exception. 'Exists' allows you to check the object is still + /// in play before utilizing it. + /// + /// + /// IObject deleteMe = World.Objects[0]; + /// + /// if (deleteMe.Exists) { + /// deleteMe.Say("Hello, I still exist!"); + /// } + /// + /// World.Objects.Remove(deleteMe); + /// + /// if (!deleteMe.Exists) { + /// Host.Console.Info("I was deleted"); + /// } + /// + /// + /// Objects should be near-guarunteed to exist for any event which + /// passes them as an argument. Storing an object for a longer period + /// of time however will limit their reliability. + /// + /// It is a good practice to use Try/Catch blocks handling for + /// NullReferenceException, when accessing remote objects. + /// + bool Exists { get; } + + /// + /// The local region-unique ID for this object. + /// + uint LocalID { get; } + + /// + /// The description assigned to this object. + /// + String Description { get; set; } + + /// + /// Returns the root object of a linkset. If this object is the root, it will return itself. + /// + IObject Root { get; } + + /// + /// Returns a collection of objects which are linked to the current object. Does not include the root object. + /// + IObject[] Children { get; } + + /// + /// Returns a list of materials attached to this object. Each may contain unique texture + /// and other visual information. For primitive based objects, this correlates with + /// Object Faces. For mesh based objects, this correlates with Materials. + /// + IObjectMaterial[] Materials { get; } + + /// + /// The bounding box of the object. Primitive and Mesh objects alike are scaled to fit within these bounds. + /// + Vector3 Scale { get; set; } + + /// + /// The rotation of the object relative to the Scene + /// + Quaternion WorldRotation { get; set; } + + /// + /// The rotation of the object relative to a parent object + /// If root, works the same as WorldRotation + /// + Quaternion OffsetRotation { get; set; } + + /// + /// The position of the object relative to a parent object + /// If root, works the same as WorldPosition + /// + Vector3 OffsetPosition { get; set; } + + Vector3 SitTarget { get; set; } + String SitTargetText { get; set; } + + String TouchText { get; set; } + + /// + /// Text to be associated with this object, in the + /// Second Life(r) viewer, this is shown above the + /// object. + /// + String Text { get; set; } + + bool IsRotationLockedX { get; set; } // SetStatus(!ROTATE_X) + bool IsRotationLockedY { get; set; } // SetStatus(!ROTATE_Y) + bool IsRotationLockedZ { get; set; } // SetStatus(!ROTATE_Z) + bool IsSandboxed { get; set; } // SetStatus(SANDBOX) + bool IsImmotile { get; set; } // SetStatus(BLOCK_GRAB) + bool IsAlwaysReturned { get; set; } // SetStatus(!DIE_AT_EDGE) + bool IsTemporary { get; set; } // TEMP_ON_REZ + + bool IsFlexible { get; set; } + + PrimType PrimShape { get; set; } + // TODO: + // PrimHole + // Repeats, Offsets, Cut/Dimple/ProfileCut + // Hollow, Twist, HoleSize, + // Taper[A+B], Shear[A+B], Revolutions, + // RadiusOffset, Skew + + PhysicsMaterial PhysicsMaterial { get; set; } + + IObjectPhysics Physics { get; } + + + /// + /// Causes the object to speak to its surroundings, + /// equivilent to LSL/OSSL llSay + /// + /// The message to send to the user + void Say(string msg); + + } + + public enum PhysicsMaterial + { + Default, + Glass, + Metal, + Plastic, + Wood, + Rubber, + Stone, + Flesh + } + + public enum PrimType + { + NotPrimitive = 255, + Box = 0, + Cylinder = 1, + Prism = 2, + Sphere = 3, + Torus = 4, + Tube = 5, + Ring = 6, + Sculpt = 7 + } + + public enum TextureMapping + { + Default, + Planar + } + + public interface IObjectMaterial + { + Color Color { get; set; } + UUID Texture { get; set; } + TextureMapping Mapping { get; set; } // SetPrimParms(PRIM_TEXGEN) + bool Bright { get; set; } // SetPrimParms(FULLBRIGHT) + double Bloom { get; set; } // SetPrimParms(GLOW) + bool Shiny { get; set; } // SetPrimParms(SHINY) + bool BumpMap { get; set; } // SetPrimParms(BUMPMAP) [DEPRECIATE IN FAVOUR OF UUID?] + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObjectAccessor.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObjectAccessor.cs new file mode 100644 index 0000000..cd27a6a --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObjectAccessor.cs @@ -0,0 +1,39 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +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/Interfaces/IParcel.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IParcel.cs new file mode 100644 index 0000000..3b229a7 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IParcel.cs @@ -0,0 +1,42 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface IParcel + { + string Name { get; set; } + string Description { get; set; } + ISocialEntity Owner { get; set; } + bool[,] Bitmap { get; } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IPersistence.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IPersistence.cs new file mode 100644 index 0000000..bde51fe --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IPersistence.cs @@ -0,0 +1,56 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + interface IPersistence + { + T Get(Guid storageID); + T Get(); + + /// + /// Stores 'data' into the persistence system + /// associated with this object, however saved + /// under the ID 'storageID'. This data may + /// be accessed by other scripts however. + /// + /// + /// + void Put(Guid storageID, T data); + + /// + /// Stores 'data' into the persistence system + /// using the default ID for this script. + /// + /// + void Put(T data); + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IScheduler.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IScheduler.cs new file mode 100644 index 0000000..cf45de7 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IScheduler.cs @@ -0,0 +1,43 @@ +using System; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + interface IScheduler + { + /// + /// Schedule an event callback to occur + /// when 'time' is elapsed. + /// + /// The period to wait before executing + void RunIn(TimeSpan time); + + /// + /// Schedule an event callback to fire + /// every "time". Equivilent to a repeating + /// timer. + /// + /// The period to wait between executions + void RunAndRepeat(TimeSpan time); + + /// + /// Fire this scheduler only when the region has + /// a user in it. + /// + bool WhenRegionOccupied { get; set; } + + /// + /// Fire this event only when the region is visible + /// to a child agent, or there is a full agent + /// in this region. + /// + bool WhenRegionVisible { get; set; } + + /// + /// Determines whether this runs in the master scheduler thread, or a new thread + /// is spawned to handle your request. Running in scheduler may mean that your + /// code does not execute perfectly on time, however will result in a lower + /// processor cost to running your code. + /// + bool Schedule { get; set; } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/ISocialEntity.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/ISocialEntity.cs new file mode 100644 index 0000000..cbac123 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/ISocialEntity.cs @@ -0,0 +1,41 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface ISocialEntity + { + UUID GlobalID { get; } + string Name { get; } + bool IsUser { get; } + } +} \ No newline at end of file diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IWorld.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IWorld.cs new file mode 100644 index 0000000..9196acd --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IWorld.cs @@ -0,0 +1,57 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public class NewUserEventArgs : EventArgs + { + public IAvatar Avatar; + } + + public delegate void OnNewUserDelegate(IWorld sender, NewUserEventArgs e); + + public class ChatEventArgs : EventArgs + { + public string Text; + public IEntity Sender; + } + + public delegate void OnChatDelegate(IWorld sender, ChatEventArgs e); + + public interface IWorld + { + IObjectAccessor Objects { get; } + IAvatar[] Avatars { get; } + IParcel[] Parcels { get; } + IHeightmap Terrain { get; } + + event OnChatDelegate OnChat; + event OnNewUserDelegate OnNewUser; + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs index 94de09e..57d84e1 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Text; +using System.Drawing; using OpenMetaverse; using OpenSim.Region.Framework.Scenes; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/DrunkenTextAppreciationModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/DrunkenTextAppreciationModule.cs index 7e8db9c..755831c 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/DrunkenTextAppreciationModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/DrunkenTextAppreciationModule.cs @@ -38,13 +38,21 @@ namespace OpenSim void World_OnChat(IWorld sender, ChatEventArgs e) { - if(!e.Text.Contains("hic!")) + if (e.Sender is IAvatar) { - e.Text = e.Text.Replace("s", "sh"); - e.Text = e.Text.Replace("S", "Sh"); - e.Text += " ...hic!"; + if (!e.Text.Contains("hic!")) + { + e.Text = e.Text.Replace("s", "sh"); + e.Text = e.Text.Replace("S", "Sh"); + e.Text += " ...hic!"; - Host.Object.Say(e.Text); + Host.Object.Say(e.Text); + } + } + + if(e.Sender is IObject) + { + // Ignore } } -- cgit v1.1 From fa29cf5c5010f7c3e83494786be1b0c11c663e6d Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 14 Apr 2009 10:00:13 +0000 Subject: Update svn properties. --- .../Scripting/Minimodule/Graphics.cs | 96 ++--- .../Scripting/Minimodule/Interfaces/IAvatar.cs | 78 ++-- .../Scripting/Minimodule/Interfaces/IEntity.cs | 28 +- .../Scripting/Minimodule/Interfaces/IGraphics.cs | 24 +- .../Scripting/Minimodule/Interfaces/IHeightmap.cs | 138 +++---- .../Scripting/Minimodule/Interfaces/IHost.cs | 82 ++-- .../Scripting/Minimodule/Interfaces/IObject.cs | 446 ++++++++++----------- .../Minimodule/Interfaces/IObjectAccessor.cs | 76 ++-- .../Scripting/Minimodule/Interfaces/IParcel.cs | 84 ++-- .../Minimodule/Interfaces/IPersistence.cs | 112 +++--- .../Scripting/Minimodule/Interfaces/IScheduler.cs | 86 ++-- .../Minimodule/Interfaces/ISocialEntity.cs | 80 ++-- .../Scripting/Minimodule/Interfaces/IWorld.cs | 114 +++--- .../Scripting/Minimodule/SOPObjectMaterial.cs | 176 ++++---- .../Test/DrunkenTextAppreciationModule.cs | 126 +++--- 15 files changed, 873 insertions(+), 873 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs index 44bae5c..bb4696b 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs @@ -1,48 +1,48 @@ -using System.Drawing; -using OpenMetaverse; -using OpenMetaverse.Imaging; -using OpenSim.Framework; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - class Graphics : IGraphics - { - private readonly Scene m_scene; - - public Graphics(Scene m_scene) - { - this.m_scene = m_scene; - } - - public UUID SaveBitmap(Bitmap data) - { - return SaveBitmap(data, false, true); - } - - public UUID SaveBitmap(Bitmap data, bool lossless, bool temporary) - { - AssetBase asset = new AssetBase(); - asset.FullID = UUID.Random(); - asset.Data = OpenJPEG.EncodeFromImage(data, lossless); - asset.Name = "MRMDynamicImage"; - asset.Type = 0; - asset.Description = "MRM Image"; - asset.Local = false; - asset.Temporary = temporary; - m_scene.CommsManager.AssetCache.AddAsset(asset); - - return asset.FullID; - } - - public Bitmap LoadBitmap(UUID assetID) - { - AssetBase bmp = m_scene.CommsManager.AssetCache.GetAsset(assetID, true); - ManagedImage outimg; - Image img; - OpenJPEG.DecodeToImage(bmp.Data, out outimg, out img); - - return new Bitmap(img); - } - } -} +using System.Drawing; +using OpenMetaverse; +using OpenMetaverse.Imaging; +using OpenSim.Framework; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + class Graphics : IGraphics + { + private readonly Scene m_scene; + + public Graphics(Scene m_scene) + { + this.m_scene = m_scene; + } + + public UUID SaveBitmap(Bitmap data) + { + return SaveBitmap(data, false, true); + } + + public UUID SaveBitmap(Bitmap data, bool lossless, bool temporary) + { + AssetBase asset = new AssetBase(); + asset.FullID = UUID.Random(); + asset.Data = OpenJPEG.EncodeFromImage(data, lossless); + asset.Name = "MRMDynamicImage"; + asset.Type = 0; + asset.Description = "MRM Image"; + asset.Local = false; + asset.Temporary = temporary; + m_scene.CommsManager.AssetCache.AddAsset(asset); + + return asset.FullID; + } + + public Bitmap LoadBitmap(UUID assetID) + { + AssetBase bmp = m_scene.CommsManager.AssetCache.GetAsset(assetID, true); + ManagedImage outimg; + Image img; + OpenJPEG.DecodeToImage(bmp.Data, out outimg, out img); + + return new Bitmap(img); + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs index 92ef490..fef85dd 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs @@ -1,39 +1,39 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Text; -using OpenMetaverse; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public interface IAvatar : IEntity - { - - } -} +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface IAvatar : IEntity + { + + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IEntity.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IEntity.cs index 94c53e3..0103a33 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IEntity.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IEntity.cs @@ -1,14 +1,14 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenMetaverse; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public interface IEntity - { - string Name { get; set; } - UUID GlobalID { get; } - Vector3 WorldPosition { get; set; } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface IEntity + { + string Name { get; set; } + UUID GlobalID { get; } + Vector3 WorldPosition { get; set; } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IGraphics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IGraphics.cs index f4bc12e..7e5b804 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IGraphics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IGraphics.cs @@ -1,12 +1,12 @@ -using System.Drawing; -using OpenMetaverse; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public interface IGraphics - { - UUID SaveBitmap(Bitmap data); - UUID SaveBitmap(Bitmap data, bool lossless, bool temporary); - Bitmap LoadBitmap(UUID assetID); - } -} +using System.Drawing; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface IGraphics + { + UUID SaveBitmap(Bitmap data); + UUID SaveBitmap(Bitmap data, bool lossless, bool temporary); + Bitmap LoadBitmap(UUID assetID); + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IHeightmap.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IHeightmap.cs index eea1baf..93cbc5b 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IHeightmap.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IHeightmap.cs @@ -1,69 +1,69 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public interface IHeightmap - { - /// - /// Returns [or sets] the heightmap value at specified coordinates. - /// - /// X Coordinate - /// Y Coordinate - /// A value in meters representing height. Can be negative. Value correlates with Z parameter in world coordinates - /// - /// double heightVal = World.Heightmap[128,128]; - /// World.Heightmap[128,128] *= 5.0; - /// World.Heightmap[128,128] = 25; - /// - double this[int x, int y] - { - get; - set; - } - - /// - /// The maximum length of the region (Y axis), exclusive. (eg Height = 256, max Y = 255). Minimum is always 0 inclusive. - /// - /// - /// Host.Console.Info("The terrain length of this region is " + World.Heightmap.Length); - /// - int Length { get; } - - /// - /// The maximum width of the region (X axis), exclusive. (eg Width = 256, max X = 255). Minimum is always 0 inclusive. - /// - /// - /// Host.Console.Info("The terrain width of this region is " + World.Heightmap.Width); - /// - int Width { get; } - } -} +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface IHeightmap + { + /// + /// Returns [or sets] the heightmap value at specified coordinates. + /// + /// X Coordinate + /// Y Coordinate + /// A value in meters representing height. Can be negative. Value correlates with Z parameter in world coordinates + /// + /// double heightVal = World.Heightmap[128,128]; + /// World.Heightmap[128,128] *= 5.0; + /// World.Heightmap[128,128] = 25; + /// + double this[int x, int y] + { + get; + set; + } + + /// + /// The maximum length of the region (Y axis), exclusive. (eg Height = 256, max Y = 255). Minimum is always 0 inclusive. + /// + /// + /// Host.Console.Info("The terrain length of this region is " + World.Heightmap.Length); + /// + int Length { get; } + + /// + /// The maximum width of the region (X axis), exclusive. (eg Width = 256, max X = 255). Minimum is always 0 inclusive. + /// + /// + /// Host.Console.Info("The terrain width of this region is " + World.Heightmap.Width); + /// + int Width { get; } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IHost.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IHost.cs index 8980b8f..6c76919 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IHost.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IHost.cs @@ -1,41 +1,41 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Text; -using log4net; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public interface IHost - { - IObject Object { get; } - ILog Console { get; } - IGraphics Graphics { get; } - } -} +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Text; +using log4net; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface IHost + { + IObject Object { get; } + ILog Console { get; } + IGraphics Graphics { get; } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs index e17b716..dc2e3fa 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs @@ -1,223 +1,223 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Drawing; -using OpenMetaverse; -using OpenSim.Region.OptionalModules.Scripting.Minimodule.Object; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public class TouchEventArgs : EventArgs - { - public IAvatar Avatar; - - public Vector3 TouchBiNormal; - public Vector3 TouchNormal; - public Vector3 TouchPosition; - - public Vector2 TouchUV; - public Vector2 TouchST; - - public int TouchMaterialIndex; - } - - public delegate void OnTouchDelegate(IObject sender, TouchEventArgs e); - - public interface IObject : IEntity - { - #region Events - - event OnTouchDelegate OnTouch; - - #endregion - - /// - /// Returns whether or not this object is still in the world. - /// Eg, if you store an IObject reference, however the object - /// is deleted before you use it, it will throw a NullReference - /// exception. 'Exists' allows you to check the object is still - /// in play before utilizing it. - /// - /// - /// IObject deleteMe = World.Objects[0]; - /// - /// if (deleteMe.Exists) { - /// deleteMe.Say("Hello, I still exist!"); - /// } - /// - /// World.Objects.Remove(deleteMe); - /// - /// if (!deleteMe.Exists) { - /// Host.Console.Info("I was deleted"); - /// } - /// - /// - /// Objects should be near-guarunteed to exist for any event which - /// passes them as an argument. Storing an object for a longer period - /// of time however will limit their reliability. - /// - /// It is a good practice to use Try/Catch blocks handling for - /// NullReferenceException, when accessing remote objects. - /// - bool Exists { get; } - - /// - /// The local region-unique ID for this object. - /// - uint LocalID { get; } - - /// - /// The description assigned to this object. - /// - String Description { get; set; } - - /// - /// Returns the root object of a linkset. If this object is the root, it will return itself. - /// - IObject Root { get; } - - /// - /// Returns a collection of objects which are linked to the current object. Does not include the root object. - /// - IObject[] Children { get; } - - /// - /// Returns a list of materials attached to this object. Each may contain unique texture - /// and other visual information. For primitive based objects, this correlates with - /// Object Faces. For mesh based objects, this correlates with Materials. - /// - IObjectMaterial[] Materials { get; } - - /// - /// The bounding box of the object. Primitive and Mesh objects alike are scaled to fit within these bounds. - /// - Vector3 Scale { get; set; } - - /// - /// The rotation of the object relative to the Scene - /// - Quaternion WorldRotation { get; set; } - - /// - /// The rotation of the object relative to a parent object - /// If root, works the same as WorldRotation - /// - Quaternion OffsetRotation { get; set; } - - /// - /// The position of the object relative to a parent object - /// If root, works the same as WorldPosition - /// - Vector3 OffsetPosition { get; set; } - - Vector3 SitTarget { get; set; } - String SitTargetText { get; set; } - - String TouchText { get; set; } - - /// - /// Text to be associated with this object, in the - /// Second Life(r) viewer, this is shown above the - /// object. - /// - String Text { get; set; } - - bool IsRotationLockedX { get; set; } // SetStatus(!ROTATE_X) - bool IsRotationLockedY { get; set; } // SetStatus(!ROTATE_Y) - bool IsRotationLockedZ { get; set; } // SetStatus(!ROTATE_Z) - bool IsSandboxed { get; set; } // SetStatus(SANDBOX) - bool IsImmotile { get; set; } // SetStatus(BLOCK_GRAB) - bool IsAlwaysReturned { get; set; } // SetStatus(!DIE_AT_EDGE) - bool IsTemporary { get; set; } // TEMP_ON_REZ - - bool IsFlexible { get; set; } - - PrimType PrimShape { get; set; } - // TODO: - // PrimHole - // Repeats, Offsets, Cut/Dimple/ProfileCut - // Hollow, Twist, HoleSize, - // Taper[A+B], Shear[A+B], Revolutions, - // RadiusOffset, Skew - - PhysicsMaterial PhysicsMaterial { get; set; } - - IObjectPhysics Physics { get; } - - - /// - /// Causes the object to speak to its surroundings, - /// equivilent to LSL/OSSL llSay - /// - /// The message to send to the user - void Say(string msg); - - } - - public enum PhysicsMaterial - { - Default, - Glass, - Metal, - Plastic, - Wood, - Rubber, - Stone, - Flesh - } - - public enum PrimType - { - NotPrimitive = 255, - Box = 0, - Cylinder = 1, - Prism = 2, - Sphere = 3, - Torus = 4, - Tube = 5, - Ring = 6, - Sculpt = 7 - } - - public enum TextureMapping - { - Default, - Planar - } - - public interface IObjectMaterial - { - Color Color { get; set; } - UUID Texture { get; set; } - TextureMapping Mapping { get; set; } // SetPrimParms(PRIM_TEXGEN) - bool Bright { get; set; } // SetPrimParms(FULLBRIGHT) - double Bloom { get; set; } // SetPrimParms(GLOW) - bool Shiny { get; set; } // SetPrimParms(SHINY) - bool BumpMap { get; set; } // SetPrimParms(BUMPMAP) [DEPRECIATE IN FAVOUR OF UUID?] - } -} +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Drawing; +using OpenMetaverse; +using OpenSim.Region.OptionalModules.Scripting.Minimodule.Object; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public class TouchEventArgs : EventArgs + { + public IAvatar Avatar; + + public Vector3 TouchBiNormal; + public Vector3 TouchNormal; + public Vector3 TouchPosition; + + public Vector2 TouchUV; + public Vector2 TouchST; + + public int TouchMaterialIndex; + } + + public delegate void OnTouchDelegate(IObject sender, TouchEventArgs e); + + public interface IObject : IEntity + { + #region Events + + event OnTouchDelegate OnTouch; + + #endregion + + /// + /// Returns whether or not this object is still in the world. + /// Eg, if you store an IObject reference, however the object + /// is deleted before you use it, it will throw a NullReference + /// exception. 'Exists' allows you to check the object is still + /// in play before utilizing it. + /// + /// + /// IObject deleteMe = World.Objects[0]; + /// + /// if (deleteMe.Exists) { + /// deleteMe.Say("Hello, I still exist!"); + /// } + /// + /// World.Objects.Remove(deleteMe); + /// + /// if (!deleteMe.Exists) { + /// Host.Console.Info("I was deleted"); + /// } + /// + /// + /// Objects should be near-guarunteed to exist for any event which + /// passes them as an argument. Storing an object for a longer period + /// of time however will limit their reliability. + /// + /// It is a good practice to use Try/Catch blocks handling for + /// NullReferenceException, when accessing remote objects. + /// + bool Exists { get; } + + /// + /// The local region-unique ID for this object. + /// + uint LocalID { get; } + + /// + /// The description assigned to this object. + /// + String Description { get; set; } + + /// + /// Returns the root object of a linkset. If this object is the root, it will return itself. + /// + IObject Root { get; } + + /// + /// Returns a collection of objects which are linked to the current object. Does not include the root object. + /// + IObject[] Children { get; } + + /// + /// Returns a list of materials attached to this object. Each may contain unique texture + /// and other visual information. For primitive based objects, this correlates with + /// Object Faces. For mesh based objects, this correlates with Materials. + /// + IObjectMaterial[] Materials { get; } + + /// + /// The bounding box of the object. Primitive and Mesh objects alike are scaled to fit within these bounds. + /// + Vector3 Scale { get; set; } + + /// + /// The rotation of the object relative to the Scene + /// + Quaternion WorldRotation { get; set; } + + /// + /// The rotation of the object relative to a parent object + /// If root, works the same as WorldRotation + /// + Quaternion OffsetRotation { get; set; } + + /// + /// The position of the object relative to a parent object + /// If root, works the same as WorldPosition + /// + Vector3 OffsetPosition { get; set; } + + Vector3 SitTarget { get; set; } + String SitTargetText { get; set; } + + String TouchText { get; set; } + + /// + /// Text to be associated with this object, in the + /// Second Life(r) viewer, this is shown above the + /// object. + /// + String Text { get; set; } + + bool IsRotationLockedX { get; set; } // SetStatus(!ROTATE_X) + bool IsRotationLockedY { get; set; } // SetStatus(!ROTATE_Y) + bool IsRotationLockedZ { get; set; } // SetStatus(!ROTATE_Z) + bool IsSandboxed { get; set; } // SetStatus(SANDBOX) + bool IsImmotile { get; set; } // SetStatus(BLOCK_GRAB) + bool IsAlwaysReturned { get; set; } // SetStatus(!DIE_AT_EDGE) + bool IsTemporary { get; set; } // TEMP_ON_REZ + + bool IsFlexible { get; set; } + + PrimType PrimShape { get; set; } + // TODO: + // PrimHole + // Repeats, Offsets, Cut/Dimple/ProfileCut + // Hollow, Twist, HoleSize, + // Taper[A+B], Shear[A+B], Revolutions, + // RadiusOffset, Skew + + PhysicsMaterial PhysicsMaterial { get; set; } + + IObjectPhysics Physics { get; } + + + /// + /// Causes the object to speak to its surroundings, + /// equivilent to LSL/OSSL llSay + /// + /// The message to send to the user + void Say(string msg); + + } + + public enum PhysicsMaterial + { + Default, + Glass, + Metal, + Plastic, + Wood, + Rubber, + Stone, + Flesh + } + + public enum PrimType + { + NotPrimitive = 255, + Box = 0, + Cylinder = 1, + Prism = 2, + Sphere = 3, + Torus = 4, + Tube = 5, + Ring = 6, + Sculpt = 7 + } + + public enum TextureMapping + { + Default, + Planar + } + + public interface IObjectMaterial + { + Color Color { get; set; } + UUID Texture { get; set; } + TextureMapping Mapping { get; set; } // SetPrimParms(PRIM_TEXGEN) + bool Bright { get; set; } // SetPrimParms(FULLBRIGHT) + double Bloom { get; set; } // SetPrimParms(GLOW) + bool Shiny { get; set; } // SetPrimParms(SHINY) + bool BumpMap { get; set; } // SetPrimParms(BUMPMAP) [DEPRECIATE IN FAVOUR OF UUID?] + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObjectAccessor.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObjectAccessor.cs index cd27a6a..7aed41b 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObjectAccessor.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObjectAccessor.cs @@ -1,39 +1,39 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -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; } - } +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +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/Interfaces/IParcel.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IParcel.cs index 3b229a7..759b26d 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IParcel.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IParcel.cs @@ -1,42 +1,42 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Text; -using OpenMetaverse; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public interface IParcel - { - string Name { get; set; } - string Description { get; set; } - ISocialEntity Owner { get; set; } - bool[,] Bitmap { get; } - } -} +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface IParcel + { + string Name { get; set; } + string Description { get; set; } + ISocialEntity Owner { get; set; } + bool[,] Bitmap { get; } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IPersistence.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IPersistence.cs index bde51fe..17bb6e7 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IPersistence.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IPersistence.cs @@ -1,56 +1,56 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - interface IPersistence - { - T Get(Guid storageID); - T Get(); - - /// - /// Stores 'data' into the persistence system - /// associated with this object, however saved - /// under the ID 'storageID'. This data may - /// be accessed by other scripts however. - /// - /// - /// - void Put(Guid storageID, T data); - - /// - /// Stores 'data' into the persistence system - /// using the default ID for this script. - /// - /// - void Put(T data); - } -} +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + interface IPersistence + { + T Get(Guid storageID); + T Get(); + + /// + /// Stores 'data' into the persistence system + /// associated with this object, however saved + /// under the ID 'storageID'. This data may + /// be accessed by other scripts however. + /// + /// + /// + void Put(Guid storageID, T data); + + /// + /// Stores 'data' into the persistence system + /// using the default ID for this script. + /// + /// + void Put(T data); + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IScheduler.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IScheduler.cs index cf45de7..0be8473 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IScheduler.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IScheduler.cs @@ -1,43 +1,43 @@ -using System; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - interface IScheduler - { - /// - /// Schedule an event callback to occur - /// when 'time' is elapsed. - /// - /// The period to wait before executing - void RunIn(TimeSpan time); - - /// - /// Schedule an event callback to fire - /// every "time". Equivilent to a repeating - /// timer. - /// - /// The period to wait between executions - void RunAndRepeat(TimeSpan time); - - /// - /// Fire this scheduler only when the region has - /// a user in it. - /// - bool WhenRegionOccupied { get; set; } - - /// - /// Fire this event only when the region is visible - /// to a child agent, or there is a full agent - /// in this region. - /// - bool WhenRegionVisible { get; set; } - - /// - /// Determines whether this runs in the master scheduler thread, or a new thread - /// is spawned to handle your request. Running in scheduler may mean that your - /// code does not execute perfectly on time, however will result in a lower - /// processor cost to running your code. - /// - bool Schedule { get; set; } - } -} +using System; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + interface IScheduler + { + /// + /// Schedule an event callback to occur + /// when 'time' is elapsed. + /// + /// The period to wait before executing + void RunIn(TimeSpan time); + + /// + /// Schedule an event callback to fire + /// every "time". Equivilent to a repeating + /// timer. + /// + /// The period to wait between executions + void RunAndRepeat(TimeSpan time); + + /// + /// Fire this scheduler only when the region has + /// a user in it. + /// + bool WhenRegionOccupied { get; set; } + + /// + /// Fire this event only when the region is visible + /// to a child agent, or there is a full agent + /// in this region. + /// + bool WhenRegionVisible { get; set; } + + /// + /// Determines whether this runs in the master scheduler thread, or a new thread + /// is spawned to handle your request. Running in scheduler may mean that your + /// code does not execute perfectly on time, however will result in a lower + /// processor cost to running your code. + /// + bool Schedule { get; set; } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/ISocialEntity.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/ISocialEntity.cs index cbac123..400367f 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/ISocialEntity.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/ISocialEntity.cs @@ -1,41 +1,41 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Text; -using OpenMetaverse; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public interface ISocialEntity - { - UUID GlobalID { get; } - string Name { get; } - bool IsUser { get; } - } +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface ISocialEntity + { + UUID GlobalID { get; } + string Name { get; } + bool IsUser { get; } + } } \ No newline at end of file diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IWorld.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IWorld.cs index 9196acd..acb569f 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IWorld.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IWorld.cs @@ -1,57 +1,57 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public class NewUserEventArgs : EventArgs - { - public IAvatar Avatar; - } - - public delegate void OnNewUserDelegate(IWorld sender, NewUserEventArgs e); - - public class ChatEventArgs : EventArgs - { - public string Text; - public IEntity Sender; - } - - public delegate void OnChatDelegate(IWorld sender, ChatEventArgs e); - - public interface IWorld - { - IObjectAccessor Objects { get; } - IAvatar[] Avatars { get; } - IParcel[] Parcels { get; } - IHeightmap Terrain { get; } - - event OnChatDelegate OnChat; - event OnNewUserDelegate OnNewUser; - } -} +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public class NewUserEventArgs : EventArgs + { + public IAvatar Avatar; + } + + public delegate void OnNewUserDelegate(IWorld sender, NewUserEventArgs e); + + public class ChatEventArgs : EventArgs + { + public string Text; + public IEntity Sender; + } + + public delegate void OnChatDelegate(IWorld sender, ChatEventArgs e); + + public interface IWorld + { + IObjectAccessor Objects { get; } + IAvatar[] Avatars { get; } + IParcel[] Parcels { get; } + IHeightmap Terrain { get; } + + event OnChatDelegate OnChat; + event OnNewUserDelegate OnNewUser; + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs index 57d84e1..63fd31e 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs @@ -1,88 +1,88 @@ -using System.Drawing; -using OpenMetaverse; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - class SOPObjectMaterial : IObjectMaterial - { - private readonly int m_face; - private readonly SceneObjectPart m_parent; - - public SOPObjectMaterial(int m_face, SceneObjectPart m_parent) - { - this.m_face = m_face; - this.m_parent = m_parent; - } - - public Color Color - { - get - { - Color4 res = GetTexface().RGBA; - return Color.FromArgb((int) (res.A*255), (int) (res.R*255), (int) (res.G*255), (int) (res.B*255)); - } - set - { - Primitive.TextureEntry tex = m_parent.Shape.Textures; - Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); - texface.RGBA = new Color4(value.R,value.G,value.B,value.A); - tex.FaceTextures[m_face] = texface; - m_parent.UpdateTexture(tex); - } - } - - public UUID Texture - { - get - { - Primitive.TextureEntryFace texface = GetTexface(); - return texface.TextureID; - } - set - { - Primitive.TextureEntry tex = m_parent.Shape.Textures; - Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); - texface.TextureID = value; - tex.FaceTextures[m_face] = texface; - m_parent.UpdateTexture(tex); - } - } - - private Primitive.TextureEntryFace GetTexface() - { - Primitive.TextureEntry tex = m_parent.Shape.Textures; - return tex.GetFace((uint)m_face); - } - - public TextureMapping Mapping - { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } - } - - public bool Bright - { - get { return GetTexface().Fullbright; } - set { throw new System.NotImplementedException(); } - } - - public double Bloom - { - get { return GetTexface().Glow; } - set { throw new System.NotImplementedException(); } - } - - public bool Shiny - { - get { return GetTexface().Shiny != Shininess.None; } - set { throw new System.NotImplementedException(); } - } - - public bool BumpMap - { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } - } - } -} +using System.Drawing; +using OpenMetaverse; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + class SOPObjectMaterial : IObjectMaterial + { + private readonly int m_face; + private readonly SceneObjectPart m_parent; + + public SOPObjectMaterial(int m_face, SceneObjectPart m_parent) + { + this.m_face = m_face; + this.m_parent = m_parent; + } + + public Color Color + { + get + { + Color4 res = GetTexface().RGBA; + return Color.FromArgb((int) (res.A*255), (int) (res.R*255), (int) (res.G*255), (int) (res.B*255)); + } + set + { + Primitive.TextureEntry tex = m_parent.Shape.Textures; + Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); + texface.RGBA = new Color4(value.R,value.G,value.B,value.A); + tex.FaceTextures[m_face] = texface; + m_parent.UpdateTexture(tex); + } + } + + public UUID Texture + { + get + { + Primitive.TextureEntryFace texface = GetTexface(); + return texface.TextureID; + } + set + { + Primitive.TextureEntry tex = m_parent.Shape.Textures; + Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); + texface.TextureID = value; + tex.FaceTextures[m_face] = texface; + m_parent.UpdateTexture(tex); + } + } + + private Primitive.TextureEntryFace GetTexface() + { + Primitive.TextureEntry tex = m_parent.Shape.Textures; + return tex.GetFace((uint)m_face); + } + + public TextureMapping Mapping + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public bool Bright + { + get { return GetTexface().Fullbright; } + set { throw new System.NotImplementedException(); } + } + + public double Bloom + { + get { return GetTexface().Glow; } + set { throw new System.NotImplementedException(); } + } + + public bool Shiny + { + get { return GetTexface().Shiny != Shininess.None; } + set { throw new System.NotImplementedException(); } + } + + public bool BumpMap + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/DrunkenTextAppreciationModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/DrunkenTextAppreciationModule.cs index 755831c..1fb7715 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/DrunkenTextAppreciationModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/DrunkenTextAppreciationModule.cs @@ -1,64 +1,64 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using OpenSim.Region.OptionalModules.Scripting.Minimodule; - -namespace OpenSim -{ - class DrunkenTextAppreciationModule : MRMBase - { - public override void Start() - { - World.OnChat += World_OnChat; - } - - void World_OnChat(IWorld sender, ChatEventArgs e) - { - if (e.Sender is IAvatar) - { - if (!e.Text.Contains("hic!")) - { - e.Text = e.Text.Replace("s", "sh"); - e.Text = e.Text.Replace("S", "Sh"); - e.Text += " ...hic!"; - - Host.Object.Say(e.Text); - } - } - - if(e.Sender is IObject) - { - // Ignore - } - } - - public override void Stop() - { - - } - } +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using OpenSim.Region.OptionalModules.Scripting.Minimodule; + +namespace OpenSim +{ + class DrunkenTextAppreciationModule : MRMBase + { + public override void Start() + { + World.OnChat += World_OnChat; + } + + void World_OnChat(IWorld sender, ChatEventArgs e) + { + if (e.Sender is IAvatar) + { + if (!e.Text.Contains("hic!")) + { + e.Text = e.Text.Replace("s", "sh"); + e.Text = e.Text.Replace("S", "Sh"); + e.Text += " ...hic!"; + + Host.Object.Say(e.Text); + } + } + + if(e.Sender is IObject) + { + // Ignore + } + } + + public override void Stop() + { + + } + } } \ No newline at end of file -- cgit v1.1 From 6e19fb8593885dd8cd8ed79223435054066803e0 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 14 Apr 2009 10:56:24 +0000 Subject: Add copyright headers. --- .../Scripting/Minimodule/Graphics.cs | 29 +++++++++++++++++++++- .../Scripting/Minimodule/Interfaces/IEntity.cs | 29 +++++++++++++++++++++- .../Scripting/Minimodule/Interfaces/IGraphics.cs | 29 +++++++++++++++++++++- .../Scripting/Minimodule/Interfaces/IScheduler.cs | 29 +++++++++++++++++++++- .../Scripting/Minimodule/SOPObjectMaterial.cs | 29 +++++++++++++++++++++- 5 files changed, 140 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs index bb4696b..50e6f6c 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs @@ -1,4 +1,31 @@ -using System.Drawing; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Drawing; using OpenMetaverse; using OpenMetaverse.Imaging; using OpenSim.Framework; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IEntity.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IEntity.cs index 0103a33..6ea23df 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IEntity.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IEntity.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; using System.Collections.Generic; using System.Text; using OpenMetaverse; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IGraphics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IGraphics.cs index 7e5b804..012cd37 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IGraphics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IGraphics.cs @@ -1,4 +1,31 @@ -using System.Drawing; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Drawing; using OpenMetaverse; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IScheduler.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IScheduler.cs index 0be8473..46b5041 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IScheduler.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IScheduler.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs index 63fd31e..e6b99be 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs @@ -1,4 +1,31 @@ -using System.Drawing; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System.Drawing; using OpenMetaverse; using OpenSim.Region.Framework.Scenes; -- cgit v1.1 From cad0aab7934bf0f81634c44fc03876f4b252eaa8 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 14 Apr 2009 11:38:33 +0000 Subject: Formatting cleanup. --- OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | 4 ++-- OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs | 2 +- .../Scripting/Minimodule/Test/DrunkenTextAppreciationModule.cs | 4 ++-- OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 5c249b9..0572fc7 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -75,7 +75,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { if (script.StartsWith("//MRM:C#")) { - if(m_scene.GetSceneObjectPart(localID).OwnerID != m_scene.RegionInfo.MasterAvatarAssignedUUID) + if (m_scene.GetSceneObjectPart(localID).OwnerID != m_scene.RegionInfo.MasterAvatarAssignedUUID) return; try @@ -221,7 +221,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule string[] lines = Script.Split(new string[] {"\n"}, StringSplitOptions.RemoveEmptyEntries); foreach (string s in lines) { - if(s.StartsWith("//@DEPENDS:")) + if (s.StartsWith("//@DEPENDS:")) { libraries.Add(s.Replace("//@DEPENDS:", "")); } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index d726de7..22a1126 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -65,7 +65,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { add { - if(!_OnTouchActive) + if (!_OnTouchActive) { GetSOP().Flags |= PrimFlags.Touch; _OnTouchActive = true; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/DrunkenTextAppreciationModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/DrunkenTextAppreciationModule.cs index 1fb7715..778bf7d 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/DrunkenTextAppreciationModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/DrunkenTextAppreciationModule.cs @@ -50,7 +50,7 @@ namespace OpenSim } } - if(e.Sender is IObject) + if (e.Sender is IObject) { // Ignore } @@ -61,4 +61,4 @@ namespace OpenSim } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index f2b3e81..cbbe86d 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs @@ -130,7 +130,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule private void HandleChatPacket(OSChatMessage chat) { - if(string.IsNullOrEmpty(chat.Message)) + if (string.IsNullOrEmpty(chat.Message)) return; // Object? -- cgit v1.1 From b2a7c1468e73294cd906574a29b8876bfd3e43e7 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 18 Apr 2009 05:43:40 +0000 Subject: * Adds IObject.Shape to MRM * Implements Sculpty modification support to MRM * Example: IObject.Shape.SculptMap = new UUID("0000-0000-0000...."); --- .../Scripting/Minimodule/Interfaces/IObject.cs | 16 +---- .../Scripting/Minimodule/Interfaces/IScheduler.cs | 46 ++++-------- .../Scripting/Minimodule/Object/IObjectShape.cs | 48 +++++++++++++ .../Scripting/Minimodule/SOPObject.cs | 83 ++++++++++++++++++++-- 4 files changed, 140 insertions(+), 53 deletions(-) create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectShape.cs (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs index dc2e3fa..ef1e896 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs @@ -157,7 +157,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule bool IsFlexible { get; set; } - PrimType PrimShape { get; set; } + IObjectShape Shape { get; } + // TODO: // PrimHole // Repeats, Offsets, Cut/Dimple/ProfileCut @@ -191,19 +192,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule Flesh } - public enum PrimType - { - NotPrimitive = 255, - Box = 0, - Cylinder = 1, - Prism = 2, - Sphere = 3, - Torus = 4, - Tube = 5, - Ring = 6, - Sculpt = 7 - } - public enum TextureMapping { Default, diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IScheduler.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IScheduler.cs index 46b5041..f850a94 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IScheduler.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IScheduler.cs @@ -1,31 +1,4 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; +using System; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { @@ -50,21 +23,30 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule /// Fire this scheduler only when the region has /// a user in it. /// - bool WhenRegionOccupied { get; set; } + bool IfOccupied { get; set; } + + /// + /// Fire this only when simulator performance + /// is reasonable. (eg sysload <= 1.0) + /// + bool IfHealthy { get; set; } /// /// Fire this event only when the region is visible /// to a child agent, or there is a full agent /// in this region. /// - bool WhenRegionVisible { get; set; } + bool IfVisible { get; set; } /// /// Determines whether this runs in the master scheduler thread, or a new thread /// is spawned to handle your request. Running in scheduler may mean that your - /// code does not execute perfectly on time, however will result in a lower - /// processor cost to running your code. + /// code does not execute perfectly on time, however will result in better + /// region performance. /// + /// + /// Default: true + /// bool Schedule { get; set; } } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectShape.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectShape.cs new file mode 100644 index 0000000..ed24680 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectShape.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object +{ + public enum SculptType + { + Default = 1, + Sphere = 1, + Torus = 2, + Plane = 3, + Cylinder = 4 + } + + public enum HoleShape + { + Default = 0x00, + Circle = 0x10, + Square = 0x20, + Triangle = 0x30 + } + + public enum PrimType + { + NotPrimitive = 255, + Box = 0, + Cylinder = 1, + Prism = 2, + Sphere = 3, + Torus = 4, + Tube = 5, + Ring = 6, + Sculpt = 7 + } + + public interface IObjectShape + { + UUID SculptMap { get; set; } + SculptType SculptType { get; set; } + + HoleShape HoleType { get; set; } + Double HoleSize { get; set; } + PrimType PrimType { get; set; } + + } +} \ No newline at end of file diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 22a1126..f29522f 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -28,14 +28,17 @@ using System; using System.Collections.Generic; using OpenMetaverse; +using OpenMetaverse.Packets; using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.OptionalModules.Scripting.Minimodule.Object; using OpenSim.Region.Physics.Manager; +using PrimType=OpenSim.Region.OptionalModules.Scripting.Minimodule.Object.PrimType; +using SculptType=OpenSim.Region.OptionalModules.Scripting.Minimodule.Object.SculptType; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - class SOPObject : MarshalByRefObject, IObject, IObjectPhysics + class SOPObject : MarshalByRefObject, IObject, IObjectPhysics, IObjectShape { private readonly Scene m_rootScene; private readonly uint m_localID; @@ -282,12 +285,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule set { throw new System.NotImplementedException(); } } - public PrimType PrimShape - { - get { return (PrimType) getScriptPrimType(GetSOP().Shape); } - set { throw new System.NotImplementedException(); } - } - public PhysicsMaterial PhysicsMaterial { get { throw new System.NotImplementedException(); } @@ -299,6 +296,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule get { return this; } } + public IObjectShape Shape + { + get { return this; } + } + #region Public Functions public void Say(string msg) @@ -569,5 +571,72 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule } #endregion + + #region Implementation of IObjectShape + + private UUID m_sculptMap = UUID.Zero; + + public UUID SculptMap + { + get { return m_sculptMap; } + set + { + m_sculptMap = value; + SetPrimitiveSculpted(SculptMap, (byte) SculptType); + } + } + + private SculptType m_sculptType = Object.SculptType.Default; + + public SculptType SculptType + { + get { return m_sculptType; } + set + { + m_sculptType = value; + SetPrimitiveSculpted(SculptMap, (byte) SculptType); + } + } + + public HoleShape HoleType + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public double HoleSize + { + get { throw new System.NotImplementedException(); } + set { throw new System.NotImplementedException(); } + } + + public PrimType PrimType + { + get { return (PrimType)getScriptPrimType(GetSOP().Shape); } + set { throw new System.NotImplementedException(); } + } + + private void SetPrimitiveSculpted(UUID map, byte type) + { + ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); + + SceneObjectPart part = GetSOP(); + + UUID sculptId = map; + + shapeBlock.ObjectLocalID = part.LocalId; + shapeBlock.PathScaleX = 100; + shapeBlock.PathScaleY = 150; + + // retain pathcurve + shapeBlock.PathCurve = part.Shape.PathCurve; + + part.Shape.SetSculptData((byte)type, sculptId); + part.Shape.SculptEntry = true; + part.UpdateShape(shapeBlock); + } + + + #endregion } } -- cgit v1.1 From 594c7c3eb13695304c755ec1bc65c5f239754222 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Tue, 21 Apr 2009 04:55:53 +0000 Subject: * Implements Extensions to MRM. This allows Region Modules to insert new classes into OpenSim MRM's. * Example in region module: Scene.GetModuleInterface.RegisterExtension(this); * In the MRM: //@DEPENDS:MyExtensionModule.dll ... Host.Extensions.DoStuff(); --- .../Scripting/Minimodule/ExtensionHandler.cs | 39 ++++++++++++++++++++++ .../OptionalModules/Scripting/Minimodule/Host.cs | 10 +++++- .../Scripting/Minimodule/IMRMModule.cs | 7 ++++ .../Scripting/Minimodule/Interfaces/IExtension.cs | 13 ++++++++ .../Scripting/Minimodule/Interfaces/IHost.cs | 2 ++ .../Scripting/Minimodule/MRMModule.cs | 13 ++++++-- 6 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/IMRMModule.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IExtension.cs (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs new file mode 100644 index 0000000..bc159eb --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + class ExtensionHandler : IExtension + { + private readonly Dictionary m_instances; + + public ExtensionHandler(Dictionary instances) + { + m_instances = instances; + } + + public T Get() + { + return (T) m_instances[typeof (T)]; + } + + public bool TryGet(out T extension) + { + if (!m_instances.ContainsKey(typeof(T))) + { + extension = default(T); + return false; + } + + extension = Get(); + return true; + } + + public bool Has() + { + return m_instances.ContainsKey(typeof (T)); + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs index b7f67dd..94796e4 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs @@ -28,6 +28,7 @@ using System.Reflection; using log4net; using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { @@ -36,11 +37,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule private readonly IObject m_obj; private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private readonly IGraphics m_graphics; + private readonly IExtension m_extend; //private Scene m_scene; - public Host(IObject m_obj, Scene m_scene) + public Host(IObject m_obj, Scene m_scene, IExtension m_extend) { this.m_obj = m_obj; + this.m_extend = m_extend; //this.m_scene = m_scene; m_graphics = new Graphics(m_scene); @@ -60,5 +63,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { get { return m_graphics; } } + + public IExtension Extensions + { + get { return m_extend; } + } } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IMRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IMRMModule.cs new file mode 100644 index 0000000..4c37a44 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IMRMModule.cs @@ -0,0 +1,7 @@ +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface IMRMModule + { + void RegisterExtension(T instance); + } +} \ No newline at end of file diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IExtension.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IExtension.cs new file mode 100644 index 0000000..b58e600 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IExtension.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces +{ + public interface IExtension + { + T Get(); + bool TryGet(out T extension); + bool Has(); + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IHost.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IHost.cs index 6c76919..fd73ffd 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IHost.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IHost.cs @@ -29,6 +29,7 @@ using System; using System.Collections.Generic; using System.Text; using log4net; +using OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { @@ -37,5 +38,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule IObject Object { get; } ILog Console { get; } IGraphics Graphics { get; } + IExtension Extensions { get; } } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 0572fc7..b0fe222 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -41,15 +41,22 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - public class MRMModule : IRegionModule + public class MRMModule : IRegionModule, IMRMModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_scene; private readonly Dictionary m_scripts = new Dictionary(); + private readonly Dictionary m_extensions = new Dictionary(); + private static readonly CSharpCodeProvider CScodeProvider = new CSharpCodeProvider(); + public void RegisterExtension(T instance) + { + m_extensions[typeof (T)] = instance; + } + public void Initialise(Scene scene, IConfigSource source) { if (source.Configs["MRM"] != null) @@ -59,6 +66,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule m_log.Info("[MRM] Enabling MRM Module"); m_scene = scene; scene.EventManager.OnRezScript += EventManager_OnRezScript; + + scene.RegisterModuleInterface(this); } else { @@ -82,7 +91,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { m_log.Info("[MRM] Found C# MRM"); IWorld m_world = new World(m_scene); - IHost m_host = new Host(new SOPObject(m_scene, localID), m_scene); + IHost m_host = new Host(new SOPObject(m_scene, localID), m_scene, new ExtensionHandler(m_extensions)); MRMBase mmb = (MRMBase)AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap( CompileFromDotNetText(script, itemID.ToString()), -- cgit v1.1 From 13f5dd5f353c5ea5e86944af3dbaa739c8be1a8a Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 21 Apr 2009 15:30:03 +0000 Subject: Update svn properties. --- .../Scripting/Minimodule/ExtensionHandler.cs | 78 +++++++++--------- .../Scripting/Minimodule/IMRMModule.cs | 12 +-- .../Scripting/Minimodule/Interfaces/IExtension.cs | 26 +++--- .../Scripting/Minimodule/Object/IObjectShape.cs | 94 +++++++++++----------- 4 files changed, 105 insertions(+), 105 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs index bc159eb..d3efe9c 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs @@ -1,39 +1,39 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - class ExtensionHandler : IExtension - { - private readonly Dictionary m_instances; - - public ExtensionHandler(Dictionary instances) - { - m_instances = instances; - } - - public T Get() - { - return (T) m_instances[typeof (T)]; - } - - public bool TryGet(out T extension) - { - if (!m_instances.ContainsKey(typeof(T))) - { - extension = default(T); - return false; - } - - extension = Get(); - return true; - } - - public bool Has() - { - return m_instances.ContainsKey(typeof (T)); - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + class ExtensionHandler : IExtension + { + private readonly Dictionary m_instances; + + public ExtensionHandler(Dictionary instances) + { + m_instances = instances; + } + + public T Get() + { + return (T) m_instances[typeof (T)]; + } + + public bool TryGet(out T extension) + { + if (!m_instances.ContainsKey(typeof(T))) + { + extension = default(T); + return false; + } + + extension = Get(); + return true; + } + + public bool Has() + { + return m_instances.ContainsKey(typeof (T)); + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IMRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IMRMModule.cs index 4c37a44..05b8bc9 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IMRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IMRMModule.cs @@ -1,7 +1,7 @@ -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public interface IMRMModule - { - void RegisterExtension(T instance); - } +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface IMRMModule + { + void RegisterExtension(T instance); + } } \ No newline at end of file diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IExtension.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IExtension.cs index b58e600..91c696f 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IExtension.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IExtension.cs @@ -1,13 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces -{ - public interface IExtension - { - T Get(); - bool TryGet(out T extension); - bool Has(); - } -} +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces +{ + public interface IExtension + { + T Get(); + bool TryGet(out T extension); + bool Has(); + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectShape.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectShape.cs index ed24680..0018b2a 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectShape.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectShape.cs @@ -1,48 +1,48 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenMetaverse; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object -{ - public enum SculptType - { - Default = 1, - Sphere = 1, - Torus = 2, - Plane = 3, - Cylinder = 4 - } - - public enum HoleShape - { - Default = 0x00, - Circle = 0x10, - Square = 0x20, - Triangle = 0x30 - } - - public enum PrimType - { - NotPrimitive = 255, - Box = 0, - Cylinder = 1, - Prism = 2, - Sphere = 3, - Torus = 4, - Tube = 5, - Ring = 6, - Sculpt = 7 - } - - public interface IObjectShape - { - UUID SculptMap { get; set; } - SculptType SculptType { get; set; } - - HoleShape HoleType { get; set; } - Double HoleSize { get; set; } - PrimType PrimType { get; set; } - - } +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object +{ + public enum SculptType + { + Default = 1, + Sphere = 1, + Torus = 2, + Plane = 3, + Cylinder = 4 + } + + public enum HoleShape + { + Default = 0x00, + Circle = 0x10, + Square = 0x20, + Triangle = 0x30 + } + + public enum PrimType + { + NotPrimitive = 255, + Box = 0, + Cylinder = 1, + Prism = 2, + Sphere = 3, + Torus = 4, + Tube = 5, + Ring = 6, + Sculpt = 7 + } + + public interface IObjectShape + { + UUID SculptMap { get; set; } + SculptType SculptType { get; set; } + + HoleShape HoleType { get; set; } + Double HoleSize { get; set; } + PrimType PrimType { get; set; } + + } } \ No newline at end of file -- cgit v1.1 From 6aa5d3904d71c4be21e5991d9ba82dff3c1cf51f Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Wed, 22 Apr 2009 00:48:56 +0000 Subject: Add copyright headers. Formatting cleanup. --- .../Scripting/Minimodule/ExtensionHandler.cs | 29 +++++++++++++++++++++- .../Scripting/Minimodule/IMRMModule.cs | 27 ++++++++++++++++++++ .../Scripting/Minimodule/Interfaces/IExtension.cs | 29 +++++++++++++++++++++- .../Scripting/Minimodule/Interfaces/IScheduler.cs | 29 +++++++++++++++++++++- .../Scripting/Minimodule/Object/IObjectShape.cs | 29 +++++++++++++++++++++- 5 files changed, 139 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs index d3efe9c..d8f7a84 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; using System.Collections.Generic; using System.Text; using OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IMRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IMRMModule.cs index 05b8bc9..486d0d9 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IMRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IMRMModule.cs @@ -1,3 +1,30 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { public interface IMRMModule diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IExtension.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IExtension.cs index 91c696f..f5beebd 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IExtension.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IExtension.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; using System.Collections.Generic; using System.Text; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IScheduler.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IScheduler.cs index f850a94..13e7934 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IScheduler.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IScheduler.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectShape.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectShape.cs index 0018b2a..27cf279 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectShape.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectShape.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; using System.Collections.Generic; using System.Text; using OpenMetaverse; -- cgit v1.1 From d6b62b677cafaa739daf7b00ff11f61a34e6f4ae Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 22 Apr 2009 10:11:12 +0000 Subject: * Committing stub VW-over-HTTP ClientStack. (2/2) * Minor MRM tweak. --- OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index b0fe222..a7b63b0 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -213,7 +213,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { m_log.Error("[Compiler]: Exception while " + "trying to write script source to file \"" + - srcFileName + "\": " + ex.ToString()); + srcFileName + "\": " + ex); } m_log.Info("MRM 4"); -- cgit v1.1 From 883f7dde3884bca10f324f6a31e0882cf23c04d8 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Fri, 24 Apr 2009 05:33:23 +0000 Subject: * Implements Microthreading for MRM scripting. * This is achieved through two new keywords "microthreaded" and "relax". example: public microthreaded void MyFunc(...) { ... relax; ... } --- .../OptionalModules/Scripting/Minimodule/Host.cs | 9 ++++- .../Scripting/Minimodule/Interfaces/IHost.cs | 1 + .../Minimodule/Interfaces/IMicrothreader.cs | 12 ++++++ .../Scripting/Minimodule/MRMModule.cs | 21 ++++++++++- .../Scripting/Minimodule/MicroScheduler.cs | 38 +++++++++++++++++++ .../Test/Microthreads/MicrothreadSample.txt | 40 ++++++++++++++++++++ .../Scripting/Minimodule/Test/TestModule.cs | 43 ++++++++++++++++++++++ 7 files changed, 162 insertions(+), 2 deletions(-) create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IMicrothreader.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/MicroScheduler.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/Microthreads/MicrothreadSample.txt (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs index 94796e4..193461d 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs @@ -38,11 +38,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private readonly IGraphics m_graphics; private readonly IExtension m_extend; + private readonly IMicrothreader m_threader; //private Scene m_scene; - public Host(IObject m_obj, Scene m_scene, IExtension m_extend) + public Host(IObject m_obj, Scene m_scene, IExtension m_extend, IMicrothreader m_threader) { this.m_obj = m_obj; + this.m_threader = m_threader; this.m_extend = m_extend; //this.m_scene = m_scene; @@ -68,5 +70,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { get { return m_extend; } } + + public IMicrothreader Microthreads + { + get { return m_threader; } + } } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IHost.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IHost.cs index fd73ffd..cf63fd6 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IHost.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IHost.cs @@ -39,5 +39,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule ILog Console { get; } IGraphics Graphics { get; } IExtension Extensions { get; } + IMicrothreader Microthreads { get; } } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IMicrothreader.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IMicrothreader.cs new file mode 100644 index 0000000..22d3a99 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IMicrothreader.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces +{ + public interface IMicrothreader + { + void Run(IEnumerable microthread); + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index a7b63b0..73eb98f 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -52,6 +52,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule private static readonly CSharpCodeProvider CScodeProvider = new CSharpCodeProvider(); + private readonly MicroScheduler m_microthreads = new MicroScheduler(); + public void RegisterExtension(T instance) { m_extensions[typeof (T)] = instance; @@ -66,6 +68,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule m_log.Info("[MRM] Enabling MRM Module"); m_scene = scene; scene.EventManager.OnRezScript += EventManager_OnRezScript; + scene.EventManager.OnFrame += EventManager_OnFrame; scene.RegisterModuleInterface(this); } @@ -80,6 +83,19 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule } } + void EventManager_OnFrame() + { + m_microthreads.Tick(1000); + } + + static string ConvertMRMKeywords(string script) + { + script = script.Replace("microthreaded void ", "IEnumerable"); + script = script.Replace("relax;", "yield return null;"); + + return script; + } + void EventManager_OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) { if (script.StartsWith("//MRM:C#")) @@ -87,11 +103,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule if (m_scene.GetSceneObjectPart(localID).OwnerID != m_scene.RegionInfo.MasterAvatarAssignedUUID) return; + script = ConvertMRMKeywords(script); + try { m_log.Info("[MRM] Found C# MRM"); IWorld m_world = new World(m_scene); - IHost m_host = new Host(new SOPObject(m_scene, localID), m_scene, new ExtensionHandler(m_extensions)); + IHost m_host = new Host(new SOPObject(m_scene, localID), m_scene, new ExtensionHandler(m_extensions), + m_microthreads); MRMBase mmb = (MRMBase)AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap( CompileFromDotNetText(script, itemID.ToString()), diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MicroScheduler.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MicroScheduler.cs new file mode 100644 index 0000000..a5da87b --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MicroScheduler.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public class MicroScheduler : IMicrothreader + { + private readonly List m_threads = new List(); + + public void Run(IEnumerable microthread) + { + lock (m_threads) + m_threads.Add(microthread.GetEnumerator()); + } + + public void Tick(int count) + { + lock (m_threads) + { + if(m_threads.Count == 0) + return; + + int i = 0; + while (m_threads.Count > 0 && i < count) + { + i++; + bool running = m_threads[i%m_threads.Count].MoveNext(); + + if (!running) + m_threads.Remove(m_threads[i%m_threads.Count]); + } + } + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/Microthreads/MicrothreadSample.txt b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/Microthreads/MicrothreadSample.txt new file mode 100644 index 0000000..dc15c47 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/Microthreads/MicrothreadSample.txt @@ -0,0 +1,40 @@ +//MRM:C# +using System.Collections; +using System.Collections.Generic; +using OpenSim.Region.OptionalModules.Scripting.Minimodule; + +namespace OpenSim +{ + class MiniModule : MRMBase + { + public microthreaded void MicroThreadFunction(string testparam) + { + Host.Object.Say("Hello " + testparam); + + relax; // the 'relax' keyword gives up processing time. + // and should be inserted before, after or in + // any computationally "heavy" zones. + + int c = 500; + while(c-- < 0) { + Host.Object.Say("C=" + c); + relax; // Putting 'relax' in microthreaded loops + // is an easy way to lower the CPU tax + // on your script. + } + + } + + public override void Start() + { + Host.Microthreads.Run( + MicroThreadFunction("World!") + ); + } + + public override void Stop() + { + + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs index 702ac74..73af7f0 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs @@ -25,12 +25,55 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System.Collections; +using System.Collections.Generic; using OpenSim.Region.OptionalModules.Scripting.Minimodule; namespace OpenSim { class MiniModule : MRMBase { + // private microthreaded Function(params...) + private IEnumerable TestMicrothread(string param) + { + Host.Console.Info("Microthreaded " + param); + // relax; + yield return null; + Host.Console.Info("Microthreaded 2" + param); + yield return null; + int c = 100; + while(c-- < 0) + { + Host.Console.Info("Microthreaded Looped " + c + " " + param); + yield return null; + } + } + + public void Microthread(IEnumerable thread) + { + + } + + public void RunMicrothread() + { + List threads = new List(); + threads.Add(TestMicrothread("A").GetEnumerator()); + threads.Add(TestMicrothread("B").GetEnumerator()); + threads.Add(TestMicrothread("C").GetEnumerator()); + + Microthread(TestMicrothread("Ohai")); + + int i = 0; + while(threads.Count > 0) + { + i++; + bool running = threads[i%threads.Count].MoveNext(); + + if (!running) + threads.Remove(threads[i%threads.Count]); + } + } + public override void Start() { // Say Hello -- cgit v1.1 From 6077bbda30bc9e5a16ec7b9c54fbdb5bbdccc11f Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 27 Apr 2009 03:22:31 +0000 Subject: Update svn properties. --- .../Minimodule/Interfaces/IMicrothreader.cs | 24 +++---- .../Scripting/Minimodule/MicroScheduler.cs | 76 ++++++++++---------- .../Test/Microthreads/MicrothreadSample.txt | 80 +++++++++++----------- 3 files changed, 90 insertions(+), 90 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IMicrothreader.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IMicrothreader.cs index 22d3a99..5e187a5 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IMicrothreader.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IMicrothreader.cs @@ -1,12 +1,12 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces -{ - public interface IMicrothreader - { - void Run(IEnumerable microthread); - } -} +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces +{ + public interface IMicrothreader + { + void Run(IEnumerable microthread); + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MicroScheduler.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MicroScheduler.cs index a5da87b..500c5bf 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MicroScheduler.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MicroScheduler.cs @@ -1,38 +1,38 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public class MicroScheduler : IMicrothreader - { - private readonly List m_threads = new List(); - - public void Run(IEnumerable microthread) - { - lock (m_threads) - m_threads.Add(microthread.GetEnumerator()); - } - - public void Tick(int count) - { - lock (m_threads) - { - if(m_threads.Count == 0) - return; - - int i = 0; - while (m_threads.Count > 0 && i < count) - { - i++; - bool running = m_threads[i%m_threads.Count].MoveNext(); - - if (!running) - m_threads.Remove(m_threads[i%m_threads.Count]); - } - } - } - } -} +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public class MicroScheduler : IMicrothreader + { + private readonly List m_threads = new List(); + + public void Run(IEnumerable microthread) + { + lock (m_threads) + m_threads.Add(microthread.GetEnumerator()); + } + + public void Tick(int count) + { + lock (m_threads) + { + if(m_threads.Count == 0) + return; + + int i = 0; + while (m_threads.Count > 0 && i < count) + { + i++; + bool running = m_threads[i%m_threads.Count].MoveNext(); + + if (!running) + m_threads.Remove(m_threads[i%m_threads.Count]); + } + } + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/Microthreads/MicrothreadSample.txt b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/Microthreads/MicrothreadSample.txt index dc15c47..d2c204a 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/Microthreads/MicrothreadSample.txt +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/Microthreads/MicrothreadSample.txt @@ -1,40 +1,40 @@ -//MRM:C# -using System.Collections; -using System.Collections.Generic; -using OpenSim.Region.OptionalModules.Scripting.Minimodule; - -namespace OpenSim -{ - class MiniModule : MRMBase - { - public microthreaded void MicroThreadFunction(string testparam) - { - Host.Object.Say("Hello " + testparam); - - relax; // the 'relax' keyword gives up processing time. - // and should be inserted before, after or in - // any computationally "heavy" zones. - - int c = 500; - while(c-- < 0) { - Host.Object.Say("C=" + c); - relax; // Putting 'relax' in microthreaded loops - // is an easy way to lower the CPU tax - // on your script. - } - - } - - public override void Start() - { - Host.Microthreads.Run( - MicroThreadFunction("World!") - ); - } - - public override void Stop() - { - - } - } -} +//MRM:C# +using System.Collections; +using System.Collections.Generic; +using OpenSim.Region.OptionalModules.Scripting.Minimodule; + +namespace OpenSim +{ + class MiniModule : MRMBase + { + public microthreaded void MicroThreadFunction(string testparam) + { + Host.Object.Say("Hello " + testparam); + + relax; // the 'relax' keyword gives up processing time. + // and should be inserted before, after or in + // any computationally "heavy" zones. + + int c = 500; + while(c-- < 0) { + Host.Object.Say("C=" + c); + relax; // Putting 'relax' in microthreaded loops + // is an easy way to lower the CPU tax + // on your script. + } + + } + + public override void Start() + { + Host.Microthreads.Run( + MicroThreadFunction("World!") + ); + } + + public override void Stop() + { + + } + } +} -- cgit v1.1 From 8dbcfc70bf87d503edd4239bd974339a130de153 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 27 Apr 2009 05:22:44 +0000 Subject: Add copyright headers. Formatting cleanup. --- .../Minimodule/Interfaces/IMicrothreader.cs | 29 +++++++++++++++++++- .../Scripting/Minimodule/MicroScheduler.cs | 31 ++++++++++++++++++++-- .../Scripting/Minimodule/Test/TestModule.cs | 4 +-- 3 files changed, 59 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IMicrothreader.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IMicrothreader.cs index 5e187a5..2723476 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IMicrothreader.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IMicrothreader.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; using System.Collections; using System.Collections.Generic; using System.Text; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MicroScheduler.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MicroScheduler.cs index 500c5bf..8fd77ee 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MicroScheduler.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MicroScheduler.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; using System.Collections; using System.Collections.Generic; using System.Text; @@ -20,7 +47,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { lock (m_threads) { - if(m_threads.Count == 0) + if (m_threads.Count == 0) return; int i = 0; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs index 73af7f0..13d0140 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs @@ -42,7 +42,7 @@ namespace OpenSim Host.Console.Info("Microthreaded 2" + param); yield return null; int c = 100; - while(c-- < 0) + while (c-- < 0) { Host.Console.Info("Microthreaded Looped " + c + " " + param); yield return null; @@ -64,7 +64,7 @@ namespace OpenSim Microthread(TestMicrothread("Ohai")); int i = 0; - while(threads.Count > 0) + while (threads.Count > 0) { i++; bool running = threads[i%threads.Count].MoveNext(); -- cgit v1.1 From c534d7f614ae5ba15dee80ccefcf8e4741f5297b Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 9 May 2009 17:44:12 +0000 Subject: * Code to make MRM debugging easier. --- OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | 3 ++- OpenSim/Region/OptionalModules/Scripting/Minimodule/MicroScheduler.cs | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 73eb98f..3a6b1b1 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -142,7 +142,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule m_scene.Broadcast(delegate(IClientAPI user) { user.SendAlertMessage( - "MiniRegionModule Compilation and Initialisation failed: " + e); + "Compile error while building MRM script, check OpenSim console for more information."); }); } } @@ -256,6 +256,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule } libraries.Add("OpenSim.Region.OptionalModules.dll"); + libraries.Add("OpenMetaverseTypes.dll"); libraries.Add("log4net.dll"); foreach (string library in libraries) diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MicroScheduler.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MicroScheduler.cs index 8fd77ee..aaa2848 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MicroScheduler.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MicroScheduler.cs @@ -28,7 +28,9 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Reflection; using System.Text; +using log4net; using OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule @@ -54,8 +56,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule while (m_threads.Count > 0 && i < count) { i++; + bool running = m_threads[i%m_threads.Count].MoveNext(); + if (!running) m_threads.Remove(m_threads[i%m_threads.Count]); } -- cgit v1.1 From 559355189af9432b01eef00c76071dee684a6cc0 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Tue, 12 May 2009 13:10:04 +0000 Subject: * Applies Mantis #3630 - Adds support for outside MRM initialisation, makes MRMModule compatible with the Visual Studio MRMLoader ( http://forge.opensimulator.org/gf/project/mrmloader/ ) --- .../Scripting/Minimodule/Graphics.cs | 2 +- .../Scripting/Minimodule/Heightmap.cs | 2 +- .../OptionalModules/Scripting/Minimodule/Host.cs | 2 +- .../Scripting/Minimodule/IMRMModule.cs | 5 ++++- .../Scripting/Minimodule/LOParcel.cs | 2 +- .../OptionalModules/Scripting/Minimodule/MRMBase.cs | 2 +- .../Scripting/Minimodule/MRMModule.cs | 21 ++++++++++++++++----- .../Scripting/Minimodule/MicroScheduler.cs | 2 +- .../Scripting/Minimodule/ObjectAccessor.cs | 4 ++-- .../OptionalModules/Scripting/Minimodule/SEUser.cs | 2 +- .../Scripting/Minimodule/SOPObjectMaterial.cs | 2 +- .../Scripting/Minimodule/SPAvatar.cs | 2 +- .../OptionalModules/Scripting/Minimodule/World.cs | 2 +- 13 files changed, 32 insertions(+), 18 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs index 50e6f6c..0b937c1 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs @@ -33,7 +33,7 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - class Graphics : IGraphics + class Graphics : System.MarshalByRefObject, IGraphics { private readonly Scene m_scene; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Heightmap.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Heightmap.cs index 9b9d686..47c3085 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Heightmap.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Heightmap.cs @@ -29,7 +29,7 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - public class Heightmap : IHeightmap + public class Heightmap : System.MarshalByRefObject, IHeightmap { private readonly Scene m_scene; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs index 193461d..cbde283 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs @@ -32,7 +32,7 @@ using OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - class Host : IHost + class Host : System.MarshalByRefObject, IHost { private readonly IObject m_obj; private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IMRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IMRMModule.cs index 486d0d9..9f48081 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IMRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IMRMModule.cs @@ -25,10 +25,13 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using OpenMetaverse; + namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { public interface IMRMModule { void RegisterExtension(T instance); + void InitializeMRM(MRMBase mmb, uint localID, UUID itemID); } -} \ No newline at end of file +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs index d2f3121..37c7434 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs @@ -30,7 +30,7 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - class LOParcel : IParcel + class LOParcel : System.MarshalByRefObject, IParcel { private readonly Scene m_scene; private readonly int m_parcelID; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMBase.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMBase.cs index c47e592..6a23f5d 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMBase.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMBase.cs @@ -29,7 +29,7 @@ using OpenMetaverse; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - public abstract class MRMBase + public abstract class MRMBase : System.MarshalByRefObject { private IWorld m_world; private IHost m_host; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 3a6b1b1..e0b6150 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -108,15 +108,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule try { m_log.Info("[MRM] Found C# MRM"); - IWorld m_world = new World(m_scene); - IHost m_host = new Host(new SOPObject(m_scene, localID), m_scene, new ExtensionHandler(m_extensions), - m_microthreads); MRMBase mmb = (MRMBase)AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap( CompileFromDotNetText(script, itemID.ToString()), "OpenSim.MiniModule"); - m_log.Info("[MRM] Created MRM Instance"); - mmb.InitMiniModule(m_world, m_host, itemID); + + InitializeMRM(mmb, localID, itemID); + m_scripts[itemID] = mmb; m_log.Info("[MRM] Starting MRM"); @@ -148,6 +146,19 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule } } + public void InitializeMRM(MRMBase mmb, uint localID, UUID itemID) + { + + m_log.Info("[MRM] Created MRM Instance"); + + IWorld m_world = new World(m_scene); + IHost m_host = new Host(new SOPObject(m_scene, localID), m_scene, new ExtensionHandler(m_extensions), + m_microthreads); + + mmb.InitMiniModule(m_world, m_host, itemID); + + } + public void PostInitialise() { diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MicroScheduler.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MicroScheduler.cs index aaa2848..73fe8b8 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MicroScheduler.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MicroScheduler.cs @@ -35,7 +35,7 @@ using OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - public class MicroScheduler : IMicrothreader + public class MicroScheduler : System.MarshalByRefObject, IMicrothreader { private readonly List m_threads = new List(); diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs index 2bd2e29..a64a1c2 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs @@ -35,7 +35,7 @@ using IEnumerable=System.Collections.IEnumerable; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - internal class IObjEnum : IEnumerator + internal class IObjEnum : System.MarshalByRefObject, IEnumerator { private readonly Scene m_scene; private readonly IEnumerator m_sogEnum; @@ -75,7 +75,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule } } - public class ObjectAccessor : IObjectAccessor + public class ObjectAccessor : System.MarshalByRefObject, IObjectAccessor { private readonly Scene m_scene; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SEUser.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SEUser.cs index ebf68b1..e2bdf5e 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SEUser.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SEUser.cs @@ -32,7 +32,7 @@ using OpenMetaverse; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - class SEUser : ISocialEntity + class SEUser : System.MarshalByRefObject, ISocialEntity { private readonly UUID m_uuid; private readonly string m_name; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs index e6b99be..68f2f52 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs @@ -31,7 +31,7 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - class SOPObjectMaterial : IObjectMaterial + class SOPObjectMaterial : System.MarshalByRefObject, IObjectMaterial { private readonly int m_face; private readonly SceneObjectPart m_parent; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs index 41074c3..0f2076e 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs @@ -31,7 +31,7 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - class SPAvatar : IAvatar + class SPAvatar : System.MarshalByRefObject, IAvatar { private readonly Scene m_rootScene; private readonly UUID m_ID; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index cbbe86d..dc80dcc 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs @@ -32,7 +32,7 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - public class World : IWorld + public class World : System.MarshalByRefObject, IWorld { private readonly Scene m_internalScene; private readonly Heightmap m_heights; -- cgit v1.1 From 3a28f748d5cb586a5401b9b4d1f2f108af79ace1 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Tue, 12 May 2009 21:21:33 +0000 Subject: * Adds ScenePresence.TeleportWithMomentum - same as .Teleport, but preserves velocity. --- OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs index 0f2076e..8fed89c 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs @@ -61,7 +61,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public Vector3 WorldPosition { get { return GetSP().AbsolutePosition; } - set { GetSP().AbsolutePosition = value; } + set { GetSP().TeleportWithMomentum(value); } } } } -- cgit v1.1 From 12d7063b0b00e152dac8befacd7d874913db8da0 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Tue, 12 May 2009 21:42:20 +0000 Subject: * Adds additional check to MRM rezzing - the host object must be created by the sim owner, not just owned by it. --- OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index e0b6150..c4648d2 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -100,7 +100,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { if (script.StartsWith("//MRM:C#")) { - if (m_scene.GetSceneObjectPart(localID).OwnerID != m_scene.RegionInfo.MasterAvatarAssignedUUID) + if (m_scene.GetSceneObjectPart(localID).OwnerID != m_scene.RegionInfo.MasterAvatarAssignedUUID + || + m_scene.GetSceneObjectPart(localID).CreatorID != m_scene.RegionInfo.MasterAvatarAssignedUUID) return; script = ConvertMRMKeywords(script); -- cgit v1.1 From 5e4fc6e91e5edffd1dc23af4f583d6294f394a3d Mon Sep 17 00:00:00 2001 From: diva Date: Fri, 15 May 2009 05:00:25 +0000 Subject: Heart surgery on asset service code bits. Affects OpenSim.ini configuration -- please see the example. Affects region servers only. This may break a lot of things, but it needs to go in. It was tested in standalone and the UCI grid, but it needs a lot more testing. Known problems: * HG asset transfers are borked for now * missing texture is missing * 3 unit tests commented out for now --- OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs index 0b937c1..963cab5 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs @@ -57,14 +57,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule asset.Description = "MRM Image"; asset.Local = false; asset.Temporary = temporary; - m_scene.CommsManager.AssetCache.AddAsset(asset); + m_scene.AssetService.Store(asset); return asset.FullID; } public Bitmap LoadBitmap(UUID assetID) { - AssetBase bmp = m_scene.CommsManager.AssetCache.GetAsset(assetID, true); + AssetBase bmp = m_scene.AssetService.Get(assetID.ToString()); ManagedImage outimg; Image img; OpenJPEG.DecodeToImage(bmp.Data, out outimg, out img); -- cgit v1.1 From 78bec422259671ad72ad46ca98ab8029b78aefe5 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Fri, 29 May 2009 22:44:49 +0000 Subject: * Implements Sound on Objects for IObject in MRM * Method: IObject.Sound.Play(UUID sound, double volume) * More feature-packed API to come soon. (I want a World.Sound with arbitrary positioning) --- .../Scripting/Minimodule/Interfaces/IObject.cs | 1 + .../Scripting/Minimodule/Object/IObjectSound.cs | 12 ++++++++++++ .../OptionalModules/Scripting/Minimodule/SOPObject.cs | 17 ++++++++++++++++- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectSound.cs (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs index ef1e896..dd9cc29 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs @@ -170,6 +170,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule IObjectPhysics Physics { get; } + IObjectSound Sound { get; } /// /// Causes the object to speak to its surroundings, diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectSound.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectSound.cs new file mode 100644 index 0000000..7204f02 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectSound.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object +{ + interface IObjectSound + { + void Play(UUID soundAsset, double volume); + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index f29522f..c1c255b 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -38,7 +38,7 @@ using SculptType=OpenSim.Region.OptionalModules.Scripting.Minimodule.Object.Scul namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - class SOPObject : MarshalByRefObject, IObject, IObjectPhysics, IObjectShape + class SOPObject : MarshalByRefObject, IObject, IObjectPhysics, IObjectShape, IObjectSound { private readonly Scene m_rootScene; private readonly uint m_localID; @@ -638,5 +638,20 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule #endregion + + + #region Implementation of IObjectSound + + public IObjectSound Sound + { + get { return this; } + } + + public void Play(UUID asset, double volume) + { + GetSOP().SendSound(asset.ToString(), volume, true, 0); + } + + #endregion } } -- cgit v1.1 From 433ee757753f0a95b83ab20ed9da9943950f723e Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Fri, 29 May 2009 22:48:34 +0000 Subject: * Protip: When you click 'make public' in resharper, note to save before committing. --- .../Region/OptionalModules/Scripting/Minimodule/Object/IObjectSound.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectSound.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectSound.cs index 7204f02..f8dde56 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectSound.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectSound.cs @@ -5,7 +5,7 @@ using OpenMetaverse; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object { - interface IObjectSound + public interface IObjectSound { void Play(UUID soundAsset, double volume); } -- cgit v1.1 From c30b5ee0144faf60bcdaf6f79c91e3eeb316f104 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Fri, 29 May 2009 23:49:48 +0000 Subject: * Adds World.Audio.* to MRM * This includes methods such as PlaySound which take a Position as an argument, allowing you to trigger sounds arbitrarily across the scene without needing a parent object in the position. --- .../Scripting/Minimodule/Interfaces/IWorld.cs | 3 ++ .../OptionalModules/Scripting/Minimodule/World.cs | 33 +++++++++++++++++++++- .../Scripting/Minimodule/WorldX/IWorldAudio.cs | 13 +++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/WorldX/IWorldAudio.cs (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IWorld.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IWorld.cs index acb569f..3c14ed5 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IWorld.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IWorld.cs @@ -26,6 +26,7 @@ */ using System; +using OpenSim.Region.OptionalModules.Scripting.Minimodule.WorldX; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { @@ -50,6 +51,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule IAvatar[] Avatars { get; } IParcel[] Parcels { get; } IHeightmap Terrain { get; } + IWorldAudio Audio { get; } + event OnChatDelegate OnChat; event OnNewUserDelegate OnNewUser; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index dc80dcc..1ec4a33 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs @@ -26,13 +26,15 @@ */ using System.Collections.Generic; +using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.OptionalModules.Scripting.Minimodule.WorldX; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - public class World : System.MarshalByRefObject, IWorld + public class World : System.MarshalByRefObject, IWorld, IWorldAudio { private readonly Scene m_internalScene; private readonly Heightmap m_heights; @@ -93,6 +95,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule private event OnChatDelegate _OnChat; private bool _OnChatActive; + public IWorldAudio Audio + { + get { return this; } + } + public event OnChatDelegate OnChat { add @@ -211,5 +218,29 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { get { return m_heights; } } + + #region Implementation of IWorldAudio + + public void PlaySound(UUID audio, Vector3 position, double volume) + { + ISoundModule soundModule = m_internalScene.RequestModuleInterface(); + if (soundModule != null) + { + soundModule.TriggerSound(audio, UUID.Zero, UUID.Zero, UUID.Zero, volume, position, + m_internalScene.RegionInfo.RegionHandle); + } + } + + public void PlaySound(UUID audio, Vector3 position) + { + ISoundModule soundModule = m_internalScene.RequestModuleInterface(); + if (soundModule != null) + { + soundModule.TriggerSound(audio, UUID.Zero, UUID.Zero, UUID.Zero, 1.0, position, + m_internalScene.RegionInfo.RegionHandle); + } + } + + #endregion } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/WorldX/IWorldAudio.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/WorldX/IWorldAudio.cs new file mode 100644 index 0000000..a131567 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/WorldX/IWorldAudio.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.WorldX +{ + public interface IWorldAudio + { + void PlaySound(UUID audio, Vector3 position, double volume); + void PlaySound(UUID audio, Vector3 position); + } +} -- cgit v1.1 From dc151903650525c20fe26b2b17924a990e2d1a0a Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 31 May 2009 12:53:05 +0000 Subject: * Adds MRM scripting commands, World.Objects.Create(Vector3 position) and World.Objects.Create(Vector3 position, Quaternion rotation). These rez a 'default box' object at the specified coordinates, and return the associated IObject. --- .../Minimodule/Interfaces/IObjectAccessor.cs | 2 ++ .../Scripting/Minimodule/ObjectAccessor.cs | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObjectAccessor.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObjectAccessor.cs index 7aed41b..a6c8c36 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObjectAccessor.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObjectAccessor.cs @@ -35,5 +35,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule IObject this[int index] { get; } IObject this[uint index] { get; } IObject this[UUID index] { get; } + IObject Create(Vector3 position); + IObject Create(Vector3 position, Quaternion rotation); } } \ 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 a64a1c2..4638ad0 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs @@ -29,6 +29,7 @@ using System; using System.Collections; using System.Collections.Generic; using OpenMetaverse; +using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; using IEnumerable=System.Collections.IEnumerable; @@ -108,6 +109,25 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule } } + public IObject Create(Vector3 position) + { + return Create(position, Quaternion.Identity); + } + + public IObject Create(Vector3 position, Quaternion rotation) + { + + SceneObjectGroup sog = m_scene.AddNewPrim(m_scene.RegionInfo.MasterAvatarAssignedUUID, + UUID.Zero, + position, + rotation, + PrimitiveBaseShape.CreateBox()); + + IObject ret = new SOPObject(m_scene, sog.LocalId); + + return ret; + } + public IEnumerator GetEnumerator() { return new IObjEnum(m_scene); -- cgit v1.1 From db2c4ab94cc40bf16910806fd4fe0d9a2b7cbd8f Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sun, 31 May 2009 16:26:18 +0000 Subject: Update svn properties. --- .../Scripting/Minimodule/Object/IObjectSound.cs | 24 ++++++++++---------- .../Scripting/Minimodule/WorldX/IWorldAudio.cs | 26 +++++++++++----------- 2 files changed, 25 insertions(+), 25 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectSound.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectSound.cs index f8dde56..962fb2f 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectSound.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectSound.cs @@ -1,12 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenMetaverse; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object -{ - public interface IObjectSound - { - void Play(UUID soundAsset, double volume); - } -} +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object +{ + public interface IObjectSound + { + void Play(UUID soundAsset, double volume); + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/WorldX/IWorldAudio.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/WorldX/IWorldAudio.cs index a131567..0398e30 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/WorldX/IWorldAudio.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/WorldX/IWorldAudio.cs @@ -1,13 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenMetaverse; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.WorldX -{ - public interface IWorldAudio - { - void PlaySound(UUID audio, Vector3 position, double volume); - void PlaySound(UUID audio, Vector3 position); - } -} +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.WorldX +{ + public interface IWorldAudio + { + void PlaySound(UUID audio, Vector3 position, double volume); + void PlaySound(UUID audio, Vector3 position); + } +} -- cgit v1.1 From 35b450d41d2695aa6a82a6d8e6bda5e327f431e1 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sun, 31 May 2009 18:35:00 +0000 Subject: Add copyright headers, formatting cleanup, ignore some generated files. --- .../Scripting/Minimodule/Object/IObjectSound.cs | 29 +++++++++++++++++++++- .../Scripting/Minimodule/WorldX/IWorldAudio.cs | 29 +++++++++++++++++++++- 2 files changed, 56 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectSound.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectSound.cs index 962fb2f..d623c51 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectSound.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectSound.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; using System.Collections.Generic; using System.Text; using OpenMetaverse; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/WorldX/IWorldAudio.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/WorldX/IWorldAudio.cs index 0398e30..712a676 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/WorldX/IWorldAudio.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/WorldX/IWorldAudio.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; using System.Collections.Generic; using System.Text; using OpenMetaverse; -- cgit v1.1 From a23d64dec1cbf88abc3c7e84664a683dee534e4a Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Wed, 10 Jun 2009 04:28:56 +0000 Subject: Formatting cleanup. --- OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index c1c255b..a40a0d9 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -170,7 +170,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule SceneObjectPart sop = GetSOP(); IObjectMaterial[] rets = new IObjectMaterial[getNumberOfSides(sop)]; - for (int i = 0; i < rets.Length;i++ ) + for (int i = 0; i < rets.Length; i++) { rets[i] = new SOPObjectMaterial(i, sop); } -- cgit v1.1 From 7bb070be55d0efe3a272f170055bdf02ee41aa65 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Mon, 29 Jun 2009 18:07:30 +0000 Subject: Thank you kindly, Snowdrop/Snowcrash for a patch that: This patch makes the worn attachments accessible to MRM scripting --- .../Scripting/Minimodule/Interfaces/IAvatar.cs | 20 +++++++++++-- .../Scripting/Minimodule/SPAvatar.cs | 28 +++++++++++++++++ .../Scripting/Minimodule/SPAvatarAttachment.cs | 35 ++++++++++++++++++++++ 3 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs index fef85dd..51ba36c 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs @@ -32,8 +32,24 @@ using OpenMetaverse; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - public interface IAvatar : IEntity + public interface IAvatarAttachment { - + //// + /// Describes where on the avatar the attachment is located + /// + int Location { get ; } + + //// + /// Accessor to the rez'ed asset, representing the attachment + /// + IObject Asset { get; } + } + + public interface IAvatar : IEntity + { + //// + /// Array of worn attachments, empty but not null, if no attachments are worn + /// + IAvatarAttachment[] Attachments { get; } } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs index 8fed89c..6fd36bf 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs @@ -26,15 +26,22 @@ */ using System; +using System.Reflection; +using System.Collections; +using System.Collections.Generic; + using OpenMetaverse; using OpenSim.Region.Framework.Scenes; +using log4net; + namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { class SPAvatar : System.MarshalByRefObject, IAvatar { private readonly Scene m_rootScene; private readonly UUID m_ID; + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public SPAvatar(Scene scene, UUID ID) { @@ -63,5 +70,26 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule get { return GetSP().AbsolutePosition; } set { GetSP().TeleportWithMomentum(value); } } + + #region IAvatar implementation + public IAvatarAttachment[] Attachments + { + get { + List attachments = new List(); + + Hashtable internalAttachments = GetSP().Appearance.GetAttachments(); + if(internalAttachments != null) + { + foreach(DictionaryEntry element in internalAttachments) + { + Hashtable attachInfo = (Hashtable)element.Value; + attachments.Add(new SPAvatarAttachment(m_rootScene, this, (int)element.Key, new UUID((string)attachInfo["item"]), new UUID((string)attachInfo["asset"]))); + } + } + + return attachments.ToArray(); + } + } + #endregion } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs new file mode 100644 index 0000000..5581fc3 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs @@ -0,0 +1,35 @@ +using System; + +using OpenMetaverse; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public class SPAvatarAttachment : IAvatarAttachment + { + private readonly Scene m_rootScene; + private readonly IAvatar m_parent; + private readonly int m_location; + private readonly UUID m_itemId; + private readonly UUID m_assetId; + + public SPAvatarAttachment(Scene rootScene, IAvatar self, int location, UUID itemId, UUID assetId) + { + m_rootScene = rootScene; + m_parent = self; + m_location = location; + m_itemId = itemId; + m_assetId = assetId; + } + + public int Location { get { return m_location; } } + + public IObject Asset + { + get + { + return new SOPObject(m_rootScene, m_rootScene.GetSceneObjectPart(m_assetId).LocalId); + } + } + } +} -- cgit v1.1 From 6942eaed5b3d8065ebf01dc465e905ca456c0fa4 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Mon, 29 Jun 2009 21:47:47 +0000 Subject: Thank you kindly, Snowdrop, for a patch that solves: The current API for MRM is quite sparse, this patch supplies basic support for accessing the task inventory of object. --- .../Scripting/Minimodule/Interfaces/IAvatar.cs | 8 +- .../Minimodule/Interfaces/IInventoryItem.cs | 16 ++ .../Scripting/Minimodule/Interfaces/IObject.cs | 4 + .../Scripting/Minimodule/InventoryItem.cs | 72 ++++++++ .../Minimodule/Object/IObjectInventory.cs | 17 ++ .../Scripting/Minimodule/SOPObject.cs | 7 +- .../Scripting/Minimodule/SOPObjectInventory.cs | 190 +++++++++++++++++++++ .../Scripting/Minimodule/SPAvatar.cs | 8 + 8 files changed, 320 insertions(+), 2 deletions(-) create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectInventory.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs index 51ba36c..3345988 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs @@ -50,6 +50,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule //// /// Array of worn attachments, empty but not null, if no attachments are worn /// - IAvatarAttachment[] Attachments { get; } + + IAvatarAttachment[] Attachments { get; } + + /// + /// Request to open an url clientside + /// + void LoadUrl(IObject sender, string message, string url); } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs new file mode 100644 index 0000000..7490dda --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs @@ -0,0 +1,16 @@ +using System; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + + /// + /// This implements the methods needed to operate on individual inventory items. + /// + public interface IInventoryItem + { + int Type { get; } + UUID AssetID { get; } + T RetreiveAsset() where T : OpenMetaverse.Asset, new(); + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs index dd9cc29..1be3b71 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs @@ -179,6 +179,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule /// The message to send to the user void Say(string msg); + //// + /// Grants access to the objects inventory + /// + IObjectInventory Inventory { get; } } public enum PhysicsMaterial diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs new file mode 100644 index 0000000..512a120 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs @@ -0,0 +1,72 @@ + +using System; +using System.Text; + +using OpenSim.Framework; +using OpenSim.Region.Framework.Scenes; +//using OpenSim.Services.AssetService; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + + + public class InventoryItem : IInventoryItem + { + TaskInventoryItem m_privateItem; + Scene m_rootSceene; + + public InventoryItem(Scene rootScene, TaskInventoryItem internalItem) + { + m_rootSceene = rootScene; + m_privateItem = internalItem; + } + + // Marked internal, to prevent scripts from accessing the internal type + internal TaskInventoryItem ToTaskInventoryItem() + { + return m_privateItem; + } + + /// + /// This will attempt to convert from an IInventoryItem to an InventoryItem object + /// + /// + /// In order for this to work the object which implements IInventoryItem must inherit from InventoryItem, otherwise + /// an exception is thrown. + /// + /// + /// The interface to upcast + /// + /// + /// The object backing the interface implementation + /// + internal static InventoryItem FromInterface(IInventoryItem i) + { + if(typeof(InventoryItem).IsAssignableFrom(i.GetType())) + { + return (InventoryItem)i; + } + else + { + throw new ApplicationException("[MRM] There is no legal conversion from IInventoryItem to InventoryItem"); + } + } + + public int Type { get { return m_privateItem.Type; } } + public UUID AssetID { get { return m_privateItem.AssetID; } } + + public T RetreiveAsset() where T : OpenMetaverse.Asset, new() + { + AssetBase a = m_rootSceene.AssetService.Get(AssetID.ToString()); + T result = new T(); + + if((sbyte)result.AssetType != a.Type) + throw new ApplicationException("[MRM] The supplied asset class does not match the found asset"); + + result.AssetData = a.Data; + result.Decode(); + return result; + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectInventory.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectInventory.cs new file mode 100644 index 0000000..98ac13d --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectInventory.cs @@ -0,0 +1,17 @@ + +using System; +using System.Collections.Generic; + +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object +{ + + /// + /// This implements the methods neccesary to operate on the inventory of an object + /// + public interface IObjectInventory : IDictionary + { + IInventoryItem this[string name] { get; } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index a40a0d9..689c70e1d 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -301,7 +301,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule get { return this; } } - #region Public Functions + public IObjectInventory Inventory + { + get { return new SOPObjectInventory(m_rootScene, GetSOP().TaskInventory); } + } + + #region Public Functions public void Say(string msg) { diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs new file mode 100644 index 0000000..19740bd --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs @@ -0,0 +1,190 @@ +using System; +using System.Collections; +using System.Collections.Generic; + +using OpenSim.Framework; +using OpenSim.Region.Framework.Scenes; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object +{ + + + public class SOPObjectInventory : IObjectInventory + { + TaskInventoryDictionary m_privateInventory; /// OpenSim's task inventory + Dictionary m_publicInventory; /// MRM's inventory + Scene m_rootScene; + + public SOPObjectInventory(Scene rootScene, TaskInventoryDictionary taskInventory) + { + m_rootScene = rootScene; + m_privateInventory = taskInventory; + m_publicInventory = new Dictionary(); + } + + /// + /// Fully populate the public dictionary with the contents of the private dictionary + /// + /// + /// This will only convert those items which hasn't already been converted. ensuring that + /// no items are converted twice, and that any references already in use are maintained. + /// + private void SynchronizeDictionaries() + { + foreach(TaskInventoryItem privateItem in m_privateInventory.Values) + if(!m_publicInventory.ContainsKey(privateItem.ItemID)) + m_publicInventory.Add(privateItem.ItemID, new InventoryItem(m_rootScene, privateItem)); + } + + #region IDictionary implementation + public void Add (UUID key, IInventoryItem value) + { + m_publicInventory.Add(key, value); + m_privateInventory.Add(key, InventoryItem.FromInterface(value).ToTaskInventoryItem()); + } + + public bool ContainsKey (UUID key) + { + return m_privateInventory.ContainsKey(key); + } + + public bool Remove (UUID key) + { + m_publicInventory.Remove(key); + return m_privateInventory.Remove(key); + } + + public bool TryGetValue (UUID key, out IInventoryItem value) + { + value = null; + + bool result = false; + if(!m_publicInventory.TryGetValue(key, out value)) + { + // wasn't found in the public inventory + TaskInventoryItem privateItem; + + result = m_privateInventory.TryGetValue(key, out privateItem); + if(result) + { + value = new InventoryItem(m_rootScene, privateItem); + m_publicInventory.Add(key, value); // add item, so we don't convert again + } + } else + return true; + + return result; + } + + public ICollection Keys { + get { + return m_privateInventory.Keys; + } + } + + public ICollection Values { + get { + SynchronizeDictionaries(); + return m_publicInventory.Values; + } + } + #endregion + + #region IEnumerable> implementation + public IEnumerator> GetEnumerator () + { + SynchronizeDictionaries(); + return m_publicInventory.GetEnumerator(); + } + + #endregion + + #region IEnumerable implementation + IEnumerator IEnumerable.GetEnumerator () + { + SynchronizeDictionaries(); + return m_publicInventory.GetEnumerator(); + } + + #endregion + + #region ICollection> implementation + public void Add (KeyValuePair item) + { + Add(item.Key, item.Value); + } + + public void Clear () + { + m_publicInventory.Clear(); + m_privateInventory.Clear(); + } + + public bool Contains (KeyValuePair item) + { + return m_privateInventory.ContainsKey(item.Key); + } + + public void CopyTo (KeyValuePair[] array, int arrayIndex) + { + throw new NotImplementedException(); + } + + public bool Remove (KeyValuePair item) + { + return Remove(item.Key); + } + + public int Count { + get { + return m_privateInventory.Count; + } + } + + public bool IsReadOnly { + get { + return false; + } + } + #endregion + + #region Explicit implementations + IInventoryItem System.Collections.Generic.IDictionary.this[UUID key] + { + get { + IInventoryItem result; + if(TryGetValue(key, out result)) + return result; + else + throw new KeyNotFoundException("[MRM] The requrested item ID could not be found"); + } + set { + m_publicInventory[key] = value; + m_privateInventory[key] = InventoryItem.FromInterface(value).ToTaskInventoryItem(); + } + } + + void System.Collections.Generic.ICollection>.CopyTo(System.Collections.Generic.KeyValuePair[] array, int offset) + { + throw new NotImplementedException(); + } + #endregion + + public IInventoryItem this[string name] + { + get { + foreach(TaskInventoryItem i in m_privateInventory.Values) + if(i.Name == name) + { + if(!m_publicInventory.ContainsKey(i.ItemID)) + m_publicInventory.Add(i.ItemID, new InventoryItem(m_rootScene, i)); + + return m_publicInventory[i.ItemID]; + } + throw new KeyNotFoundException(); + } + } + + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs index 6fd36bf..a71d1e5 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs @@ -32,6 +32,7 @@ using System.Collections.Generic; using OpenMetaverse; using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Interfaces; using log4net; @@ -90,6 +91,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule return attachments.ToArray(); } } + + public void LoadUrl(IObject sender, string message, string url) + { + IDialogModule dm = m_rootScene.RequestModuleInterface(); + if(dm != null) + dm.SendUrlToUser(GetSP().UUID, sender.Name, sender.GlobalID, GetSP().UUID, false, message, url); + } #endregion } } -- cgit v1.1 From 3f2fba610ea48b6d93a77f3965882d600b6a908a Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Wed, 1 Jul 2009 10:26:43 +0000 Subject: Update svn properties. --- .../Minimodule/Interfaces/IInventoryItem.cs | 32 +- .../Scripting/Minimodule/InventoryItem.cs | 144 ++++---- .../Minimodule/Object/IObjectInventory.cs | 34 +- .../Scripting/Minimodule/SOPObjectInventory.cs | 380 ++++++++++----------- .../Scripting/Minimodule/SPAvatarAttachment.cs | 70 ++-- 5 files changed, 330 insertions(+), 330 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs index 7490dda..79ee4d6 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs @@ -1,16 +1,16 @@ -using System; -using OpenMetaverse; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - - /// - /// This implements the methods needed to operate on individual inventory items. - /// - public interface IInventoryItem - { - int Type { get; } - UUID AssetID { get; } - T RetreiveAsset() where T : OpenMetaverse.Asset, new(); - } -} +using System; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + + /// + /// This implements the methods needed to operate on individual inventory items. + /// + public interface IInventoryItem + { + int Type { get; } + UUID AssetID { get; } + T RetreiveAsset() where T : OpenMetaverse.Asset, new(); + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs index 512a120..d85066b 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs @@ -1,72 +1,72 @@ - -using System; -using System.Text; - -using OpenSim.Framework; -using OpenSim.Region.Framework.Scenes; -//using OpenSim.Services.AssetService; -using OpenMetaverse; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - - - public class InventoryItem : IInventoryItem - { - TaskInventoryItem m_privateItem; - Scene m_rootSceene; - - public InventoryItem(Scene rootScene, TaskInventoryItem internalItem) - { - m_rootSceene = rootScene; - m_privateItem = internalItem; - } - - // Marked internal, to prevent scripts from accessing the internal type - internal TaskInventoryItem ToTaskInventoryItem() - { - return m_privateItem; - } - - /// - /// This will attempt to convert from an IInventoryItem to an InventoryItem object - /// - /// - /// In order for this to work the object which implements IInventoryItem must inherit from InventoryItem, otherwise - /// an exception is thrown. - /// - /// - /// The interface to upcast - /// - /// - /// The object backing the interface implementation - /// - internal static InventoryItem FromInterface(IInventoryItem i) - { - if(typeof(InventoryItem).IsAssignableFrom(i.GetType())) - { - return (InventoryItem)i; - } - else - { - throw new ApplicationException("[MRM] There is no legal conversion from IInventoryItem to InventoryItem"); - } - } - - public int Type { get { return m_privateItem.Type; } } - public UUID AssetID { get { return m_privateItem.AssetID; } } - - public T RetreiveAsset() where T : OpenMetaverse.Asset, new() - { - AssetBase a = m_rootSceene.AssetService.Get(AssetID.ToString()); - T result = new T(); - - if((sbyte)result.AssetType != a.Type) - throw new ApplicationException("[MRM] The supplied asset class does not match the found asset"); - - result.AssetData = a.Data; - result.Decode(); - return result; - } - } -} + +using System; +using System.Text; + +using OpenSim.Framework; +using OpenSim.Region.Framework.Scenes; +//using OpenSim.Services.AssetService; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + + + public class InventoryItem : IInventoryItem + { + TaskInventoryItem m_privateItem; + Scene m_rootSceene; + + public InventoryItem(Scene rootScene, TaskInventoryItem internalItem) + { + m_rootSceene = rootScene; + m_privateItem = internalItem; + } + + // Marked internal, to prevent scripts from accessing the internal type + internal TaskInventoryItem ToTaskInventoryItem() + { + return m_privateItem; + } + + /// + /// This will attempt to convert from an IInventoryItem to an InventoryItem object + /// + /// + /// In order for this to work the object which implements IInventoryItem must inherit from InventoryItem, otherwise + /// an exception is thrown. + /// + /// + /// The interface to upcast + /// + /// + /// The object backing the interface implementation + /// + internal static InventoryItem FromInterface(IInventoryItem i) + { + if(typeof(InventoryItem).IsAssignableFrom(i.GetType())) + { + return (InventoryItem)i; + } + else + { + throw new ApplicationException("[MRM] There is no legal conversion from IInventoryItem to InventoryItem"); + } + } + + public int Type { get { return m_privateItem.Type; } } + public UUID AssetID { get { return m_privateItem.AssetID; } } + + public T RetreiveAsset() where T : OpenMetaverse.Asset, new() + { + AssetBase a = m_rootSceene.AssetService.Get(AssetID.ToString()); + T result = new T(); + + if((sbyte)result.AssetType != a.Type) + throw new ApplicationException("[MRM] The supplied asset class does not match the found asset"); + + result.AssetData = a.Data; + result.Decode(); + return result; + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectInventory.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectInventory.cs index 98ac13d..f03e96f 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectInventory.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectInventory.cs @@ -1,17 +1,17 @@ - -using System; -using System.Collections.Generic; - -using OpenMetaverse; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object -{ - - /// - /// This implements the methods neccesary to operate on the inventory of an object - /// - public interface IObjectInventory : IDictionary - { - IInventoryItem this[string name] { get; } - } -} + +using System; +using System.Collections.Generic; + +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object +{ + + /// + /// This implements the methods neccesary to operate on the inventory of an object + /// + public interface IObjectInventory : IDictionary + { + IInventoryItem this[string name] { get; } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs index 19740bd..8a7681f 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs @@ -1,190 +1,190 @@ -using System; -using System.Collections; -using System.Collections.Generic; - -using OpenSim.Framework; -using OpenSim.Region.Framework.Scenes; -using OpenMetaverse; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object -{ - - - public class SOPObjectInventory : IObjectInventory - { - TaskInventoryDictionary m_privateInventory; /// OpenSim's task inventory - Dictionary m_publicInventory; /// MRM's inventory - Scene m_rootScene; - - public SOPObjectInventory(Scene rootScene, TaskInventoryDictionary taskInventory) - { - m_rootScene = rootScene; - m_privateInventory = taskInventory; - m_publicInventory = new Dictionary(); - } - - /// - /// Fully populate the public dictionary with the contents of the private dictionary - /// - /// - /// This will only convert those items which hasn't already been converted. ensuring that - /// no items are converted twice, and that any references already in use are maintained. - /// - private void SynchronizeDictionaries() - { - foreach(TaskInventoryItem privateItem in m_privateInventory.Values) - if(!m_publicInventory.ContainsKey(privateItem.ItemID)) - m_publicInventory.Add(privateItem.ItemID, new InventoryItem(m_rootScene, privateItem)); - } - - #region IDictionary implementation - public void Add (UUID key, IInventoryItem value) - { - m_publicInventory.Add(key, value); - m_privateInventory.Add(key, InventoryItem.FromInterface(value).ToTaskInventoryItem()); - } - - public bool ContainsKey (UUID key) - { - return m_privateInventory.ContainsKey(key); - } - - public bool Remove (UUID key) - { - m_publicInventory.Remove(key); - return m_privateInventory.Remove(key); - } - - public bool TryGetValue (UUID key, out IInventoryItem value) - { - value = null; - - bool result = false; - if(!m_publicInventory.TryGetValue(key, out value)) - { - // wasn't found in the public inventory - TaskInventoryItem privateItem; - - result = m_privateInventory.TryGetValue(key, out privateItem); - if(result) - { - value = new InventoryItem(m_rootScene, privateItem); - m_publicInventory.Add(key, value); // add item, so we don't convert again - } - } else - return true; - - return result; - } - - public ICollection Keys { - get { - return m_privateInventory.Keys; - } - } - - public ICollection Values { - get { - SynchronizeDictionaries(); - return m_publicInventory.Values; - } - } - #endregion - - #region IEnumerable> implementation - public IEnumerator> GetEnumerator () - { - SynchronizeDictionaries(); - return m_publicInventory.GetEnumerator(); - } - - #endregion - - #region IEnumerable implementation - IEnumerator IEnumerable.GetEnumerator () - { - SynchronizeDictionaries(); - return m_publicInventory.GetEnumerator(); - } - - #endregion - - #region ICollection> implementation - public void Add (KeyValuePair item) - { - Add(item.Key, item.Value); - } - - public void Clear () - { - m_publicInventory.Clear(); - m_privateInventory.Clear(); - } - - public bool Contains (KeyValuePair item) - { - return m_privateInventory.ContainsKey(item.Key); - } - - public void CopyTo (KeyValuePair[] array, int arrayIndex) - { - throw new NotImplementedException(); - } - - public bool Remove (KeyValuePair item) - { - return Remove(item.Key); - } - - public int Count { - get { - return m_privateInventory.Count; - } - } - - public bool IsReadOnly { - get { - return false; - } - } - #endregion - - #region Explicit implementations - IInventoryItem System.Collections.Generic.IDictionary.this[UUID key] - { - get { - IInventoryItem result; - if(TryGetValue(key, out result)) - return result; - else - throw new KeyNotFoundException("[MRM] The requrested item ID could not be found"); - } - set { - m_publicInventory[key] = value; - m_privateInventory[key] = InventoryItem.FromInterface(value).ToTaskInventoryItem(); - } - } - - void System.Collections.Generic.ICollection>.CopyTo(System.Collections.Generic.KeyValuePair[] array, int offset) - { - throw new NotImplementedException(); - } - #endregion - - public IInventoryItem this[string name] - { - get { - foreach(TaskInventoryItem i in m_privateInventory.Values) - if(i.Name == name) - { - if(!m_publicInventory.ContainsKey(i.ItemID)) - m_publicInventory.Add(i.ItemID, new InventoryItem(m_rootScene, i)); - - return m_publicInventory[i.ItemID]; - } - throw new KeyNotFoundException(); - } - } - - } -} +using System; +using System.Collections; +using System.Collections.Generic; + +using OpenSim.Framework; +using OpenSim.Region.Framework.Scenes; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object +{ + + + public class SOPObjectInventory : IObjectInventory + { + TaskInventoryDictionary m_privateInventory; /// OpenSim's task inventory + Dictionary m_publicInventory; /// MRM's inventory + Scene m_rootScene; + + public SOPObjectInventory(Scene rootScene, TaskInventoryDictionary taskInventory) + { + m_rootScene = rootScene; + m_privateInventory = taskInventory; + m_publicInventory = new Dictionary(); + } + + /// + /// Fully populate the public dictionary with the contents of the private dictionary + /// + /// + /// This will only convert those items which hasn't already been converted. ensuring that + /// no items are converted twice, and that any references already in use are maintained. + /// + private void SynchronizeDictionaries() + { + foreach(TaskInventoryItem privateItem in m_privateInventory.Values) + if(!m_publicInventory.ContainsKey(privateItem.ItemID)) + m_publicInventory.Add(privateItem.ItemID, new InventoryItem(m_rootScene, privateItem)); + } + + #region IDictionary implementation + public void Add (UUID key, IInventoryItem value) + { + m_publicInventory.Add(key, value); + m_privateInventory.Add(key, InventoryItem.FromInterface(value).ToTaskInventoryItem()); + } + + public bool ContainsKey (UUID key) + { + return m_privateInventory.ContainsKey(key); + } + + public bool Remove (UUID key) + { + m_publicInventory.Remove(key); + return m_privateInventory.Remove(key); + } + + public bool TryGetValue (UUID key, out IInventoryItem value) + { + value = null; + + bool result = false; + if(!m_publicInventory.TryGetValue(key, out value)) + { + // wasn't found in the public inventory + TaskInventoryItem privateItem; + + result = m_privateInventory.TryGetValue(key, out privateItem); + if(result) + { + value = new InventoryItem(m_rootScene, privateItem); + m_publicInventory.Add(key, value); // add item, so we don't convert again + } + } else + return true; + + return result; + } + + public ICollection Keys { + get { + return m_privateInventory.Keys; + } + } + + public ICollection Values { + get { + SynchronizeDictionaries(); + return m_publicInventory.Values; + } + } + #endregion + + #region IEnumerable> implementation + public IEnumerator> GetEnumerator () + { + SynchronizeDictionaries(); + return m_publicInventory.GetEnumerator(); + } + + #endregion + + #region IEnumerable implementation + IEnumerator IEnumerable.GetEnumerator () + { + SynchronizeDictionaries(); + return m_publicInventory.GetEnumerator(); + } + + #endregion + + #region ICollection> implementation + public void Add (KeyValuePair item) + { + Add(item.Key, item.Value); + } + + public void Clear () + { + m_publicInventory.Clear(); + m_privateInventory.Clear(); + } + + public bool Contains (KeyValuePair item) + { + return m_privateInventory.ContainsKey(item.Key); + } + + public void CopyTo (KeyValuePair[] array, int arrayIndex) + { + throw new NotImplementedException(); + } + + public bool Remove (KeyValuePair item) + { + return Remove(item.Key); + } + + public int Count { + get { + return m_privateInventory.Count; + } + } + + public bool IsReadOnly { + get { + return false; + } + } + #endregion + + #region Explicit implementations + IInventoryItem System.Collections.Generic.IDictionary.this[UUID key] + { + get { + IInventoryItem result; + if(TryGetValue(key, out result)) + return result; + else + throw new KeyNotFoundException("[MRM] The requrested item ID could not be found"); + } + set { + m_publicInventory[key] = value; + m_privateInventory[key] = InventoryItem.FromInterface(value).ToTaskInventoryItem(); + } + } + + void System.Collections.Generic.ICollection>.CopyTo(System.Collections.Generic.KeyValuePair[] array, int offset) + { + throw new NotImplementedException(); + } + #endregion + + public IInventoryItem this[string name] + { + get { + foreach(TaskInventoryItem i in m_privateInventory.Values) + if(i.Name == name) + { + if(!m_publicInventory.ContainsKey(i.ItemID)) + m_publicInventory.Add(i.ItemID, new InventoryItem(m_rootScene, i)); + + return m_publicInventory[i.ItemID]; + } + throw new KeyNotFoundException(); + } + } + + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs index 5581fc3..387cba0 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs @@ -1,35 +1,35 @@ -using System; - -using OpenMetaverse; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - public class SPAvatarAttachment : IAvatarAttachment - { - private readonly Scene m_rootScene; - private readonly IAvatar m_parent; - private readonly int m_location; - private readonly UUID m_itemId; - private readonly UUID m_assetId; - - public SPAvatarAttachment(Scene rootScene, IAvatar self, int location, UUID itemId, UUID assetId) - { - m_rootScene = rootScene; - m_parent = self; - m_location = location; - m_itemId = itemId; - m_assetId = assetId; - } - - public int Location { get { return m_location; } } - - public IObject Asset - { - get - { - return new SOPObject(m_rootScene, m_rootScene.GetSceneObjectPart(m_assetId).LocalId); - } - } - } -} +using System; + +using OpenMetaverse; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public class SPAvatarAttachment : IAvatarAttachment + { + private readonly Scene m_rootScene; + private readonly IAvatar m_parent; + private readonly int m_location; + private readonly UUID m_itemId; + private readonly UUID m_assetId; + + public SPAvatarAttachment(Scene rootScene, IAvatar self, int location, UUID itemId, UUID assetId) + { + m_rootScene = rootScene; + m_parent = self; + m_location = location; + m_itemId = itemId; + m_assetId = assetId; + } + + public int Location { get { return m_location; } } + + public IObject Asset + { + get + { + return new SOPObject(m_rootScene, m_rootScene.GetSceneObjectPart(m_assetId).LocalId); + } + } + } +} -- cgit v1.1 From a0a44d8ebc8ce9d6edddd8faeff909c10daea746 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Wed, 1 Jul 2009 23:25:59 +0000 Subject: Add copyright headers. --- .../Minimodule/Interfaces/IInventoryItem.cs | 27 ++++++++++++++++++++ .../Scripting/Minimodule/InventoryItem.cs | 28 +++++++++++++++++++-- .../Minimodule/Object/IObjectInventory.cs | 27 +++++++++++++++++++- .../Scripting/Minimodule/SOPObjectInventory.cs | 29 ++++++++++++++++++++-- .../Scripting/Minimodule/SPAvatarAttachment.cs | 27 ++++++++++++++++++++ 5 files changed, 133 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs index 79ee4d6..50f98a2 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs @@ -1,3 +1,30 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + using System; using OpenMetaverse; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs index d85066b..dc0b94a 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs @@ -1,3 +1,29 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ using System; using System.Text; @@ -9,8 +35,6 @@ using OpenMetaverse; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - - public class InventoryItem : IInventoryItem { TaskInventoryItem m_privateItem; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectInventory.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectInventory.cs index f03e96f..126250a 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectInventory.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectInventory.cs @@ -1,3 +1,29 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ using System; using System.Collections.Generic; @@ -6,7 +32,6 @@ using OpenMetaverse; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object { - /// /// This implements the methods neccesary to operate on the inventory of an object /// diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs index 8a7681f..cae49a3 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs @@ -1,3 +1,30 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + using System; using System.Collections; using System.Collections.Generic; @@ -8,8 +35,6 @@ using OpenMetaverse; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object { - - public class SOPObjectInventory : IObjectInventory { TaskInventoryDictionary m_privateInventory; /// OpenSim's task inventory diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs index 387cba0..4d6e4b6 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs @@ -1,3 +1,30 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + using System; using OpenMetaverse; -- cgit v1.1 From 1d01d6d919ec55e59d5c9b20a978aa6b802bd45d Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Wed, 1 Jul 2009 23:37:09 +0000 Subject: Formatting cleanup. --- .../Scripting/Minimodule/Interfaces/IAvatar.cs | 36 +-- .../Minimodule/Interfaces/IInventoryItem.cs | 20 +- .../Scripting/Minimodule/Interfaces/IObject.cs | 8 +- .../Scripting/Minimodule/InventoryItem.cs | 110 +++---- .../Minimodule/Object/IObjectInventory.cs | 14 +- .../Scripting/Minimodule/SOPObject.cs | 12 +- .../Scripting/Minimodule/SOPObjectInventory.cs | 336 ++++++++++----------- .../Scripting/Minimodule/SPAvatar.cs | 54 ++-- .../Scripting/Minimodule/SPAvatarAttachment.cs | 50 +-- 9 files changed, 320 insertions(+), 320 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs index 3345988..849e3ca 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs @@ -34,28 +34,28 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { public interface IAvatarAttachment { - //// - /// Describes where on the avatar the attachment is located - /// - int Location { get ; } - - //// - /// Accessor to the rez'ed asset, representing the attachment - /// - IObject Asset { get; } + //// + /// Describes where on the avatar the attachment is located + /// + int Location { get ; } + + //// + /// Accessor to the rez'ed asset, representing the attachment + /// + IObject Asset { get; } } - public interface IAvatar : IEntity + public interface IAvatar : IEntity { - //// - /// Array of worn attachments, empty but not null, if no attachments are worn - /// + //// + /// Array of worn attachments, empty but not null, if no attachments are worn + /// - IAvatarAttachment[] Attachments { get; } + IAvatarAttachment[] Attachments { get; } - /// - /// Request to open an url clientside - /// - void LoadUrl(IObject sender, string message, string url); + /// + /// Request to open an url clientside + /// + void LoadUrl(IObject sender, string message, string url); } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs index 50f98a2..208ddb0 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs @@ -30,14 +30,14 @@ using OpenMetaverse; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - - /// - /// This implements the methods needed to operate on individual inventory items. - /// - public interface IInventoryItem - { - int Type { get; } - UUID AssetID { get; } - T RetreiveAsset() where T : OpenMetaverse.Asset, new(); - } + + /// + /// This implements the methods needed to operate on individual inventory items. + /// + public interface IInventoryItem + { + int Type { get; } + UUID AssetID { get; } + T RetreiveAsset() where T : OpenMetaverse.Asset, new(); + } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs index 1be3b71..f45df48 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs @@ -179,10 +179,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule /// The message to send to the user void Say(string msg); - //// - /// Grants access to the objects inventory - /// - IObjectInventory Inventory { get; } + //// + /// Grants access to the objects inventory + /// + IObjectInventory Inventory { get; } } public enum PhysicsMaterial diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs index dc0b94a..b9c0065 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs @@ -35,62 +35,62 @@ using OpenMetaverse; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - public class InventoryItem : IInventoryItem - { - TaskInventoryItem m_privateItem; - Scene m_rootSceene; - - public InventoryItem(Scene rootScene, TaskInventoryItem internalItem) - { - m_rootSceene = rootScene; - m_privateItem = internalItem; - } + public class InventoryItem : IInventoryItem + { + TaskInventoryItem m_privateItem; + Scene m_rootSceene; + + public InventoryItem(Scene rootScene, TaskInventoryItem internalItem) + { + m_rootSceene = rootScene; + m_privateItem = internalItem; + } - // Marked internal, to prevent scripts from accessing the internal type - internal TaskInventoryItem ToTaskInventoryItem() - { - return m_privateItem; - } + // Marked internal, to prevent scripts from accessing the internal type + internal TaskInventoryItem ToTaskInventoryItem() + { + return m_privateItem; + } - /// - /// This will attempt to convert from an IInventoryItem to an InventoryItem object - /// - /// - /// In order for this to work the object which implements IInventoryItem must inherit from InventoryItem, otherwise - /// an exception is thrown. - /// - /// - /// The interface to upcast - /// - /// - /// The object backing the interface implementation - /// - internal static InventoryItem FromInterface(IInventoryItem i) - { - if(typeof(InventoryItem).IsAssignableFrom(i.GetType())) - { - return (InventoryItem)i; - } - else - { - throw new ApplicationException("[MRM] There is no legal conversion from IInventoryItem to InventoryItem"); - } - } - - public int Type { get { return m_privateItem.Type; } } - public UUID AssetID { get { return m_privateItem.AssetID; } } - - public T RetreiveAsset() where T : OpenMetaverse.Asset, new() - { - AssetBase a = m_rootSceene.AssetService.Get(AssetID.ToString()); - T result = new T(); + /// + /// This will attempt to convert from an IInventoryItem to an InventoryItem object + /// + /// + /// In order for this to work the object which implements IInventoryItem must inherit from InventoryItem, otherwise + /// an exception is thrown. + /// + /// + /// The interface to upcast + /// + /// + /// The object backing the interface implementation + /// + internal static InventoryItem FromInterface(IInventoryItem i) + { + if (typeof(InventoryItem).IsAssignableFrom(i.GetType())) + { + return (InventoryItem)i; + } + else + { + throw new ApplicationException("[MRM] There is no legal conversion from IInventoryItem to InventoryItem"); + } + } + + public int Type { get { return m_privateItem.Type; } } + public UUID AssetID { get { return m_privateItem.AssetID; } } + + public T RetreiveAsset() where T : OpenMetaverse.Asset, new() + { + AssetBase a = m_rootSceene.AssetService.Get(AssetID.ToString()); + T result = new T(); - if((sbyte)result.AssetType != a.Type) - throw new ApplicationException("[MRM] The supplied asset class does not match the found asset"); - - result.AssetData = a.Data; - result.Decode(); - return result; - } - } + if ((sbyte)result.AssetType != a.Type) + throw new ApplicationException("[MRM] The supplied asset class does not match the found asset"); + + result.AssetData = a.Data; + result.Decode(); + return result; + } + } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectInventory.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectInventory.cs index 126250a..bb85d06 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectInventory.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectInventory.cs @@ -32,11 +32,11 @@ using OpenMetaverse; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object { - /// - /// This implements the methods neccesary to operate on the inventory of an object - /// - public interface IObjectInventory : IDictionary - { - IInventoryItem this[string name] { get; } - } + /// + /// This implements the methods neccesary to operate on the inventory of an object + /// + public interface IObjectInventory : IDictionary + { + IInventoryItem this[string name] { get; } + } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 689c70e1d..bc26389 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -301,12 +301,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule get { return this; } } - public IObjectInventory Inventory - { - get { return new SOPObjectInventory(m_rootScene, GetSOP().TaskInventory); } - } - - #region Public Functions + public IObjectInventory Inventory + { + get { return new SOPObjectInventory(m_rootScene, GetSOP().TaskInventory); } + } + + #region Public Functions public void Say(string msg) { diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs index cae49a3..d20f4a4 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs @@ -35,181 +35,181 @@ using OpenMetaverse; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object { - public class SOPObjectInventory : IObjectInventory - { - TaskInventoryDictionary m_privateInventory; /// OpenSim's task inventory - Dictionary m_publicInventory; /// MRM's inventory - Scene m_rootScene; + public class SOPObjectInventory : IObjectInventory + { + TaskInventoryDictionary m_privateInventory; /// OpenSim's task inventory + Dictionary m_publicInventory; /// MRM's inventory + Scene m_rootScene; - public SOPObjectInventory(Scene rootScene, TaskInventoryDictionary taskInventory) - { - m_rootScene = rootScene; - m_privateInventory = taskInventory; - m_publicInventory = new Dictionary(); - } + public SOPObjectInventory(Scene rootScene, TaskInventoryDictionary taskInventory) + { + m_rootScene = rootScene; + m_privateInventory = taskInventory; + m_publicInventory = new Dictionary(); + } - /// - /// Fully populate the public dictionary with the contents of the private dictionary - /// - /// - /// This will only convert those items which hasn't already been converted. ensuring that - /// no items are converted twice, and that any references already in use are maintained. - /// - private void SynchronizeDictionaries() - { - foreach(TaskInventoryItem privateItem in m_privateInventory.Values) - if(!m_publicInventory.ContainsKey(privateItem.ItemID)) - m_publicInventory.Add(privateItem.ItemID, new InventoryItem(m_rootScene, privateItem)); - } - - #region IDictionary implementation - public void Add (UUID key, IInventoryItem value) - { - m_publicInventory.Add(key, value); - m_privateInventory.Add(key, InventoryItem.FromInterface(value).ToTaskInventoryItem()); - } - - public bool ContainsKey (UUID key) - { - return m_privateInventory.ContainsKey(key); - } - - public bool Remove (UUID key) - { - m_publicInventory.Remove(key); - return m_privateInventory.Remove(key); - } - - public bool TryGetValue (UUID key, out IInventoryItem value) - { - value = null; + /// + /// Fully populate the public dictionary with the contents of the private dictionary + /// + /// + /// This will only convert those items which hasn't already been converted. ensuring that + /// no items are converted twice, and that any references already in use are maintained. + /// + private void SynchronizeDictionaries() + { + foreach (TaskInventoryItem privateItem in m_privateInventory.Values) + if (!m_publicInventory.ContainsKey(privateItem.ItemID)) + m_publicInventory.Add(privateItem.ItemID, new InventoryItem(m_rootScene, privateItem)); + } + + #region IDictionary implementation + public void Add (UUID key, IInventoryItem value) + { + m_publicInventory.Add(key, value); + m_privateInventory.Add(key, InventoryItem.FromInterface(value).ToTaskInventoryItem()); + } + + public bool ContainsKey (UUID key) + { + return m_privateInventory.ContainsKey(key); + } + + public bool Remove (UUID key) + { + m_publicInventory.Remove(key); + return m_privateInventory.Remove(key); + } + + public bool TryGetValue (UUID key, out IInventoryItem value) + { + value = null; - bool result = false; - if(!m_publicInventory.TryGetValue(key, out value)) - { - // wasn't found in the public inventory - TaskInventoryItem privateItem; - - result = m_privateInventory.TryGetValue(key, out privateItem); - if(result) - { - value = new InventoryItem(m_rootScene, privateItem); - m_publicInventory.Add(key, value); // add item, so we don't convert again - } - } else - return true; - - return result; - } - - public ICollection Keys { - get { - return m_privateInventory.Keys; - } - } - - public ICollection Values { - get { - SynchronizeDictionaries(); - return m_publicInventory.Values; - } - } - #endregion + bool result = false; + if (!m_publicInventory.TryGetValue(key, out value)) + { + // wasn't found in the public inventory + TaskInventoryItem privateItem; + + result = m_privateInventory.TryGetValue(key, out privateItem); + if (result) + { + value = new InventoryItem(m_rootScene, privateItem); + m_publicInventory.Add(key, value); // add item, so we don't convert again + } + } else + return true; + + return result; + } + + public ICollection Keys { + get { + return m_privateInventory.Keys; + } + } + + public ICollection Values { + get { + SynchronizeDictionaries(); + return m_publicInventory.Values; + } + } + #endregion - #region IEnumerable> implementation - public IEnumerator> GetEnumerator () - { - SynchronizeDictionaries(); - return m_publicInventory.GetEnumerator(); - } + #region IEnumerable> implementation + public IEnumerator> GetEnumerator () + { + SynchronizeDictionaries(); + return m_publicInventory.GetEnumerator(); + } - #endregion + #endregion - #region IEnumerable implementation - IEnumerator IEnumerable.GetEnumerator () - { - SynchronizeDictionaries(); - return m_publicInventory.GetEnumerator(); - } + #region IEnumerable implementation + IEnumerator IEnumerable.GetEnumerator () + { + SynchronizeDictionaries(); + return m_publicInventory.GetEnumerator(); + } - #endregion + #endregion - #region ICollection> implementation - public void Add (KeyValuePair item) - { - Add(item.Key, item.Value); - } - - public void Clear () - { - m_publicInventory.Clear(); - m_privateInventory.Clear(); - } - - public bool Contains (KeyValuePair item) - { - return m_privateInventory.ContainsKey(item.Key); - } - - public void CopyTo (KeyValuePair[] array, int arrayIndex) - { - throw new NotImplementedException(); - } - - public bool Remove (KeyValuePair item) - { - return Remove(item.Key); - } - - public int Count { - get { - return m_privateInventory.Count; - } - } - - public bool IsReadOnly { - get { - return false; - } - } - #endregion - - #region Explicit implementations - IInventoryItem System.Collections.Generic.IDictionary.this[UUID key] - { - get { - IInventoryItem result; - if(TryGetValue(key, out result)) - return result; - else - throw new KeyNotFoundException("[MRM] The requrested item ID could not be found"); - } - set { - m_publicInventory[key] = value; - m_privateInventory[key] = InventoryItem.FromInterface(value).ToTaskInventoryItem(); - } - } - - void System.Collections.Generic.ICollection>.CopyTo(System.Collections.Generic.KeyValuePair[] array, int offset) - { - throw new NotImplementedException(); - } - #endregion - - public IInventoryItem this[string name] - { - get { - foreach(TaskInventoryItem i in m_privateInventory.Values) - if(i.Name == name) - { - if(!m_publicInventory.ContainsKey(i.ItemID)) - m_publicInventory.Add(i.ItemID, new InventoryItem(m_rootScene, i)); - - return m_publicInventory[i.ItemID]; - } - throw new KeyNotFoundException(); - } - } + #region ICollection> implementation + public void Add (KeyValuePair item) + { + Add(item.Key, item.Value); + } + + public void Clear () + { + m_publicInventory.Clear(); + m_privateInventory.Clear(); + } + + public bool Contains (KeyValuePair item) + { + return m_privateInventory.ContainsKey(item.Key); + } + + public void CopyTo (KeyValuePair[] array, int arrayIndex) + { + throw new NotImplementedException(); + } + + public bool Remove (KeyValuePair item) + { + return Remove(item.Key); + } + + public int Count { + get { + return m_privateInventory.Count; + } + } + + public bool IsReadOnly { + get { + return false; + } + } + #endregion + + #region Explicit implementations + IInventoryItem System.Collections.Generic.IDictionary.this[UUID key] + { + get { + IInventoryItem result; + if (TryGetValue(key, out result)) + return result; + else + throw new KeyNotFoundException("[MRM] The requrested item ID could not be found"); + } + set { + m_publicInventory[key] = value; + m_privateInventory[key] = InventoryItem.FromInterface(value).ToTaskInventoryItem(); + } + } + + void System.Collections.Generic.ICollection>.CopyTo(System.Collections.Generic.KeyValuePair[] array, int offset) + { + throw new NotImplementedException(); + } + #endregion + + public IInventoryItem this[string name] + { + get { + foreach (TaskInventoryItem i in m_privateInventory.Values) + if (i.Name == name) + { + if (!m_publicInventory.ContainsKey(i.ItemID)) + m_publicInventory.Add(i.ItemID, new InventoryItem(m_rootScene, i)); + + return m_publicInventory[i.ItemID]; + } + throw new KeyNotFoundException(); + } + } - } + } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs index a71d1e5..8a38f01 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs @@ -71,33 +71,33 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule get { return GetSP().AbsolutePosition; } set { GetSP().TeleportWithMomentum(value); } } - - #region IAvatar implementation - public IAvatarAttachment[] Attachments - { - get { - List attachments = new List(); - - Hashtable internalAttachments = GetSP().Appearance.GetAttachments(); - if(internalAttachments != null) - { - foreach(DictionaryEntry element in internalAttachments) - { - Hashtable attachInfo = (Hashtable)element.Value; - attachments.Add(new SPAvatarAttachment(m_rootScene, this, (int)element.Key, new UUID((string)attachInfo["item"]), new UUID((string)attachInfo["asset"]))); - } - } - - return attachments.ToArray(); - } - } + + #region IAvatar implementation + public IAvatarAttachment[] Attachments + { + get { + List attachments = new List(); + + Hashtable internalAttachments = GetSP().Appearance.GetAttachments(); + if (internalAttachments != null) + { + foreach (DictionaryEntry element in internalAttachments) + { + Hashtable attachInfo = (Hashtable)element.Value; + attachments.Add(new SPAvatarAttachment(m_rootScene, this, (int)element.Key, new UUID((string)attachInfo["item"]), new UUID((string)attachInfo["asset"]))); + } + } + + return attachments.ToArray(); + } + } - public void LoadUrl(IObject sender, string message, string url) - { - IDialogModule dm = m_rootScene.RequestModuleInterface(); - if(dm != null) - dm.SendUrlToUser(GetSP().UUID, sender.Name, sender.GlobalID, GetSP().UUID, false, message, url); - } - #endregion + public void LoadUrl(IObject sender, string message, string url) + { + IDialogModule dm = m_rootScene.RequestModuleInterface(); + if (dm != null) + dm.SendUrlToUser(GetSP().UUID, sender.Name, sender.GlobalID, GetSP().UUID, false, message, url); + } + #endregion } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs index 4d6e4b6..971119f 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs @@ -33,30 +33,30 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { public class SPAvatarAttachment : IAvatarAttachment - { + { private readonly Scene m_rootScene; - private readonly IAvatar m_parent; - private readonly int m_location; - private readonly UUID m_itemId; - private readonly UUID m_assetId; - - public SPAvatarAttachment(Scene rootScene, IAvatar self, int location, UUID itemId, UUID assetId) - { - m_rootScene = rootScene; - m_parent = self; - m_location = location; - m_itemId = itemId; - m_assetId = assetId; - } - - public int Location { get { return m_location; } } - - public IObject Asset - { - get - { - return new SOPObject(m_rootScene, m_rootScene.GetSceneObjectPart(m_assetId).LocalId); - } - } - } + private readonly IAvatar m_parent; + private readonly int m_location; + private readonly UUID m_itemId; + private readonly UUID m_assetId; + + public SPAvatarAttachment(Scene rootScene, IAvatar self, int location, UUID itemId, UUID assetId) + { + m_rootScene = rootScene; + m_parent = self; + m_location = location; + m_itemId = itemId; + m_assetId = assetId; + } + + public int Location { get { return m_location; } } + + public IObject Asset + { + get + { + return new SOPObject(m_rootScene, m_rootScene.GetSceneObjectPart(m_assetId).LocalId); + } + } + } } -- cgit v1.1 From 61008c9c13e88e1979fd339257497fb079170507 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Wed, 8 Jul 2009 20:57:26 +0000 Subject: Thank you kindly, SnowDrop, for a patch that: This add a configuration option to the MRM module called "hidden". if MRM is marked as enabled, the module will additionally check for the "Hidden" flag, before registering for client side scriping events. When MRM is running hidden, it will not respond to client side scripting events, giving serverside scripting modules, like MRMLoader and MRMAddin the ability to leverage the MRM engine. This way, even a possible clientside exploit will not be possible, while still allowing the MRM engine to run. --- .../Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index c4648d2..2b84016 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -67,7 +67,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { m_log.Info("[MRM] Enabling MRM Module"); m_scene = scene; - scene.EventManager.OnRezScript += EventManager_OnRezScript; + + // when hidden, we don't listen for client initiated script events + // only making the MRM engine available for region modules + if(!source.Configs["MRM"].GetBoolean("Hidden", false)) + { + scene.EventManager.OnRezScript += EventManager_OnRezScript; + } + scene.EventManager.OnFrame += EventManager_OnFrame; scene.RegisterModuleInterface(this); @@ -158,7 +165,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule m_microthreads); mmb.InitMiniModule(m_world, m_host, itemID); - } public void PostInitialise() @@ -192,7 +198,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule /// internal string CompileFromDotNetText(string Script, string uuid) { - m_log.Info("MRM 1"); + m_log.Info("MRM 1"); const string ext = ".cs"; const string FilePrefix = "MiniModule"; -- cgit v1.1 From cce451d9de1ee9877dd089917a682127224f56d5 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sat, 11 Jul 2009 11:47:33 +0000 Subject: Formatting cleanup. --- .../OptionalModules/Scripting/Minimodule/MRMModule.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 2b84016..53145e2 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -68,13 +68,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule m_log.Info("[MRM] Enabling MRM Module"); m_scene = scene; - // when hidden, we don't listen for client initiated script events - // only making the MRM engine available for region modules - if(!source.Configs["MRM"].GetBoolean("Hidden", false)) - { - scene.EventManager.OnRezScript += EventManager_OnRezScript; - } - + // when hidden, we don't listen for client initiated script events + // only making the MRM engine available for region modules + if (!source.Configs["MRM"].GetBoolean("Hidden", false)) + { + scene.EventManager.OnRezScript += EventManager_OnRezScript; + } + scene.EventManager.OnFrame += EventManager_OnFrame; scene.RegisterModuleInterface(this); @@ -198,7 +198,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule /// internal string CompileFromDotNetText(string Script, string uuid) { - m_log.Info("MRM 1"); + m_log.Info("MRM 1"); const string ext = ".cs"; const string FilePrefix = "MiniModule"; -- cgit v1.1 From 5815162d7ef1df861de082cee9e99cec14805572 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 15 Jul 2009 20:49:58 +0000 Subject: minor: remove some mono compiler warnings --- OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs | 2 +- .../OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs index 8a38f01..ce2d339 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs @@ -42,7 +42,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { private readonly Scene m_rootScene; private readonly UUID m_ID; - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public SPAvatar(Scene scene, UUID ID) { diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs index 971119f..9b684fe 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs @@ -35,17 +35,17 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public class SPAvatarAttachment : IAvatarAttachment { private readonly Scene m_rootScene; - private readonly IAvatar m_parent; + //private readonly IAvatar m_parent; private readonly int m_location; - private readonly UUID m_itemId; + //private readonly UUID m_itemId; private readonly UUID m_assetId; public SPAvatarAttachment(Scene rootScene, IAvatar self, int location, UUID itemId, UUID assetId) { m_rootScene = rootScene; - m_parent = self; + //m_parent = self; m_location = location; - m_itemId = itemId; + //m_itemId = itemId; m_assetId = assetId; } -- cgit v1.1 From 64bd9a335444379ebe1cad8e34d5b5953a76f671 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sat, 25 Jul 2009 15:49:10 +0000 Subject: * Updates libOMV to version 0.7.0 * Uses mantis #3811 as a base (thanks jhuliman) with changes. * E-mail regarding interface changes sent to the opensim-dev list * Archive: https://lists.berlios.de/pipermail/opensim-dev/2009-July/007219.html --- .../OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs | 3 ++- OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs index 208ddb0..5fac189 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs @@ -27,6 +27,7 @@ using System; using OpenMetaverse; +using OpenMetaverse.Assets; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { @@ -38,6 +39,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { int Type { get; } UUID AssetID { get; } - T RetreiveAsset() where T : OpenMetaverse.Asset, new(); + T RetreiveAsset() where T : Asset, new(); } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs index b9c0065..40693ab 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs @@ -32,6 +32,7 @@ using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; //using OpenSim.Services.AssetService; using OpenMetaverse; +using OpenMetaverse.Assets; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { @@ -80,7 +81,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public int Type { get { return m_privateItem.Type; } } public UUID AssetID { get { return m_privateItem.AssetID; } } - public T RetreiveAsset() where T : OpenMetaverse.Asset, new() + public T RetreiveAsset() where T : OpenMetaverse.Assets.Asset, new() { AssetBase a = m_rootSceene.AssetService.Get(AssetID.ToString()); T result = new T(); -- cgit v1.1 From 270ae50d700831ac996025045dc32341d68ee0f9 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Fri, 7 Aug 2009 14:17:51 +1000 Subject: * Implements MRM's Stop() interface member. * MRM Scripts should do appropriate cleanup within this event, to allow for clean shutdowns and script updates. This means unbinding from events you are listening to, and releasing any resources. --- .../Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs | 1 + OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | 9 +++++++++ 2 files changed, 10 insertions(+) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs index 40693ab..5bf29d7 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs @@ -81,6 +81,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public int Type { get { return m_privateItem.Type; } } public UUID AssetID { get { return m_privateItem.AssetID; } } + // This method exposes OpenSim/OpenMetaverse internals and needs to be replaced with a IAsset specific to MRM. public T RetreiveAsset() where T : OpenMetaverse.Assets.Asset, new() { AssetBase a = m_rootSceene.AssetService.Get(AssetID.ToString()); diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 53145e2..eb807f2 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -73,6 +73,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule if (!source.Configs["MRM"].GetBoolean("Hidden", false)) { scene.EventManager.OnRezScript += EventManager_OnRezScript; + scene.EventManager.OnStopScript += EventManager_OnStopScript; } scene.EventManager.OnFrame += EventManager_OnFrame; @@ -90,6 +91,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule } } + void EventManager_OnStopScript(uint localID, UUID itemID) + { + if(m_scripts.ContainsKey(itemID)) + { + m_scripts[itemID].Stop(); + } + } + void EventManager_OnFrame() { m_microthreads.Tick(1000); -- cgit v1.1 From 3219e648ccee074e28135430afe2d26a7cf53c9e Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 7 Aug 2009 19:04:20 +0100 Subject: From: Snowcrash Date: Wed, 5 Aug 2009 12:45:56 +0200 Subject: [PATCH] A few minor tweaks to the MRM API's in order to make it possible for MRM's to run in a separate AppDomain without poluting the primary appdomain of OpenSim Specifically: Added an explicit method for getting the "globals" of the MRM, removing the need to have the MRM script code loaded into the primary domain, in order to set up proxies Added a [Serializable] attribute to TouchEventArgs, again in order to remove the need to have MRM script code loaded into the primary domain. --------- Applied with whitespace changes --- .../OptionalModules/Scripting/Minimodule/IMRMModule.cs | 1 + .../Scripting/Minimodule/Interfaces/IObject.cs | 1 + .../OptionalModules/Scripting/Minimodule/MRMModule.cs | 15 +++++++++++---- 3 files changed, 13 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IMRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IMRMModule.cs index 9f48081..e957a62 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IMRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IMRMModule.cs @@ -33,5 +33,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { void RegisterExtension(T instance); void InitializeMRM(MRMBase mmb, uint localID, UUID itemID); + void GetGlobalEnvironment(uint localID, out IWorld world, out IHost host); } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs index f45df48..6415250 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs @@ -32,6 +32,7 @@ using OpenSim.Region.OptionalModules.Scripting.Minimodule.Object; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { + [Serializable] public class TouchEventArgs : EventArgs { public IAvatar Avatar; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index eb807f2..6a15a33 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -164,16 +164,23 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule } } + public void GetGlobalEnvironment(uint localID, out IWorld world, out IHost host) + { + world = new World(m_scene); + host = new Host(new SOPObject(m_scene, localID), m_scene, new ExtensionHandler(m_extensions), m_microthreads); + } + public void InitializeMRM(MRMBase mmb, uint localID, UUID itemID) { m_log.Info("[MRM] Created MRM Instance"); - IWorld m_world = new World(m_scene); - IHost m_host = new Host(new SOPObject(m_scene, localID), m_scene, new ExtensionHandler(m_extensions), - m_microthreads); + IWorld world; + IHost host; + + GetGlobalEnvironment(localID, out world, out host); - mmb.InitMiniModule(m_world, m_host, itemID); + mmb.InitMiniModule(world, host, itemID); } public void PostInitialise() -- cgit v1.1 From bc6ec3b56469f2d722ceee8fdb37059125878f66 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sun, 9 Aug 2009 00:43:13 +0900 Subject: Formatting cleanup. --- OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 6a15a33..5ed9af3 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -93,7 +93,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule void EventManager_OnStopScript(uint localID, UUID itemID) { - if(m_scripts.ContainsKey(itemID)) + if (m_scripts.ContainsKey(itemID)) { m_scripts[itemID].Stop(); } -- cgit v1.1 From 9090a907692e7deaafd79150bf6482507be86d55 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 16 Aug 2009 03:48:16 +1000 Subject: * Beginnings of a Security Credential system in MRM. This will eventually lead to trusted execution of untrusted MRMs. --- .../Scripting/Minimodule/ISecurityCredential.cs | 7 +++++++ .../Scripting/Minimodule/MRMModule.cs | 10 ++++++++-- .../Scripting/Minimodule/ObjectAccessor.cs | 22 +++++++++++++--------- .../Scripting/Minimodule/SOPObject.cs | 9 +++++++++ .../Scripting/Minimodule/SecurityCredential.cs | 21 +++++++++++++++++++++ .../OptionalModules/Scripting/Minimodule/World.cs | 6 ++++-- 6 files changed, 62 insertions(+), 13 deletions(-) create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/ISecurityCredential.cs create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/SecurityCredential.cs (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISecurityCredential.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISecurityCredential.cs new file mode 100644 index 0000000..464723e --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISecurityCredential.cs @@ -0,0 +1,7 @@ +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface ISecurityCredential + { + ISocialEntity owner { get; } + } +} \ No newline at end of file diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 5ed9af3..0cc7930 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -166,8 +166,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public void GetGlobalEnvironment(uint localID, out IWorld world, out IHost host) { - world = new World(m_scene); - host = new Host(new SOPObject(m_scene, localID), m_scene, new ExtensionHandler(m_extensions), m_microthreads); + // UUID should be changed to object owner. + UUID owner = m_scene.RegionInfo.MasterAvatarAssignedUUID; + SEUser securityUser = new SEUser(owner, "Name Unassigned"); + SecurityCredential creds = new SecurityCredential(securityUser); + + world = new World(m_scene, creds); + host = new Host(new SOPObject(m_scene, localID, creds), m_scene, new ExtensionHandler(m_extensions), + m_microthreads); } public void InitializeMRM(MRMBase mmb, uint localID, UUID itemID) diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs index 4638ad0..6ba5ccf 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs @@ -40,10 +40,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { private readonly Scene m_scene; private readonly IEnumerator m_sogEnum; + private readonly ISecurityCredential m_security; - public IObjEnum(Scene scene) + public IObjEnum(Scene scene, ISecurityCredential security) { m_scene = scene; + m_security = security; m_sogEnum = m_scene.Entities.GetAllByType().GetEnumerator(); } @@ -66,7 +68,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { get { - return new SOPObject(m_scene, m_sogEnum.Current.LocalId); + return new SOPObject(m_scene, m_sogEnum.Current.LocalId, m_security); } } @@ -79,17 +81,19 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public class ObjectAccessor : System.MarshalByRefObject, IObjectAccessor { private readonly Scene m_scene; + private readonly ISecurityCredential m_security; - public ObjectAccessor(Scene scene) + public ObjectAccessor(Scene scene, ISecurityCredential security) { m_scene = scene; + m_security = security; } public IObject this[int index] { get { - return new SOPObject(m_scene, m_scene.Entities[(uint)index].LocalId); + return new SOPObject(m_scene, m_scene.Entities[(uint)index].LocalId, m_security); } } @@ -97,7 +101,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { get { - return new SOPObject(m_scene, m_scene.Entities[index].LocalId); + return new SOPObject(m_scene, m_scene.Entities[index].LocalId, m_security); } } @@ -105,7 +109,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { get { - return new SOPObject(m_scene, m_scene.Entities[index].LocalId); + return new SOPObject(m_scene, m_scene.Entities[index].LocalId, m_security); } } @@ -117,20 +121,20 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public IObject Create(Vector3 position, Quaternion rotation) { - SceneObjectGroup sog = m_scene.AddNewPrim(m_scene.RegionInfo.MasterAvatarAssignedUUID, + SceneObjectGroup sog = m_scene.AddNewPrim(m_security.owner.GlobalID, UUID.Zero, position, rotation, PrimitiveBaseShape.CreateBox()); - IObject ret = new SOPObject(m_scene, sog.LocalId); + IObject ret = new SOPObject(m_scene, sog.LocalId, m_security); return ret; } public IEnumerator GetEnumerator() { - return new IObjEnum(m_scene); + return new IObjEnum(m_scene, m_security); } IEnumerator IEnumerable.GetEnumerator() diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index bc26389..fa9ef53 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -42,13 +42,22 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { private readonly Scene m_rootScene; private readonly uint m_localID; + private readonly ISecurityCredential m_security; + [Obsolete("Replace with 'credential' constructor [security]")] public SOPObject(Scene rootScene, uint localID) { m_rootScene = rootScene; m_localID = localID; } + public SOPObject(Scene rootScene, uint localID, ISecurityCredential credential) + { + m_rootScene = rootScene; + m_localID = localID; + m_security = credential; + } + /// /// This needs to run very, very quickly. /// It is utilized in nearly every property and method. diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SecurityCredential.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SecurityCredential.cs new file mode 100644 index 0000000..bd4440c --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SecurityCredential.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + class SecurityCredential : ISecurityCredential + { + private readonly ISocialEntity m_owner; + + public SecurityCredential(ISocialEntity m_owner) + { + this.m_owner = m_owner; + } + + public ISocialEntity owner + { + get { return m_owner; } + } + } +} diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index 1ec4a33..a34684f 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs @@ -37,15 +37,17 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public class World : System.MarshalByRefObject, IWorld, IWorldAudio { private readonly Scene m_internalScene; + private readonly ISecurityCredential m_security; private readonly Heightmap m_heights; private readonly ObjectAccessor m_objs; - public World(Scene internalScene) + public World(Scene internalScene, ISecurityCredential securityCredential) { + m_security = securityCredential; m_internalScene = internalScene; m_heights = new Heightmap(m_internalScene); - m_objs = new ObjectAccessor(m_internalScene); + m_objs = new ObjectAccessor(m_internalScene, securityCredential); } #region Events -- cgit v1.1 From 9d9fcac0386ba6adc7a1f6c08f82bd5c0b6cd1d2 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Fri, 14 Aug 2009 17:16:41 +0900 Subject: Misc cleanup. --- .../Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs index 6415250..19f7210 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs @@ -212,6 +212,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule bool Bright { get; set; } // SetPrimParms(FULLBRIGHT) double Bloom { get; set; } // SetPrimParms(GLOW) bool Shiny { get; set; } // SetPrimParms(SHINY) - bool BumpMap { get; set; } // SetPrimParms(BUMPMAP) [DEPRECIATE IN FAVOUR OF UUID?] + bool BumpMap { get; set; } // SetPrimParms(BUMPMAP) [DEPRECATE IN FAVOUR OF UUID?] } } -- cgit v1.1 From 2b630470b064bc4d0fe84210839409f3c7bf5823 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sun, 16 Aug 2009 17:30:13 +0900 Subject: Add copyright headers. Formatting cleanup. --- .../Scripting/Minimodule/ISecurityCredential.cs | 27 ++++++++++++++++++++ .../Scripting/Minimodule/SecurityCredential.cs | 29 +++++++++++++++++++++- 2 files changed, 55 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISecurityCredential.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISecurityCredential.cs index 464723e..7e084d8 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISecurityCredential.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISecurityCredential.cs @@ -1,3 +1,30 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { public interface ISecurityCredential diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SecurityCredential.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SecurityCredential.cs index bd4440c..cbcd137 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SecurityCredential.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SecurityCredential.cs @@ -1,4 +1,31 @@ -using System; +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; using System.Collections.Generic; using System.Text; -- cgit v1.1 From 975c49a399d2822b93496d7abea8587c9f8c7af4 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 16 Aug 2009 21:20:45 +1000 Subject: * [MRM] Implements permission checks on IObject implementations in SOPObject.cs. Does not implement security on IObjectInventory yet. --- .../Scripting/Minimodule/ISecurityCredential.cs | 2 + .../Scripting/Minimodule/SOPObject.cs | 86 +++++++++++++++++++--- .../Scripting/Minimodule/SecurityCredential.cs | 13 ++++ 3 files changed, 92 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISecurityCredential.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISecurityCredential.cs index 464723e..e6878d1 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISecurityCredential.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISecurityCredential.cs @@ -3,5 +3,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public interface ISecurityCredential { ISocialEntity owner { get; } + bool CanEditObject(IObject target); + bool CanEditTerrain(int x, int y); } } \ No newline at end of file diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index fa9ef53..674c9e0 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; +using System.Security; using OpenMetaverse; using OpenMetaverse.Packets; using OpenSim.Framework; @@ -68,6 +69,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule return m_rootScene.GetSceneObjectPart(m_localID); } + private bool CanEdit() + { + if(!m_security.CanEditObject(this)) + { + throw new SecurityException("Insufficient Permission to edit object with UUID [" + GetSOP().UUID + "]"); + } + return true; + } + #region OnTouch private event OnTouchDelegate _OnTouch; @@ -139,13 +149,21 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public string Name { get { return GetSOP().Name; } - set { GetSOP().Name = value; } + set + { + if (CanEdit()) + GetSOP().Name = value; + } } public string Description { get { return GetSOP().Description; } - set { GetSOP().Description = value; } + set + { + if (CanEdit()) + GetSOP().Description = value; + } } public IObject[] Children @@ -169,7 +187,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public IObject Root { - get { return new SOPObject(m_rootScene, GetSOP().ParentGroup.RootPart.LocalId); } + get { return new SOPObject(m_rootScene, GetSOP().ParentGroup.RootPart.LocalId, m_security); } } public IObjectMaterial[] Materials @@ -191,7 +209,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public Vector3 Scale { get { return GetSOP().Scale; } - set { GetSOP().Scale = value; } + set + { + if (CanEdit()) + GetSOP().Scale = value; + } } public Quaternion WorldRotation @@ -211,15 +233,24 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule get { return GetSOP().AbsolutePosition; } set { - SceneObjectPart pos = GetSOP(); - pos.UpdateOffSet(value - pos.AbsolutePosition); + if (CanEdit()) + { + SceneObjectPart pos = GetSOP(); + pos.UpdateOffSet(value - pos.AbsolutePosition); + } } } public Vector3 OffsetPosition { get { return GetSOP().OffsetPosition; } - set { GetSOP().OffsetPosition = value; } + set + { + if (CanEdit()) + { + GetSOP().OffsetPosition = value; + } + } } public Vector3 SitTarget @@ -319,8 +350,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public void Say(string msg) { - SceneObjectPart sop = GetSOP(); + if (!CanEdit()) + return; + SceneObjectPart sop = GetSOP(); m_rootScene.SimChat(msg, ChatTypeEnum.Say, sop.AbsolutePosition, sop.Name, sop.UUID, false); } @@ -512,6 +545,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule } set { + if (!CanEdit()) + return; + GetSOP().PhysActor.RotationalVelocity = new PhysicsVector(value.X, value.Y, value.Z); } } @@ -525,6 +561,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule } set { + if (!CanEdit()) + return; + GetSOP().PhysActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z); } } @@ -538,6 +577,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule } set { + if (!CanEdit()) + return; + GetSOP().PhysActor.Torque = new PhysicsVector(value.X, value.Y, value.Z); } } @@ -560,27 +602,44 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule } set { + if (!CanEdit()) + return; + GetSOP().PhysActor.Force = new PhysicsVector(value.X, value.Y, value.Z); } } public bool FloatOnWater { - set { GetSOP().PhysActor.FloatOnWater = value; } + set + { + if (!CanEdit()) + return; + GetSOP().PhysActor.FloatOnWater = value; + } } public void AddForce(Vector3 force, bool pushforce) { + if (!CanEdit()) + return; + GetSOP().PhysActor.AddForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce); } public void AddAngularForce(Vector3 force, bool pushforce) { + if (!CanEdit()) + return; + GetSOP().PhysActor.AddAngularForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce); } public void SetMomentum(Vector3 momentum) { + if (!CanEdit()) + return; + GetSOP().PhysActor.SetMomentum(new PhysicsVector(momentum.X, momentum.Y, momentum.Z)); } @@ -595,6 +654,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule get { return m_sculptMap; } set { + if (!CanEdit()) + return; + m_sculptMap = value; SetPrimitiveSculpted(SculptMap, (byte) SculptType); } @@ -607,6 +669,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule get { return m_sculptType; } set { + if(!CanEdit()) + return; + m_sculptType = value; SetPrimitiveSculpted(SculptMap, (byte) SculptType); } @@ -663,6 +728,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public void Play(UUID asset, double volume) { + if (!CanEdit()) + return; + GetSOP().SendSound(asset.ToString(), volume, true, 0); } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SecurityCredential.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SecurityCredential.cs index bd4440c..771bc8b 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SecurityCredential.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SecurityCredential.cs @@ -1,12 +1,15 @@ using System; using System.Collections.Generic; using System.Text; +using OpenMetaverse; +using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { class SecurityCredential : ISecurityCredential { private readonly ISocialEntity m_owner; + private readonly Scene m_scene; public SecurityCredential(ISocialEntity m_owner) { @@ -17,5 +20,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { get { return m_owner; } } + + public bool CanEditObject(IObject target) + { + return m_scene.Permissions.CanEditObject(target.GlobalID, m_owner.GlobalID); + } + + public bool CanEditTerrain(int x, int y) + { + return m_scene.Permissions.CanTerraformLand(m_owner.GlobalID, new Vector3(x, y, 0)); + } } } -- cgit v1.1 From 8621dc405e2f0f1ea81baa52ec124d8b362a2abf Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 16 Aug 2009 21:23:39 +1000 Subject: * Fixes potential NulRef in MRM Security Checks. --- OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | 2 +- .../OptionalModules/Scripting/Minimodule/SecurityCredential.cs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 0cc7930..6daae29 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -169,7 +169,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule // UUID should be changed to object owner. UUID owner = m_scene.RegionInfo.MasterAvatarAssignedUUID; SEUser securityUser = new SEUser(owner, "Name Unassigned"); - SecurityCredential creds = new SecurityCredential(securityUser); + SecurityCredential creds = new SecurityCredential(securityUser, m_scene); world = new World(m_scene, creds); host = new Host(new SOPObject(m_scene, localID, creds), m_scene, new ExtensionHandler(m_extensions), diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SecurityCredential.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SecurityCredential.cs index 6e350b9..bc7f6cb 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SecurityCredential.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SecurityCredential.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -38,9 +38,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule private readonly ISocialEntity m_owner; private readonly Scene m_scene; - public SecurityCredential(ISocialEntity m_owner) + public SecurityCredential(ISocialEntity m_owner, Scene m_scene) { this.m_owner = m_owner; + this.m_scene = m_scene; } public ISocialEntity owner -- cgit v1.1 From adae13cd185b17b4644f2d939b1970aab309097a Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 16 Aug 2009 21:36:33 +1000 Subject: * [MRM] Added permission checks to MRM Events (ie, requires edit permission to bind to OnTouch) --- .../OptionalModules/Scripting/Minimodule/SOPObject.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 674c9e0..2e3ed3c 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -87,14 +87,17 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { add { - if (!_OnTouchActive) + if (CanEdit()) { - GetSOP().Flags |= PrimFlags.Touch; - _OnTouchActive = true; - m_rootScene.EventManager.OnObjectGrab += EventManager_OnObjectGrab; + if (!_OnTouchActive) + { + GetSOP().Flags |= PrimFlags.Touch; + _OnTouchActive = true; + m_rootScene.EventManager.OnObjectGrab += EventManager_OnObjectGrab; + } + + _OnTouch += value; } - - _OnTouch += value; } remove { -- cgit v1.1 From b28e82654150edd0ef21fc8361c023a99186d658 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 16 Aug 2009 21:41:57 +1000 Subject: * Implements ISecurityCredential on all uses of SOPObject.cs except Avatar Attachments. --- OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs | 2 +- OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 2e3ed3c..bdc7a15 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -181,7 +181,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule int i = 0; foreach (KeyValuePair pair in my.ParentGroup.Children) { - rets[i++] = new SOPObject(m_rootScene, pair.Value.LocalId); + rets[i++] = new SOPObject(m_rootScene, pair.Value.LocalId, m_security); } return rets; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index a34684f..497ca39 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs @@ -146,7 +146,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule if (chat.Sender == null && chat.SenderObject != null) { ChatEventArgs e = new ChatEventArgs(); - e.Sender = new SOPObject(m_internalScene, ((SceneObjectPart) chat.SenderObject).LocalId); + e.Sender = new SOPObject(m_internalScene, ((SceneObjectPart) chat.SenderObject).LocalId, m_security); e.Text = chat.Message; _OnChat(this, e); -- cgit v1.1 From c2be3edd2d8cb2aabb5040d14167c2bed7c4635c Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 16 Aug 2009 21:49:53 +1000 Subject: * Refactor: Moves IAvatarAttachment into IAvatarAttachment.cs instead of IAvatar.cs --- .../Scripting/Minimodule/Interfaces/IAvatar.cs | 13 ------------- .../Scripting/Minimodule/Interfaces/IAvatarAttachment.cs | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 13 deletions(-) create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs index 849e3ca..03c1e95 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs @@ -32,19 +32,6 @@ using OpenMetaverse; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - public interface IAvatarAttachment - { - //// - /// Describes where on the avatar the attachment is located - /// - int Location { get ; } - - //// - /// Accessor to the rez'ed asset, representing the attachment - /// - IObject Asset { get; } - } - public interface IAvatar : IEntity { //// diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs new file mode 100644 index 0000000..22b4605 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs @@ -0,0 +1,15 @@ +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule +{ + public interface IAvatarAttachment + { + //// + /// Describes where on the avatar the attachment is located + /// + int Location { get ; } + + //// + /// Accessor to the rez'ed asset, representing the attachment + /// + IObject Asset { get; } + } +} \ No newline at end of file -- cgit v1.1 From cbd454d69231598daf6748070fb5f0baace61c59 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 16 Aug 2009 22:01:18 +1000 Subject: * Implements ISecurityCredential member on SPAvatar, SPAvatarAttachment * Disables 'event not used' warning for IRCClientView; cuts OpenSim total warnings back. --- OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs | 2 +- OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs | 8 ++++++-- .../OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs | 7 +++++-- OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs | 6 +++--- 4 files changed, 15 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index bdc7a15..35b0a0f 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -117,7 +117,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule if (_OnTouchActive && m_localID == localID) { TouchEventArgs e = new TouchEventArgs(); - e.Avatar = new SPAvatar(m_rootScene, remoteClient.AgentId); + e.Avatar = new SPAvatar(m_rootScene, remoteClient.AgentId, m_security); e.TouchBiNormal = surfaceArgs.Binormal; e.TouchMaterialIndex = surfaceArgs.FaceIndex; e.TouchNormal = surfaceArgs.Normal; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs index ce2d339..4600836 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs @@ -42,11 +42,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { private readonly Scene m_rootScene; private readonly UUID m_ID; + private readonly ISecurityCredential m_security; //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public SPAvatar(Scene scene, UUID ID) + public SPAvatar(Scene scene, UUID ID, ISecurityCredential security) { m_rootScene = scene; + m_security = security; m_ID = ID; } @@ -84,7 +86,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule foreach (DictionaryEntry element in internalAttachments) { Hashtable attachInfo = (Hashtable)element.Value; - attachments.Add(new SPAvatarAttachment(m_rootScene, this, (int)element.Key, new UUID((string)attachInfo["item"]), new UUID((string)attachInfo["asset"]))); + attachments.Add(new SPAvatarAttachment(m_rootScene, this, (int) element.Key, + new UUID((string) attachInfo["item"]), + new UUID((string) attachInfo["asset"]), m_security)); } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs index 9b684fe..570459a 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs @@ -39,10 +39,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule private readonly int m_location; //private readonly UUID m_itemId; private readonly UUID m_assetId; + + private readonly ISecurityCredential m_security; - public SPAvatarAttachment(Scene rootScene, IAvatar self, int location, UUID itemId, UUID assetId) + public SPAvatarAttachment(Scene rootScene, IAvatar self, int location, UUID itemId, UUID assetId, ISecurityCredential security) { m_rootScene = rootScene; + m_security = security; //m_parent = self; m_location = location; //m_itemId = itemId; @@ -55,7 +58,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { get { - return new SOPObject(m_rootScene, m_rootScene.GetSceneObjectPart(m_assetId).LocalId); + return new SOPObject(m_rootScene, m_rootScene.GetSceneObjectPart(m_assetId).LocalId, m_security); } } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index 497ca39..da5ea0d 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs @@ -86,7 +86,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule if (_OnNewUser != null) { NewUserEventArgs e = new NewUserEventArgs(); - e.Avatar = new SPAvatar(m_internalScene, presence.UUID); + e.Avatar = new SPAvatar(m_internalScene, presence.UUID, m_security); _OnNewUser(this, e); } } @@ -156,7 +156,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule if (chat.Sender != null && chat.SenderObject == null) { ChatEventArgs e = new ChatEventArgs(); - e.Sender = new SPAvatar(m_internalScene, chat.SenderUUID); + e.Sender = new SPAvatar(m_internalScene, chat.SenderUUID, m_security); e.Text = chat.Message; _OnChat(this, e); @@ -209,7 +209,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule for (int i = 0; i < ents.Count; i++) { EntityBase ent = ents[i]; - rets[i] = new SPAvatar(m_internalScene, ent.UUID); + rets[i] = new SPAvatar(m_internalScene, ent.UUID, m_security); } return rets; -- cgit v1.1 From fa921ec147cae620f3126c01b1db94a8f6e90c7e Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Mon, 17 Aug 2009 02:25:00 +1000 Subject: * Implements AppDomain Security for MRM Scripts. * Added permissionLevel attribute to [MRM] section in OpenSim.ini. Default is 'Internet', however may be any of the following (case sensitive), FullTrust, SkipVerification, Execution, Nothing, LocalIntranet, Internet, Everything. For previous functionality, set to FullTrust or Execution. --- .../Scripting/Minimodule/MRMModule.cs | 103 ++++++++++++++++++++- 1 file changed, 101 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 6daae29..9042e0d 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -27,9 +27,14 @@ using System; using System.CodeDom.Compiler; +using System.Collections; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Reflection; +using System.Security; +using System.Security.Permissions; +using System.Security.Policy; using System.Text; using log4net; using Microsoft.CSharp; @@ -54,6 +59,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule private readonly MicroScheduler m_microthreads = new MicroScheduler(); + + private IConfig m_config; + public void RegisterExtension(T instance) { m_extensions[typeof (T)] = instance; @@ -63,6 +71,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { if (source.Configs["MRM"] != null) { + m_config = source.Configs["MRM"]; + if (source.Configs["MRM"].GetBoolean("Enabled", false)) { m_log.Info("[MRM] Enabling MRM Module"); @@ -112,6 +122,91 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule return script; } + /// + /// Create an AppDomain that contains policy restricting code to execute + /// with only the permissions granted by a named permission set + /// + /// name of the permission set to restrict to + /// 'friendly' name of the appdomain to be created + /// + /// if is null + /// + /// + /// if is empty + /// + /// AppDomain with a restricted security policy + /// Substantial portions of this function from: http://blogs.msdn.com/shawnfa/archive/2004/10/25/247379.aspx + /// Valid permissionSetName values are: + /// * FullTrust + /// * SkipVerification + /// * Execution + /// * Nothing + /// * LocalIntranet + /// * Internet + /// * Everything + /// + public static AppDomain CreateRestrictedDomain(string permissionSetName, string appDomainName) + { + if (permissionSetName == null) + throw new ArgumentNullException("permissionSetName"); + if (permissionSetName.Length == 0) + throw new ArgumentOutOfRangeException("permissionSetName", permissionSetName, + "Cannot have an empty permission set name"); + + // Default to all code getting nothing + PolicyStatement emptyPolicy = new PolicyStatement(new PermissionSet(PermissionState.None)); + UnionCodeGroup policyRoot = new UnionCodeGroup(new AllMembershipCondition(), emptyPolicy); + + bool foundName = false; + PermissionSet setIntersection = new PermissionSet(PermissionState.Unrestricted); + + // iterate over each policy level + IEnumerator levelEnumerator = SecurityManager.PolicyHierarchy(); + while (levelEnumerator.MoveNext()) + { + PolicyLevel level = levelEnumerator.Current as PolicyLevel; + + // if this level has defined a named permission set with the + // given name, then intersect it with what we've retrieved + // from all the previous levels + if (level != null) + { + PermissionSet levelSet = level.GetNamedPermissionSet(permissionSetName); + if (levelSet != null) + { + foundName = true; + if (setIntersection != null) + setIntersection = setIntersection.Intersect(levelSet); + } + } + } + + // Intersect() can return null for an empty set, so convert that + // to an empty set object. Also return an empty set if we didn't find + // the named permission set we were looking for + if (setIntersection == null || !foundName) + setIntersection = new PermissionSet(PermissionState.None); + else + setIntersection = new NamedPermissionSet(permissionSetName, setIntersection); + + // if no named permission sets were found, return an empty set, + // otherwise return the set that was found + PolicyStatement permissions = new PolicyStatement(setIntersection); + policyRoot.AddChild(new UnionCodeGroup(new AllMembershipCondition(), permissions)); + + // create an AppDomain policy level for the policy tree + PolicyLevel appDomainLevel = PolicyLevel.CreateAppDomainLevel(); + appDomainLevel.RootCodeGroup = policyRoot; + + // create an AppDomain where this policy will be in effect + string domainName = appDomainName; + AppDomain restrictedDomain = AppDomain.CreateDomain(domainName); + restrictedDomain.SetAppDomainPolicy(appDomainLevel); + + return restrictedDomain; + } + + void EventManager_OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) { if (script.StartsWith("//MRM:C#")) @@ -125,9 +220,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule try { - m_log.Info("[MRM] Found C# MRM"); + m_log.Info("[MRM] Found C# MRM - Starting in AppDomain with " + m_config.GetString("permissionLevel", "Internet") + "-level security."); + + string domainName = UUID.Random().ToString(); + AppDomain target = CreateRestrictedDomain(m_config.GetString("permissionLevel", "Internet"), + domainName); - MRMBase mmb = (MRMBase)AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap( + MRMBase mmb = (MRMBase) target.CreateInstanceFromAndUnwrap( CompileFromDotNetText(script, itemID.ToString()), "OpenSim.MiniModule"); -- cgit v1.1 From 58d2775ff29c1a4faa26302515c7a6cbd8bdb764 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 17 Aug 2009 02:05:12 +0900 Subject: Add copyright header. Formatting cleanup. --- .../Minimodule/Interfaces/IAvatarAttachment.cs | 27 ++++++++++++++++++++++ .../Scripting/Minimodule/SOPObject.cs | 4 ++-- 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs index 22b4605..1993948 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs @@ -1,3 +1,30 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { public interface IAvatarAttachment diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 35b0a0f..292e345 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -71,7 +71,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule private bool CanEdit() { - if(!m_security.CanEditObject(this)) + if (!m_security.CanEditObject(this)) { throw new SecurityException("Insufficient Permission to edit object with UUID [" + GetSOP().UUID + "]"); } @@ -672,7 +672,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule get { return m_sculptType; } set { - if(!CanEdit()) + if (!CanEdit()) return; m_sculptType = value; -- cgit v1.1 From 8c101d24dfc48ae20ddf963e51b07b43019930ea Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Tue, 18 Aug 2009 00:23:02 +1000 Subject: * Implementing a bunch of Unimplemented MRM stubs. --- .../Scripting/Minimodule/SOPObjectMaterial.cs | 29 +++++++++++++++++++--- .../Scripting/Minimodule/SPAvatar.cs | 8 ++---- 2 files changed, 27 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs index 68f2f52..0cba6af 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs @@ -91,24 +91,45 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public bool Bright { get { return GetTexface().Fullbright; } - set { throw new System.NotImplementedException(); } + set + { + Primitive.TextureEntry tex = m_parent.Shape.Textures; + Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); + texface.Fullbright = value; + tex.FaceTextures[m_face] = texface; + m_parent.UpdateTexture(tex); + } } public double Bloom { get { return GetTexface().Glow; } - set { throw new System.NotImplementedException(); } + set + { + Primitive.TextureEntry tex = m_parent.Shape.Textures; + Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); + texface.Glow = (float) value; + tex.FaceTextures[m_face] = texface; + m_parent.UpdateTexture(tex); + } } public bool Shiny { get { return GetTexface().Shiny != Shininess.None; } - set { throw new System.NotImplementedException(); } + set + { + Primitive.TextureEntry tex = m_parent.Shape.Textures; + Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); + texface.Shiny = value ? Shininess.High : Shininess.None; + tex.FaceTextures[m_face] = texface; + m_parent.UpdateTexture(tex); + } } public bool BumpMap { - get { throw new System.NotImplementedException(); } + get { return GetTexface().Bump == Bumpiness.None; } set { throw new System.NotImplementedException(); } } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs index 4600836..4427426 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs @@ -25,17 +25,13 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using System; -using System.Reflection; using System.Collections; using System.Collections.Generic; - +using System.Security; using OpenMetaverse; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Interfaces; -using log4net; - namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { class SPAvatar : System.MarshalByRefObject, IAvatar @@ -60,7 +56,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public string Name { get { return GetSP().Name; } - set { throw new InvalidOperationException("Avatar Names are a read-only property."); } + set { throw new SecurityException("Avatar Names are a read-only property."); } } public UUID GlobalID -- cgit v1.1 From 30c4aa55e6f18d153f164529a3435e44754c5352 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Tue, 18 Aug 2009 00:58:42 +1000 Subject: Added additional configuration options for MRM Security. See OpenSim.ini.example under the [MRM] section. --- .../Scripting/Minimodule/MRMModule.cs | 30 ++++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 9042e0d..bf523dd 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -211,25 +211,39 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { if (script.StartsWith("//MRM:C#")) { - if (m_scene.GetSceneObjectPart(localID).OwnerID != m_scene.RegionInfo.MasterAvatarAssignedUUID - || - m_scene.GetSceneObjectPart(localID).CreatorID != m_scene.RegionInfo.MasterAvatarAssignedUUID) - return; + if (m_config.GetBoolean("OwnerOnly", true)) + if (m_scene.GetSceneObjectPart(localID).OwnerID != m_scene.RegionInfo.MasterAvatarAssignedUUID + || m_scene.GetSceneObjectPart(localID).CreatorID != m_scene.RegionInfo.MasterAvatarAssignedUUID) + return; script = ConvertMRMKeywords(script); try { - m_log.Info("[MRM] Found C# MRM - Starting in AppDomain with " + m_config.GetString("permissionLevel", "Internet") + "-level security."); + AppDomain target; + if (m_config.GetBoolean("Sandboxed", true)) + { + m_log.Info("[MRM] Found C# MRM - Starting in AppDomain with " + + m_config.GetString("SandboxLevel", "Internet") + "-level security."); - string domainName = UUID.Random().ToString(); - AppDomain target = CreateRestrictedDomain(m_config.GetString("permissionLevel", "Internet"), - domainName); + string domainName = UUID.Random().ToString(); + target = CreateRestrictedDomain(m_config.GetString("SandboxLevel", "Internet"), + domainName); + } + else + { + m_log.Info("[MRM] Found C# MRM - Starting in current AppDomain"); + m_log.Warn( + "[MRM] Security Risk: AppDomain is run in current context. Use only in trusted environments."); + target = AppDomain.CurrentDomain; + } + m_log.Info("[MRM] Unwrapping into target AppDomain"); MRMBase mmb = (MRMBase) target.CreateInstanceFromAndUnwrap( CompileFromDotNetText(script, itemID.ToString()), "OpenSim.MiniModule"); + m_log.Info("[MRM] Initialising MRM Globals"); InitializeMRM(mmb, localID, itemID); m_scripts[itemID] = mmb; -- cgit v1.1 From ee205e7e812e170f670e690a4e0fa9caa652f226 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 1 Oct 2009 01:00:09 +0900 Subject: Formatting cleanup. --- OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index bf523dd..ce50f9e 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -136,7 +136,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule /// /// AppDomain with a restricted security policy /// Substantial portions of this function from: http://blogs.msdn.com/shawnfa/archive/2004/10/25/247379.aspx - /// Valid permissionSetName values are: + /// Valid permissionSetName values are: /// * FullTrust /// * SkipVerification /// * Execution -- cgit v1.1 From 2107b67f1b145f7718fdb1450be1a7b8dd1a0bf7 Mon Sep 17 00:00:00 2001 From: dr scofield (aka dirk husemann) Date: Fri, 2 Oct 2009 11:10:52 +0200 Subject: - cleaning up LandData/ILandObject capitalization issues - adding LandDataSerializer to OAR mechanics --- .../Region/OptionalModules/Scripting/Minimodule/LOParcel.cs | 10 +++++----- OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs index 37c7434..8df020f 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs @@ -48,14 +48,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public string Name { - get { return GetLO().landData.Name; } - set { GetLO().landData.Name = value; } + get { return GetLO().LandData.Name; } + set { GetLO().LandData.Name = value; } } public string Description { - get { return GetLO().landData.Description; } - set { GetLO().landData.Description = value; } + get { return GetLO().LandData.Description; } + set { GetLO().LandData.Description = value; } } public ISocialEntity Owner @@ -66,7 +66,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public bool[,] Bitmap { - get { return GetLO().landBitmap; } + get { return GetLO().LandBitmap; } } } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index da5ea0d..6fcb5d0 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs @@ -191,7 +191,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule foreach (ILandObject landObject in m_los) { - m_parcels.Add(new LOParcel(m_internalScene, landObject.landData.LocalID)); + m_parcels.Add(new LOParcel(m_internalScene, landObject.LandData.LocalID)); } return m_parcels.ToArray(); -- cgit v1.1 From d44b50ee462978b4899c0b142f6ecbfb553f06b6 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 15 Oct 2009 15:25:02 -0700 Subject: * Removed some of the redundant broadcast functions in Scene and SceneGraph so it is clear who/what the broadcast is going to each time * Removed two redundant parameters from SceneObjectPart * Changed some code in terse update sending that was meant to work with references to work with value types (since Vector3 and Quaternion are structs) * Committing a preview of a new method for sending object updates efficiently (all commented out for now) --- OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index ce50f9e..4521f8e 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -259,7 +259,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule if (e.InnerException != null) m_log.Error("[MRM] " + e.InnerException); - m_scene.Broadcast(delegate(IClientAPI user) + m_scene.ForEachClient(delegate(IClientAPI user) { user.SendAlertMessage( "MRM UnAuthorizedAccess: " + e); @@ -268,7 +268,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule catch (Exception e) { m_log.Info("[MRM] Error: " + e); - m_scene.Broadcast(delegate(IClientAPI user) + m_scene.ForEachClient(delegate(IClientAPI user) { user.SendAlertMessage( "Compile error while building MRM script, check OpenSim console for more information."); -- cgit v1.1 From d199767e6991d6f368661fce9c5a072e564b8a4b Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Sun, 25 Oct 2009 23:16:12 -0700 Subject: Experimental change of PhysicsVector to Vector3. Untested --- .../Scripting/Minimodule/SOPObject.cs | 42 +++++++++++----------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 292e345..1f1ebae 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -525,8 +525,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { get { - PhysicsVector tmp = GetSOP().PhysActor.GeometricCenter; - return new Vector3(tmp.X, tmp.Y, tmp.Z); + Vector3 tmp = GetSOP().PhysActor.GeometricCenter; + return tmp; } } @@ -534,8 +534,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { get { - PhysicsVector tmp = GetSOP().PhysActor.CenterOfMass; - return new Vector3(tmp.X, tmp.Y, tmp.Z); + Vector3 tmp = GetSOP().PhysActor.CenterOfMass; + return tmp; } } @@ -543,15 +543,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { get { - PhysicsVector tmp = GetSOP().PhysActor.RotationalVelocity; - return new Vector3(tmp.X, tmp.Y, tmp.Z); + Vector3 tmp = GetSOP().PhysActor.RotationalVelocity; + return tmp; } set { if (!CanEdit()) return; - GetSOP().PhysActor.RotationalVelocity = new PhysicsVector(value.X, value.Y, value.Z); + GetSOP().PhysActor.RotationalVelocity = value; } } @@ -559,15 +559,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { get { - PhysicsVector tmp = GetSOP().PhysActor.Velocity; - return new Vector3(tmp.X, tmp.Y, tmp.Z); + Vector3 tmp = GetSOP().PhysActor.Velocity; + return tmp; } set { if (!CanEdit()) return; - GetSOP().PhysActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z); + GetSOP().PhysActor.Velocity = value; } } @@ -575,15 +575,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { get { - PhysicsVector tmp = GetSOP().PhysActor.Torque; - return new Vector3(tmp.X, tmp.Y, tmp.Z); + Vector3 tmp = GetSOP().PhysActor.Torque; + return tmp; } set { if (!CanEdit()) return; - GetSOP().PhysActor.Torque = new PhysicsVector(value.X, value.Y, value.Z); + GetSOP().PhysActor.Torque = value; } } @@ -591,8 +591,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { get { - PhysicsVector tmp = GetSOP().PhysActor.Acceleration; - return new Vector3(tmp.X, tmp.Y, tmp.Z); + Vector3 tmp = GetSOP().PhysActor.Acceleration; + return tmp; } } @@ -600,15 +600,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { get { - PhysicsVector tmp = GetSOP().PhysActor.Force; - return new Vector3(tmp.X, tmp.Y, tmp.Z); + Vector3 tmp = GetSOP().PhysActor.Force; + return tmp; } set { if (!CanEdit()) return; - GetSOP().PhysActor.Force = new PhysicsVector(value.X, value.Y, value.Z); + GetSOP().PhysActor.Force = value; } } @@ -627,7 +627,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule if (!CanEdit()) return; - GetSOP().PhysActor.AddForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce); + GetSOP().PhysActor.AddForce(force, pushforce); } public void AddAngularForce(Vector3 force, bool pushforce) @@ -635,7 +635,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule if (!CanEdit()) return; - GetSOP().PhysActor.AddAngularForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce); + GetSOP().PhysActor.AddAngularForce(force, pushforce); } public void SetMomentum(Vector3 momentum) @@ -643,7 +643,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule if (!CanEdit()) return; - GetSOP().PhysActor.SetMomentum(new PhysicsVector(momentum.X, momentum.Y, momentum.Z)); + GetSOP().PhysActor.SetMomentum(momentum); } #endregion -- cgit v1.1 From afef1ac191d32e9c1514c294b17e404b1d4ae217 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 5 Nov 2009 13:10:58 -0800 Subject: Changing the AssetBase constructors to avoid initializing assets with an unknown asset type, and log an error if it ever does happen --- OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs index 963cab5..8ea7ad3 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs @@ -49,11 +49,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public UUID SaveBitmap(Bitmap data, bool lossless, bool temporary) { - AssetBase asset = new AssetBase(); - asset.FullID = UUID.Random(); + AssetBase asset = new AssetBase(UUID.Random(), "MRMDynamicImage", (sbyte)AssetType.Texture); asset.Data = OpenJPEG.EncodeFromImage(data, lossless); - asset.Name = "MRMDynamicImage"; - asset.Type = 0; asset.Description = "MRM Image"; asset.Local = false; asset.Temporary = temporary; -- cgit v1.1 From de59910758483f18068f786dc0b5ecab66a5e08b Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 21 Dec 2009 14:46:07 +0000 Subject: Patch from Ziah. Mantis #4456: Patch to implement some minor MRM Functions : SitTarget, SitTargetText, TouchText and Text --- .../Scripting/Minimodule/SOPObject.cs | 40 +++++++++++++++++----- 1 file changed, 32 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 1f1ebae..143c454 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -258,26 +258,50 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public Vector3 SitTarget { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } + get { return GetSOP().SitTargetPosition; } + set + { + if (CanEdit()) + { + GetSOP().SitTargetPosition = value; + } + } } public string SitTargetText { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } + get { return GetSOP().SitName; } + set + { + if (CanEdit()) + { + GetSOP().SitName = value; + } + } } public string TouchText { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } + get { return GetSOP().TouchName; } + set + { + if (CanEdit()) + { + GetSOP().TouchName = value; + } + } } public string Text { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } + get { return GetSOP().Text; } + set + { + if (CanEdit()) + { + GetSOP().SetText(value,new Vector3(1.0f,1.0f,1.0f),1.0f); + } + } } public bool IsRotationLockedX -- cgit v1.1 From fddefff28479b6874235419dd5d26214afabb4f2 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Wed, 23 Dec 2009 10:34:11 -0800 Subject: Thank you kindly, Ziah for a patch that adds the channel to the class ChatEventArgs and retrieves it's value along with the others from the OSChatMessage in HandleChatPackage. With this the MRM Script can check if a ChatEvent is coming in on a specifc Channel. The Second Part adds the Method say(string msg , int channel) to send a chat message on the specified channel. The idea behind this is to enable MRM's to communicate with regular LSL or OSSL Scripts so that they may can act as a Backend to access a Database or do business Logic for those Scripts. Signed-off-by: Charles Krinke --- .../OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs | 2 ++ .../OptionalModules/Scripting/Minimodule/Interfaces/IWorld.cs | 1 + OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs | 9 +++++++++ OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs | 6 ++++-- 4 files changed, 16 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs index 19f7210..9d64667 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs @@ -179,6 +179,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule /// /// The message to send to the user void Say(string msg); + + void Say(string msg,int channel); //// /// Grants access to the objects inventory diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IWorld.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IWorld.cs index 3c14ed5..3b3b3d0 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IWorld.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IWorld.cs @@ -41,6 +41,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { public string Text; public IEntity Sender; + public int Channel; } public delegate void OnChatDelegate(IWorld sender, ChatEventArgs e); diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 143c454..9596d13 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -384,6 +384,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule m_rootScene.SimChat(msg, ChatTypeEnum.Say, sop.AbsolutePosition, sop.Name, sop.UUID, false); } + public void Say(string msg,int channel) + { + if (!CanEdit()) + return; + + SceneObjectPart sop = GetSOP(); + m_rootScene.SimChat(Utils.StringToBytes(msg), ChatTypeEnum.Say,channel, sop.AbsolutePosition, sop.Name, sop.UUID, false); + } + #endregion diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index 6fcb5d0..82020cb 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs @@ -148,7 +148,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule ChatEventArgs e = new ChatEventArgs(); e.Sender = new SOPObject(m_internalScene, ((SceneObjectPart) chat.SenderObject).LocalId, m_security); e.Text = chat.Message; - + e.Channel = chat.Channel; + _OnChat(this, e); return; } @@ -158,7 +159,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule ChatEventArgs e = new ChatEventArgs(); e.Sender = new SPAvatar(m_internalScene, chat.SenderUUID, m_security); e.Text = chat.Message; - + e.Channel = chat.Channel; + _OnChat(this, e); return; } -- cgit v1.1 From 70d5b1c34cf2eb6621f383169fdee03966850762 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 4 Jan 2010 06:10:45 +0900 Subject: Formatting cleanup. Add copyright headers. --- .../OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs | 4 ++-- .../Region/OptionalModules/Scripting/Minimodule/SOPObject.cs | 10 +++++----- OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs index 9d64667..30580e7 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs @@ -179,8 +179,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule /// /// The message to send to the user void Say(string msg); - - void Say(string msg,int channel); + + void Say(string msg,int channel); //// /// Grants access to the objects inventory diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 9596d13..31f28e0 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -264,7 +264,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule if (CanEdit()) { GetSOP().SitTargetPosition = value; - } + } } } @@ -276,7 +276,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule if (CanEdit()) { GetSOP().SitName = value; - } + } } } @@ -288,7 +288,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule if (CanEdit()) { GetSOP().TouchName = value; - } + } } } @@ -384,7 +384,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule m_rootScene.SimChat(msg, ChatTypeEnum.Say, sop.AbsolutePosition, sop.Name, sop.UUID, false); } - public void Say(string msg,int channel) + public void Say(string msg,int channel) { if (!CanEdit()) return; @@ -392,7 +392,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule SceneObjectPart sop = GetSOP(); m_rootScene.SimChat(Utils.StringToBytes(msg), ChatTypeEnum.Say,channel, sop.AbsolutePosition, sop.Name, sop.UUID, false); } - + #endregion diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index 82020cb..c7cd37b 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs @@ -149,7 +149,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule e.Sender = new SOPObject(m_internalScene, ((SceneObjectPart) chat.SenderObject).LocalId, m_security); e.Text = chat.Message; e.Channel = chat.Channel; - + _OnChat(this, e); return; } @@ -160,7 +160,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule e.Sender = new SPAvatar(m_internalScene, chat.SenderUUID, m_security); e.Text = chat.Message; e.Channel = chat.Channel; - + _OnChat(this, e); return; } -- cgit v1.1 From 3c90d834eac382af5edf091e83aea1ffcce91792 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 10 Jan 2010 22:41:42 +0000 Subject: Remove all references to master avatar, replacing with estate owner where appropriate. This changes the behavior of the REST plugins and RemoteAdmin's region creation process. --- OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 4521f8e..19f9a82 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -212,8 +212,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule if (script.StartsWith("//MRM:C#")) { if (m_config.GetBoolean("OwnerOnly", true)) - if (m_scene.GetSceneObjectPart(localID).OwnerID != m_scene.RegionInfo.MasterAvatarAssignedUUID - || m_scene.GetSceneObjectPart(localID).CreatorID != m_scene.RegionInfo.MasterAvatarAssignedUUID) + if (m_scene.GetSceneObjectPart(localID).OwnerID != m_scene.RegionInfo.EstateSettings.EstateOwner) + || m_scene.GetSceneObjectPart(localID).CreatorID != m_scene.RegionInfo.EstateSettings.EstateOwner) return; script = ConvertMRMKeywords(script); @@ -280,7 +280,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public void GetGlobalEnvironment(uint localID, out IWorld world, out IHost host) { // UUID should be changed to object owner. - UUID owner = m_scene.RegionInfo.MasterAvatarAssignedUUID; + UUID owner = m_scene.RegionInfo.EstateSettings.EstateOwner) SEUser securityUser = new SEUser(owner, "Name Unassigned"); SecurityCredential creds = new SecurityCredential(securityUser, m_scene); -- cgit v1.1 From e31131b40fbadbba6e28d2386168ecaf2f9f743a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 10 Jan 2010 15:41:49 -0800 Subject: Some typos fixed related to master avie removal --- OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 19f9a82..b4866b2 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -212,7 +212,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule if (script.StartsWith("//MRM:C#")) { if (m_config.GetBoolean("OwnerOnly", true)) - if (m_scene.GetSceneObjectPart(localID).OwnerID != m_scene.RegionInfo.EstateSettings.EstateOwner) + if (m_scene.GetSceneObjectPart(localID).OwnerID != m_scene.RegionInfo.EstateSettings.EstateOwner || m_scene.GetSceneObjectPart(localID).CreatorID != m_scene.RegionInfo.EstateSettings.EstateOwner) return; @@ -280,7 +280,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public void GetGlobalEnvironment(uint localID, out IWorld world, out IHost host) { // UUID should be changed to object owner. - UUID owner = m_scene.RegionInfo.EstateSettings.EstateOwner) + UUID owner = m_scene.RegionInfo.EstateSettings.EstateOwner; SEUser securityUser = new SEUser(owner, "Name Unassigned"); SecurityCredential creds = new SecurityCredential(securityUser, m_scene); -- cgit v1.1 From ec3c31e61e5e540f822891110df9bc978655bbaf Mon Sep 17 00:00:00 2001 From: Revolution Date: Fri, 22 Jan 2010 18:09:33 -0600 Subject: Updates all IRegionModules to the new style region modules. Signed-off-by: Melanie --- .../Scripting/Minimodule/MRMModule.cs | 64 ++++++++++++++-------- 1 file changed, 41 insertions(+), 23 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 4521f8e..f24bcdc 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -38,6 +38,7 @@ using System.Security.Policy; using System.Text; using log4net; using Microsoft.CSharp; +using Mono.Addins; using Nini.Config; using OpenMetaverse; using OpenSim.Framework; @@ -46,7 +47,8 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - public class MRMModule : IRegionModule, IMRMModule + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + public class MRMModule : INonSharedRegionModule, IMRMModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_scene; @@ -62,12 +64,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule private IConfig m_config; + private bool m_hidden = true; + public void RegisterExtension(T instance) { m_extensions[typeof (T)] = instance; } - public void Initialise(Scene scene, IConfigSource source) + public void Initialise(IConfigSource source) { if (source.Configs["MRM"] != null) { @@ -76,19 +80,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule if (source.Configs["MRM"].GetBoolean("Enabled", false)) { m_log.Info("[MRM] Enabling MRM Module"); - m_scene = scene; - + // when hidden, we don't listen for client initiated script events // only making the MRM engine available for region modules - if (!source.Configs["MRM"].GetBoolean("Hidden", false)) - { - scene.EventManager.OnRezScript += EventManager_OnRezScript; - scene.EventManager.OnStopScript += EventManager_OnStopScript; - } - - scene.EventManager.OnFrame += EventManager_OnFrame; - - scene.RegisterModuleInterface(this); + m_hidden = source.Configs["MRM"].GetBoolean("Hidden", false); } else { @@ -101,6 +96,39 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule } } + public Type ReplaceableInterface + { + get { return null; } + } + + public void AddRegion(Scene scene) + { + m_scene = scene; + if (!m_hidden) + { + scene.EventManager.OnRezScript += EventManager_OnRezScript; + scene.EventManager.OnStopScript += EventManager_OnStopScript; + } + scene.EventManager.OnFrame += EventManager_OnFrame; + + scene.RegisterModuleInterface(this); + } + public void RegionLoaded(Scene scene) + { + } + + public void RemoveRegion(Scene scene) + { + if (!m_hidden) + { + scene.EventManager.OnRezScript -= EventManager_OnRezScript; + scene.EventManager.OnStopScript -= EventManager_OnStopScript; + } + scene.EventManager.OnFrame -= EventManager_OnFrame; + + scene.UnregisterModuleInterface(this); + } + void EventManager_OnStopScript(uint localID, UUID itemID) { if (m_scripts.ContainsKey(itemID)) @@ -302,11 +330,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule mmb.InitMiniModule(world, host, itemID); } - public void PostInitialise() - { - - } - public void Close() { foreach (KeyValuePair pair in m_scripts) @@ -320,11 +343,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule get { return "MiniRegionModule"; } } - public bool IsSharedModule - { - get { return false; } - } - /// /// Stolen from ScriptEngine Common /// -- cgit v1.1 From a87a247f0548d39a8c39b1d28123d7da8db44598 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 29 Jan 2010 07:20:13 +0000 Subject: Revert "Updates all IRegionModules to the new style region modules." This reverts commit ec3c31e61e5e540f822891110df9bc978655bbaf. --- .../Scripting/Minimodule/MRMModule.cs | 64 ++++++++-------------- 1 file changed, 23 insertions(+), 41 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index f24bcdc..4521f8e 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -38,7 +38,6 @@ using System.Security.Policy; using System.Text; using log4net; using Microsoft.CSharp; -using Mono.Addins; using Nini.Config; using OpenMetaverse; using OpenSim.Framework; @@ -47,8 +46,7 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] - public class MRMModule : INonSharedRegionModule, IMRMModule + public class MRMModule : IRegionModule, IMRMModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_scene; @@ -64,14 +62,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule private IConfig m_config; - private bool m_hidden = true; - public void RegisterExtension(T instance) { m_extensions[typeof (T)] = instance; } - public void Initialise(IConfigSource source) + public void Initialise(Scene scene, IConfigSource source) { if (source.Configs["MRM"] != null) { @@ -80,10 +76,19 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule if (source.Configs["MRM"].GetBoolean("Enabled", false)) { m_log.Info("[MRM] Enabling MRM Module"); - + m_scene = scene; + // when hidden, we don't listen for client initiated script events // only making the MRM engine available for region modules - m_hidden = source.Configs["MRM"].GetBoolean("Hidden", false); + if (!source.Configs["MRM"].GetBoolean("Hidden", false)) + { + scene.EventManager.OnRezScript += EventManager_OnRezScript; + scene.EventManager.OnStopScript += EventManager_OnStopScript; + } + + scene.EventManager.OnFrame += EventManager_OnFrame; + + scene.RegisterModuleInterface(this); } else { @@ -96,39 +101,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule } } - public Type ReplaceableInterface - { - get { return null; } - } - - public void AddRegion(Scene scene) - { - m_scene = scene; - if (!m_hidden) - { - scene.EventManager.OnRezScript += EventManager_OnRezScript; - scene.EventManager.OnStopScript += EventManager_OnStopScript; - } - scene.EventManager.OnFrame += EventManager_OnFrame; - - scene.RegisterModuleInterface(this); - } - public void RegionLoaded(Scene scene) - { - } - - public void RemoveRegion(Scene scene) - { - if (!m_hidden) - { - scene.EventManager.OnRezScript -= EventManager_OnRezScript; - scene.EventManager.OnStopScript -= EventManager_OnStopScript; - } - scene.EventManager.OnFrame -= EventManager_OnFrame; - - scene.UnregisterModuleInterface(this); - } - void EventManager_OnStopScript(uint localID, UUID itemID) { if (m_scripts.ContainsKey(itemID)) @@ -330,6 +302,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule mmb.InitMiniModule(world, host, itemID); } + public void PostInitialise() + { + + } + public void Close() { foreach (KeyValuePair pair in m_scripts) @@ -343,6 +320,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule get { return "MiniRegionModule"; } } + public bool IsSharedModule + { + get { return false; } + } + /// /// Stolen from ScriptEngine Common /// -- cgit v1.1 From 4c1365f1496b2c60c313b6d221362d3e09a8c1d4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 30 Jan 2010 00:15:37 +0000 Subject: apply http://opensimulator.org/mantis/view.php?id=4486 fix compilation of mrm scripts using microthreaded parmeter Thanks ziah --- OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 4521f8e..f2adcb7 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -116,7 +116,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule static string ConvertMRMKeywords(string script) { - script = script.Replace("microthreaded void ", "IEnumerable"); + script = script.Replace("microthreaded void", "IEnumerable"); script = script.Replace("relax;", "yield return null;"); return script; -- cgit v1.1 From 9821c4f566e11c75c8d87721777480c5b2e2bd4e Mon Sep 17 00:00:00 2001 From: Revolution Date: Sun, 14 Feb 2010 15:41:57 -0600 Subject: Revolution is on the roll again! :) Fixes: Undo, T-pose of others on login, modifiedBulletX works again, feet now stand on the ground instead of in the ground, adds checks to CombatModule. Adds: Redo, Land Undo, checks to agentUpdate (so one can not fall off of a region), more vehicle parts. Finishes almost all of LSL (1 function left, 2 events). Direct flames and kudos to Revolution, please Signed-off-by: Melanie --- OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs | 2 +- OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 31f28e0..5bfe4be 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -767,7 +767,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule if (!CanEdit()) return; - GetSOP().SendSound(asset.ToString(), volume, true, 0); + GetSOP().SendSound(asset.ToString(), volume, true, 0, 0, false, false); } #endregion diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index c7cd37b..45bb005 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs @@ -231,7 +231,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule if (soundModule != null) { soundModule.TriggerSound(audio, UUID.Zero, UUID.Zero, UUID.Zero, volume, position, - m_internalScene.RegionInfo.RegionHandle); + m_internalScene.RegionInfo.RegionHandle, 0); } } @@ -241,7 +241,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule if (soundModule != null) { soundModule.TriggerSound(audio, UUID.Zero, UUID.Zero, UUID.Zero, 1.0, position, - m_internalScene.RegionInfo.RegionHandle); + m_internalScene.RegionInfo.RegionHandle, 0); } } -- cgit v1.1 From 68b494b2cc54cfdd8fa8a0736332046de3887d6f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 19 Feb 2010 22:44:33 +0000 Subject: Apply http://opensimulator.org/mantis/view.php?id=4495 Adds IsChildAgent property to IAvatar in MRM. Thanks ziah --- .../OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs | 3 +++ OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs | 5 +++++ 2 files changed, 8 insertions(+) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs index 03c1e95..3d49732 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs @@ -34,6 +34,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { public interface IAvatar : IEntity { + + bool IsChildAgent { get; } + //// /// Array of worn attachments, empty but not null, if no attachments are worn /// diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs index 4427426..0786bd9 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs @@ -70,6 +70,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule set { GetSP().TeleportWithMomentum(value); } } + public bool IsChildAgent + { + get { return GetSP().IsChildAgent; } + } + #region IAvatar implementation public IAvatarAttachment[] Attachments { -- cgit v1.1 From 7665aad002ef066fc31fa9497225d2668641c769 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 22 Feb 2010 13:27:17 -0800 Subject: * Adds CreatorID to asset metadata. This is just the plumbing to support CreatorID, it doesn't modify database backends or OAR files to support storing/loading it --- OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs index 8ea7ad3..4a5248b 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs @@ -49,7 +49,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public UUID SaveBitmap(Bitmap data, bool lossless, bool temporary) { - AssetBase asset = new AssetBase(UUID.Random(), "MRMDynamicImage", (sbyte)AssetType.Texture); + AssetBase asset = new AssetBase(UUID.Random(), "MRMDynamicImage", (sbyte)AssetType.Texture, m_scene.RegionInfo.RegionID); asset.Data = OpenJPEG.EncodeFromImage(data, lossless); asset.Description = "MRM Image"; asset.Local = false; -- cgit v1.1 From df76e95aa2dc9f3f3a0c546761b7624adc183ed0 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 22 Feb 2010 14:18:59 -0800 Subject: Changed asset CreatorID to a string --- OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs index 4a5248b..a0dc38b 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs @@ -49,7 +49,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public UUID SaveBitmap(Bitmap data, bool lossless, bool temporary) { - AssetBase asset = new AssetBase(UUID.Random(), "MRMDynamicImage", (sbyte)AssetType.Texture, m_scene.RegionInfo.RegionID); + AssetBase asset = new AssetBase(UUID.Random(), "MRMDynamicImage", (sbyte)AssetType.Texture, m_scene.RegionInfo.RegionID.ToString()); asset.Data = OpenJPEG.EncodeFromImage(data, lossless); asset.Description = "MRM Image"; asset.Local = false; -- cgit v1.1 From fb7458be3185802c4511306c0cda7648d702de59 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 25 Apr 2010 10:13:13 +0300 Subject: Minor spelling corrections in MiniModule: "RetreiveAsset" changed to "RetrieveAsset" and 'm_rootSceene' to m_rootScene'. --- .../Scripting/Minimodule/Interfaces/IInventoryItem.cs | 2 +- .../Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs index 5fac189..16cd7e4 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs @@ -39,6 +39,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { int Type { get; } UUID AssetID { get; } - T RetreiveAsset() where T : Asset, new(); + T RetrieveAsset() where T : Asset, new(); } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs index 5bf29d7..bf85cbc 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs @@ -39,11 +39,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public class InventoryItem : IInventoryItem { TaskInventoryItem m_privateItem; - Scene m_rootSceene; + Scene m_rootScene; public InventoryItem(Scene rootScene, TaskInventoryItem internalItem) { - m_rootSceene = rootScene; + m_rootScene = rootScene; m_privateItem = internalItem; } @@ -82,9 +82,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public UUID AssetID { get { return m_privateItem.AssetID; } } // This method exposes OpenSim/OpenMetaverse internals and needs to be replaced with a IAsset specific to MRM. - public T RetreiveAsset() where T : OpenMetaverse.Assets.Asset, new() + public T RetrieveAsset() where T : OpenMetaverse.Assets.Asset, new() { - AssetBase a = m_rootSceene.AssetService.Get(AssetID.ToString()); + AssetBase a = m_rootScene.AssetService.Get(AssetID.ToString()); T result = new T(); if ((sbyte)result.AssetType != a.Type) -- cgit v1.1 From 074937e0e510e9be6b7a0e5639d93a93be38d6b1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 21 May 2010 23:34:47 +0100 Subject: Apply http://opensimulator.org/mantis/view.php?id=4627 Adds OwnerId and CreatorId properties to MRM.IObject --- .../OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs | 10 ++++++++++ .../Region/OptionalModules/Scripting/Minimodule/SOPObject.cs | 10 ++++++++++ 2 files changed, 20 insertions(+) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs index 30580e7..29f7f68 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs @@ -98,6 +98,16 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule String Description { get; set; } /// + /// Returns the UUID of the Owner of the Object. + /// + UUID OwnerId { get; } + + /// + /// Returns the UUID of the Creator of the Object. + /// + UUID CreatorId { get; } + + /// /// Returns the root object of a linkset. If this object is the root, it will return itself. /// IObject Root { get; } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 5bfe4be..f51498c 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -169,6 +169,16 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule } } + public UUID OwnerId + { + get { return GetSOP().OwnerID;} + } + + public UUID CreatorId + { + get { return GetSOP().CreatorID;} + } + public IObject[] Children { get -- cgit v1.1 From b2197e3b94f3865ba3927a4aaaf38cffe141cd72 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 21 May 2010 23:37:05 +0100 Subject: Apply http://opensimulator.org/mantis/view.php?id=4632 Adds dialog methods for MRM. Thanks ziah. --- .../Scripting/Minimodule/Interfaces/IObject.cs | 18 ++++++++- .../Scripting/Minimodule/SOPObject.cs | 44 +++++++++++++++++++++- 2 files changed, 60 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs index 29f7f68..e189489 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs @@ -189,9 +189,25 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule /// /// The message to send to the user void Say(string msg); - + + /// + /// Causes the object to speak to on a specific channel, + /// equivilent to LSL/OSSL llSay + /// + /// The message to send to the user + /// The channel on which to send the message void Say(string msg,int channel); + /// + /// Opens a Dialog Panel in the Users Viewer, + /// equivilent to LSL/OSSL llDialog + /// + /// The UUID of the Avatar to which the Dialog should be send + /// The Message to display at the top of the Dialog + /// The Strings that act as label/value of the Bottons in the Dialog + /// The channel on which to send the response + void Dialog(UUID avatar, string message, string[] buttons, int chat_channel); + //// /// Grants access to the objects inventory /// diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index f51498c..96cccb7 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -31,6 +31,7 @@ using System.Security; using OpenMetaverse; using OpenMetaverse.Packets; using OpenSim.Framework; +using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.OptionalModules.Scripting.Minimodule.Object; using OpenSim.Region.Physics.Manager; @@ -402,7 +403,48 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule SceneObjectPart sop = GetSOP(); m_rootScene.SimChat(Utils.StringToBytes(msg), ChatTypeEnum.Say,channel, sop.AbsolutePosition, sop.Name, sop.UUID, false); } - + + public void Dialog(UUID avatar, string message, string[] buttons, int chat_channel) + { + if (!CanEdit()) + return; + + IDialogModule dm = m_rootScene.RequestModuleInterface(); + + if (dm == null) + return; + + if (buttons.Length < 1) + { + Say("ERROR: No less than 1 button can be shown",2147483647); + return; + } + if (buttons.Length > 12) + { + Say("ERROR: No more than 12 buttons can be shown",2147483647); + return; + } + + foreach(string button in buttons) + { + if (button == String.Empty) + { + Say("ERROR: button label cannot be blank",2147483647); + return; + } + if (button.Length > 24) + { + Say("ERROR: button label cannot be longer than 24 characters",2147483647); + return; + } + } + + dm.SendDialogToUser( + avatar, GetSOP().Name, GetSOP().UUID, GetSOP().OwnerID, + message, new UUID("00000000-0000-2222-3333-100000001000"), chat_channel, buttons); + + } + #endregion -- cgit v1.1 From 8031f8ec09df4f654c86a9c7bc498664f7b9d9dc Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 26 Aug 2010 00:08:53 +0100 Subject: Improve consistency of locking for SOG.m_parts in order to avoid race conditions in linking and unlinking --- .../OptionalModules/Scripting/Minimodule/SOPObject.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 96cccb7..34171b0 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -185,14 +185,19 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule get { SceneObjectPart my = GetSOP(); - int total = my.ParentGroup.Children.Count; - - IObject[] rets = new IObject[total]; - - int i = 0; - foreach (KeyValuePair pair in my.ParentGroup.Children) + IObject[] rets = null; + + lock (my.ParentGroup.Children) { - rets[i++] = new SOPObject(m_rootScene, pair.Value.LocalId, m_security); + int total = my.ParentGroup.Children.Count; + + rets = new IObject[total]; + + int i = 0; + foreach (KeyValuePair pair in my.ParentGroup.Children) + { + rets[i++] = new SOPObject(m_rootScene, pair.Value.LocalId, m_security); + } } return rets; -- cgit v1.1 From 1c0b4457cdcd543f04bc818a987f6e3f2311098d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 28 Aug 2010 00:40:33 +0100 Subject: Improve liveness by operating on list copies of SOG.Children where appropriate --- .../Scripting/Minimodule/SOPObject.cs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 34171b0..c439e3e 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -186,18 +186,20 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { SceneObjectPart my = GetSOP(); IObject[] rets = null; - + + int total = my.ParentGroup.PrimCount; + + rets = new IObject[total]; + + int i = 0; + + List partList = null; lock (my.ParentGroup.Children) + partList = new List(my.ParentGroup.Children.Values); + + foreach (SceneObjectPart part in partList) { - int total = my.ParentGroup.Children.Count; - - rets = new IObject[total]; - - int i = 0; - foreach (KeyValuePair pair in my.ParentGroup.Children) - { - rets[i++] = new SOPObject(m_rootScene, pair.Value.LocalId, m_security); - } + rets[i++] = new SOPObject(m_rootScene, part.LocalId, m_security); } return rets; -- cgit v1.1 From dd277a0d02f1aa79f4fcb5d108cbc696e90500c2 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 10 Sep 2010 12:04:12 -0700 Subject: First pass at cleaning up thread safety in EntityManager and SceneGraph --- .../Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs | 4 +++- OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs index 6ba5ccf..140264b 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs @@ -41,12 +41,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule private readonly Scene m_scene; private readonly IEnumerator m_sogEnum; private readonly ISecurityCredential m_security; + private readonly List m_entities; public IObjEnum(Scene scene, ISecurityCredential security) { m_scene = scene; m_security = security; - m_sogEnum = m_scene.Entities.GetAllByType().GetEnumerator(); + m_entities = new List(m_scene.Entities.GetEntities()); + m_sogEnum = m_entities.GetEnumerator(); } public void Dispose() diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index 45bb005..f2324d2 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs @@ -205,10 +205,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { get { - List ents = m_internalScene.Entities.GetAllByType(); - IAvatar[] rets = new IAvatar[ents.Count]; + EntityBase[] ents = m_internalScene.Entities.GetAllByType(); + IAvatar[] rets = new IAvatar[ents.Length]; - for (int i = 0; i < ents.Count; i++) + for (int i = 0; i < ents.Length; i++) { EntityBase ent = ents[i]; rets[i] = new SPAvatar(m_internalScene, ent.UUID, m_security); -- cgit v1.1 From f1f0bc23f4501ba99035283d3407ddad2b21b785 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sun, 12 Sep 2010 13:43:49 -0400 Subject: Formatting cleanup. --- OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index c439e3e..59ad9d8 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -432,7 +432,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule return; } - foreach(string button in buttons) + foreach (string button in buttons) { if (button == String.Empty) { @@ -448,7 +448,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule dm.SendDialogToUser( avatar, GetSOP().Name, GetSOP().UUID, GetSOP().OwnerID, - message, new UUID("00000000-0000-2222-3333-100000001000"), chat_channel, buttons); + message, new UUID("00000000-0000-2222-3333-100000001000"), chat_channel, buttons); } -- cgit v1.1 From 860b2a502f797e5822c6705d4639f370f3ac5861 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 16 Sep 2010 17:30:46 -0700 Subject: Changed SceneObjectGroup to store parts with the fast and thread-safe MapAndArray collection --- OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 59ad9d8..faed522 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -193,11 +193,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule int i = 0; - List partList = null; - lock (my.ParentGroup.Children) - partList = new List(my.ParentGroup.Children.Values); - - foreach (SceneObjectPart part in partList) + foreach (SceneObjectPart part in my.ParentGroup.Parts) { rets[i++] = new SOPObject(m_rootScene, part.LocalId, m_security); } -- cgit v1.1 From 267f18925d06ca05e2a5ffbfbb63582783762439 Mon Sep 17 00:00:00 2001 From: Master ScienceSim Date: Thu, 21 Oct 2010 16:48:58 -0700 Subject: First attempt to get multiple attachments working to support viewer2. The attachment code appears to work correctly for 1.23 viewers so, in spite of some big changes in the internal representation, there don't appear to be regressions. That being said, I still can't get a viewer2 avatar to show correctly. --- .../OptionalModules/Scripting/Minimodule/SPAvatar.cs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs index 0786bd9..922eaaf 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs @@ -29,6 +29,7 @@ using System.Collections; using System.Collections.Generic; using System.Security; using OpenMetaverse; +using OpenSim.Framework; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Interfaces; @@ -81,16 +82,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule get { List attachments = new List(); - Hashtable internalAttachments = GetSP().Appearance.GetAttachments(); - if (internalAttachments != null) + List internalAttachments = GetSP().Appearance.GetAttachments(); + foreach (AvatarAttachment attach in internalAttachments) { - foreach (DictionaryEntry element in internalAttachments) - { - Hashtable attachInfo = (Hashtable)element.Value; - attachments.Add(new SPAvatarAttachment(m_rootScene, this, (int) element.Key, - new UUID((string) attachInfo["item"]), - new UUID((string) attachInfo["asset"]), m_security)); - } + attachments.Add(new SPAvatarAttachment(m_rootScene, this, attach.AttachPoint, + new UUID(attach.ItemID), + new UUID(attach.AssetID), m_security)); } return attachments.ToArray(); -- cgit v1.1 From a331fd4e24012a246bea9ac11689afe933e7968e Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Wed, 27 Oct 2010 00:01:03 -0400 Subject: Formatting cleanup. --- .../Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 2ddc31b..f47e71c 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -50,7 +50,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_scene; - + private readonly Dictionary m_scripts = new Dictionary(); private readonly Dictionary m_extensions = new Dictionary(); @@ -77,7 +77,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { m_log.Info("[MRM] Enabling MRM Module"); m_scene = scene; - + // when hidden, we don't listen for client initiated script events // only making the MRM engine available for region modules if (!source.Configs["MRM"].GetBoolean("Hidden", false)) @@ -85,7 +85,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule scene.EventManager.OnRezScript += EventManager_OnRezScript; scene.EventManager.OnStopScript += EventManager_OnStopScript; } - + scene.EventManager.OnFrame += EventManager_OnFrame; scene.RegisterModuleInterface(this); @@ -304,7 +304,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public void PostInitialise() { - } public void Close() @@ -350,7 +349,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule if (!Directory.Exists(tmp)) Directory.CreateDirectory(tmp); - m_log.Info("MRM 2"); try @@ -396,8 +394,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule parameters.IncludeDebugInformation = true; - string rootPath = - Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); + string rootPath = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); List libraries = new List(); string[] lines = Script.Split(new string[] {"\n"}, StringSplitOptions.RemoveEmptyEntries); -- cgit v1.1 From 727838f914d8e8aaf77df79356ef9d234ffc1b23 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 28 Oct 2010 00:37:32 -0400 Subject: Formatting cleanup. --- OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs | 2 +- OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs index d8f7a84..3f1bd54 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ExtensionHandler.cs @@ -32,7 +32,7 @@ using OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - class ExtensionHandler : IExtension + class ExtensionHandler : IExtension { private readonly Dictionary m_instances; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index f47e71c..df60709 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -291,7 +291,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public void InitializeMRM(MRMBase mmb, uint localID, UUID itemID) { - m_log.Info("[MRM] Created MRM Instance"); IWorld world; -- cgit v1.1 From 6ae04448f73afdca791ea185fdc0e9c062dea87b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 25 Mar 2011 23:05:51 +0000 Subject: Start using IPrimCounts populated by PrimCountModule instead of LandData counts populated by LandManagementModule. In order to pass ILandObject into IClientAPI.SendLandProperties(), had to push ILandObject and IPrimCounts into OpenSim.Framework from OpenSim.Region.Framework.Interfaces, in order to avoid ci Counts are showing odd behaviour at the moment, this will be addressed shortly. --- OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs index 8df020f..c898da6 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/LOParcel.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; -- cgit v1.1 From 4f56c732bc00588cd8ced1be85bc4d13815f86bd Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 2 Apr 2011 02:29:42 +0100 Subject: Comment out some startup logging lines to make up for the one I added earlier on. Most of these are where the region modules are telling us they are disabled. Convention is only to log when enabled (even that is really noisy) --- .../Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index df60709..74f5208 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -75,7 +75,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule if (source.Configs["MRM"].GetBoolean("Enabled", false)) { - m_log.Info("[MRM] Enabling MRM Module"); + m_log.Info("[MRM]: Enabling MRM Module"); m_scene = scene; // when hidden, we don't listen for client initiated script events @@ -90,14 +90,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule scene.RegisterModuleInterface(this); } - else - { - m_log.Info("[MRM] Disabled MRM Module (Disabled in ini)"); - } - } - else - { - m_log.Info("[MRM] Disabled MRM Module (Default disabled)"); } } -- cgit v1.1 From d79c6c8820e7219afa3f01a0910a794bcdbb307d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 9 Jul 2011 00:42:48 +0100 Subject: Rename SetSculptData() to SetSculptProperties(), since this is what it does (setting SculptData is done through the property) --- OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index faed522..aa23fee 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -801,7 +801,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule // retain pathcurve shapeBlock.PathCurve = part.Shape.PathCurve; - part.Shape.SetSculptData((byte)type, sculptId); + part.Shape.SetSculptProperties((byte)type, sculptId); part.Shape.SculptEntry = true; part.UpdateShape(shapeBlock); } -- cgit v1.1 From 66f4ce354f57646de32b376cba79dfc6ded17c14 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 5 Dec 2011 19:01:14 +0000 Subject: Fix CHANGED_TEXTURE and CHANGED_COLOR. --- .../OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs index 0cba6af..cea738c 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectMaterial.cs @@ -55,7 +55,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); texface.RGBA = new Color4(value.R,value.G,value.B,value.A); tex.FaceTextures[m_face] = texface; - m_parent.UpdateTexture(tex); + m_parent.UpdateTextureEntry(tex.GetBytes()); } } @@ -72,7 +72,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); texface.TextureID = value; tex.FaceTextures[m_face] = texface; - m_parent.UpdateTexture(tex); + m_parent.UpdateTextureEntry(tex.GetBytes()); } } @@ -97,7 +97,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); texface.Fullbright = value; tex.FaceTextures[m_face] = texface; - m_parent.UpdateTexture(tex); + m_parent.UpdateTextureEntry(tex.GetBytes()); } } @@ -110,7 +110,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); texface.Glow = (float) value; tex.FaceTextures[m_face] = texface; - m_parent.UpdateTexture(tex); + m_parent.UpdateTextureEntry(tex.GetBytes()); } } @@ -123,7 +123,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); texface.Shiny = value ? Shininess.High : Shininess.None; tex.FaceTextures[m_face] = texface; - m_parent.UpdateTexture(tex); + m_parent.UpdateTextureEntry(tex.GetBytes()); } } -- cgit v1.1 From 7319ba62dd1791a3dade5b5453e369d955de48a2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 5 Jan 2012 20:51:49 +0000 Subject: Move simulator asset info commands to an optional module from the connector. Make them conform with service side commands. This stops them appearing twice when Hypergrid is enabled. --- .../Scripting/Minimodule/Interfaces/IInventoryItem.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs index 16cd7e4..a8e545c 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs @@ -30,8 +30,7 @@ using OpenMetaverse; using OpenMetaverse.Assets; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule -{ - +{ /// /// This implements the methods needed to operate on individual inventory items. /// @@ -39,6 +38,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { int Type { get; } UUID AssetID { get; } - T RetrieveAsset() where T : Asset, new(); + T RetrieveAsset() where T : OpenMetaverse.Assets.Asset, new(); } } -- cgit v1.1 From 683cfc6f827c15ee70e4651cbcc7b94a01d2f8e3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 25 Apr 2012 02:07:55 +0100 Subject: refactor: Combine ScenePresence.Teleport() and TeleportWithMomentum() These are identical apart from setting Velocity = zero, which has no practical effect anyway since this is zeroed when the avatar is added back to the physics scene. --- OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs index 922eaaf..d192309 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs @@ -68,7 +68,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule public Vector3 WorldPosition { get { return GetSP().AbsolutePosition; } - set { GetSP().TeleportWithMomentum(value); } + set { GetSP().Teleport(value); } } public bool IsChildAgent -- cgit v1.1 From 916e3bf886ee622e2f18d6eb74f90fee8c630471 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 11 Jul 2012 22:54:22 +0100 Subject: Where possible, use the system Encoding.ASCII and Encoding.UTF8 rather than constructing fresh copies. The encodings are thread-safe and already used in such a manner in other places. This isn't done where Byte Order Mark output is suppressed, since Encoding.UTF8 is constructed to output the BOM. --- OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 74f5208..03481d2 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -482,10 +482,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule // Convert to base64 // string filetext = Convert.ToBase64String(data); - - ASCIIEncoding enc = new ASCIIEncoding(); - - Byte[] buf = enc.GetBytes(filetext); + Byte[] buf = Encoding.ASCII.GetBytes(filetext); m_log.Info("MRM 9"); -- cgit v1.1 From 5abcecc7356bf58c479a7cff86581131a6ab3c9e Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Tue, 16 Oct 2012 12:24:33 +0100 Subject: moving SendSound from SceneObjectPart to ISoundModule --- OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index aa23fee..9e438e2 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -821,8 +821,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { if (!CanEdit()) return; - - GetSOP().SendSound(asset.ToString(), volume, true, 0, 0, false, false); + ISoundModule module = m_rootScene.RequestModuleInterface(); + if (module != null) + { + module.SendSound(GetSOP().UUID, asset.ToString(), volume, true, 0, 0, false, false); + } } #endregion -- cgit v1.1 From c5af16aef82e2bdf2f4d877a231180e00a8893a6 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Tue, 16 Oct 2012 12:40:21 +0100 Subject: shuffling code around so that the interface for ISoundModule.SendSound() specifies a UUID rather than a string --- OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index 9e438e2..5ed1514 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs @@ -824,7 +824,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule ISoundModule module = m_rootScene.RequestModuleInterface(); if (module != null) { - module.SendSound(GetSOP().UUID, asset.ToString(), volume, true, 0, 0, false, false); + module.SendSound(GetSOP().UUID, asset, volume, true, 0, 0, false, false); } } -- cgit v1.1 From 4e8c8b2cd8954ca2ce87d642e4c106c904ec2295 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 11 Nov 2012 16:18:47 -0800 Subject: One more module converted: MRMModule. --- .../Scripting/Minimodule/MRMModule.cs | 91 +++++++++++++--------- 1 file changed, 56 insertions(+), 35 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 03481d2..6fb28e2 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -43,13 +43,17 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using Mono.Addins; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - public class MRMModule : IRegionModule, IMRMModule + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MRMModule")] + public class MRMModule : INonSharedRegionModule, IMRMModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_scene; + private bool m_Enabled; + private bool m_Hidden; private readonly Dictionary m_scripts = new Dictionary(); @@ -67,7 +71,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule m_extensions[typeof (T)] = instance; } - public void Initialise(Scene scene, IConfigSource source) + #region INonSharedRegionModule + + public void Initialise(IConfigSource source) { if (source.Configs["MRM"] != null) { @@ -76,23 +82,60 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule if (source.Configs["MRM"].GetBoolean("Enabled", false)) { m_log.Info("[MRM]: Enabling MRM Module"); - m_scene = scene; + m_Enabled = true; + m_Hidden = source.Configs["MRM"].GetBoolean("Hidden", false); + } + } + } - // when hidden, we don't listen for client initiated script events - // only making the MRM engine available for region modules - if (!source.Configs["MRM"].GetBoolean("Hidden", false)) - { - scene.EventManager.OnRezScript += EventManager_OnRezScript; - scene.EventManager.OnStopScript += EventManager_OnStopScript; - } + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; - scene.EventManager.OnFrame += EventManager_OnFrame; + m_scene = scene; - scene.RegisterModuleInterface(this); - } + // when hidden, we don't listen for client initiated script events + // only making the MRM engine available for region modules + if (!m_Hidden) + { + scene.EventManager.OnRezScript += EventManager_OnRezScript; + scene.EventManager.OnStopScript += EventManager_OnStopScript; } + + scene.EventManager.OnFrame += EventManager_OnFrame; + + scene.RegisterModuleInterface(this); + } + + public void RegionLoaded(Scene scene) + { } + public void RemoveRegion(Scene scene) + { + } + + public void Close() + { + foreach (KeyValuePair pair in m_scripts) + { + pair.Value.Stop(); + } + } + + public string Name + { + get { return "MiniRegionModule"; } + } + + public Type ReplaceableInterface + { + get { return null; } + } + + #endregion + void EventManager_OnStopScript(uint localID, UUID itemID) { if (m_scripts.ContainsKey(itemID)) @@ -293,28 +336,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule mmb.InitMiniModule(world, host, itemID); } - public void PostInitialise() - { - } - - public void Close() - { - foreach (KeyValuePair pair in m_scripts) - { - pair.Value.Stop(); - } - } - - public string Name - { - get { return "MiniRegionModule"; } - } - - public bool IsSharedModule - { - get { return false; } - } - /// /// Stolen from ScriptEngine Common /// -- cgit v1.1 From 14b4d8bad796527a05a5f5992d1a1df1c5c43e6f Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Fri, 31 Jul 2015 18:13:39 +0300 Subject: Eliminated several warnings --- OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule') diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 6fb28e2..4bafe2f 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs @@ -180,6 +180,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule /// * Internet /// * Everything /// +#pragma warning disable 0618 public static AppDomain CreateRestrictedDomain(string permissionSetName, string appDomainName) { if (permissionSetName == null) @@ -240,6 +241,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule return restrictedDomain; } +#pragma warning restore 0618 void EventManager_OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) -- cgit v1.1