Exemple #1
0
        public void MakeDefaultAppearance(string wear)
        {
            try
            {
                if (wear == "yes")
                {
                    //TODO: Implement random outfit picking
                    m_log.DebugFormat("Picks a random outfit. Not yet implemented.");
                }
                else if (wear != "save")
                {
                    saveDir = "MyAppearance/" + wear;
                }
                saveDir = saveDir + "/";

                string[]             clothing      = Directory.GetFiles(saveDir, "*.clothing", SearchOption.TopDirectoryOnly);
                string[]             bodyparts     = Directory.GetFiles(saveDir, "*.bodypart", SearchOption.TopDirectoryOnly);
                InventoryFolder      clothfolder   = FindClothingFolder();
                UUID                 transid       = UUID.Random();
                List <InventoryBase> listwearables = new List <InventoryBase>();

                for (int i = 0; i < clothing.Length; i++)
                {
                    UUID          assetID = UUID.Random();
                    AssetClothing asset   = new AssetClothing(assetID, File.ReadAllBytes(clothing[i]));
                    asset.Decode();
                    asset.Owner        = Client.Self.AgentID;
                    asset.WearableType = GetWearableType(clothing[i]);
                    asset.Encode();
                    transid = Client.Assets.RequestUpload(asset, true);
                    Client.Inventory.RequestCreateItem(clothfolder.UUID, "MyClothing" + i.ToString(), "MyClothing", AssetType.Clothing,
                                                       transid, InventoryType.Wearable, asset.WearableType, (OpenMetaverse.PermissionMask) PermissionMask.All, delegate(bool success, InventoryItem item)
                    {
                        if (success)
                        {
                            listwearables.Add(item);
                        }
                        else
                        {
                            m_log.WarnFormat("Failed to create item {0}", item.Name);
                        }
                    }
                                                       );
                }

                for (int i = 0; i < bodyparts.Length; i++)
                {
                    UUID          assetID = UUID.Random();
                    AssetBodypart asset   = new AssetBodypart(assetID, File.ReadAllBytes(bodyparts[i]));
                    asset.Decode();
                    asset.Owner        = Client.Self.AgentID;
                    asset.WearableType = GetWearableType(bodyparts[i]);
                    asset.Encode();
                    transid = Client.Assets.RequestUpload(asset, true);
                    Client.Inventory.RequestCreateItem(clothfolder.UUID, "MyBodyPart" + i.ToString(), "MyBodyPart", AssetType.Bodypart,
                                                       transid, InventoryType.Wearable, asset.WearableType, (OpenMetaverse.PermissionMask) PermissionMask.All, delegate(bool success, InventoryItem item)
                    {
                        if (success)
                        {
                            listwearables.Add(item);
                        }
                        else
                        {
                            m_log.WarnFormat("Failed to create item {0}", item.Name);
                        }
                    }
                                                       );
                }

                Thread.Sleep(1000);

                if (listwearables == null || listwearables.Count == 0)
                {
                    m_log.DebugFormat("Nothing to send on this folder!");
                }
                else
                {
                    m_log.DebugFormat("Sending {0} wearables...", listwearables.Count);
                    Client.Appearance.WearOutfit(listwearables, false);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Exemple #2
0
        public void MakeDefaultAppearance(string wear)
        {
            try
            {
                if (wear == "yes")
                {
                    //TODO: Implement random outfit picking
                    m_log.DebugFormat("Picks a random outfit. Not yet implemented.");
                }
                else if (wear != "save")
                    saveDir = "MyAppearance/" + wear;
                saveDir = saveDir + "/";

                string[] clothing = Directory.GetFiles(saveDir, "*.clothing", SearchOption.TopDirectoryOnly);
                string[] bodyparts = Directory.GetFiles(saveDir, "*.bodypart", SearchOption.TopDirectoryOnly);
                InventoryFolder clothfolder = FindClothingFolder();
                UUID transid = UUID.Random();
                List<InventoryBase> listwearables = new List<InventoryBase>();
                
                for (int i = 0; i < clothing.Length; i++)
                {
                    UUID assetID = UUID.Random();
                    AssetClothing asset = new AssetClothing(assetID, File.ReadAllBytes(clothing[i]));
                    asset.Decode();
                    asset.Owner = Client.Self.AgentID;
                    asset.WearableType = GetWearableType(clothing[i]);
                    asset.Encode();
                    transid = Client.Assets.RequestUpload(asset,true);
                    Client.Inventory.RequestCreateItem(clothfolder.UUID, "MyClothing" + i.ToString(), "MyClothing", AssetType.Clothing,
                         transid, InventoryType.Wearable, asset.WearableType, (OpenMetaverse.PermissionMask)PermissionMask.All, delegate(bool success, InventoryItem item)
                    {
                        if (success)
                        {
                            listwearables.Add(item);
                        }
                        else
                        {
                            m_log.WarnFormat("Failed to create item {0}", item.Name);
                        }
                    }
                    );
                }

                for (int i = 0; i < bodyparts.Length; i++)
                {
                    UUID assetID = UUID.Random();
                    AssetBodypart asset = new AssetBodypart(assetID, File.ReadAllBytes(bodyparts[i]));
                    asset.Decode();
                    asset.Owner = Client.Self.AgentID;
                    asset.WearableType = GetWearableType(bodyparts[i]);
                    asset.Encode();
                    transid = Client.Assets.RequestUpload(asset,true);
                    Client.Inventory.RequestCreateItem(clothfolder.UUID, "MyBodyPart" + i.ToString(), "MyBodyPart", AssetType.Bodypart,
                         transid, InventoryType.Wearable, asset.WearableType, (OpenMetaverse.PermissionMask)PermissionMask.All, delegate(bool success, InventoryItem item)
                    {
                        if (success)
                        {
                            listwearables.Add(item);
                        }
                        else
                        {
                            m_log.WarnFormat("Failed to create item {0}", item.Name);
                        }
                    }
                    );
                }

                Thread.Sleep(1000);

                if (listwearables == null || listwearables.Count == 0)
                {
                    m_log.DebugFormat("Nothing to send on this folder!");
                }
                else
                {
                    m_log.DebugFormat("Sending {0} wearables...", listwearables.Count);
                    Client.Appearance.WearOutfit(listwearables, false);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }