Example #1
0
    public override void RefreshEnabled()
    {
        base.RefreshEnabled();
        this.state = ItemActionEntryResharpenSDX.StateTypes.Normal;
        XUi xui = base.ItemController.xui;

        if (((XUiC_ItemStack)base.ItemController).ItemStack.IsEmpty() || ((XUiC_ItemStack)base.ItemController).StackLock)
        {
            return;
        }
        ItemClass forId = ItemClass.GetForId(((XUiC_ItemStack)base.ItemController).ItemStack.itemValue.type);

        base.Enabled = (this.state == ItemActionEntryResharpenSDX.StateTypes.Normal);
        if (!base.Enabled)
        {
            base.IconName = "ui_game_symbol_book";
            return;
        }
        ItemValue itemValue = ((XUiC_ItemStack)base.ItemController).ItemStack.itemValue;

        if (forId.RepairTools != null && forId.RepairTools.Length > 0)
        {
            ItemClass itemClass = ItemClass.GetItemClass(forId.RepairTools[0].Value, false);
            if (itemClass != null)
            {
                int b = Convert.ToInt32(Math.Ceiling((double)((float)Mathf.CeilToInt(itemValue.UseTimes) / (float)itemClass.RepairAmount.Value)));
                xui.PlayerInventory.GetItemCount(new ItemValue(itemClass.Id, false));
                if (Mathf.Min(xui.PlayerInventory.GetItemCount(new ItemValue(itemClass.Id, false)), b) * itemClass.RepairAmount.Value <= 0)
                {
                    this.state   = ItemActionEntryResharpenSDX.StateTypes.NotEnoughMaterials;
                    base.Enabled = (this.state == ItemActionEntryResharpenSDX.StateTypes.Normal);
                }
            }
        }
    }
Example #2
0
    public override void OnDisabledActivate()
    {
        ItemActionEntryResharpenSDX.StateTypes stateTypes = this.state;
        if (stateTypes != ItemActionEntryResharpenSDX.StateTypes.NotEnoughMaterials)
        {
            return;
        }
        GameManager.ShowTooltip(base.ItemController.xui.playerUI.entityPlayer, this.lblNeedMaterials);
        ItemClass forId = ItemClass.GetForId(((XUiC_ItemStack)base.ItemController).ItemStack.itemValue.type);

        if (forId.Properties.Contains("SharpenItem"))
        {
            String strSharpenItem = String.Empty;
            forId.Properties.ParseString("SharpenItem", ref strSharpenItem);
            if (String.IsNullOrEmpty(strSharpenItem))
            {
                return;
            }
            ItemClass itemClass = ItemClass.GetItemClass(strSharpenItem, false);
            if (itemClass != null)
            {
                ItemStack @is = new ItemStack(new ItemValue(itemClass.Id, false), 0);
                base.ItemController.xui.playerUI.entityPlayer.AddUIHarvestingItem(@is, true);
            }
        }
    }