diff options
author | gareth | 2007-03-22 10:11:15 +0000 |
---|---|---|
committer | gareth | 2007-03-22 10:11:15 +0000 |
commit | 7daa3955bc3a1918e40962851f9e8d38597a245e (patch) | |
tree | bee3e1372a7eed0c1b220a8a49f7bee7d29a6b91 /OpenSim.Framework/Inventory.cs | |
parent | Load XML for neighbourinfo from grid (diff) | |
download | opensim-SC-7daa3955bc3a1918e40962851f9e8d38597a245e.zip opensim-SC-7daa3955bc3a1918e40962851f9e8d38597a245e.tar.gz opensim-SC-7daa3955bc3a1918e40962851f9e8d38597a245e.tar.bz2 opensim-SC-7daa3955bc3a1918e40962851f9e8d38597a245e.tar.xz |
brought zircon branch into trunk
Diffstat (limited to 'OpenSim.Framework/Inventory.cs')
-rw-r--r-- | OpenSim.Framework/Inventory.cs | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/OpenSim.Framework/Inventory.cs b/OpenSim.Framework/Inventory.cs new file mode 100644 index 0000000..e34ea75 --- /dev/null +++ b/OpenSim.Framework/Inventory.cs | |||
@@ -0,0 +1,127 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using libsecondlife; | ||
5 | using OpenSim.Framework.Assets; | ||
6 | |||
7 | namespace OpenSim.Framework.Inventory | ||
8 | { | ||
9 | public class AgentInventory | ||
10 | { | ||
11 | //Holds the local copy of Inventory info for a agent | ||
12 | public Dictionary<LLUUID, InventoryFolder> InventoryFolders; | ||
13 | public Dictionary<LLUUID, InventoryItem> InventoryItems; | ||
14 | public InventoryFolder InventoryRoot; | ||
15 | public int LastCached; //maybe used by opensim app, time this was last stored/compared to user server | ||
16 | public LLUUID AgentID; | ||
17 | public AvatarWearable[] Wearables; | ||
18 | |||
19 | public AgentInventory() | ||
20 | { | ||
21 | InventoryFolders = new Dictionary<LLUUID, InventoryFolder>(); | ||
22 | InventoryItems = new Dictionary<LLUUID, InventoryItem>(); | ||
23 | this.Initialise(); | ||
24 | } | ||
25 | |||
26 | public virtual void Initialise() | ||
27 | { | ||
28 | Wearables = new AvatarWearable[2]; //should be 12 of these | ||
29 | for (int i = 0; i < 2; i++) | ||
30 | { | ||
31 | Wearables[i] = new AvatarWearable(); | ||
32 | } | ||
33 | |||
34 | InventoryRoot = new InventoryFolder(); | ||
35 | InventoryRoot.FolderID = LLUUID.Random(); | ||
36 | InventoryRoot.ParentID = new LLUUID(); | ||
37 | InventoryRoot.Version = 1; | ||
38 | InventoryRoot.DefaultType = 8; | ||
39 | InventoryRoot.FolderName = "My Inventory"; | ||
40 | InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot); | ||
41 | } | ||
42 | |||
43 | public bool CreateNewFolder(LLUUID folderID) | ||
44 | { | ||
45 | InventoryFolder Folder = new InventoryFolder(); | ||
46 | Folder.FolderID = folderID; | ||
47 | Folder.OwnerID = this.AgentID; | ||
48 | this.InventoryFolders.Add(Folder.FolderID, Folder); | ||
49 | |||
50 | return (true); | ||
51 | } | ||
52 | |||
53 | public LLUUID AddToInventory(LLUUID folderID, AssetBase asset) | ||
54 | { | ||
55 | if (this.InventoryFolders.ContainsKey(folderID)) | ||
56 | { | ||
57 | LLUUID NewItemID = LLUUID.Random(); | ||
58 | |||
59 | InventoryItem Item = new InventoryItem(); | ||
60 | Item.FolderID = folderID; | ||
61 | Item.OwnerID = AgentID; | ||
62 | Item.AssetID = asset.FullID; | ||
63 | Item.ItemID = NewItemID; | ||
64 | Item.Type = asset.Type; | ||
65 | Item.Name = asset.Name; | ||
66 | Item.Description = asset.Description; | ||
67 | Item.InvType = asset.InvType; | ||
68 | this.InventoryItems.Add(Item.ItemID, Item); | ||
69 | InventoryFolder Folder = InventoryFolders[Item.FolderID]; | ||
70 | Folder.Items.Add(Item); | ||
71 | return (Item.ItemID); | ||
72 | } | ||
73 | else | ||
74 | { | ||
75 | return (null); | ||
76 | } | ||
77 | } | ||
78 | } | ||
79 | |||
80 | public class InventoryFolder | ||
81 | { | ||
82 | public List<InventoryItem> Items; | ||
83 | //public List<InventoryFolder> Subfolders; | ||
84 | public LLUUID FolderID; | ||
85 | public LLUUID OwnerID; | ||
86 | public LLUUID ParentID; | ||
87 | public string FolderName; | ||
88 | public ushort DefaultType; | ||
89 | public ushort Version; | ||
90 | |||
91 | public InventoryFolder() | ||
92 | { | ||
93 | Items = new List<InventoryItem>(); | ||
94 | //Subfolders = new List<InventoryFolder>(); | ||
95 | } | ||
96 | |||
97 | } | ||
98 | |||
99 | public class InventoryItem | ||
100 | { | ||
101 | public LLUUID FolderID; | ||
102 | public LLUUID OwnerID; | ||
103 | public LLUUID ItemID; | ||
104 | public LLUUID AssetID; | ||
105 | public LLUUID CreatorID; | ||
106 | public sbyte InvType; | ||
107 | public sbyte Type; | ||
108 | public string Name; | ||
109 | public string Description; | ||
110 | |||
111 | public InventoryItem() | ||
112 | { | ||
113 | this.CreatorID = LLUUID.Zero; | ||
114 | } | ||
115 | } | ||
116 | |||
117 | public class AvatarWearable | ||
118 | { | ||
119 | public LLUUID AssetID = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
120 | public LLUUID ItemID = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
121 | |||
122 | public AvatarWearable() | ||
123 | { | ||
124 | |||
125 | } | ||
126 | } | ||
127 | } | ||