public static bool GetAgingMultiplierForItem(ref Cask __instance, Item item, ref float __result) { __result = 0f; if (item != null && (Utility.IsNormalObjectAtParentSheetIndex(item, item.ParentSheetIndex) || IsColoredObjectAtParentSheetIndex(item, item.ParentSheetIndex))) { if (IsVanillaCask(__instance)) { if (DataLoader.CaskDataId.ContainsKey(item.ParentSheetIndex)) { __result = DataLoader.CaskDataId[item.ParentSheetIndex]; } else if (DataLoader.CaskDataId.ContainsKey(item.Category)) { __result = DataLoader.CaskDataId[item.Category]; } else { return(true); } } else { if (AgerController.GetAger(__instance.Name) is CustomAger ager) { var agingMultiplier = AgerController.GetAgingMultiplierForItem(ager, item); if (agingMultiplier.HasValue) { __result = agingMultiplier.Value; } } } } return(false); }
public static void LoadContentPacksCommand(string command = null, string[] args = null) { Dictionary <int, string> objects = DataLoader.Helper.Content.Load <Dictionary <int, string> >("Data\\ObjectInformation", ContentSource.GameContent); foreach (IContentPack contentPack in Helper.ContentPacks.GetOwned()) { bool hasFile = false; if (File.Exists(Path.Combine(contentPack.DirectoryPath, CaskDataJson))) { hasFile = true; CustomCaskModEntry.ModMonitor.Log($"Reading file {AgersDataJson} from content pack: {contentPack.Manifest.Name} {contentPack.Manifest.Version} from {contentPack.DirectoryPath}"); Dictionary <object, float> caskData = contentPack.ReadJsonFile <Dictionary <object, float> >(CaskDataJson); foreach (var caskItem in caskData) { DataLoader.CaskData[caskItem.Key] = caskItem.Value; } } if (File.Exists(Path.Combine(contentPack.DirectoryPath, AgersDataJson))) { hasFile = true; CustomCaskModEntry.ModMonitor.Log($"Reading file {AgersDataJson} from content pack: {contentPack.Manifest.Name} {contentPack.Manifest.Version} from {contentPack.DirectoryPath}"); List <CustomAger> agersData = contentPack.ReadJsonFile <List <CustomAger> >(AgersDataJson); foreach (CustomAger customAger in agersData) { if (customAger.Name != "Cask") { customAger.ModUniqueID = contentPack.Manifest.UniqueID; if (AgerController.GetAger(customAger.Name) is CustomAger currentAger) { if (currentAger.ModUniqueID != customAger.ModUniqueID) { CustomCaskModEntry.ModMonitor.Log($"Both mods '{currentAger.ModUniqueID}' and '{customAger.ModUniqueID}' have data for '{customAger.Name}'. You should report the problem to these mod's authors. Data from mod '{currentAger.ModUniqueID}' will be used.", LogLevel.Warn); continue; } } customAger.AgingData.ToList().ForEach(d => { int?id = GetId(d.Key, objects); if (id.HasValue) { customAger.AgingDataId[id.Value] = d.Value; } }); AgerController.SetAger(customAger); } else { CustomCaskModEntry.ModMonitor.Log($"Cask data can't be added on {AgersDataJson} file. Use {CaskDataJson} file instead.", LogLevel.Warn); } } } if (!hasFile) { CustomCaskModEntry.ModMonitor.Log($"Ignoring content pack: {contentPack.Manifest.Name} {contentPack.Manifest.Version} from {contentPack.DirectoryPath}\nIt doesn't have both {CaskDataJson} and {AgersDataJson} files.", LogLevel.Warn); } } FillCaskDataIds(); }
public static bool IsValidCaskLocation(ref Cask __instance, ref bool __result) { if ((IsVanillaCask(__instance) && DataLoader.ModConfig.EnableCasksAnywhere) || (AgerController.GetAger(__instance.Name) is CustomAger ager && ager.EnableAgingAnywhere)) { __result = true; return(false); }