diff options
author | Justin Clarke Casey | 2008-01-06 22:55:45 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-01-06 22:55:45 +0000 |
commit | 286802558e063dd6b3997cefba06f277de51b639 (patch) | |
tree | 0e4a9f289141cd569e58ee4acf827d786480063d /OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs | |
parent | Factor out inventory related code in SceneObjectPart into separate class (diff) | |
download | opensim-SC_OLD-286802558e063dd6b3997cefba06f277de51b639.zip opensim-SC_OLD-286802558e063dd6b3997cefba06f277de51b639.tar.gz opensim-SC_OLD-286802558e063dd6b3997cefba06f277de51b639.tar.bz2 opensim-SC_OLD-286802558e063dd6b3997cefba06f277de51b639.tar.xz |
Factor out inventory code in SceneObjectGroup into seperate class.
As was true for the previous update, this might require nant users to re-run prebuild.[sh|bat]
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs new file mode 100644 index 0000000..046e05b --- /dev/null +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs | |||
@@ -0,0 +1,136 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | |||
29 | using System; | ||
30 | |||
31 | using libsecondlife; | ||
32 | |||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Console; | ||
35 | using OpenSim.Region.Environment.Interfaces; | ||
36 | |||
37 | namespace OpenSim.Region.Environment.Scenes | ||
38 | { | ||
39 | public partial class SceneObjectGroup : EntityBase | ||
40 | { | ||
41 | /// <summary> | ||
42 | /// | ||
43 | /// </summary> | ||
44 | /// <param name="remoteClient"></param> | ||
45 | /// <param name="localID"></param> | ||
46 | public bool GetPartInventoryFileName(IClientAPI remoteClient, uint localID) | ||
47 | { | ||
48 | SceneObjectPart part = GetChildPart(localID); | ||
49 | if (part != null) | ||
50 | { | ||
51 | return part.GetInventoryFileName(remoteClient, localID); | ||
52 | } | ||
53 | else | ||
54 | { | ||
55 | MainLog.Instance.Warn( | ||
56 | "SCENE", | ||
57 | "Couldn't find part {0} in object group {1}, {2} to retreive prim inventory", | ||
58 | localID, Name, UUID); | ||
59 | } | ||
60 | return false; | ||
61 | } | ||
62 | |||
63 | public void RequestInventoryFile(uint localID, IXfer xferManager) | ||
64 | { | ||
65 | SceneObjectPart part = GetChildPart(localID); | ||
66 | if (part != null) | ||
67 | { | ||
68 | part.RequestInventoryFile(xferManager); | ||
69 | } | ||
70 | else | ||
71 | { | ||
72 | MainLog.Instance.Warn( | ||
73 | "PRIMINVENTORY", | ||
74 | "Couldn't find part {0} in object group {1}, {2} to request inventory data", | ||
75 | localID, Name, UUID); | ||
76 | } | ||
77 | } | ||
78 | |||
79 | public bool AddInventoryItem(IClientAPI remoteClient, uint localID, InventoryItemBase item) | ||
80 | { | ||
81 | SceneObjectPart part = GetChildPart(localID); | ||
82 | if (part != null) | ||
83 | { | ||
84 | TaskInventoryItem taskItem = new TaskInventoryItem(); | ||
85 | taskItem.item_id = item.inventoryID; | ||
86 | taskItem.asset_id = item.assetID; | ||
87 | taskItem.name = item.inventoryName; | ||
88 | taskItem.desc = item.inventoryDescription; | ||
89 | taskItem.owner_id = item.avatarID; | ||
90 | taskItem.creator_id = item.creatorsID; | ||
91 | taskItem.type = TaskInventoryItem.Types[item.assetType]; | ||
92 | taskItem.inv_type = TaskInventoryItem.Types[item.invType]; | ||
93 | part.AddInventoryItem(taskItem); | ||
94 | return true; | ||
95 | } | ||
96 | return false; | ||
97 | } | ||
98 | |||
99 | public bool AddInventoryItem(IClientAPI remoteClient, uint localID, InventoryItemBase item, LLUUID copyItemID) | ||
100 | { | ||
101 | if (copyItemID != LLUUID.Zero) | ||
102 | { | ||
103 | SceneObjectPart part = GetChildPart(localID); | ||
104 | if (part != null) | ||
105 | { | ||
106 | TaskInventoryItem taskItem = new TaskInventoryItem(); | ||
107 | taskItem.item_id = copyItemID; | ||
108 | taskItem.asset_id = item.assetID; | ||
109 | taskItem.name = item.inventoryName; | ||
110 | taskItem.desc = item.inventoryDescription; | ||
111 | taskItem.owner_id = new LLUUID(item.avatarID.ToString()); | ||
112 | taskItem.creator_id = new LLUUID(item.creatorsID.ToString()); | ||
113 | taskItem.type = TaskInventoryItem.Types[item.assetType]; | ||
114 | taskItem.inv_type = TaskInventoryItem.InvTypes[item.invType]; | ||
115 | part.AddInventoryItem(taskItem); | ||
116 | return true; | ||
117 | } | ||
118 | } | ||
119 | else | ||
120 | { | ||
121 | return AddInventoryItem(remoteClient, localID, item); | ||
122 | } | ||
123 | return false; | ||
124 | } | ||
125 | |||
126 | public int RemoveInventoryItem(IClientAPI remoteClient, uint localID, LLUUID itemID) | ||
127 | { | ||
128 | SceneObjectPart part = GetChildPart(localID); | ||
129 | if (part != null) | ||
130 | { | ||
131 | return part.RemoveInventoryItem(remoteClient, localID, itemID); | ||
132 | } | ||
133 | return -1; | ||
134 | } | ||
135 | } | ||
136 | } \ No newline at end of file | ||