Пример #1
0
        public PlayerItemEditor(IReadOnlyList <T> array, int width, int height, bool sysbot = false)
        {
            InitializeComponent();
            this.TranslateInterface(GameInfo.CurrentLanguage);
            ItemArray = new ItemArrayEditor <T>(array);

            var Editor = ItemGrid = new ItemGridEditor(ItemEditor, array)
            {
                Dock = DockStyle.Fill
            };

            Editor.InitializeGrid(width, height, 64, 64);
            PAN_Items.Controls.Add(Editor);

            ItemEditor.Initialize(GameInfo.Strings.ItemDataSource);
            Editor.LoadItems();
            DialogResult     = DialogResult.Cancel;
            LoadItems        = () => Editor.LoadItems();
            B_Inject.Visible = sysbot;
        }
Пример #2
0
    public void LoadCheats()
    {
        if (UI_ACItemGrid.LastInstanceOfItemGrid == null)
        {
            return;
        }
        string parseable = CheatField.text;
        ItemArrayEditor <Item> ItemArray = new ItemArrayEditor <Item>(UI_ACItemGrid.LastInstanceOfItemGrid.Items);

        if (parseable != "")
        {
            var bytes = ItemCheatCode.ReadCode(parseable);
            if (bytes.Length % ItemArray.ItemSize == 0)
            {
                ItemArray.ImportItemDataX(bytes, EmptySpacesOnly.isOn, 0);
            }
        }

        for (int i = 0; i < ItemArray.Items.Count; ++i)
        {
            UI_ACItemGrid.LastInstanceOfItemGrid.SetItemAt(ItemArray.Items[i], i, i == (ItemArray.Items.Count - 1));
        }
    }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="items">Items to inject to floor of island</param>
        /// <param name="fillToMax">Whether to fill the array to the full <see cref="MaxOrder"/> amount</param>
        public MultiItem(Item[] items, bool catalogue = false, bool fillToMax = true, bool stackMax = true)
        {
            var itemArray = items;

            if (stackMax)
            {
                StackToMax(itemArray);
            }

            if (items.Length < MaxOrder && fillToMax && !catalogue)
            {
                int itemMultiplier = (int)(1f / ((1f / MaxOrder) * items.Length));
                var newItems       = new List <Item>(items);
                for (int i = 0; i < items.Length; ++i)
                {
                    // duplicate those without variations
                    // attempt get body variations
                    var currentItem = items[i];
                    var remake      = ItemRemakeUtil.GetRemakeIndex(currentItem.ItemId);
                    var associated  = GameInfo.Strings.GetAssociatedItems(currentItem.ItemId, out _);
                    if (remake > 0 && currentItem.Count == 0) // ItemRemake: only do this if they've asked for the base count of an item!
                    {
                        var info           = ItemRemakeInfoData.List[remake];
                        var body           = info.GetBodySummary(GameInfo.Strings);
                        var bodyVariations = body.Split(new string[2] {
                            "\n", "\r\n"
                        }, StringSplitOptions.RemoveEmptyEntries);
                        if (bodyVariations.Length < 1)
                        {
                            var mItems = DeepDuplicateItem(currentItem, itemMultiplier);
                            newItems.AddRange(mItems);
                            continue;
                        }
                        int varCount = bodyVariations.Length;
                        if (!bodyVariations[0].StartsWith("0"))
                        {
                            varCount++;
                        }
                        var multipliedItems = DeepDuplicateItem(currentItem, varCount);
                        for (ushort j = 1; j < varCount; ++j)
                        {
                            var itemToAdd = multipliedItems[j];
                            itemToAdd.Count = j;
                            newItems.Add(itemToAdd);
                        }
                    }
                    else if (associated.Count > 1 && currentItem.ItemId != Item.DIYRecipe) // clothing with parenthesised versions
                    {
                        for (int j = 0; j < associated.Count; ++j)
                        {
                            var toAdd = new Item();
                            toAdd.CopyFrom(currentItem);
                            toAdd.ItemId = (ushort)associated[j].Value;
                            newItems.Add(toAdd);
                        }
                    }
                    else if (remake < 0)
                    {
                        var multipliedItems = DeepDuplicateItem(currentItem, itemMultiplier);
                        newItems.AddRange(multipliedItems);
                    }

                    if (newItems.Count >= MaxOrder) // not the best way to do this, but at worst you'll need an extra line on your map
                    {
                        break;
                    }
                }

                if (newItems.Count > MaxOrder)
                {
                    itemArray = newItems.Take(MaxOrder).ToArray();
                }
                else
                {
                    itemArray = newItems.ToArray();
                }
            }
            var itemsToAdd = (Item[])itemArray.Clone();

            var len = itemsToAdd.Length;

            if (len < MaxOrder && fillToMax)
            {
                // repeat last item
                Item toDupe = itemsToAdd[len - 1];
                var  dupes  = DeepDuplicateItem(toDupe, MaxOrder - len);
                itemsToAdd = itemsToAdd.Concat(dupes).ToArray();

                // add a hole to know where the split is
                itemsToAdd[len] = new Item(Item.NONE);
            }

            ItemArray = new ItemArrayEditor <Item>(itemsToAdd);
        }
