Exemple #1
0
        private void CB_ItemID_SelectedValueChanged(object sender, EventArgs e)
        {
            var itemID    = (ushort)WinFormsUtil.GetIndex(CB_ItemID);
            var itemCount = (ushort)NUD_Count.Value;

            ChangeItem(itemID, itemCount);
            var kind = ItemInfo.GetItemKind(itemID);

            ToggleEditorVisibility(kind);
            if (!Loading)
            {
                LoadItemTypeValues(kind, itemID);
            }

            var remake = ItemRemakeUtil.GetRemakeIndex(itemID);

            if (remake < 0)
            {
                L_RemakeBody.Visible   = false;
                L_RemakeFabric.Visible = false;
            }
            else
            {
                var info = ItemRemakeInfoData.List[remake];
                var body = info.GetBodySummary(GameInfo.Strings);
                L_RemakeBody.Text    = body;
                L_RemakeBody.Visible = body.Length != 0;

                var fabric = info.GetFabricSummary(GameInfo.Strings);
                L_RemakeFabric.Text    = fabric;
                L_RemakeFabric.Visible = fabric.Length != 0;
            }
        }
Exemple #2
0
        private void FillRemake(IReadOnlyList <string> items)
        {
            var str    = GameInfo.Strings;
            var invert = ItemRemakeUtil.GetInvertedDictionary();
            var ofs    = Player.Personal.Offsets.ItemRemakeCollectBit;
            var max    = Player.Personal.Offsets.MaxRemakeBitFlag;
            var data   = Player.Personal.Data;

            for (int i = 0; i < max; i++)
            {
                var remakeIndex = i >> 3; // ItemRemakeInfo.BodyColorCountMax
                var variant     = i & 7;

                ushort itemId   = invert.TryGetValue((short)remakeIndex, out var id) ? id : (ushort)0;
                var    itemName = remakeIndex == 0652 ? "photo" : items[itemId];

                var    flag = FlagUtil.GetFlag(data, ofs, i);
                string name = $"{remakeIndex:0000} V{variant:0} - {itemName}";

                if (ItemRemakeInfoData.List.TryGetValue((short)remakeIndex, out var info))
                {
                    name = $"{name} ({info.GetBodyDescription(variant, str)})";
                }

                CLB_Remake.Items.Add(name, flag);
            }
        }
        public async Task CustomizeAsync([Summary("Item ID (in hex)")] string itemHex, [Summary("Customization value sum")] int sum)
        {
            if (!Globals.Bot.Config.AllowLookup)
            {
                return;
            }
            ushort itemID = ItemUtil.GetID(itemHex);

            if (itemID == Item.NONE)
            {
                await ReplyAsync("Invalid item requested.").ConfigureAwait(false);

                return;
            }
            if (sum <= 0)
            {
                await ReplyAsync("No customization data specified.").ConfigureAwait(false);

                return;
            }

            var remake = ItemRemakeUtil.GetRemakeIndex(itemID);

            if (remake < 0)
            {
                await ReplyAsync("No customization data available for the requested item.").ConfigureAwait(false);

                return;
            }

            int body   = sum & 7;
            int fabric = sum >> 5;

            if (fabric > 7 || ((fabric << 5) | body) != sum)
            {
                await ReplyAsync("Invalid customization data specified.").ConfigureAwait(false);

                return;
            }

            var info = ItemRemakeInfoData.List[remake];
            // already checked out-of-range body/fabric values above
            bool hasBody   = body == 0 || body <= info.ReBodyPatternNum;
            bool hasFabric = fabric == 0 || info.GetFabricDescription(fabric) != "Invalid";

            if (!hasBody || !hasFabric)
            {
                await ReplyAsync("Requested customization for item appears to be invalid.").ConfigureAwait(false);
            }

            var item = new Item(itemID)
            {
                BodyType = body, PatternChoice = fabric
            };
            var msg = ItemUtil.GetItemText(item);

            await ReplyAsync(msg).ConfigureAwait(false);
        }
        private void CB_Item_SelectedValueChanged(object sender, EventArgs e)
        {
            var index = WinFormsUtil.GetIndex(CB_Item);
            if ((uint)index >= CLB_Items.Items.Count)
                index = 0;
            CLB_Items.SelectedIndex = index;

            var remake = ItemRemakeUtil.GetRemakeIndex((ushort)index);
            if (remake > 0)
                CLB_Remake.SelectedIndex = remake * ItemRemakeInfo.BodyColorCountMax;
        }
