Esempio n. 1
0
        private void DeleteOutfit(string evt, string data, VMEODClient client)
        {
            uint outfitId = 0;

            if (!uint.TryParse(data, out outfitId))
            {
                return;
            }


            GetOutfits(client.vm, outfits =>
            {
                var outfit = outfits.FirstOrDefault(x => x.outfit_id == outfitId);
                if (outfit == null)
                {
                    //You don't own this outfit!
                    return;
                }

                var isDecoration = VMPersonSuitsUtils.IsDecoration((VMPersonSuits)outfit.outfit_type);

                if (!isDecoration)
                {
                    var numInCategory = outfits.Count(x => x.outfit_type == outfit.outfit_type);
                    if (numInCategory <= 1)
                    {
                        //You must keep at least one item of clothing in clothes categories
                        return;
                    }

                    //If its the default, I need to change the default
                    ulong currentDefault = VMPersonSuitsUtils.GetValue(client.Avatar, (VMPersonSuits)outfit.outfit_type);

                    if (outfit.asset_id == currentDefault)
                    {
                        var firstOutfit = outfits.First(x => x.outfit_type == outfit.outfit_type && x.outfit_id != outfitId);
                        //Change the default outfit to the first one in the list for the category
                        client.vm.SendCommand(new VMNetSetOutfitCmd
                        {
                            UID    = client.Avatar.PersistID,
                            Scope  = (VMPersonSuits)outfit.outfit_type,
                            Outfit = firstOutfit.asset_id
                        });
                    }
                }

                client.vm.GlobalLink.DeleteOutfit(client.vm, outfit.outfit_id, VMGLOutfitOwner.AVATAR, client.Avatar.PersistID, success => {
                    BroadcastOutfits(client.vm, false);
                });
            });
        }