コード例 #1
0
 private static string ReplaceLine(ItemDrop.ItemData item, int qualityLevel, bool crafting, string line)
 {
     return(line
            .Replace("{itemDescription}", item.m_shared.m_description)
            .Replace("{itemSpawnName}", GetSpawnName(item))
            .Replace("{itemCrafterName}", item.m_crafterName.ToString())
            .Replace("{itemValue}", item.GetValue().ToString())
            .Replace("{itemBaseValue}", item.m_shared.m_value.ToString())
            .Replace("{itemWeight}", item.GetWeight().ToString())
            .Replace("{itemQuality}", qualityLevel.ToString())
            .Replace("{itemMaxDurability}", item.GetMaxDurability(qualityLevel).ToString())
            .Replace("{itemPercentDurability}", (item.GetDurabilityPercentage() * 100f).ToString("0"))
            .Replace("{itemDurability}", item.m_durability.ToString("0"))
            .Replace("{itemStationLevel}", ObjectDB.instance.GetRecipe(item)?.m_minStationLevel.ToString())
            .Replace("{itemMovementMod}", (item.m_shared.m_movementModifier * 100f).ToString("+0;-0"))
            .Replace("{totalMovementMod}", (Player.m_localPlayer.GetEquipmentMovementModifier() * 100).ToString("+0;-0"))
            .Replace("{itemSetSize}", item.m_shared.m_setSize.ToString())
            .Replace("{itemDamage}", GetDamageString(item, qualityLevel))
            .Replace("{itemBaseBlock}", item.GetBaseBlockPower(qualityLevel).ToString())
            .Replace("{itemBlock}", item.GetBlockPowerTooltip(qualityLevel).ToString("0"))
            .Replace("{itemDeflection}", item.GetDeflectionForce(qualityLevel).ToString())
            .Replace("{itemBlockBonus}", item.m_shared.m_timedBlockBonus.ToString())
            .Replace("{itemAttackForce}", item.m_shared.m_attackForce.ToString())
            .Replace("{itemBackstab}", item.m_shared.m_backstabBonus.ToString())
            .Replace("{itemArmor}", item.GetArmor(qualityLevel).ToString())
            .Replace("{itemFoodHealth}", item.m_shared.m_food.ToString())
            .Replace("{itemSetSize}", item.m_shared.m_setSize.ToString())
            .Replace("{itemFoodStamina}", item.m_shared.m_foodStamina.ToString())
            .Replace("{itemFoodDuration}", item.m_shared.m_foodBurnTime.ToString())
            .Replace("{itemFoodRegen}", item.m_shared.m_foodRegen.ToString())
            .Replace("\\n", "\n"));
 }
