aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs32
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs144
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/Object/IObjectInventory.cs34
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs380
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs70
5 files changed, 330 insertions, 330 deletions
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 @@
1using System; 1using System;
2using OpenMetaverse; 2using OpenMetaverse;
3 3
4namespace OpenSim.Region.OptionalModules.Scripting.Minimodule 4namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
5{ 5{
6 6
7 /// <summary> 7 /// <summary>
8 /// This implements the methods needed to operate on individual inventory items. 8 /// This implements the methods needed to operate on individual inventory items.
9 /// </summary> 9 /// </summary>
10 public interface IInventoryItem 10 public interface IInventoryItem
11 { 11 {
12 int Type { get; } 12 int Type { get; }
13 UUID AssetID { get; } 13 UUID AssetID { get; }
14 T RetreiveAsset<T>() where T : OpenMetaverse.Asset, new(); 14 T RetreiveAsset<T>() where T : OpenMetaverse.Asset, new();
15 } 15 }
16} 16}
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 @@
1 1
2using System; 2using System;
3using System.Text; 3using System.Text;
4 4
5using OpenSim.Framework; 5using OpenSim.Framework;
6using OpenSim.Region.Framework.Scenes; 6using OpenSim.Region.Framework.Scenes;
7//using OpenSim.Services.AssetService; 7//using OpenSim.Services.AssetService;
8using OpenMetaverse; 8using OpenMetaverse;
9 9
10namespace OpenSim.Region.OptionalModules.Scripting.Minimodule 10namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
11{ 11{
12 12
13 13
14 public class InventoryItem : IInventoryItem 14 public class InventoryItem : IInventoryItem
15 { 15 {
16 TaskInventoryItem m_privateItem; 16 TaskInventoryItem m_privateItem;
17 Scene m_rootSceene; 17 Scene m_rootSceene;
18 18
19 public InventoryItem(Scene rootScene, TaskInventoryItem internalItem) 19 public InventoryItem(Scene rootScene, TaskInventoryItem internalItem)
20 { 20 {
21 m_rootSceene = rootScene; 21 m_rootSceene = rootScene;
22 m_privateItem = internalItem; 22 m_privateItem = internalItem;
23 } 23 }
24 24
25 // Marked internal, to prevent scripts from accessing the internal type 25 // Marked internal, to prevent scripts from accessing the internal type
26 internal TaskInventoryItem ToTaskInventoryItem() 26 internal TaskInventoryItem ToTaskInventoryItem()
27 { 27 {
28 return m_privateItem; 28 return m_privateItem;
29 } 29 }
30 30
31 /// <summary> 31 /// <summary>
32 /// This will attempt to convert from an IInventoryItem to an InventoryItem object 32 /// This will attempt to convert from an IInventoryItem to an InventoryItem object
33 /// </summary> 33 /// </summary>
34 /// <description> 34 /// <description>
35 /// In order for this to work the object which implements IInventoryItem must inherit from InventoryItem, otherwise 35 /// In order for this to work the object which implements IInventoryItem must inherit from InventoryItem, otherwise
36 /// an exception is thrown. 36 /// an exception is thrown.
37 /// </description> 37 /// </description>
38 /// <param name="i"> 38 /// <param name="i">
39 /// The interface to upcast <see cref="IInventoryItem"/> 39 /// The interface to upcast <see cref="IInventoryItem"/>
40 /// </param> 40 /// </param>
41 /// <returns> 41 /// <returns>
42 /// The object backing the interface implementation <see cref="InventoryItem"/> 42 /// The object backing the interface implementation <see cref="InventoryItem"/>
43 /// </returns> 43 /// </returns>
44 internal static InventoryItem FromInterface(IInventoryItem i) 44 internal static InventoryItem FromInterface(IInventoryItem i)
45 { 45 {
46 if(typeof(InventoryItem).IsAssignableFrom(i.GetType())) 46 if(typeof(InventoryItem).IsAssignableFrom(i.GetType()))
47 { 47 {
48 return (InventoryItem)i; 48 return (InventoryItem)i;
49 } 49 }
50 else 50 else
51 { 51 {
52 throw new ApplicationException("[MRM] There is no legal conversion from IInventoryItem to InventoryItem"); 52 throw new ApplicationException("[MRM] There is no legal conversion from IInventoryItem to InventoryItem");
53 } 53 }
54 } 54 }
55 55
56 public int Type { get { return m_privateItem.Type; } } 56 public int Type { get { return m_privateItem.Type; } }
57 public UUID AssetID { get { return m_privateItem.AssetID; } } 57 public UUID AssetID { get { return m_privateItem.AssetID; } }
58 58
59 public T RetreiveAsset<T>() where T : OpenMetaverse.Asset, new() 59 public T RetreiveAsset<T>() where T : OpenMetaverse.Asset, new()
60 { 60 {
61 AssetBase a = m_rootSceene.AssetService.Get(AssetID.ToString()); 61 AssetBase a = m_rootSceene.AssetService.Get(AssetID.ToString());
62 T result = new T(); 62 T result = new T();
63 63
64 if((sbyte)result.AssetType != a.Type) 64 if((sbyte)result.AssetType != a.Type)
65 throw new ApplicationException("[MRM] The supplied asset class does not match the found asset"); 65 throw new ApplicationException("[MRM] The supplied asset class does not match the found asset");
66 66
67 result.AssetData = a.Data; 67 result.AssetData = a.Data;
68 result.Decode(); 68 result.Decode();
69 return result; 69 return result;
70 } 70 }
71 } 71 }
72} 72}
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 @@
1 1
2using System; 2using System;
3using System.Collections.Generic; 3using System.Collections.Generic;
4 4
5using OpenMetaverse; 5using OpenMetaverse;
6 6
7namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object 7namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object
8{ 8{
9 9
10 /// <summary> 10 /// <summary>
11 /// This implements the methods neccesary to operate on the inventory of an object 11 /// This implements the methods neccesary to operate on the inventory of an object
12 /// </summary> 12 /// </summary>
13 public interface IObjectInventory : IDictionary<UUID, IInventoryItem> 13 public interface IObjectInventory : IDictionary<UUID, IInventoryItem>
14 { 14 {
15 IInventoryItem this[string name] { get; } 15 IInventoryItem this[string name] { get; }
16 } 16 }
17} 17}
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 @@
1using System; 1using System;
2using System.Collections; 2using System.Collections;
3using System.Collections.Generic; 3using System.Collections.Generic;
4 4
5using OpenSim.Framework; 5using OpenSim.Framework;
6using OpenSim.Region.Framework.Scenes; 6using OpenSim.Region.Framework.Scenes;
7using OpenMetaverse; 7using OpenMetaverse;
8 8
9namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object 9namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object
10{ 10{
11 11
12 12
13 public class SOPObjectInventory : IObjectInventory 13 public class SOPObjectInventory : IObjectInventory
14 { 14 {
15 TaskInventoryDictionary m_privateInventory; /// OpenSim's task inventory 15 TaskInventoryDictionary m_privateInventory; /// OpenSim's task inventory
16 Dictionary<UUID, IInventoryItem> m_publicInventory; /// MRM's inventory 16 Dictionary<UUID, IInventoryItem> m_publicInventory; /// MRM's inventory
17 Scene m_rootScene; 17 Scene m_rootScene;
18 18
19 public SOPObjectInventory(Scene rootScene, TaskInventoryDictionary taskInventory) 19 public SOPObjectInventory(Scene rootScene, TaskInventoryDictionary taskInventory)
20 { 20 {
21 m_rootScene = rootScene; 21 m_rootScene = rootScene;
22 m_privateInventory = taskInventory; 22 m_privateInventory = taskInventory;
23 m_publicInventory = new Dictionary<UUID, IInventoryItem>(); 23 m_publicInventory = new Dictionary<UUID, IInventoryItem>();
24 } 24 }
25 25
26 /// <summary> 26 /// <summary>
27 /// Fully populate the public dictionary with the contents of the private dictionary 27 /// Fully populate the public dictionary with the contents of the private dictionary
28 /// </summary> 28 /// </summary>
29 /// <description> 29 /// <description>
30 /// This will only convert those items which hasn't already been converted. ensuring that 30 /// This will only convert those items which hasn't already been converted. ensuring that
31 /// no items are converted twice, and that any references already in use are maintained. 31 /// no items are converted twice, and that any references already in use are maintained.
32 /// </description> 32 /// </description>
33 private void SynchronizeDictionaries() 33 private void SynchronizeDictionaries()
34 { 34 {
35 foreach(TaskInventoryItem privateItem in m_privateInventory.Values) 35 foreach(TaskInventoryItem privateItem in m_privateInventory.Values)
36 if(!m_publicInventory.ContainsKey(privateItem.ItemID)) 36 if(!m_publicInventory.ContainsKey(privateItem.ItemID))
37 m_publicInventory.Add(privateItem.ItemID, new InventoryItem(m_rootScene, privateItem)); 37 m_publicInventory.Add(privateItem.ItemID, new InventoryItem(m_rootScene, privateItem));
38 } 38 }
39 39
40 #region IDictionary<UUID, IInventoryItem> implementation 40 #region IDictionary<UUID, IInventoryItem> implementation
41 public void Add (UUID key, IInventoryItem value) 41 public void Add (UUID key, IInventoryItem value)
42 { 42 {
43 m_publicInventory.Add(key, value); 43 m_publicInventory.Add(key, value);
44 m_privateInventory.Add(key, InventoryItem.FromInterface(value).ToTaskInventoryItem()); 44 m_privateInventory.Add(key, InventoryItem.FromInterface(value).ToTaskInventoryItem());
45 } 45 }
46 46
47 public bool ContainsKey (UUID key) 47 public bool ContainsKey (UUID key)
48 { 48 {
49 return m_privateInventory.ContainsKey(key); 49 return m_privateInventory.ContainsKey(key);
50 } 50 }
51 51
52 public bool Remove (UUID key) 52 public bool Remove (UUID key)
53 { 53 {
54 m_publicInventory.Remove(key); 54 m_publicInventory.Remove(key);
55 return m_privateInventory.Remove(key); 55 return m_privateInventory.Remove(key);
56 } 56 }
57 57
58 public bool TryGetValue (UUID key, out IInventoryItem value) 58 public bool TryGetValue (UUID key, out IInventoryItem value)
59 { 59 {
60 value = null; 60 value = null;
61 61
62 bool result = false; 62 bool result = false;
63 if(!m_publicInventory.TryGetValue(key, out value)) 63 if(!m_publicInventory.TryGetValue(key, out value))
64 { 64 {
65 // wasn't found in the public inventory 65 // wasn't found in the public inventory
66 TaskInventoryItem privateItem; 66 TaskInventoryItem privateItem;
67 67
68 result = m_privateInventory.TryGetValue(key, out privateItem); 68 result = m_privateInventory.TryGetValue(key, out privateItem);
69 if(result) 69 if(result)
70 { 70 {
71 value = new InventoryItem(m_rootScene, privateItem); 71 value = new InventoryItem(m_rootScene, privateItem);
72 m_publicInventory.Add(key, value); // add item, so we don't convert again 72 m_publicInventory.Add(key, value); // add item, so we don't convert again
73 } 73 }
74 } else 74 } else
75 return true; 75 return true;
76 76
77 return result; 77 return result;
78 } 78 }
79 79
80 public ICollection<UUID> Keys { 80 public ICollection<UUID> Keys {
81 get { 81 get {
82 return m_privateInventory.Keys; 82 return m_privateInventory.Keys;
83 } 83 }
84 } 84 }
85 85
86 public ICollection<IInventoryItem> Values { 86 public ICollection<IInventoryItem> Values {
87 get { 87 get {
88 SynchronizeDictionaries(); 88 SynchronizeDictionaries();
89 return m_publicInventory.Values; 89 return m_publicInventory.Values;
90 } 90 }
91 } 91 }
92 #endregion 92 #endregion
93 93
94 #region IEnumerable<KeyValuePair<UUID, IInventoryItem>> implementation 94 #region IEnumerable<KeyValuePair<UUID, IInventoryItem>> implementation
95 public IEnumerator<KeyValuePair<UUID, IInventoryItem>> GetEnumerator () 95 public IEnumerator<KeyValuePair<UUID, IInventoryItem>> GetEnumerator ()
96 { 96 {
97 SynchronizeDictionaries(); 97 SynchronizeDictionaries();
98 return m_publicInventory.GetEnumerator(); 98 return m_publicInventory.GetEnumerator();
99 } 99 }
100 100
101 #endregion 101 #endregion
102 102
103 #region IEnumerable implementation 103 #region IEnumerable implementation
104 IEnumerator IEnumerable.GetEnumerator () 104 IEnumerator IEnumerable.GetEnumerator ()
105 { 105 {
106 SynchronizeDictionaries(); 106 SynchronizeDictionaries();
107 return m_publicInventory.GetEnumerator(); 107 return m_publicInventory.GetEnumerator();
108 } 108 }
109 109
110 #endregion 110 #endregion
111 111
112 #region ICollection<KeyValuePair<UUID, IInventoryItem>> implementation 112 #region ICollection<KeyValuePair<UUID, IInventoryItem>> implementation
113 public void Add (KeyValuePair<UUID, IInventoryItem> item) 113 public void Add (KeyValuePair<UUID, IInventoryItem> item)
114 { 114 {
115 Add(item.Key, item.Value); 115 Add(item.Key, item.Value);
116 } 116 }
117 117
118 public void Clear () 118 public void Clear ()
119 { 119 {
120 m_publicInventory.Clear(); 120 m_publicInventory.Clear();
121 m_privateInventory.Clear(); 121 m_privateInventory.Clear();
122 } 122 }
123 123
124 public bool Contains (KeyValuePair<UUID, IInventoryItem> item) 124 public bool Contains (KeyValuePair<UUID, IInventoryItem> item)
125 { 125 {
126 return m_privateInventory.ContainsKey(item.Key); 126 return m_privateInventory.ContainsKey(item.Key);
127 } 127 }
128 128
129 public void CopyTo (KeyValuePair<UUID, IInventoryItem>[] array, int arrayIndex) 129 public void CopyTo (KeyValuePair<UUID, IInventoryItem>[] array, int arrayIndex)
130 { 130 {
131 throw new NotImplementedException(); 131 throw new NotImplementedException();
132 } 132 }
133 133
134 public bool Remove (KeyValuePair<UUID, IInventoryItem> item) 134 public bool Remove (KeyValuePair<UUID, IInventoryItem> item)
135 { 135 {
136 return Remove(item.Key); 136 return Remove(item.Key);
137 } 137 }
138 138
139 public int Count { 139 public int Count {
140 get { 140 get {
141 return m_privateInventory.Count; 141 return m_privateInventory.Count;
142 } 142 }
143 } 143 }
144 144
145 public bool IsReadOnly { 145 public bool IsReadOnly {
146 get { 146 get {
147 return false; 147 return false;
148 } 148 }
149 } 149 }
150 #endregion 150 #endregion
151 151
152 #region Explicit implementations 152 #region Explicit implementations
153 IInventoryItem System.Collections.Generic.IDictionary<UUID, IInventoryItem>.this[UUID key] 153 IInventoryItem System.Collections.Generic.IDictionary<UUID, IInventoryItem>.this[UUID key]
154 { 154 {
155 get { 155 get {
156 IInventoryItem result; 156 IInventoryItem result;
157 if(TryGetValue(key, out result)) 157 if(TryGetValue(key, out result))
158 return result; 158 return result;
159 else 159 else
160 throw new KeyNotFoundException("[MRM] The requrested item ID could not be found"); 160 throw new KeyNotFoundException("[MRM] The requrested item ID could not be found");
161 } 161 }
162 set { 162 set {
163 m_publicInventory[key] = value; 163 m_publicInventory[key] = value;
164 m_privateInventory[key] = InventoryItem.FromInterface(value).ToTaskInventoryItem(); 164 m_privateInventory[key] = InventoryItem.FromInterface(value).ToTaskInventoryItem();
165 } 165 }
166 } 166 }
167 167
168 void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<UUID, IInventoryItem>>.CopyTo(System.Collections.Generic.KeyValuePair<UUID,IInventoryItem>[] array, int offset) 168 void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<UUID, IInventoryItem>>.CopyTo(System.Collections.Generic.KeyValuePair<UUID,IInventoryItem>[] array, int offset)
169 { 169 {
170 throw new NotImplementedException(); 170 throw new NotImplementedException();
171 } 171 }
172 #endregion 172 #endregion
173 173
174 public IInventoryItem this[string name] 174 public IInventoryItem this[string name]
175 { 175 {
176 get { 176 get {
177 foreach(TaskInventoryItem i in m_privateInventory.Values) 177 foreach(TaskInventoryItem i in m_privateInventory.Values)
178 if(i.Name == name) 178 if(i.Name == name)
179 { 179 {
180 if(!m_publicInventory.ContainsKey(i.ItemID)) 180 if(!m_publicInventory.ContainsKey(i.ItemID))
181 m_publicInventory.Add(i.ItemID, new InventoryItem(m_rootScene, i)); 181 m_publicInventory.Add(i.ItemID, new InventoryItem(m_rootScene, i));
182 182
183 return m_publicInventory[i.ItemID]; 183 return m_publicInventory[i.ItemID];
184 } 184 }
185 throw new KeyNotFoundException(); 185 throw new KeyNotFoundException();
186 } 186 }
187 } 187 }
188 188
189 } 189 }
190} 190}
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 @@
1using System; 1using System;
2 2
3using OpenMetaverse; 3using OpenMetaverse;
4using OpenSim.Region.Framework.Scenes; 4using OpenSim.Region.Framework.Scenes;
5 5
6namespace OpenSim.Region.OptionalModules.Scripting.Minimodule 6namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
7{ 7{
8 public class SPAvatarAttachment : IAvatarAttachment 8 public class SPAvatarAttachment : IAvatarAttachment
9 { 9 {
10 private readonly Scene m_rootScene; 10 private readonly Scene m_rootScene;
11 private readonly IAvatar m_parent; 11 private readonly IAvatar m_parent;
12 private readonly int m_location; 12 private readonly int m_location;
13 private readonly UUID m_itemId; 13 private readonly UUID m_itemId;
14 private readonly UUID m_assetId; 14 private readonly UUID m_assetId;
15 15
16 public SPAvatarAttachment(Scene rootScene, IAvatar self, int location, UUID itemId, UUID assetId) 16 public SPAvatarAttachment(Scene rootScene, IAvatar self, int location, UUID itemId, UUID assetId)
17 { 17 {
18 m_rootScene = rootScene; 18 m_rootScene = rootScene;
19 m_parent = self; 19 m_parent = self;
20 m_location = location; 20 m_location = location;
21 m_itemId = itemId; 21 m_itemId = itemId;
22 m_assetId = assetId; 22 m_assetId = assetId;
23 } 23 }
24 24
25 public int Location { get { return m_location; } } 25 public int Location { get { return m_location; } }
26 26
27 public IObject Asset 27 public IObject Asset
28 { 28 {
29 get 29 get
30 { 30 {
31 return new SOPObject(m_rootScene, m_rootScene.GetSceneObjectPart(m_assetId).LocalId); 31 return new SOPObject(m_rootScene, m_rootScene.GetSceneObjectPart(m_assetId).LocalId);
32 } 32 }
33 } 33 }
34 } 34 }
35} 35}