Пример #4
0
 public MultiItem()
 {
     ItemArray = new ItemArrayEditor <Item>(System.Array.Empty <Item>());
 }
Пример #5
0
    public void LoadCheats()
    {
        string parseable = CheatField.text;
        ItemArrayEditor <Item> ItemArray;

        if (SaveMode.value == 0)
        {
            ItemArray = new ItemArrayEditor <Item>(UI_ACItemGrid.LastInstanceOfItemGrid.Items);
        }
        else
        {
            ItemArray = new ItemArrayEditor <Item>(GetNoItems(40));
        }

        byte[] allItemBytes = null;

        if (EnteredValueParseMode.value == 0) // 0 == cheat
        {
            if (parseable != "")
            {
                var bytes = ItemCheatCode.ReadCode(parseable);
                ItemArray = new ItemArrayEditor <Item>(UI_ACItemGrid.LastInstanceOfItemGrid.Items);
                if (bytes.Length % ItemArray.ItemSize == 0)
                {
                    ItemArray.ImportItemDataX(bytes, EmptySpacesOnly.isOn, 0);
                }
                allItemBytes = bytes;
            }
        }
        else // 1 == hexdata
        {
            if (parseable != "")
            {
                List <byte[]> loadedItems = new List <byte[]>();
                var           split       = parseable.Split(new[] { " ", "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < split.Length; ++i)
                {
                    var itemText = split[i];
                    var item     = itemText.Trim();
                    var asBytes  = GetBytesFromString(item);
                    loadedItems.Add(asBytes);
                }

                while (loadedItems.Count < 40)
                {
                    loadedItems.Add(Item.NO_ITEM.ToBytesClass());
                }

                allItemBytes = new byte[Item.SIZE * 40];
                for (int i = 0; i < loadedItems.Count; ++i)
                {
                    Array.Copy(loadedItems[i], 0, allItemBytes, i * Item.SIZE, Item.SIZE);
                }

                ItemArray.ImportItemDataX(allItemBytes, EmptySpacesOnly.isOn, 0);
            }
        }


        if (SaveMode.value == 0) // 0 == inventory
        {
            if (UI_ACItemGrid.LastInstanceOfItemGrid == null)
            {
                return;
            }

            for (int i = 0; i < ItemArray.Items.Count; ++i)
            {
                UI_ACItemGrid.LastInstanceOfItemGrid.SetItemAt(ItemArray.Items[i], i, i == (ItemArray.Items.Count - 1));
            }
        }
        else
        {
            if (allItemBytes != null)
            {
                UI_NFSOACNHHandler.LastInstanceOfNFSO.SaveFile("NHIItems.nhi", allItemBytes);
            }
            else
            {
                throw new Exception("No valid items.");
            }
        }
    }
Пример #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="items">Items to inject to floor of island</param>
        /// <param name="fillToMax">Whether to fill the array to the full <see cref="MaxOrder"/> amount</param>
        public MultiItem(Item[] items, bool catalogue = false, bool fillToMax = true, bool stackMax = true)
        {
            var itemArray = items;

            if (stackMax)
            {
                StackToMax(itemArray);
            }

            if (items.Length < MaxOrder && fillToMax && !catalogue)
            {
                int itemMultiplier = (int)(1f / ((1f / MaxOrder) * items.Length));
                var newItems       = new List <Item>(items);
                for (int i = 0; i < items.Length; ++i)
                {
                    // duplicate those without variations
                    // attempt get body variations
                    var currentItem = items[i];
                    var remake      = ItemRemakeUtil.GetRemakeIndex(currentItem.ItemId);
                    if (remake > 0 && currentItem.Count == 0) // only do this if they've asked for the base count of an item!
                    {
                        var info           = ItemRemakeInfoData.List[remake];
                        var body           = info.GetBodySummary(GameInfo.Strings);
                        var bodyVariations = body.Split(new string[2] {
                            "\n", "\r\n"
                        }, StringSplitOptions.RemoveEmptyEntries);
                        int varCount = bodyVariations.Length;
                        if (!bodyVariations[0].StartsWith("0"))
                        {
                            varCount++;
                        }
                        var multipliedItems = DeepDuplicateItem(currentItem, varCount);
                        for (ushort j = 1; j < varCount; ++j)
                        {
                            var itemToAdd = multipliedItems[j];
                            itemToAdd.Count = j;
                            newItems.Add(itemToAdd);
                        }
                    }
                    else if (remake < 0)
                    {
                        var multipliedItems = DeepDuplicateItem(currentItem, itemMultiplier);
                        newItems.AddRange(multipliedItems);
                    }

                    if (newItems.Count >= MaxOrder) // not the best way to do this, but at worst you'll need an extra line on your map
                    {
                        break;
                    }
                }

                if (newItems.Count > MaxOrder)
                {
                    itemArray = newItems.Take(MaxOrder).ToArray();
                }
                else
                {
                    itemArray = newItems.ToArray();
                }
            }
            var itemsToAdd = (Item[])itemArray.Clone();

            ItemArray = new ItemArrayEditor <Item>(itemsToAdd);
        }