public static void RemoveFriend(object obj = null) { int serial = obj != null ? AliasCommands.ResolveSerial(obj) : UOC.GetTargetSerialAsync(Strings.Target_friend_to_remove___).Result; if (serial == 0) { UOC.SystemMessage(Strings.Invalid_or_unknown_object_id); return; } FriendEntry entry = Options.CurrentOptions.Friends.FirstOrDefault(i => i.Serial == serial); if (entry == null) { return; } Engine.Dispatcher?.Invoke(() => { bool result = Options.CurrentOptions.Friends.Remove(entry); if (!Options.CurrentOptions.RehueFriends) { return(result); } Engine.RehueList.Remove(serial); MainCommands.Resync(); return(result); }); }
public override void Execute() { int serial = UOC.GetTargetSerialAsync(Strings.Target_container___).Result; Entity entity = Engine.Items.GetItem(serial) ?? (Entity)Engine.Mobiles.GetMobile(serial); if (entity == null) { UOC.SystemMessage(Strings.Cannot_find_item___); return; } ItemCollection collection = new ItemCollection(entity.Serial); switch (entity) { case Item item: if (item.Container == null) { UOC.WaitForContainerContentsUse(item.Serial, 1000); } collection = item.Container ?? new ItemCollection(item.Serial); break; case Mobile mobile: collection = new ItemCollection(entity.Serial) { mobile.GetEquippedItems() }; break; } Thread t = new Thread(() => { EntityCollectionViewer window = new EntityCollectionViewer { DataContext = new EntityCollectionViewerViewModel(collection) }; window.Show(); Dispatcher.Run(); }) { IsBackground = true }; t.SetApartmentState(ApartmentState.STA); t.Start(); }
private static bool OnHide(string[] arg) { Task.Run(async() => { int serial = await UOC.GetTargetSerialAsync(); if (serial == 0) { UOC.SystemMessage(Strings.Cannot_find_item___); return; } UOC.RemoveObject(serial); }); return(true); }
public static int AddFriend(object obj = null) { int serial = obj != null ? AliasCommands.ResolveSerial(obj) : UOC.GetTargetSerialAsync(Strings.Target_new_friend___).Result; if (serial == 0) { UOC.SystemMessage(Strings.Invalid_or_unknown_object_id); return(0); } Mobile m = Engine.Mobiles.GetMobile(serial); if (m == null) { UOC.SystemMessage(Strings.Invalid_or_unknown_object_id); return(0); } FriendEntry fe = new FriendEntry { Name = m.Name?.Trim(), Serial = m.Serial }; if (!Options.CurrentOptions.Friends.Contains(fe)) { Engine.Dispatcher?.Invoke(() => { Options.CurrentOptions.Friends.Add(fe); if (Options.CurrentOptions.RehueFriends) { MainCommands.Resync(); } }); } return(m.Serial); }