コード例 #2
0
ファイル: ItemDrop.cs プロジェクト: ingvard/valheim-jserver
        // Token: 0x0600114C RID: 4428 RVA: 0x00077F18 File Offset: 0x00076118
        public static string GetTooltip(ItemDrop.ItemData item, int qualityLevel, bool crafting)
        {
            Player        localPlayer   = Player.m_localPlayer;
            StringBuilder stringBuilder = new StringBuilder(256);

            stringBuilder.Append(item.m_shared.m_description);
            stringBuilder.Append("\n\n");
            if (item.m_shared.m_dlc.Length > 0)
            {
                stringBuilder.Append("\n<color=aqua>$item_dlc</color>");
            }
            ItemDrop.ItemData.AddHandedTip(item, stringBuilder);
            if (item.m_crafterID != 0L)
            {
                stringBuilder.AppendFormat("\n$item_crafter: <color=orange>{0}</color>", item.m_crafterName);
            }
            if (!item.m_shared.m_teleportable)
            {
                stringBuilder.Append("\n<color=orange>$item_noteleport</color>");
            }
            if (item.m_shared.m_value > 0)
            {
                stringBuilder.AppendFormat("\n$item_value: <color=orange>{0}  ({1})</color>", item.GetValue(), item.m_shared.m_value);
            }
            stringBuilder.AppendFormat("\n$item_weight: <color=orange>{0}</color>", item.GetWeight().ToString("0.0"));
            if (item.m_shared.m_maxQuality > 1)
            {
                stringBuilder.AppendFormat("\n$item_quality: <color=orange>{0}</color>", qualityLevel);
            }
            if (item.m_shared.m_useDurability)
            {
                if (crafting)
                {
                    float maxDurability = item.GetMaxDurability(qualityLevel);
                    stringBuilder.AppendFormat("\n$item_durability: <color=orange>{0}</color>", maxDurability);
                }
                else
                {
                    float maxDurability2 = item.GetMaxDurability(qualityLevel);
                    float durability     = item.m_durability;
                    stringBuilder.AppendFormat("\n$item_durability: <color=orange>{0}%</color> <color=yellow>({1}/{2})</color>", (item.GetDurabilityPercentage() * 100f).ToString("0"), durability.ToString("0"), maxDurability2.ToString("0"));
                }
                if (item.m_shared.m_canBeReparied)
                {
                    Recipe recipe = ObjectDB.instance.GetRecipe(item);
                    if (recipe != null)
                    {
                        int minStationLevel = recipe.m_minStationLevel;
                        stringBuilder.AppendFormat("\n$item_repairlevel: <color=orange>{0}</color>", minStationLevel.ToString());
                    }
                }
            }
            switch (item.m_shared.m_itemType)
            {
            case ItemDrop.ItemData.ItemType.Consumable:
            {
                if (item.m_shared.m_food > 0f)
                {
                    stringBuilder.AppendFormat("\n$item_food_health: <color=orange>{0}</color>", item.m_shared.m_food);
                    stringBuilder.AppendFormat("\n$item_food_stamina: <color=orange>{0}</color>", item.m_shared.m_foodStamina);
                    stringBuilder.AppendFormat("\n$item_food_duration: <color=orange>{0}s</color>", item.m_shared.m_foodBurnTime);
                    stringBuilder.AppendFormat("\n$item_food_regen: <color=orange>{0} hp/tick</color>", item.m_shared.m_foodRegen);
                }
                string statusEffectTooltip = item.GetStatusEffectTooltip();
                if (statusEffectTooltip.Length > 0)
                {
                    stringBuilder.Append("\n\n");
                    stringBuilder.Append(statusEffectTooltip);
                }
                break;
            }

            case ItemDrop.ItemData.ItemType.OneHandedWeapon:
            case ItemDrop.ItemData.ItemType.Bow:
            case ItemDrop.ItemData.ItemType.TwoHandedWeapon:
            case ItemDrop.ItemData.ItemType.Torch:
            {
                stringBuilder.Append(item.GetDamage(qualityLevel).GetTooltipString(item.m_shared.m_skillType));
                stringBuilder.AppendFormat("\n$item_blockpower: <color=orange>{0}</color> <color=yellow>({1})</color>", item.GetBaseBlockPower(qualityLevel), item.GetBlockPowerTooltip(qualityLevel).ToString("0"));
                if (item.m_shared.m_timedBlockBonus > 1f)
                {
                    stringBuilder.AppendFormat("\n$item_deflection: <color=orange>{0}</color>", item.GetDeflectionForce(qualityLevel));
                    stringBuilder.AppendFormat("\n$item_parrybonus: <color=orange>{0}x</color>", item.m_shared.m_timedBlockBonus);
                }
                stringBuilder.AppendFormat("\n$item_knockback: <color=orange>{0}</color>", item.m_shared.m_attackForce);
                stringBuilder.AppendFormat("\n$item_backstab: <color=orange>{0}x</color>", item.m_shared.m_backstabBonus);
                string projectileTooltip = item.GetProjectileTooltip(qualityLevel);
                if (projectileTooltip.Length > 0)
                {
                    stringBuilder.Append("\n\n");
                    stringBuilder.Append(projectileTooltip);
                }
                string statusEffectTooltip2 = item.GetStatusEffectTooltip();
                if (statusEffectTooltip2.Length > 0)
                {
                    stringBuilder.Append("\n\n");
                    stringBuilder.Append(statusEffectTooltip2);
                }
                break;
            }

            case ItemDrop.ItemData.ItemType.Shield:
                stringBuilder.AppendFormat("\n$item_blockpower: <color=orange>{0}</color> <color=yellow>({1})</color>", item.GetBaseBlockPower(qualityLevel), item.GetBlockPowerTooltip(qualityLevel).ToString("0"));
                if (item.m_shared.m_timedBlockBonus > 1f)
                {
                    stringBuilder.AppendFormat("\n$item_deflection: <color=orange>{0}</color>", item.GetDeflectionForce(qualityLevel));
                    stringBuilder.AppendFormat("\n$item_parrybonus: <color=orange>{0}x</color>", item.m_shared.m_timedBlockBonus);
                }
                break;

            case ItemDrop.ItemData.ItemType.Helmet:
            case ItemDrop.ItemData.ItemType.Chest:
            case ItemDrop.ItemData.ItemType.Legs:
            case ItemDrop.ItemData.ItemType.Shoulder:
            {
                stringBuilder.AppendFormat("\n$item_armor: <color=orange>{0}</color>", item.GetArmor(qualityLevel));
                string damageModifiersTooltipString = SE_Stats.GetDamageModifiersTooltipString(item.m_shared.m_damageModifiers);
                if (damageModifiersTooltipString.Length > 0)
                {
                    stringBuilder.Append(damageModifiersTooltipString);
                }
                string statusEffectTooltip3 = item.GetStatusEffectTooltip();
                if (statusEffectTooltip3.Length > 0)
                {
                    stringBuilder.Append("\n\n");
                    stringBuilder.Append(statusEffectTooltip3);
                }
                break;
            }

            case ItemDrop.ItemData.ItemType.Ammo:
                stringBuilder.Append(item.GetDamage(qualityLevel).GetTooltipString(item.m_shared.m_skillType));
                stringBuilder.AppendFormat("\n$item_knockback: <color=orange>{0}</color>", item.m_shared.m_attackForce);
                break;
            }
            if (item.m_shared.m_movementModifier != 0f && localPlayer != null)
            {
                float equipmentMovementModifier = localPlayer.GetEquipmentMovementModifier();
                stringBuilder.AppendFormat("\n$item_movement_modifier: <color=orange>{0}%</color> ($item_total:<color=yellow>{1}%</color>)", (item.m_shared.m_movementModifier * 100f).ToString("+0;-0"), (equipmentMovementModifier * 100f).ToString("+0;-0"));
            }
            string setStatusEffectTooltip = item.GetSetStatusEffectTooltip();

            if (setStatusEffectTooltip.Length > 0)
            {
                stringBuilder.AppendFormat("\n\n$item_seteffect (<color=orange>{0}</color> $item_parts):<color=orange>{1}</color>", item.m_shared.m_setSize, setStatusEffectTooltip);
            }
            return(stringBuilder.ToString());
        }
