public ViewModelWindowEditorItemsBrowserWindow(Action closeCallback) { this.CommandClose = new ActionCommand(closeCallback); this.AllItemsList = ClientContainerSortHelper.SortItemPrototypes( Api.FindProtoEntities <IProtoItem>().ToList()) .ToList() .Where(i => i.Icon != null) .Select(i => new ViewItemWithIcon(i)) .ToList(); this.SelectedProtoItemViewModel = this.AllItemsList.FirstOrDefault(); }
public ViewModelWindowEditorSkinsBrowser(Action closeCallback) { this.CommandClose = new ActionCommand(closeCallback); var list = ClientContainerSortHelper.SortItemPrototypes( Api.FindProtoEntities <IProtoItem>().ToList()) .Cast <IProtoItemWithSkinData>() .ToList() .Where(i => i.IsSkin || i.IsSkinnable && i.Skins.Count > 0) .Select(i => new ViewItemSkinWithIcon(i)) .ToList(); list.SortBy(g => (ushort)g.ProtoItem.SkinId); var grouped = list.GroupBy(g => g.ProtoItem.BaseProtoItem ?? g.ProtoItem).ToList(); grouped.SortBy(g => (ushort)g.FirstOrDefault(g => g.ProtoItem.IsSkin).ProtoItem.SkinId); this.AllItemsList = grouped.SelectMany(g => g).ToList(); }
private void ExecuteCommandMatch(bool isUp) { var playerPrivateState = PlayerCharacter.GetPrivateState(Character); var playerInventory = playerPrivateState.ContainerInventory; var playerHotbar = playerPrivateState.ContainerHotbar; var receivingContainers = new List <IItemsContainer>(); IEnumerable <IItem> sourceItems; if (isUp) { // move items "up" - from player inventory to this crate container sourceItems = playerInventory.Items; receivingContainers.AddRange(inputContainers); foreach (var receivingContainer in receivingContainers) { ClientContainerSortHelper.ConsolidateItemStacks((IClientItemsContainer)receivingContainer); } } else { // move items "down" - from this crate container to player containers sourceItems = outputContainers.SelectMany(i => i.Items); receivingContainers.Add(playerInventory); receivingContainers.Add(playerHotbar); } var isAtLeastOneItemMoved = false; if (isUp && isInsertingWithoutMatch) { foreach (var itemToMove in sourceItems.OrderBy(i => i.ProtoItem.Id)) { if (receivingContainers .Any(it => ItemsService.MoveOrSwapItem(itemToMove, it, allowSwapping: false, isLogErrors: false))) { isAtLeastOneItemMoved = true; } } if (isAtLeastOneItemMoved) { ItemsSoundPresets.ItemGeneric.PlaySound(ItemSound.Drop); } return; } var itemTypesToMove = new HashSet <IProtoItem>(receivingContainers.SelectMany(i => i.Items).Select(i => i.ProtoItem)); var itemsToMove = sourceItems .Where(item => itemTypesToMove.Contains(item.ProtoItem)) .OrderBy(i => i.ProtoItem.Id) .ToList(); foreach (var itemToMove in itemsToMove) { if (receivingContainers .Any(it => ItemsService.MoveOrSwapItem(itemToMove, it, allowSwapping: false, isLogErrors: false))) { isAtLeastOneItemMoved = true; } } if (isAtLeastOneItemMoved) { ItemsSoundPresets.ItemGeneric.PlaySound(ItemSound.Drop); } if (!isUp && itemsToMove.Any(i => outputContainers.Contains(i.Container))) { // at least one item stuck in the container when matching down // it means there are not enough space NotificationSystem.ClientShowNotificationNoSpaceInInventory(); } }