mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Better asset processor selection, process subassets
This commit is contained in:
@@ -35,13 +35,13 @@ public class AssetIdentifier
|
||||
[AllowAppend]
|
||||
public this(StringView assetIdentifier, StringView subAssetIdentifier)
|
||||
{
|
||||
String identifier = append String(assetIdentifier.Length + 1 + subAssetIdentifier.Length);
|
||||
identifier.AppendF($"{assetIdentifier}:{subAssetIdentifier}");
|
||||
String fullIdentifier = append String(assetIdentifier.Length + 1 + subAssetIdentifier.Length);
|
||||
fullIdentifier.AppendF($"{assetIdentifier}:{subAssetIdentifier}");
|
||||
|
||||
Fixup(identifier);
|
||||
Fixup(fullIdentifier);
|
||||
|
||||
_fullIdentifier = fullIdentifier;
|
||||
_subassetSeperator = _fullIdentifier.IndexOf(':', 0);
|
||||
|
||||
}
|
||||
|
||||
public static StringView operator implicit(AssetIdentifier identifier) => identifier.FullIdentifier;
|
||||
|
||||
@@ -105,6 +105,19 @@ namespace GlitchyEngine.Content
|
||||
|
||||
return (T)asset;
|
||||
}
|
||||
|
||||
/// Loads the specified asset with the given contentManager or the current applications content manager.
|
||||
public static Asset GetAsset(AssetHandle handle, IContentManager contentManager = null)
|
||||
{
|
||||
var contentManager;
|
||||
|
||||
if (contentManager == null)
|
||||
contentManager = Application.Instance.ContentManager;
|
||||
|
||||
Asset asset = contentManager.GetAsset(null, handle);
|
||||
|
||||
return asset;
|
||||
}
|
||||
|
||||
public static AssetHandle ManageAsset(Asset asset, IContentManager contentManager = null)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using GlitchyEngine.Math;
|
||||
using GlitchyEngine.Renderer;
|
||||
using System.Threading;
|
||||
|
||||
namespace GlitchyEngine.Content;
|
||||
|
||||
class SpriteLoader : IProcessedAssetLoader
|
||||
{
|
||||
public Result<Asset> Load(Stream dataStream)
|
||||
{
|
||||
AssetHandle textureHandle = Try!(dataStream.Read<AssetHandle>());
|
||||
float4 textureCoordinates = Try!(dataStream.Read<float4>());
|
||||
|
||||
return new Sprite(textureHandle, textureCoordinates);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using System.IO;
|
||||
using System.Collections;
|
||||
using GlitchyEngine.Math;
|
||||
using GlitchyEngine.Renderer;
|
||||
using System.Threading;
|
||||
|
||||
namespace GlitchyEngine.Content;
|
||||
|
||||
@@ -73,6 +74,8 @@ class TextureLoader : IProcessedAssetLoader
|
||||
result.SamplerState = samplerState;
|
||||
}
|
||||
|
||||
//Thread.Sleep(1000);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user