コード例 #3
0
    // Token: 0x060004F3 RID: 1267 RVA: 0x00028F64 File Offset: 0x00027164
    private void UpdateIcons(Player player)
    {
        if (!player || player.IsDead())
        {
            foreach (HotkeyBar.ElementData elementData in this.m_elements)
            {
                UnityEngine.Object.Destroy(elementData.m_go);
            }
            this.m_elements.Clear();
            return;
        }
        player.GetInventory().GetBoundItems(this.m_items);
        this.m_items.Sort((ItemDrop.ItemData x, ItemDrop.ItemData y) => x.m_gridPos.x.CompareTo(y.m_gridPos.x));
        int num = 0;

        foreach (ItemDrop.ItemData itemData in this.m_items)
        {
            if (itemData.m_gridPos.x + 1 > num)
            {
                num = itemData.m_gridPos.x + 1;
            }
        }
        if (this.m_elements.Count != num)
        {
            foreach (HotkeyBar.ElementData elementData2 in this.m_elements)
            {
                UnityEngine.Object.Destroy(elementData2.m_go);
            }
            this.m_elements.Clear();
            for (int i = 0; i < num; i++)
            {
                HotkeyBar.ElementData elementData3 = new HotkeyBar.ElementData();
                elementData3.m_go = UnityEngine.Object.Instantiate <GameObject>(this.m_elementPrefab, base.transform);
                elementData3.m_go.transform.localPosition = new Vector3((float)i * this.m_elementSpace, 0f, 0f);
                elementData3.m_go.transform.Find("binding").GetComponent <Text>().text = (i + 1).ToString();
                elementData3.m_icon       = elementData3.m_go.transform.transform.Find("icon").GetComponent <Image>();
                elementData3.m_durability = elementData3.m_go.transform.Find("durability").GetComponent <GuiBar>();
                elementData3.m_amount     = elementData3.m_go.transform.Find("amount").GetComponent <Text>();
                elementData3.m_equiped    = elementData3.m_go.transform.Find("equiped").gameObject;
                elementData3.m_queued     = elementData3.m_go.transform.Find("queued").gameObject;
                elementData3.m_selection  = elementData3.m_go.transform.Find("selected").gameObject;
                this.m_elements.Add(elementData3);
            }
        }
        foreach (HotkeyBar.ElementData elementData4 in this.m_elements)
        {
            elementData4.m_used = false;
        }
        bool flag = ZInput.IsGamepadActive();

        for (int j = 0; j < this.m_items.Count; j++)
        {
            ItemDrop.ItemData     itemData2    = this.m_items[j];
            HotkeyBar.ElementData elementData5 = this.m_elements[itemData2.m_gridPos.x];
            elementData5.m_used = true;
            elementData5.m_icon.gameObject.SetActive(true);
            elementData5.m_icon.sprite = itemData2.GetIcon();
            elementData5.m_durability.gameObject.SetActive(itemData2.m_shared.m_useDurability);
            if (itemData2.m_shared.m_useDurability)
            {
                if (itemData2.m_durability <= 0f)
                {
                    elementData5.m_durability.SetValue(1f);
                    elementData5.m_durability.SetColor((Mathf.Sin(Time.time * 10f) > 0f) ? Color.red : new Color(0f, 0f, 0f, 0f));
                }
                else
                {
                    elementData5.m_durability.SetValue(itemData2.GetDurabilityPercentage());
                    elementData5.m_durability.ResetColor();
                }
            }
            elementData5.m_equiped.SetActive(itemData2.m_equiped);
            elementData5.m_queued.SetActive(player.IsItemQueued(itemData2));
            if (itemData2.m_shared.m_maxStackSize > 1)
            {
                elementData5.m_amount.gameObject.SetActive(true);
                elementData5.m_amount.text = itemData2.m_stack.ToString() + "/" + itemData2.m_shared.m_maxStackSize.ToString();
            }
            else
            {
                elementData5.m_amount.gameObject.SetActive(false);
            }
        }
        for (int k = 0; k < this.m_elements.Count; k++)
        {
            HotkeyBar.ElementData elementData6 = this.m_elements[k];
            elementData6.m_selection.SetActive(flag && k == this.m_selected);
            if (!elementData6.m_used)
            {
                elementData6.m_icon.gameObject.SetActive(false);
                elementData6.m_durability.gameObject.SetActive(false);
                elementData6.m_equiped.SetActive(false);
                elementData6.m_queued.SetActive(false);
                elementData6.m_amount.gameObject.SetActive(false);
            }
        }
    }