Exemple #5
0
        public static string GetItemInfo(ushort itemID)
        {
            var remake = ItemRemakeUtil.GetRemakeIndex(itemID);

            if (remake < 0)
            {
                return(string.Empty);
            }

            var info = ItemRemakeInfoData.List[remake];

            return(GetItemInfo(info, GameInfo.Strings));
        }
        private void GiveItem(ushort item, bool value = true)
        {
            CLB_Items.SetItemChecked(item, value);

            var remakeIndex = ItemRemakeUtil.GetRemakeIndex(item);
            if (!ItemRemakeInfoData.List.TryGetValue(remakeIndex, out var info))
                return;

            for (int i = 0; i < ItemRemakeInfo.BodyColorCountMax; i++)
            {
                if (!info.HasBodyColor(i))
                    continue;
                int rIndex = (remakeIndex * ItemRemakeInfo.BodyColorCountMax) + i;
                CLB_Remake.SetItemChecked(rIndex, value);
            }
        }
Exemple #7
0
        private void CB_ItemID_SelectedValueChanged(object sender, EventArgs e)
        {
            var itemID    = (ushort)WinFormsUtil.GetIndex(CB_ItemID);
            var itemCount = (ushort)NUD_Count.Value;

            ChangeItem(itemID, itemCount);
            var kind = ItemInfo.GetItemKind(itemID);

            ToggleEditorVisibility(kind, itemID);
            if (!Loading)
            {
                LoadItemTypeValues(kind, itemID);
            }

            var remake = ItemRemakeUtil.GetRemakeIndex(itemID);

            if (remake < 0)
            {
                var closeItems = GameInfo.Strings.GetAssociatedItems(itemID, out var bse);
                if (closeItems.Count > 1) // ignore if we are the only parenthesised item
                {
                    L_RemakeBody.Text    = $"{bse.Trim()}:\n" + closeItems.ToStringList(false);
                    L_RemakeBody.Visible = true;
                }
                else
                {
                    L_RemakeBody.Visible   = false;
                    L_RemakeFabric.Visible = false;
                }
            }
            else
            {
                var info = ItemRemakeInfoData.List[remake];
                var body = info.GetBodySummary(GameInfo.Strings);
                L_RemakeBody.Text    = body;
                L_RemakeBody.Visible = body.Length != 0;

                var fabric = info.GetFabricSummary(GameInfo.Strings);
                L_RemakeFabric.Text    = fabric;
                L_RemakeFabric.Visible = fabric.Length != 0;
            }
            MakeMaxCount();
        }
    public void SelectItem(ItemFilter itemF, int id, UI_SearchItem sItem)
    {
        if (id == Item.NONE)
        {
            return;
        }
        if (ItemExtensions.IsInternalItem((ushort)id))
        {
            if (!InternalItemWarning.gameObject.activeInHierarchy)
            {
                InternalItemWarning.gameObject.SetActive(true);
            }
            else
            {
                InternalItemWarning.Start();
            }
        }
        SetController.FCount.text = id.ToString();
        ItemSelectedName.text     = sItem.RawValue;
        switch (itemF)
        {
        case ItemFilter.Recipes:
            CurrentItemID = RECIPEITEM;
            break;

        case ItemFilter.Fossils:
            CurrentItemID = FOSSILITEM;
            break;

        case ItemFilter.MsgBottle:
            CurrentItemID = MESSAGEBOTTLEITEM;
            break;

        default:
            CurrentItemID             = id;
            SetController.FCount.text = 0.ToString();
            break;
        }

        CurrentSelectedIndex = spawnedObjects.IndexOf(sItem);
        if (ItemInfo.GetItemKind(Convert.ToUInt16(CurrentItemID)).IsFlower())
        {
            FlowerButtonRoot.SetActive(true);
        }
        else
        {
            FlowerController.ResetToZero();
            FlowerButtonRoot.SetActive(false);
        }

        /*if (new Item((ushort)id).IsMoneyTree())
         *  TreeButtonRoot.gameObject.SetActive(true);
         * else
         *  TreeButtonRoot.gameObject.SetActive(false);*///uncomment this if you want star tree editor again for whatever reason

        short remakeIndex = ItemRemakeUtil.GetRemakeIndex(Convert.ToUInt16(CurrentItemID));

        if (remakeIndex < 0)
        {
            SetController.CreateBody(new string[0]);
            SetController.CreateFabric(new string[0]);
        }
        else
        {
            ItemRemakeInfo itemRemakeInfo = ItemRemakeInfoData.List[remakeIndex];
            string         bodySummary    = itemRemakeInfo.GetBodySummary(GameInfo.Strings, false);
            if (bodySummary.Length != 0)
            {
                string[] values = bodySummary.Split(new string[3]
                {
                    "\r\n",
                    "\r",
                    "\n"
                }, StringSplitOptions.None);
                SetController.CreateBody(values);
            }
            else
            {
                SetController.CreateBody(new string[0]);
            }
            string fabricSummary = itemRemakeInfo.GetFabricSummary(GameInfo.Strings, false, false);
            if (fabricSummary.Length != 0)
            {
                string[] values2 = fabricSummary.Split(new string[3]
                {
                    "\r\n",
                    "\r",
                    "\n"
                }, StringSplitOptions.None);
                SetController.CreateFabric(values2);
            }
            else
            {
                SetController.CreateFabric(new string[0]);
            }
        }
        if (currentAnimationFuction != null)
        {
            StopCoroutine(currentAnimationFuction);
        }
        currentAnimationFuction = StartCoroutine(sendSelectorToSelected());

        UpdateSprite();
    }
        /// <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);
        }
