105 lines
5.1 KiB
C#
105 lines
5.1 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace Harmony.XUiC_ItemInfoWindowPatches
|
|
{
|
|
[HarmonyPatch(typeof(XUiC_ItemInfoWindow))]
|
|
[HarmonyPatch("GetBindingValue")]
|
|
public class GetBindingValuePatch
|
|
{
|
|
public static void Postfix(XUiC_ItemInfoWindow __instance, ref string value, string bindingName)
|
|
{
|
|
if (bindingName == "itemtypeicon")
|
|
{
|
|
if (RebirthUtilities.ScenarioSkip())
|
|
{
|
|
ItemValue itemValue = __instance.itemStack.itemValue;
|
|
//Log.Out("XUiC_ItemInfoWindowPatches-GetBindingValue POST, Item: " + itemValue.ItemClass.Name);
|
|
|
|
if (itemValue != null &&
|
|
itemValue.HasMetadata("bonus") &&
|
|
itemValue.HasMetadata("level") &&
|
|
itemValue.HasMetadata("type") &&
|
|
itemValue.HasMetadata("active"))
|
|
{
|
|
//Log.Out("XUiC_ItemInfoWindowPatches-GetBindingValue IS SPECIAL");
|
|
value = (string)itemValue.GetMetadata("bonus");
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
else if (bindingName == "hasitemtypeicon" && !__instance.itemStack.IsEmpty())
|
|
{
|
|
if (RebirthUtilities.ScenarioSkip())
|
|
{
|
|
ItemValue itemValue = __instance.itemStack.itemValue;
|
|
//Log.Out("XUiC_ItemInfoWindowPatches-GetBindingValue POST, Item: " + itemValue.ItemClass.Name);
|
|
|
|
if (itemValue != null &&
|
|
itemValue.HasMetadata("bonus") &&
|
|
itemValue.HasMetadata("level") &&
|
|
itemValue.HasMetadata("type") &&
|
|
itemValue.HasMetadata("active"))
|
|
{
|
|
//Log.Out("XUiC_ItemInfoWindowPatches-GetBindingValue IS SPECIAL");
|
|
value = "true";
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
else if (bindingName == "itemdescription")
|
|
{
|
|
value = "";
|
|
if (__instance.itemClass != null)
|
|
{
|
|
if (__instance.itemClass.IsBlock())
|
|
{
|
|
string descriptionKey = Block.list[__instance.itemClass.Id].DescriptionKey;
|
|
if (Localization.Exists(descriptionKey))
|
|
value = Localization.Get(descriptionKey);
|
|
}
|
|
else
|
|
{
|
|
string descriptionKey = __instance.itemClass.DescriptionKey;
|
|
if (Localization.Exists(descriptionKey))
|
|
value = Localization.Get(descriptionKey);
|
|
if (__instance.itemClass.Unlocks != "")
|
|
{
|
|
ItemClass itemClass = ItemClass.GetItemClass(__instance.itemClass.Unlocks);
|
|
if (itemClass != null)
|
|
value = value + "\n\n" + Localization.Get(itemClass.DescriptionKey);
|
|
}
|
|
|
|
if (RebirthUtilities.ScenarioSkip())
|
|
{
|
|
ItemValue itemValue = __instance.itemStack.itemValue;
|
|
|
|
if (itemValue != null &&
|
|
itemValue.HasMetadata("bonus") &&
|
|
itemValue.HasMetadata("level") &&
|
|
itemValue.HasMetadata("type") &&
|
|
itemValue.HasMetadata("active"))
|
|
{
|
|
if ((int)itemValue.GetMetadata("active") == 1)
|
|
{
|
|
value = value + "\n\n" + Localization.Get("statBonus").ToUpper() + ": " + $"{Localization.Get("xui" + (string)itemValue.GetMetadata("bonus"))} [c9c7c7]([-]{Localization.Get("ttLevelFull")} [e0dcab]{(int)itemValue.GetMetadata("level")}[-][c9c7c7])[-]";
|
|
|
|
List<string> tagNames = itemValue.ItemClass.ItemTags.GetTagNames();
|
|
bool isMelee = RebirthUtilities.isMeleeWeapon(tagNames);
|
|
|
|
float chance = RebirthUtilities.GetBonusChance(itemValue, isMelee, true);
|
|
|
|
value = value + "\n" + Localization.Get("statChanceToTrigger").ToUpper() + ": " + $"[e0dcab]{RebirthUtilities.FormatFloat(chance, 2)}[-]%";
|
|
}
|
|
else if ((int)itemValue.GetMetadata("active") == 2)
|
|
{
|
|
value = value + "\n\n" + Localization.Get("statBonus").ToUpper() + ": " + $"{Localization.Get((string)itemValue.GetMetadata("bonus") + "Name")} [c9c7c7]([-]{Localization.Get("ttLevelFull")} [e0dcab]{(int)itemValue.GetMetadata("level")}[-][c9c7c7])[-]";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|