/// <summary> /// Collects assets of the specified prefab type. /// </summary> /// <typeparam name="TPrefab">The type of the prefab.</typeparam> /// <typeparam name="TAsset">The type of the asset.</typeparam> /// <returns>A sequence of assets of the specified type.</returns> protected static IEnumerable <AssetInfo> CollectPrefabs <TPrefab, TAsset>(Func <PrefabInfo, bool> predicate) where TPrefab : PrefabInfo where TAsset : AssetInfo, new() { return(PrefabHelper.Collect <TPrefab>() .Where(p => predicate(p)) .Select(p => { AssetInfo a = new TAsset(); a.Initialize(p); return a; }) .Where(a => a.Initialized)); }
/// <summary> /// Saves the assets. /// </summary> public void SaveAssets() { try { Configuration config = new Configuration(Configuration.ItemTypes.Assets, Configuration.AssetTypes.Buildings, null); foreach (BuildingInfo building in PrefabHelper.Collect <BuildingInfo>()) { config.Add(this.NewItem(null, config, "Asset", 0, building)); } config.Save(); } catch (Exception ex) { Log.Error(this, "SaveAssets", ex); } }
/// <summary> /// Logs the assets. /// </summary> public void LogAssets() { try { foreach (BuildingInfo building in PrefabHelper.Collect <BuildingInfo>()) { Log.InfoList info = this.GetBuildingLogInfo(null, building); if (info != null) { Log.DevDebug(this, "LogAssets", info); } } } catch (Exception ex) { Log.Error(this, "LogAssets", ex); } }