private void ReloadResource <T>(int id, Dictionary <int, T> map, Func <OnyxProjectAsset, T> loadFallback) where T : GameAsset { OnyxProjectAsset asset = GetResource(id, map, loadFallback, 0).LinkedProjectAsset; T newAsset = loadFallback(asset); map[id].Copy(newAsset); map[id].IsDirty = false; }
public Material LoadMaterial(OnyxProjectAsset asset) { XmlReader xmlReader = XmlReader.Create(asset.Path); Material m = new Material(); m.ReadXml(xmlReader); return(m); }
// ---------------------------------------------------------------- Getters private T GetResource <T>(int id, Dictionary <int, T> map, Func <OnyxProjectAsset, T> loadFallback) where T : GameAsset { if (!map.ContainsKey(id)) { OnyxProjectAsset asset = ProjectManager.Instance.Content.GetAsset(id); map[id] = loadFallback(asset); map[id].LinkedProjectAsset = asset; } return(map[id]); }
// -------------------------------------------------------------------- private void Refresh(int guid) { if (!mLoadedAssets.ContainsKey(guid)) { return; } GameAsset asset = mLoadedAssets[guid]; Type assetType = asset.GetType(); OnyxProjectAsset projectAsset = asset.LinkedProjectAsset; if (projectAsset == null) { projectAsset = ProjectManager.Instance.Content.GetAsset(guid); mLoadedAssets[guid].LinkedProjectAsset = projectAsset; } mLoadedAssets[guid].Copy(mLoaders[assetType](projectAsset)); Logger.Instance.Append("Reloaded " + assetType + " guid : " + guid); }
// -------------------------------------------------------------------- // ----------------------------------------------------------- Getters // -------------------------------------------------------------------- private T GetResource <T>(int id, Func <OnyxProjectAsset, T> loadFallback, int defaultAsset) where T : GameAsset { if (!mLoadedAssets.ContainsKey(id)) { OnyxProjectAsset asset = ProjectManager.Instance.Content.GetAsset(id); if (asset == null) { if (defaultAsset > 0) { return(GetResource(defaultAsset, loadFallback, 0)); } else { return(null); } } mLoadedAssets[id] = loadFallback(asset); mLoadedAssets[id].LinkedProjectAsset = asset; } return((T)mLoadedAssets[id]); }
// ---------------------------------------------------------------- Getters private T GetResource <T>(int id, Dictionary <int, T> map, Func <OnyxProjectAsset, T> loadFallback, int defaultAsset) where T : GameAsset { if (!map.ContainsKey(id)) { OnyxProjectAsset asset = ProjectManager.Instance.Content.GetAsset(id); if (asset == null) { if (defaultAsset > 0) { return(GetResource(defaultAsset, map, loadFallback, 0)); } else { return(null); } } Onyx3D.MakeCurrent(); map[id] = loadFallback(asset); map[id].LinkedProjectAsset = asset; } return(map[id]); }
public void AddAsset(OnyxProjectAsset asset) { mMappedResources.Add(asset.Guid, asset); }
private Entity LoadEntity(OnyxProjectAsset asset) { return(AssetLoader <Entity> .Load(asset.Path, true)); }
private Texture LoadTexture(OnyxProjectAsset asset) { return(new Texture(asset.AbsolutePath)); }
private Shader LoadShader(OnyxProjectAsset asset) { OnyxProjectShaderAsset sAsset = (OnyxProjectShaderAsset)asset; return(new Shader(sAsset.PathVertex, sAsset.PathFragment)); }
private Material LoadMaterial(OnyxProjectAsset asset) { return(AssetLoader <Material> .Load(asset.Path, true)); }
// ---------------------------------------------------------------- Loaders private Mesh LoadMesh(OnyxProjectAsset asset) { return(AssetLoader <Mesh> .Load(asset.Path, true)); }
// -------------------------------------------------------------------- public void MapAsset(OnyxProjectAsset asset) { mMappedResources.Remove(asset.Guid); mMappedResources.Add(asset.Guid, asset); }
public Texture LoadTexture(OnyxProjectAsset asset) { return(new Texture(asset.Path)); }
// ---------------------------------------------------------------- Loaders public Mesh LoadMesh(OnyxProjectAsset asset) { return(ObjLoader.Load(asset.Path)); }