private void EquipmentIcon_SetDisplayData(ILContext il) { ILCursor c = new ILCursor(il); c.GotoNext( x => x.MatchLdarg(0), x => x.MatchLdarg(1), x => x.MatchStfld(out _), x => x.MatchRet() ); c.Index += 3; Debug.Log(c); c.Emit(OpCodes.Ldarg, 0); Debug.Log(c); c.Emit(OpCodes.Ldarg, 1); Debug.Log(c); c.Emit(OpCodes.Ldfld, typeof(EquipmentIcon).GetNestedTypeCached("DisplayData").GetFieldCached("equipmentDef")); Debug.Log(c); c.EmitDelegate <Action <EquipmentIcon, EquipmentDef> >((icon, equipDef) => { if (icon.tooltipProvider != null && equipDef != null) { var equipDesc = !Language.IsTokenInvalid(equipDef.descriptionToken) ? Language.GetString(equipDef.descriptionToken) : Language.GetString(equipDef.pickupToken); equipDesc += "\n\n" + PickupStatProvider.ProvideEquipmentStats(equipDef.equipmentIndex); icon.tooltipProvider.overrideBodyText = equipDesc; } }); }
private void ItemIcon_SetItemIndex(On.RoR2.UI.ItemIcon.orig_SetItemIndex orig, RoR2.UI.ItemIcon self, ItemIndex newItemIndex, int newItemCount) { orig(self, newItemIndex, newItemCount); var itemDef = ItemCatalog.GetItemDef(newItemIndex); if (self.tooltipProvider != null && itemDef != null) { var itemDescription = !Language.IsTokenInvalid(itemDef.descriptionToken) ? Language.GetString(itemDef.descriptionToken) : Language.GetString(itemDef.pickupToken); itemDescription += "\n\n" + PickupStatProvider.ProvideItemStats(newItemIndex, newItemCount); self.tooltipProvider.overrideBodyText = itemDescription; } }
private void UpdateInventoryStats() { Logger.LogDebug("Updating inventory stats."); PickupStatProvider.UpdateItemDefs(); PickupStatProvider.UpdateEquipmentDefs(); }