diff options
Diffstat (limited to 'tools/mass test client/Commands/Inventory/ImportOutfitCommand.cs')
-rw-r--r-- | tools/mass test client/Commands/Inventory/ImportOutfitCommand.cs | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/tools/mass test client/Commands/Inventory/ImportOutfitCommand.cs b/tools/mass test client/Commands/Inventory/ImportOutfitCommand.cs new file mode 100644 index 0000000..595ce98 --- /dev/null +++ b/tools/mass test client/Commands/Inventory/ImportOutfitCommand.cs | |||
@@ -0,0 +1,66 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.IO; | ||
4 | using System.Xml; | ||
5 | using System.Xml.Serialization; | ||
6 | using libsecondlife; | ||
7 | using libsecondlife.Packets; | ||
8 | |||
9 | namespace libsecondlife.TestClient | ||
10 | { | ||
11 | public class ImportOutfitCommand : Command | ||
12 | { | ||
13 | private uint SerialNum = 1; | ||
14 | |||
15 | public ImportOutfitCommand(TestClient testClient) | ||
16 | { | ||
17 | Name = "importoutfit"; | ||
18 | Description = "Imports an appearance from an xml file. Usage: importoutfit inputfile.xml"; | ||
19 | } | ||
20 | |||
21 | public override string Execute(string[] args, LLUUID fromAgentID) | ||
22 | { | ||
23 | if (args.Length != 1) | ||
24 | return "Usage: importoutfit inputfile.xml"; | ||
25 | |||
26 | try | ||
27 | { | ||
28 | XmlReader reader = XmlReader.Create(args[0]); | ||
29 | XmlSerializer serializer = new XmlSerializer(typeof(Packet)); | ||
30 | AvatarAppearancePacket appearance = (AvatarAppearancePacket)serializer.Deserialize(reader); | ||
31 | reader.Close(); | ||
32 | |||
33 | AgentSetAppearancePacket set = new AgentSetAppearancePacket(); | ||
34 | |||
35 | set.AgentData.AgentID = Client.Network.AgentID; | ||
36 | set.AgentData.SessionID = Client.Network.SessionID; | ||
37 | set.AgentData.SerialNum = SerialNum++; | ||
38 | |||
39 | float AV_Height_Range = 2.025506f - 1.50856f; | ||
40 | float AV_Height = 1.50856f + (((float)appearance.VisualParam[25].ParamValue / 255.0f) * AV_Height_Range); | ||
41 | set.AgentData.Size = new LLVector3(0.45f, 0.6f, AV_Height); | ||
42 | |||
43 | set.ObjectData.TextureEntry = appearance.ObjectData.TextureEntry; | ||
44 | set.VisualParam = new AgentSetAppearancePacket.VisualParamBlock[appearance.VisualParam.Length]; | ||
45 | |||
46 | int i = 0; | ||
47 | foreach (AvatarAppearancePacket.VisualParamBlock block in appearance.VisualParam) | ||
48 | { | ||
49 | set.VisualParam[i] = new AgentSetAppearancePacket.VisualParamBlock(); | ||
50 | set.VisualParam[i].ParamValue = block.ParamValue; | ||
51 | i++; | ||
52 | } | ||
53 | |||
54 | set.WearableData = new AgentSetAppearancePacket.WearableDataBlock[0]; | ||
55 | |||
56 | Client.Network.SendPacket(set); | ||
57 | } | ||
58 | catch (Exception) | ||
59 | { | ||
60 | return "Failed to import the appearance XML file, maybe it doesn't exist or is in the wrong format?"; | ||
61 | } | ||
62 | |||
63 | return "Imported " + args[0] + " and sent an AgentSetAppearance packet"; | ||
64 | } | ||
65 | } | ||
66 | } | ||