public bool AddBundle(string gameName, string bundleName, byte[] bytes, AssetBundle bundle = null) { if (bundle == null) { bundle = AssetBundle.LoadFromMemory(bytes); if (bundle == null) { Debug.LogErrorFormat("Error while loading bundle {0} for {1} game", bundleName, gameName); return(false); } } if (!Bundles.ContainsKey(gameName)) { Bundles.Add(gameName, new Dictionary <string, AssetBundle>()); Cache.Add(gameName, new Dictionary <string, string>()); } if (Bundles[gameName].ContainsKey(bundleName)) { RemoveBundle(gameName, bundleName); } Bundles[gameName].Add(bundleName, bundle); Cache[gameName].Add(bundleName, bytes.Base64GetString()); UpdateAssetBundlesCache(); return(true); }
public SpecificVersion GetBundle(Dependency bundle) { lock (Bundles) { if (!Bundles.ContainsKey(bundle.Name)) { return(null); } var bundles = Bundles[bundle.Name]; if (!bundles.Any()) { return(null); } if ((bundle.Version == null) && (bundle.Branch == null)) { return(new SpecificVersion(bundle.Name, Dependency.FindLatestPreferNonBranched(bundles))); } if (bundles.Contains(bundle.VersionData)) { return(new SpecificVersion(bundle.GetFullName())); } var m = _dependencyVersionMatcher.MatchesConstraints(bundles, bundle.Version, bundle.Branch); return(m == null ? null : new SpecificVersion(bundle.Name, m)); } }
public void RemoveBundle(string gameName, string bundleName) { if (!Bundles.ContainsKey(gameName)) { return; } if (!Bundles[gameName].ContainsKey(bundleName)) { return; } AssetBundle assetBundle = GetBundle(gameName, bundleName); assetBundle.Unload(false); Bundles[gameName].Remove(bundleName); Cache[gameName].Remove(bundleName); if (Bundles[gameName].Count == 0) { Bundles.Remove(gameName); Cache.Remove(gameName); } UpdateAssetBundlesCache(); }
/// <summary> /// Load a single bundle /// </summary> /// <param name="filename"></param> public void LoadBundle(string filename) { if (Bundles.ContainsKey(filename)) return; var bundle = new Bundle(filename); foreach (var item in bundle.Items) { if (!Items.ContainsKey(item.Key)) Items.Add(item.Key, new List<BundleItem>()); Items[item.Key].Add(item.Value); } Bundles.Add(filename, bundle); }
public bool HasBundle(SpecificVersion bundle) { lock (Bundles) { if (!Bundles.ContainsKey(bundle.Name)) { return(false); } if ((bundle.Version == null) && (bundle.Branch == null)) { return(true); } var bundles = Bundles[bundle.Name]; if (bundles.Contains(bundle.VersionData)) { return(true); } } return(false); }
public bool AddBundle(SpecificVersion bundle) { if (bundle == null) { throw new ArgumentNullException(nameof(bundle)); } lock (Bundles) { if (!HasBundle(bundle)) { if (!Bundles.ContainsKey(bundle.Name)) { Bundles.Add(bundle.Name, new List <string>()); } Bundles[bundle.Name].Add(bundle.VersionData); return(true); } } return(false); }
/// <summary> /// Load a single bundle /// </summary> /// <param name="filename"></param> public void LoadBundle(string filename) { if (Bundles.ContainsKey(filename)) { return; } var bundle = new Bundle(filename); foreach (var item in bundle.Items) { if (!Items.ContainsKey(item.Key)) { Items.Add(item.Key, new List <IWitcherFile>()); } Items[item.Key].Add(item.Value); } Bundles.Add(filename, bundle); }
/// <summary> /// Load a single bundle /// </summary> /// <param name="filename"></param> public void LoadBundle(string filename) { if (Bundles.ContainsKey(filename)) { return; } var bundle = new Bundle(filename); Dictionary <string, BundleItem> itemsDict = bundle.Items.ToDictionary(_ => _.DepotPath, _ => _); foreach (var item in itemsDict) { if (!Items.ContainsKey(item.Key)) { Items.Add(item.Key, new List <IWitcherFile>()); } Items[item.Key].Add(item.Value); } Bundles.Add(filename, bundle); }