Example #1
0
        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;
        }
Example #2
0
        public Material LoadMaterial(OnyxProjectAsset asset)
        {
            XmlReader xmlReader = XmlReader.Create(asset.Path);
            Material  m         = new Material();

            m.ReadXml(xmlReader);
            return(m);
        }
Example #3
0
        // ----------------------------------------------------------------  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]);
        }
Example #4
0
        // --------------------------------------------------------------------

        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);
        }
Example #5
0
        // --------------------------------------------------------------------
        // -----------------------------------------------------------  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]);
        }
Example #6
0
        // ----------------------------------------------------------------  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]);
        }
Example #7
0
 public void AddAsset(OnyxProjectAsset asset)
 {
     mMappedResources.Add(asset.Guid, asset);
 }
Example #8
0
 private Entity LoadEntity(OnyxProjectAsset asset)
 {
     return(AssetLoader <Entity> .Load(asset.Path, true));
 }
Example #9
0
 private Texture LoadTexture(OnyxProjectAsset asset)
 {
     return(new Texture(asset.AbsolutePath));
 }
Example #10
0
        private Shader LoadShader(OnyxProjectAsset asset)
        {
            OnyxProjectShaderAsset sAsset = (OnyxProjectShaderAsset)asset;

            return(new Shader(sAsset.PathVertex, sAsset.PathFragment));
        }
Example #11
0
 private Material LoadMaterial(OnyxProjectAsset asset)
 {
     return(AssetLoader <Material> .Load(asset.Path, true));
 }
Example #12
0
        // ----------------------------------------------------------------  Loaders

        private Mesh LoadMesh(OnyxProjectAsset asset)
        {
            return(AssetLoader <Mesh> .Load(asset.Path, true));
        }
Example #13
0
        // --------------------------------------------------------------------

        public void MapAsset(OnyxProjectAsset asset)
        {
            mMappedResources.Remove(asset.Guid);
            mMappedResources.Add(asset.Guid, asset);
        }
Example #14
0
 public Texture LoadTexture(OnyxProjectAsset asset)
 {
     return(new Texture(asset.Path));
 }
Example #15
0
        // ----------------------------------------------------------------  Loaders

        public Mesh LoadMesh(OnyxProjectAsset asset)
        {
            return(ObjLoader.Load(asset.Path));
        }