public static void Invoke(this ItemTrashedEventArgs e) { if (OnTrashed != null && e != null) { OnTrashed(e); } }
public bool Trash(Mobile from, Item trashed, ref int tokens, bool message = true) { tokens = Math.Max(0, tokens); if (!Enabled || from == null || trashed == null || trashed.Deleted) { return(false); } if (!CanTrash(from, trashed)) { OnTrashRejected(from, trashed, message); return(false); } bool multiple = false; if (trashed is Container) { bool trashThis = true; Container c = (Container)trashed; var items = c.FindItemsByType <Item>(false); if (items.Count > 0) { multiple = true; } items.ForEach( ci => { if (ci is Container) { from.SendMessage(0x55, "You cannot trash containers within containers. Please trash them individually."); trashThis = false; } if (!Trash(from, ci, false)) { trashThis = false; } }); if (!trashThis) { OnTrashRejected(from, trashed, message); return(false); } } GetTrashTokens(from, trashed, ref tokens); OnTrashed(from, trashed, ref tokens, message); ItemTrashedEventArgs e = new ItemTrashedEventArgs(this, from, trashed, tokens, message); VitaNexCore.TryCatch(e.Invoke, TrashCollection.CMOptions.ToConsole); if (tokens != e.Tokens) { tokens = Math.Max(0, e.Tokens); } message = e.Message; if (!e.HandledTokens) { TrashCollection.EnsureProfile(from).TransferTokens(from, trashed, tokens, message); } if (from.Backpack != null && TrashCollection.CMOptions.UseTrashedProps) { from.Backpack.FindItemsByType(true, (Item i) => (i is ITrashTokenProperties)).ForEach(i => i.InvalidateProperties()); } if (multiple && message) { from.SendMessage(0x55, "You trashed multiple items, check your profile history for more information."); } trashed.Delete(); return(true); }
public bool Trash(Mobile from, Item trashed, ref int tokens, bool message = true) { tokens = Math.Max(0, tokens); if (!Enabled || from == null || trashed == null || trashed.Deleted) { return(false); } var andThis = true; var multiple = false; if (trashed is Container) { if (trashed.Items.Count > 0) { var i = trashed.Items.Count; while (--i >= 0) { if (!trashed.Items.InBounds(i)) { continue; } if (Trash(from, trashed.Items[i], ref tokens, false)) { multiple = true; } else { andThis = false; } } } if (trashed.Items.Count > 0) { andThis = false; } } if (multiple && message) { from.SendMessage(0x55, "You trashed multiple items, check your profile history for more information."); } if (!CanTrash(from, trashed)) { andThis = false; } if (!andThis) { OnTrashRejected(from, trashed, message); return(false); } GetTrashTokens(from, trashed, ref tokens); OnTrashed(from, trashed, ref tokens, message); var e = new ItemTrashedEventArgs(this, from, trashed, tokens, message); VitaNexCore.TryCatch(e.Invoke, TrashCollection.CMOptions.ToConsole); if (tokens != e.Tokens) { tokens = Math.Max(0, e.Tokens); } message = e.Message; if (!e.HandledTokens) { TrashCollection.EnsureProfile(from).TransferTokens(from, trashed, tokens, message); } if (!multiple && from.Backpack != null && TrashCollection.CMOptions.UseTrashedProps) { from.Backpack.InvalidateProperties <ITrashTokenProperties>(); } trashed.Delete(); return(true); }
public bool Trash(Mobile from, Item trashed, ref int tokens, bool message = true) { tokens = Math.Max(0, tokens); if (!Enabled || from == null || trashed == null || trashed.Deleted) { return false; } if (!CanTrash(from, trashed)) { OnTrashRejected(from, trashed, message); return false; } bool multiple = false; if (trashed is Container) { bool trashThis = true; Container c = (Container)trashed; var items = c.FindItemsByType<Item>(false); if (items.Count > 0) { multiple = true; } items.ForEach( ci => { if (ci is Container) { from.SendMessage(0x55, "You cannot trash containers within containers. Please trash them individually."); trashThis = false; } if (!Trash(from, ci, false)) { trashThis = false; } }); if (!trashThis) { OnTrashRejected(from, trashed, message); return false; } } GetTrashTokens(from, trashed, ref tokens); OnTrashed(from, trashed, ref tokens, message); ItemTrashedEventArgs e = new ItemTrashedEventArgs(this, from, trashed, tokens, message); VitaNexCore.TryCatch(e.Invoke, TrashCollection.CMOptions.ToConsole); if (tokens != e.Tokens) { tokens = Math.Max(0, e.Tokens); } message = e.Message; if (!e.HandledTokens) { TrashCollection.EnsureProfile(from).TransferTokens(from, trashed, tokens, message); } if (from.Backpack != null && TrashCollection.CMOptions.UseTrashedProps) { from.Backpack.FindItemsByType(true, (Item i) => (i is ITrashTokenProperties)).ForEach(i => i.InvalidateProperties()); } if (multiple && message) { from.SendMessage(0x55, "You trashed multiple items, check your profile history for more information."); } trashed.Delete(); return true; }
public bool Trash(Mobile from, Item trashed, ref int tokens, bool message = true) { tokens = Math.Max(0, tokens); if (!Enabled || from == null || trashed == null || trashed.Deleted) { return false; } var andThis = true; var multiple = false; if (trashed is Container) { if (trashed.Items.Count > 0) { var i = trashed.Items.Count; while (--i >= 0) { if (Trash(from, trashed.Items[i], ref tokens, false)) { multiple = true; } else { andThis = false; } } } if (trashed.Items.Count > 0) { andThis = false; } } if (multiple && message) { from.SendMessage(0x55, "You trashed multiple items, check your profile history for more information."); } if (!CanTrash(from, trashed)) { andThis = false; } if (!andThis) { OnTrashRejected(from, trashed, message); return false; } GetTrashTokens(from, trashed, ref tokens); OnTrashed(from, trashed, ref tokens, message); var e = new ItemTrashedEventArgs(this, from, trashed, tokens, message); VitaNexCore.TryCatch(e.Invoke, TrashCollection.CMOptions.ToConsole); if (tokens != e.Tokens) { tokens = Math.Max(0, e.Tokens); } message = e.Message; if (!e.HandledTokens) { TrashCollection.EnsureProfile(from).TransferTokens(from, trashed, tokens, message); } if (!multiple && from.Backpack != null && TrashCollection.CMOptions.UseTrashedProps) { from.Backpack.InvalidateProperties<ITrashTokenProperties>(); } trashed.Delete(); return true; }