コード例 #4
0
        private static bool Prefix(ref string __result, ItemDrop.ItemData item, int qualityLevel, bool crafting)
        {
            if (!item.IsMagic())
            {
                return(true);
            }

            Player        localPlayer = Player.m_localPlayer;
            StringBuilder text        = new StringBuilder(256);

            var magicItem   = item.GetMagicItem();
            var magicColor  = magicItem.GetColorString();
            var displayName = magicItem.GetDisplayName(item.Extended());

            text.Append($"<color={magicColor}>{magicItem.GetRarityDisplay()} {displayName}</color>\n");
            text.Append(item.m_shared.m_description);

            text.Append("\n");
            if (item.m_shared.m_dlc.Length > 0)
            {
                text.Append("\n<color=aqua>$item_dlc</color>");
            }

            ItemDrop.ItemData.AddHandedTip(item, text);
            if (item.m_crafterID != 0L)
            {
                text.AppendFormat("\n$item_crafter: <color=orange>{0}</color>", item.m_crafterName);
            }

            if (!item.m_shared.m_teleportable)
            {
                text.Append("\n<color=orange>$item_noteleport</color>");
            }

            if (item.m_shared.m_value > 0)
            {
                text.AppendFormat("\n$item_value: <color=orange>{0} ({1})</color>", item.GetValue(), item.m_shared.m_value);
            }

            var weightColor = magicItem.HasEffect(MagicEffectType.ReduceWeight) || magicItem.HasEffect(MagicEffectType.Weightless) ? magicColor : "orange";

            text.Append($"\n$item_weight: <color={weightColor}>{item.GetWeight():0.0}</color>");

            if (item.m_shared.m_maxQuality > 1)
            {
                text.AppendFormat("\n$item_quality: <color=orange>{0}</color>", qualityLevel);
            }

            var indestructible = magicItem.HasEffect(MagicEffectType.Indestructible);

            if (!indestructible && item.m_shared.m_useDurability)
            {
                var maxDurabilityColor1 = magicItem.HasEffect(MagicEffectType.ModifyDurability) ? magicColor : "orange";
                var maxDurabilityColor2 = magicItem.HasEffect(MagicEffectType.ModifyDurability) ? magicColor : "yellow";

                float  maxDurability = item.GetMaxDurability(qualityLevel);
                float  durability    = item.m_durability;
                float  currentDurabilityPercentage = item.GetDurabilityPercentage() * 100f;
                string durabilityPercentageString  = currentDurabilityPercentage.ToString("0");
                string durabilityValueString       = durability.ToString("0");
                string durabilityMaxString         = maxDurability.ToString("0");
                text.Append($"\n$item_durability: <color={maxDurabilityColor1}>{durabilityPercentageString}%</color> <color={maxDurabilityColor2}>({durabilityValueString}/{durabilityMaxString})</color>");

                if (item.m_shared.m_canBeReparied)
                {
                    Recipe recipe = ObjectDB.instance.GetRecipe(item);
                    if (recipe != null)
                    {
                        int minStationLevel = recipe.m_minStationLevel;
                        text.AppendFormat("\n$item_repairlevel: <color=orange>{0}</color>", minStationLevel.ToString());
                    }
                }
            }
            else if (indestructible)
            {
                text.Append($"\n$item_durability: <color={magicColor}>Indestructible</color>");
            }

            var magicBlockPower    = magicItem.HasEffect(MagicEffectType.ModifyBlockPower);
            var magicBlockColor1   = magicBlockPower ? magicColor : "orange";
            var magicBlockColor2   = magicBlockPower ? magicColor : "yellow";
            var magicParry         = magicItem.HasEffect(MagicEffectType.ModifyParry);
            var totalParryBonusMod = magicItem.GetTotalEffectValue(MagicEffectType.ModifyParry, 0.01f);
            var magicParryColor    = magicParry ? magicColor : "orange";

            switch (item.m_shared.m_itemType)
            {
            case ItemDrop.ItemData.ItemType.Consumable:
                if (item.m_shared.m_food > 0.0)
                {
                    text.AppendFormat("\n$item_food_health: <color=orange>{0}</color>", item.m_shared.m_food);
                    text.AppendFormat("\n$item_food_stamina: <color=orange>{0}</color>", item.m_shared.m_foodStamina);
                    text.AppendFormat("\n$item_food_duration: <color=orange>{0}s</color>", item.m_shared.m_foodBurnTime);
                    text.AppendFormat("\n$item_food_regen: <color=orange>{0} hp/tick</color>", item.m_shared.m_foodRegen);
                }

                string consumeStatusEffectTooltip = item.GetStatusEffectTooltip();
                if (consumeStatusEffectTooltip.Length > 0)
                {
                    text.Append("\n\n");
                    text.Append(consumeStatusEffectTooltip);
                }

                break;

            case ItemDrop.ItemData.ItemType.OneHandedWeapon:
            case ItemDrop.ItemData.ItemType.Bow:
            case ItemDrop.ItemData.ItemType.TwoHandedWeapon:
            case ItemDrop.ItemData.ItemType.Torch:
                text.Append(GetDamageTooltipString(magicItem, item.GetDamage(qualityLevel), item.m_shared.m_skillType, magicColor));
                float  baseBlockPower1            = item.GetBaseBlockPower(qualityLevel);
                float  blockPowerTooltipValue     = item.GetBlockPowerTooltip(qualityLevel);
                string blockPowerPercentageString = blockPowerTooltipValue.ToString("0");
                text.Append($"\n$item_blockpower: <color={magicBlockColor1}>{baseBlockPower1}</color> <color={magicBlockColor2}>({blockPowerPercentageString})</color>");
                if (item.m_shared.m_timedBlockBonus > 1.0)
                {
                    text.Append($"\n$item_deflection: <color={magicParryColor}>{item.GetDeflectionForce(qualityLevel)}</color>");

                    var timedBlockBonus = item.m_shared.m_timedBlockBonus;
                    if (magicParry)
                    {
                        timedBlockBonus *= 1.0f + totalParryBonusMod;
                    }

                    text.Append($"\n$item_parrybonus: <color={magicParryColor}>{timedBlockBonus:0.#}x</color>");
                }

                text.AppendFormat("\n$item_knockback: <color=orange>{0}</color>", item.m_shared.m_attackForce);

                var magicBackstab         = magicItem.HasEffect(MagicEffectType.ModifyBackstab);
                var totalBackstabBonusMod = magicItem.GetTotalEffectValue(MagicEffectType.ModifyBackstab, 0.01f);
                var magicBackstabColor    = magicBackstab ? magicColor : "orange";
                var backstabValue         = item.m_shared.m_backstabBonus * (1.0f + totalBackstabBonusMod);
                text.Append($"\n$item_backstab: <color={magicBackstabColor}>{backstabValue:0.#}x</color>");

                string projectileTooltip = item.GetProjectileTooltip(qualityLevel);
                if (projectileTooltip.Length > 0)
                {
                    text.Append("\n\n");
                    text.Append(projectileTooltip);
                }

                string statusEffectTooltip2 = item.GetStatusEffectTooltip();
                if (statusEffectTooltip2.Length > 0)
                {
                    text.Append("\n\n");
                    text.Append(statusEffectTooltip2);
                }

                break;

            case ItemDrop.ItemData.ItemType.Shield:
                float baseBlockPower2 = item.GetBaseBlockPower(qualityLevel);
                blockPowerTooltipValue = item.GetBlockPowerTooltip(qualityLevel);
                string str5 = blockPowerTooltipValue.ToString("0");
                text.Append($"\n$item_blockpower: <color={magicBlockColor1}>{baseBlockPower2}</color> <color={magicBlockColor2}>({str5})</color>");
                if (item.m_shared.m_timedBlockBonus > 1.0)
                {
                    text.Append($"\n$item_deflection: <color={magicParryColor}>{item.GetDeflectionForce(qualityLevel)}</color>");

                    var timedBlockBonus = item.m_shared.m_timedBlockBonus;
                    if (magicParry)
                    {
                        timedBlockBonus *= 1.0f + totalParryBonusMod;
                    }

                    text.Append($"\n$item_parrybonus: <color={magicParryColor}>{timedBlockBonus:0.#}x</color>");
                }

                break;

            case ItemDrop.ItemData.ItemType.Helmet:
            case ItemDrop.ItemData.ItemType.Chest:
            case ItemDrop.ItemData.ItemType.Legs:
            case ItemDrop.ItemData.ItemType.Shoulder:
                var magicArmorColor = magicItem.HasEffect(MagicEffectType.ModifyArmor) ? magicColor : "orange";
                text.Append($"\n$item_armor: <color={magicArmorColor}>{item.GetArmor(qualityLevel):0.#}</color>");
                string modifiersTooltipString = SE_Stats.GetDamageModifiersTooltipString(item.m_shared.m_damageModifiers);
                if (modifiersTooltipString.Length > 0)
                {
                    text.Append(modifiersTooltipString);
                }

                string statusEffectTooltip3 = item.GetStatusEffectTooltip();
                if (statusEffectTooltip3.Length > 0)
                {
                    text.Append("\n");
                    text.Append(statusEffectTooltip3);
                }

                break;

            case ItemDrop.ItemData.ItemType.Ammo:
                text.Append(item.GetDamage(qualityLevel).GetTooltipString(item.m_shared.m_skillType));
                text.AppendFormat("\n$item_knockback: <color=orange>{0}</color>", item.m_shared.m_attackForce);
                break;
            }

            var magicMovement = magicItem.HasEffect(MagicEffectType.ModifyMovementSpeed);

            if ((magicMovement || item.m_shared.m_movementModifier != 0) && localPlayer != null)
            {
                var removePenalty = magicItem.HasEffect(MagicEffectType.RemoveSpeedPenalty);

                var itemMovementModifier = removePenalty ? 0 : item.m_shared.m_movementModifier * 100f;
                if (magicMovement)
                {
                    itemMovementModifier += magicItem.GetTotalEffectValue(MagicEffectType.ModifyMovementSpeed);
                }

                var itemMovementModDisplay = (itemMovementModifier == 0) ? "0%" : $"{itemMovementModifier:+0;-0}%";

                float movementModifier      = localPlayer.GetEquipmentMovementModifier();
                var   totalMovementModifier = movementModifier * 100f;
                var   color = (removePenalty || magicMovement) ? magicColor : "orange";
                text.Append($"\n$item_movement_modifier: <color={color}>{itemMovementModDisplay}</color> ($item_total:<color=yellow>{totalMovementModifier:+0;-0}%</color>)");
            }

            // Add magic item effects here
            text.Append(magicItem.GetTooltip());

            // Set stuff
            if (!string.IsNullOrEmpty(item.m_shared.m_setName))
            {
                AddSetTooltip(item, text);
            }

            __result = text.ToString();
            return(false);
        }
