Better asset processor selection, process subassets

This commit is contained in:
Simon Lübeß
2024-06-13 15:44:27 +02:00
parent 36e98311c6
commit cd434d64f9
22 changed files with 356 additions and 292 deletions
+4 -4
View File
@@ -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)
{
+19
View File
@@ -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;
}