public bool CanBundleLoad(string bundleID) { BundleInfo loadStatus = bundleInfoDic[bundleID]; if (loadStatus.Status == BundleStatus.Loaded || loadStatus.Status == BundleStatus.Loading || loadStatus.Status == BundleStatus.Unloaded) { OtherLogger.LogError($"Mod is already loading or loaded, but something is still asking to load it! BundleID ({bundleID})"); return(false); } return(loadStatus.Status == BundleStatus.CanLoad); }
public void AddToLoadOrder(string bundleID, LoadOrderType loadOrderType) { BundleInfo bundleInfo = new BundleInfo(bundleID, loadOrderType); //If this is replacing an already loaded bundle (load late), remove the old instances //Also, update the new bundle info to be marked as unloaded if (bundleInfoDic.ContainsKey(bundleID)) { BundleInfo oldInfo = bundleInfoDic[bundleID]; bundleInfoDic.Remove(bundleID); loadFirst.Remove(oldInfo); loadUnordered.Remove(oldInfo); loadLast.Remove(oldInfo); bundleInfo.Status = BundleStatus.Unloaded; bundleInfo.LoadOrderType = oldInfo.LoadOrderType; if (oldInfo.Status != BundleStatus.Loaded && oldInfo.Status != BundleStatus.Unloaded) { OtherLogger.LogError("Tracking a late bundle, but the data bundle isn't already loaded! Data bundle status: " + oldInfo.Status); } } //If this is a new bundle, we should decide if it is able to start being loaded immediately else { if (loadOrderType == LoadOrderType.LoadFirst) { if (loadFirst.Count == 0 || loadFirst.All(o => o.Status == BundleStatus.Loaded || o.Status == BundleStatus.Unloaded)) { bundleInfo.Status = BundleStatus.CanLoad; } //When adding load first bundles, there must never be unordered or load last bundles already added if (loadUnordered.Count != 0 || loadLast.Count != 0) { OtherLogger.LogError($"Mod is set to load first, but it looks like unordered or load last mods are already loading! BundleID ({bundleID})"); loadUnordered.ForEach(o => OtherLogger.LogError($"Load Unordered BundleID ({o.BundleID})")); loadLast.ForEach(o => OtherLogger.LogError($"Load Last BundleID ({o.BundleID})")); } } if (loadOrderType == LoadOrderType.LoadUnordered) { if (loadFirst.Count == 0 || loadFirst.All(o => o.Status == BundleStatus.Loaded || o.Status == BundleStatus.Unloaded)) { bundleInfo.Status = BundleStatus.CanLoad; } //When adding load unordered bundles, there must never be load last bundles already added if (loadLast.Count != 0) { OtherLogger.LogError($"Mod is set to load unordered, but it looks like load last mods are already loading! BundleID ({bundleID})"); loadLast.ForEach(o => OtherLogger.LogError($"Load Last BundleID ({o.BundleID})")); } } if (loadOrderType == LoadOrderType.LoadLast) { if ((loadFirst.Count == 0 && loadUnordered.Count == 0 && loadLast.Count == 0) || (loadFirst.All(o => o.Status == BundleStatus.Loaded || o.Status == BundleStatus.Unloaded) && loadUnordered.All(o => o.Status == BundleStatus.Loaded || o.Status == BundleStatus.Unloaded) && loadLast.All(o => o.Status == BundleStatus.Loaded || o.Status == BundleStatus.Unloaded))) { bundleInfo.Status = BundleStatus.CanLoad; } } } bundleInfoDic.Add(bundleID, bundleInfo); if (loadOrderType == LoadOrderType.LoadFirst) { loadFirst.Add(bundleInfo); } else if (loadOrderType == LoadOrderType.LoadLast) { loadLast.Add(bundleInfo); } else if (loadOrderType == LoadOrderType.LoadUnordered) { loadUnordered.Add(bundleInfo); } }