コード例 #5
0
        public static string GetTooltip(ItemDrop.ItemData item, int qualityLevel, bool crafting)
        {
            Player        localPlayer = Player.m_localPlayer;
            StringBuilder text        = new StringBuilder(256);

            text.Append(item.m_shared.m_description);
            text.Append("\n\n");
            if (item.m_shared.m_dlc.Length > 0)
            {
                text.Append("\n<color=aqua>$item_dlc</color>");
            }
            ItemDrop.ItemData.AddHandedTip(item, text);
            if (item.m_crafterID != 0L)
            {
                text.AppendFormat("\n$item_crafter: <color=orange>{0}</color>", (object)item.m_crafterName);
            }
            if (!item.m_shared.m_teleportable)
            {
                text.Append("\n<color=orange>$item_noteleport</color>");
            }
            if (item.m_shared.m_value > 0)
            {
                text.AppendFormat("\n$item_value: <color=orange>{0}  ({1})</color>", (object)item.GetValue(), (object)item.m_shared.m_value);
            }
            text.AppendFormat("\n$item_weight: <color=orange>{0}</color>", (object)item.GetWeight().ToString("0.0"));
            if (item.m_shared.m_maxQuality > 1)
            {
                text.AppendFormat("\n$item_quality: <color=orange>{0}</color>", (object)qualityLevel);
            }
            float num;

            if (item.m_shared.m_useDurability)
            {
                if (crafting)
                {
                    float maxDurability = item.GetMaxDurability(qualityLevel);
                    text.AppendFormat("\n$item_durability: <color=orange>{0}</color>", (object)maxDurability);
                }
                else
                {
                    float         maxDurability = item.GetMaxDurability(qualityLevel);
                    float         durability    = item.m_durability;
                    StringBuilder stringBuilder = text;
                    num = item.GetDurabilityPercentage() * 100f;
                    string str1 = num.ToString("0");
                    string str2 = durability.ToString("0");
                    string str3 = maxDurability.ToString("0");
                    stringBuilder.AppendFormat("\n$item_durability: <color=orange>{0}%</color> <color=yellow>({1}/{2})</color>", (object)str1, (object)str2, (object)str3);
                }
                if (item.m_shared.m_canBeReparied)
                {
                    Recipe recipe = ObjectDB.instance.GetRecipe(item);
                    if ((UnityEngine.Object)recipe != (UnityEngine.Object)null)
                    {
                        int minStationLevel = recipe.m_minStationLevel;
                        text.AppendFormat("\n$item_repairlevel: <color=orange>{0}</color>", (object)minStationLevel.ToString());
                    }
                }
            }
            switch (item.m_shared.m_itemType)
            {
            case ItemDrop.ItemData.ItemType.Consumable:
                if ((double)item.m_shared.m_food > 0.0)
                {
                    text.AppendFormat("\n$item_food_health: <color=orange>{0}</color>", (object)item.m_shared.m_food);
                    text.AppendFormat("\n$item_food_stamina: <color=orange>{0}</color>", (object)item.m_shared.m_foodStamina);
                    text.AppendFormat("\n$item_food_duration: <color=orange>{0}s</color>", (object)item.m_shared.m_foodBurnTime);
                    text.AppendFormat("\n$item_food_regen: <color=orange>{0} hp/tick</color>", (object)item.m_shared.m_foodRegen);
                }
                string statusEffectTooltip1 = item.GetStatusEffectTooltip();
                if (statusEffectTooltip1.Length > 0)
                {
                    text.Append("\n\n");
                    text.Append(statusEffectTooltip1);
                    break;
                }
                break;

            case ItemDrop.ItemData.ItemType.OneHandedWeapon:
            case ItemDrop.ItemData.ItemType.Bow:
            case ItemDrop.ItemData.ItemType.TwoHandedWeapon:
            case ItemDrop.ItemData.ItemType.Torch:
                text.Append(item.GetDamage(qualityLevel).GetTooltipString(item.m_shared.m_skillType));
                StringBuilder stringBuilder1 = text;
                // ISSUE: variable of a boxed type
                __Boxed <float> baseBlockPower1 = (ValueType)item.GetBaseBlockPower(qualityLevel);
                num = item.GetBlockPowerTooltip(qualityLevel);
                string str4 = num.ToString("0");
                stringBuilder1.AppendFormat("\n$item_blockpower: <color=orange>{0}</color> <color=yellow>({1})</color>", (object)baseBlockPower1, (object)str4);
                if ((double)item.m_shared.m_timedBlockBonus > 1.0)
                {
                    text.AppendFormat("\n$item_deflection: <color=orange>{0}</color>", (object)item.GetDeflectionForce(qualityLevel));
                    text.AppendFormat("\n$item_parrybonus: <color=orange>{0}x</color>", (object)item.m_shared.m_timedBlockBonus);
                }
                text.AppendFormat("\n$item_knockback: <color=orange>{0}</color>", (object)item.m_shared.m_attackForce);
                text.AppendFormat("\n$item_backstab: <color=orange>{0}x</color>", (object)item.m_shared.m_backstabBonus);
                string projectileTooltip = item.GetProjectileTooltip(qualityLevel);
                if (projectileTooltip.Length > 0)
                {
                    text.Append("\n\n");
                    text.Append(projectileTooltip);
                }
                string statusEffectTooltip2 = item.GetStatusEffectTooltip();
                if (statusEffectTooltip2.Length > 0)
                {
                    text.Append("\n\n");
                    text.Append(statusEffectTooltip2);
                    break;
                }
                break;

            case ItemDrop.ItemData.ItemType.Shield:
                StringBuilder stringBuilder2 = text;
                // ISSUE: variable of a boxed type
                __Boxed <float> baseBlockPower2 = (ValueType)item.GetBaseBlockPower(qualityLevel);
                num = item.GetBlockPowerTooltip(qualityLevel);
                string str5 = num.ToString("0");
                stringBuilder2.AppendFormat("\n$item_blockpower: <color=orange>{0}</color> <color=yellow>({1})</color>", (object)baseBlockPower2, (object)str5);
                if ((double)item.m_shared.m_timedBlockBonus > 1.0)
                {
                    text.AppendFormat("\n$item_deflection: <color=orange>{0}</color>", (object)item.GetDeflectionForce(qualityLevel));
                    text.AppendFormat("\n$item_parrybonus: <color=orange>{0}x</color>", (object)item.m_shared.m_timedBlockBonus);
                    break;
                }
                break;

            case ItemDrop.ItemData.ItemType.Helmet:
            case ItemDrop.ItemData.ItemType.Chest:
            case ItemDrop.ItemData.ItemType.Legs:
            case ItemDrop.ItemData.ItemType.Shoulder:
                text.AppendFormat("\n$item_armor: <color=orange>{0}</color>", (object)item.GetArmor(qualityLevel));
                string modifiersTooltipString = SE_Stats.GetDamageModifiersTooltipString(item.m_shared.m_damageModifiers);
                if (modifiersTooltipString.Length > 0)
                {
                    text.Append(modifiersTooltipString);
                }
                string statusEffectTooltip3 = item.GetStatusEffectTooltip();
                if (statusEffectTooltip3.Length > 0)
                {
                    text.Append("\n\n");
                    text.Append(statusEffectTooltip3);
                    break;
                }
                break;

            case ItemDrop.ItemData.ItemType.Ammo:
                text.Append(item.GetDamage(qualityLevel).GetTooltipString(item.m_shared.m_skillType));
                text.AppendFormat("\n$item_knockback: <color=orange>{0}</color>", (object)item.m_shared.m_attackForce);
                break;
            }
            if ((double)item.m_shared.m_movementModifier != 0.0 && (UnityEngine.Object)localPlayer != (UnityEngine.Object)null)
            {
                float         movementModifier = localPlayer.GetEquipmentMovementModifier();
                StringBuilder stringBuilder3   = text;
                num = item.m_shared.m_movementModifier * 100f;
                string str1 = num.ToString("+0;-0");
                num = movementModifier * 100f;
                string str2 = num.ToString("+0;-0");
                stringBuilder3.AppendFormat("\n$item_movement_modifier: <color=orange>{0}%</color> ($item_total:<color=yellow>{1}%</color>)", (object)str1, (object)str2);
            }
            string statusEffectTooltip4 = item.GetSetStatusEffectTooltip();

            if (statusEffectTooltip4.Length > 0)
            {
                text.AppendFormat("\n\n$item_seteffect (<color=orange>{0}</color> $item_parts):<color=orange>{1}</color>", (object)item.m_shared.m_setSize, (object)statusEffectTooltip4);
            }
            return(text.ToString());
        }
