public ItemGridProvider Clone(int newRotation) { var provider = new ItemGridProvider(Items.ToList(), Rows, Columns, CurrentRotation); if (CurrentRotation != -1) { provider.UpdateCurrentRotation(newRotation); } return(provider); }
public void Initialize() { name = Config.Name; description = Config.Description ?? description; defaultSourceRect = sourceRect = GetDefaultSourceRect(Config.Sprite, defaultSourceRect.Width, defaultSourceRect.Height); for (var i = 0; i < currentRotation; ++i) { rotate(); } var heldChest = heldObject as Chest; if (heldChest == null) { heldChest = new Chest(true); heldChest.items.AddRange(Enumerable.Repeat <Item>(null, Config.Layout.Rows * Config.Layout.Columns)); heldChest.items[0] = heldObject; heldObject = heldChest; } ItemProvider = new ItemGridProvider(heldChest.items, Config.Layout.Rows, Config.Layout.Columns, currentRotation); }
private static void ForEachDrawItem(ItemGridProvider itemProvider, IShowcaseLayout layout, Action <Item, Vector2> action) { for (var i = 0; i < itemProvider.Rows; ++i) { for (var j = 0; j < itemProvider.Columns; ++j) { var item = itemProvider[i, j]; if (item == null) { continue; } var relativeItemPosition = layout.GetItemViewRelativePosition(i, j); if (relativeItemPosition == null) { return; } action(item, relativeItemPosition.Value); } } }
private IShowcaseLayout GetLayout(float scaleSize, Rectangle actualSourceRect, ItemGridProvider itemProvider) { switch (Config.Layout.Type) { case ShowcaseLayoutKind.Fixed: return(new ShowcaseFixedLayout(scaleSize, actualSourceRect, itemProvider, Config.Layout)); case ShowcaseLayoutKind.Auto: return(new ShowcaseAutoLayout(scaleSize, actualSourceRect, itemProvider, Config.Layout)); case ShowcaseLayoutKind.Manual: return(new ShowcaseManualLayout(scaleSize, Config.Layout)); default: throw new ArgumentOutOfRangeException(); } }