diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs | 144 |
1 files changed, 72 insertions, 72 deletions
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 | ||
2 | using System; | 2 | using System; |
3 | using System.Text; | 3 | using System.Text; |
4 | 4 | ||
5 | using OpenSim.Framework; | 5 | using OpenSim.Framework; |
6 | using OpenSim.Region.Framework.Scenes; | 6 | using OpenSim.Region.Framework.Scenes; |
7 | //using OpenSim.Services.AssetService; | 7 | //using OpenSim.Services.AssetService; |
8 | using OpenMetaverse; | 8 | using OpenMetaverse; |
9 | 9 | ||
10 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | 10 | namespace 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 | } |