コード例 #6
0
        private void UpdateIcons(Player player)
        {
            if (!player || player.IsDead())
            {
                foreach (ElementData elementData in m_elements)
                {
                    Destroy(elementData.m_go);
                }
                m_elements.Clear();
                return;
            }

            m_items.Clear();

            Inventory inv = player.GetInventory();

            if (inv.GetItemAt(5, inv.GetHeight() - 1) != null)
            {
                m_items.Add(inv.GetItemAt(5, inv.GetHeight() - 1));
            }
            if (inv.GetItemAt(6, inv.GetHeight() - 1) != null)
            {
                m_items.Add(inv.GetItemAt(6, inv.GetHeight() - 1));
            }
            if (inv.GetItemAt(7, inv.GetHeight() - 1) != null)
            {
                m_items.Add(inv.GetItemAt(7, inv.GetHeight() - 1));
            }

            m_items.Sort((ItemDrop.ItemData x, ItemDrop.ItemData y) => x.m_gridPos.x.CompareTo(y.m_gridPos.x));
            int num = 0;

            foreach (ItemDrop.ItemData itemData in m_items)
            {
                if (itemData.m_gridPos.x - 4 > num)
                {
                    num = itemData.m_gridPos.x - 4;
                }
            }

            if (m_elements.Count != num)
            {
                foreach (ElementData elementData in m_elements)
                {
                    Destroy(elementData.m_go);
                }
                m_elements.Clear();
                for (int i = 0; i < num; i++)
                {
                    ElementData elementData = new ElementData();
                    elementData.m_go = Instantiate(m_elementPrefab, transform);
                    elementData.m_go.transform.localPosition = new Vector3(i * m_elementSpace, 0f, 0f);
                    elementData.m_go.transform.Find("binding").GetComponent <Text>().text = BepInExPlugin.hotkeys[i].Value;
                    elementData.m_icon       = elementData.m_go.transform.transform.Find("icon").GetComponent <Image>();
                    elementData.m_durability = elementData.m_go.transform.Find("durability").GetComponent <GuiBar>();
                    elementData.m_amount     = elementData.m_go.transform.Find("amount").GetComponent <Text>();
                    elementData.m_equiped    = elementData.m_go.transform.Find("equiped").gameObject;
                    elementData.m_queued     = elementData.m_go.transform.Find("queued").gameObject;
                    elementData.m_selection  = elementData.m_go.transform.Find("selected").gameObject;
                    m_elements.Add(elementData);
                }
            }

            foreach (ElementData elementData in m_elements)
            {
                elementData.m_used = false;
            }
            bool flag = ZInput.IsGamepadActive();

            for (int j = 0; j < m_items.Count; j++)
            {
                ItemDrop.ItemData itemData2   = m_items[j];
                ElementData       elementData = m_elements[itemData2.m_gridPos.x - 5];
                elementData.m_used = true;
                elementData.m_icon.gameObject.SetActive(true);
                elementData.m_icon.sprite = itemData2.GetIcon();
                elementData.m_durability.gameObject.SetActive(itemData2.m_shared.m_useDurability);
                if (itemData2.m_shared.m_useDurability)
                {
                    if (itemData2.m_durability <= 0f)
                    {
                        elementData.m_durability.SetValue(1f);
                        elementData.m_durability.SetColor((Mathf.Sin(Time.time * 10f) > 0f) ? Color.red : new Color(0f, 0f, 0f, 0f));
                    }
                    else
                    {
                        elementData.m_durability.SetValue(itemData2.GetDurabilityPercentage());
                        elementData.m_durability.ResetColor();
                    }
                }
                elementData.m_equiped.SetActive(itemData2.m_equiped);
                elementData.m_queued.SetActive(player.IsItemQueued(itemData2));
                if (itemData2.m_shared.m_maxStackSize > 1)
                {
                    elementData.m_amount.gameObject.SetActive(true);
                    elementData.m_amount.text = itemData2.m_stack.ToString() + "/" + itemData2.m_shared.m_maxStackSize.ToString();
                }
                else
                {
                    elementData.m_amount.gameObject.SetActive(false);
                }
            }

            for (int k = 0; k < m_elements.Count; k++)
            {
                ElementData elementData = m_elements[k];
                elementData.m_selection.SetActive(flag && k == m_selected);
                if (!elementData.m_used)
                {
                    elementData.m_icon.gameObject.SetActive(false);
                    elementData.m_durability.gameObject.SetActive(false);
                    elementData.m_equiped.SetActive(false);
                    elementData.m_queued.SetActive(false);
                    elementData.m_amount.gameObject.SetActive(false);
                }
            }
        }
