public virtual void Destroy( bool toBackpack )
{
Return();
if ( !BaseHouse.NewVendorSystem )
FixDresswear();
/* Possible cases regarding item return:
*
* 1. No item must be returned
* -> do nothing.
* 2. ( toBackpack is false OR the vendor is in the internal map ) AND the vendor is associated with a AOS house
* -> put the items into the moving crate or a vendor inventory,
* depending on whether the vendor owner is also the house owner.
* 3. ( toBackpack is true OR the vendor isn't associated with any AOS house ) AND the vendor isn't in the internal map
* -> put the items into a backpack.
* 4. The vendor isn't associated with any house AND it's in the internal map
* -> do nothing (we can't do anything).
*/
ArrayList list = GetItems();
if ( list.Count > 0 || HoldGold > 0 ) // No case 1
{
if ( ( !toBackpack || this.Map == Map.Internal ) && House != null && House.IsAosRules ) // Case 2
{
if ( House.IsOwner( Owner ) ) // Move to moving crate
{
if ( House.MovingCrate == null )
House.MovingCrate = new MovingCrate( House );
if ( HoldGold > 0 )
Banker.Deposit( House.MovingCrate, HoldGold );
foreach ( Item item in list )
{
House.MovingCrate.DropItem( item );
}
}
else // Move to vendor inventory
{
VendorInventory inventory = new VendorInventory( House, Owner, Name, ShopName );
inventory.Gold = HoldGold;
foreach ( Item item in list )
{
inventory.AddItem( item );
}
House.VendorInventories.Add( inventory );
}
}
else if ( ( toBackpack || House == null || !House.IsAosRules ) && this.Map != Map.Internal ) // Case 3 - Move to backpack
{
Container backpack = new Backpack();
if ( HoldGold > 0 )
Banker.Deposit( backpack, HoldGold );
foreach ( Item item in list )
{
backpack.DropItem( item );
}
backpack.MoveToWorld( this.Location, this.Map );
}
}
Delete();
}