public CraftedItemInfo(ItemObject item , WeaponDesign design , CultureObject culture , TaleWorlds.Localization.TextObject itemName , Crafting.OverrideData overrideData) { this.item = item; this.design = design; this.culture = culture; this.itemName = itemName; this.overrideData = overrideData; }
/// <summary> /// Function for checking if any village has the same production output as chosen workshop has inputs. /// </summary> /// <param name="w">Workshop of interest</param> /// <returns>True if exists, any other case returns False</returns> private bool CheckIfBoundVillagesCreatesMaterial(Workshop w) { TaleWorlds.CampaignSystem.WorkshopType workshopType = w.WorkshopType; TaleWorlds.Library.MBReadOnlyList <Village> boundVillages = w.Settlement.BoundVillages; foreach (Village v in boundVillages) { IReadOnlyList <TaleWorlds.CampaignSystem.WorkshopType.Production> workShopProductions = workshopType.Productions; IReadOnlyList <(ItemObject, float)> villageProductions = v.VillageType.Productions; TaleWorlds.Localization.TextObject villageOutput = v.VillageType.Productions[0].Item1.ItemCategory.GetName(); TaleWorlds.Localization.TextObject workshopInput = workshopType.Productions[0].Inputs[0].Item1.GetName(); if (villageOutput.ToString() == workshopInput.ToString()) { return(true); } } return(false); }
private static ItemObject InitializePreCraftedWeaponOnLoad(ItemObject itemObject, WeaponDesign craftedData, TaleWorlds.Localization.TextObject itemName, BasicCultureObject culture, Crafting.OverrideData overrideData) { Crafting crafting1 = new Crafting(craftedData.Template, culture); crafting1.CraftedWeaponName = itemName.ToString(); crafting1.GetType().GetProperty("CurrentWeaponDesign", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.SetProperty).SetValue(crafting1, craftedData); crafting1.GetType().GetProperty("_history", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.SetProperty).SetValue(crafting1, new System.Collections.Generic.List <WeaponDesign> { craftedData }); crafting1.GetType().GetMethod("SetItemObject", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.InvokeMethod).Invoke(crafting1, new Object[] { overrideData, itemObject }); return(itemObject); }