protected internal override Texture2D LoadTexture2D(string relativeDirectory, string file, bool mipmap = false, bool linear = false) { if (!FileExists(relativeDirectory, file)) { return(null); } var data = ReadAllBytes(relativeDirectory, file); return(CustomTextures.LoadTexture(data, mipmap, linear)); }
private static Item NewHellstone(int baseItemID, int newItemId, String name, String desc) { int totalWeight = CurrencyEffects.ALL[newItemId].Sum(x => x.GetWeight()); desc += "\n"; CurrencyEffects.ALL[newItemId].ForEach(x => { float chance = (float)x.GetWeight() / (float)totalWeight * 100; desc += "\n" + chance + "% to: " + x.Get().GetDescription() + "\n"; }); desc += "\n Use when your desired gear is in your pouch (and no other gear there)."; if (HELLSTONE_OF_ARCANA_ID != newItemId) // this hellstone is used on non magical items, unlike others { desc += "\n Only works on Magical items."; } else { desc += "\n Only works on Non Magical items."; } var template = new SL_Item() { Name = name, Description = desc, Target_ItemID = baseItemID, New_ItemID = newItemId, Tags = new string[] { TagSourceManager.Valuable.TagName }, IsUsable = true }; var item = CustomItems.CreateCustomItem(template); var effects = item.transform.Find("Effects"); if (effects == null) { // If the item doesn't have "Effects", just add it. effects = new GameObject("Effects").transform; effects.transform.parent = item.transform; // If you didn't use CreateCustomItem, you'd need to call DontDestroyOnLoad(gaberries.gameObject); } CurrencyEffectComponent eff = effects.gameObject.AddComponent <CurrencyEffectComponent>(); UnityEngine.Object.DontDestroyOnLoad(eff); var png = CustomTextures.LoadTexture(@"BepInEx\plugins\Grindward\Icons\" + newItemId + ".png", false, false); var sprite = CustomTextures.CreateSprite(png, CustomTextures.SpriteBorderTypes.ItemIcon); CustomItemVisuals.SetSpriteLink(item, sprite); At.SetValue(sprite, typeof(Item), item, "m_itemIcon"); return(item); }