Exemple #10
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);
        }
        public static void TestDuplicateVariation(string name, ulong itemValueParse)
        {
            var items = ItemParser.GetItemsFromUserInput(itemValueParse.ToString("X"), new DropBotConfig(), ItemDestination.PlayerDropped);

            items.Count.Should().Be(1);

            var currentItem = items.ElementAt(0);
            var multiItem   = new MultiItem(new Item[1] {
                currentItem
            });

            var itemName = GameInfo.Strings.GetItemName(currentItem);

            itemName.Should().StartWith(name);

            // variations
            var remake = ItemRemakeUtil.GetRemakeIndex(currentItem.ItemId);

            if (remake > 0)
            {
                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++;
                }

                multiItem.ItemArray.Items[varCount].ItemId.Should().Be(Item.NONE);
                multiItem.ItemArray.Items[varCount + 1].ItemId.Should().Be(currentItem.ItemId);

                foreach (var itm in multiItem.ItemArray.Items)
                {
                    // No leaking associated items
                    if (itm.IsNone)
                    {
                        continue;
                    }
                    var itmName = GameInfo.Strings.GetItemName(itm);
                    itemName.Should().Be(itmName);
                }
            }

            // association
            var associated = GameInfo.Strings.GetAssociatedItems(currentItem.ItemId, out var itemPrefix);

            if (associated.Count > 1 && currentItem.ItemId != Item.DIYRecipe)
            {
                foreach (var asoc in multiItem.ItemArray.Items)
                {
                    var asocName = GameInfo.Strings.GetItemName(asoc);
                    asocName.Should().EndWith(")");
                }
            }

            // everything else
            if (currentItem.ItemId == Item.DIYRecipe)
            {
                foreach (var itm in multiItem.ItemArray.Items)
                {
                    itm.ItemId.Should().Be(Item.DIYRecipe);
                }
            }
        }
Exemple #12
0
    public void SelectItem(ItemFilter itemF, int id, UI_SearchItem sItem)
    {
        if (id == Item.NONE)
        {
            return;
        }
        SetController.FCount.text = id.ToString();
        ItemSelectedName.text     = sItem.RawValue;
        switch (itemF)
        {
        case ItemFilter.Recipes:
            CurrentItemID = RECIPEITEM;
            break;

        case ItemFilter.Fossils:
            CurrentItemID = FOSSILITEM;
            break;

        case ItemFilter.MsgBottle:
            CurrentItemID = MESSAGEBOTTLEITEM;
            break;

        default:
            CurrentItemID             = id;
            SetController.FCount.text = 0.ToString();
            break;
        }
        CurrentSelectedIndex = spawnedObjects.IndexOf(sItem);
        if (ItemInfo.GetItemKind(Convert.ToUInt16(CurrentItemID)).IsFlower())
        {
            FlowerButtonRoot.SetActive(true);
        }
        else
        {
            FlowerController.ResetToZero();
            FlowerButtonRoot.SetActive(false);
        }
        short remakeIndex = ItemRemakeUtil.GetRemakeIndex(Convert.ToUInt16(CurrentItemID));

        if (remakeIndex < 0)
        {
            SetController.CreateBody(new string[0]);
            SetController.CreateFabric(new string[0]);
        }
        else
        {
            ItemRemakeInfo itemRemakeInfo = ItemRemakeInfoData.List[remakeIndex];
            string         bodySummary    = itemRemakeInfo.GetBodySummary(GameInfo.Strings, tryGetDescriptor: false);
            if (bodySummary.Length != 0)
            {
                string[] values = bodySummary.Split(new string[3]
                {
                    "\r\n",
                    "\r",
                    "\n"
                }, StringSplitOptions.None);
                SetController.CreateBody(values);
            }
            else
            {
                SetController.CreateBody(new string[0]);
            }
            string fabricSummary = itemRemakeInfo.GetFabricSummary(GameInfo.Strings, tryGetDescriptor: false);
            if (fabricSummary.Length != 0)
            {
                string[] values2 = fabricSummary.Split(new string[3]
                {
                    "\r\n",
                    "\r",
                    "\n"
                }, StringSplitOptions.None);
                SetController.CreateFabric(values2);
            }
            else
            {
                SetController.CreateFabric(new string[0]);
            }
        }
        if (currentAnimationFuction != null)
        {
            StopCoroutine(currentAnimationFuction);
        }
        currentAnimationFuction = StartCoroutine(sendSelectorToSelected());
    }