diff options
author | Jeff Ames | 2009-07-01 10:26:43 +0000 |
---|---|---|
committer | Jeff Ames | 2009-07-01 10:26:43 +0000 |
commit | 3f2fba610ea48b6d93a77f3965882d600b6a908a (patch) | |
tree | 6c69fcfd02023f5450e11a6f244a611298d8091f /OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs | |
parent | add some more intuitive overloads for PrimitiveBaseShape SetPathRange and Set... (diff) | |
download | opensim-SC-3f2fba610ea48b6d93a77f3965882d600b6a908a.zip opensim-SC-3f2fba610ea48b6d93a77f3965882d600b6a908a.tar.gz opensim-SC-3f2fba610ea48b6d93a77f3965882d600b6a908a.tar.bz2 opensim-SC-3f2fba610ea48b6d93a77f3965882d600b6a908a.tar.xz |
Update svn properties.
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs')
-rw-r--r-- | OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs | 380 |
1 files changed, 190 insertions, 190 deletions
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 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections; | 2 | using System.Collections; |
3 | using System.Collections.Generic; | 3 | using System.Collections.Generic; |
4 | 4 | ||
5 | using OpenSim.Framework; | 5 | using OpenSim.Framework; |
6 | using OpenSim.Region.Framework.Scenes; | 6 | using OpenSim.Region.Framework.Scenes; |
7 | using OpenMetaverse; | 7 | using OpenMetaverse; |
8 | 8 | ||
9 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object | 9 | namespace 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 | } |