コード例 #7
0
        public static bool Prefix(HotkeyBar __instance, Player player, List <HotkeyBar.ElementData> ___m_elements, List <ItemDrop.ItemData> ___m_items, int ___m_selected)
        {
            if (!EquipmentAndQuickSlots.QuickSlotsEnabled.Value)
            {
                return(true);
            }

            if (player == null || player.IsDead())
            {
                foreach (HotkeyBar.ElementData element in ___m_elements)
                {
                    UnityEngine.Object.Destroy((UnityEngine.Object)element.m_go);
                }
                ___m_elements.Clear();
            }
            else
            {
                player.GetInventory().GetBoundItems(___m_items);
                ___m_items.Sort((Comparison <ItemDrop.ItemData>)((a, b) => a.m_gridPos.y == b.m_gridPos.y ? a.m_gridPos.x.CompareTo(b.m_gridPos.x) : a.m_gridPos.y.CompareTo(b.m_gridPos.y)));
                int num = player.GetInventory().m_width + EquipmentAndQuickSlots.QuickUseSlotCount;
                if (___m_elements.Count != num)
                {
                    foreach (HotkeyBar.ElementData element in ___m_elements)
                    {
                        UnityEngine.Object.Destroy((UnityEngine.Object)element.m_go);
                    }
                    ___m_elements.Clear();
                    for (int index = 0; index < num; ++index)
                    {
                        var parent = __instance.transform;
                        if (index >= 8)
                        {
                            parent = __instance.transform.parent.Find("healthpanel");
                        }
                        HotkeyBar.ElementData elementData = new HotkeyBar.ElementData()
                        {
                            m_go = UnityEngine.Object.Instantiate <GameObject>(__instance.m_elementPrefab, parent)
                        };

                        if (index < 8)
                        {
                            elementData.m_go.transform.localPosition = new Vector3(index * __instance.m_elementSpace, 0.0f, 0.0f);
                            elementData.m_go.transform.Find("binding").GetComponent <Text>().text = (index + 1).ToString();
                        }
                        else
                        {
                            var offset         = new Vector2(100, -150);
                            var quickSlotIndex = index - 8;
                            elementData.m_go.transform.localPosition    = new Vector3(offset.x, offset.y - quickSlotIndex * __instance.m_elementSpace, 0.0f);
                            elementData.m_go.transform.localEulerAngles = new Vector3(0, 0, -90);
                            string label       = EquipmentAndQuickSlots.GetBindingLabel(quickSlotIndex);
                            var    bindingText = elementData.m_go.transform.Find("binding").GetComponent <Text>();
                            bindingText.text = label;
                            bindingText.horizontalOverflow = HorizontalWrapMode.Overflow;
                        }
                        elementData.m_icon       = elementData.m_go.transform.transform.Find("icon").GetComponent <Image>();
                        elementData.m_durability = elementData.m_go.transform.Find("durability").GetComponent <GuiBar>();
                        elementData.m_amount     = elementData.m_go.transform.Find("amount").GetComponent <Text>();
                        elementData.m_equiped    = elementData.m_go.transform.Find("equiped").gameObject;
                        elementData.m_queued     = elementData.m_go.transform.Find("queued").gameObject;
                        elementData.m_selection  = elementData.m_go.transform.Find("selected").gameObject;
                        ___m_elements.Add(elementData);
                    }
                }

                foreach (HotkeyBar.ElementData element in ___m_elements)
                {
                    element.m_used = false;
                }

                bool isGamepadActive = ZInput.IsGamepadActive();
                for (int index = 0; index < ___m_items.Count; ++index)
                {
                    ItemDrop.ItemData     itemData = ___m_items[index];
                    HotkeyBar.ElementData element  = GetElementForItem(___m_elements, itemData);
                    element.m_used = true;
                    element.m_icon.gameObject.SetActive(true);
                    element.m_icon.sprite = itemData.GetIcon();
                    element.m_durability.gameObject.SetActive(itemData.m_shared.m_useDurability);
                    if (itemData.m_shared.m_useDurability)
                    {
                        if (itemData.m_durability <= 0.0f)
                        {
                            element.m_durability.SetValue(1.0f);
                            element.m_durability.SetColor(Mathf.Sin(Time.time * 10.0f) > 0.0f ? Color.red : new Color(0.0f, 0.0f, 0.0f, 0.0f));
                        }
                        else
                        {
                            element.m_durability.SetValue(itemData.GetDurabilityPercentage());
                            element.m_durability.ResetColor();
                        }
                    }
                    element.m_equiped.SetActive(itemData.m_equiped);
                    element.m_queued.SetActive(player.IsItemQueued(itemData));
                    if (itemData.m_shared.m_maxStackSize > 1)
                    {
                        element.m_amount.gameObject.SetActive(true);
                        element.m_amount.text = $"{itemData.m_stack}/{itemData.m_shared.m_maxStackSize}";
                    }
                    else
                    {
                        element.m_amount.gameObject.SetActive(false);
                    }
                }

                for (int index = 0; index < ___m_elements.Count; ++index)
                {
                    HotkeyBar.ElementData element = ___m_elements[index];
                    element.m_selection.SetActive(isGamepadActive && index == ___m_selected);
                    if (!element.m_used)
                    {
                        element.m_icon.gameObject.SetActive(false);
                        element.m_durability.gameObject.SetActive(false);
                        element.m_equiped.SetActive(false);
                        element.m_queued.SetActive(false);
                        element.m_amount.gameObject.SetActive(false);
                    }
                }
            }

            return(false);
        }