2024-11-12 23:57:46 +00:00
|
|
|
using LyraApi.Ecs;
|
|
|
|
using ExampleWorld.wit.imports.lyra.api;
|
2024-11-14 00:11:26 +00:00
|
|
|
using System.Numerics;
|
2024-11-12 23:57:46 +00:00
|
|
|
|
|
|
|
namespace LyraApi.Asset;
|
|
|
|
|
|
|
|
public class AssetManager(IAsset.AssetManager assetManager) : IResource
|
|
|
|
{
|
|
|
|
internal IAsset.AssetManager inner = assetManager;
|
|
|
|
|
|
|
|
public static ulong TypeId => 567234789345;
|
|
|
|
|
|
|
|
public static object? FromWasmResult(IEcs.WorldResourceResult result)
|
|
|
|
{
|
|
|
|
switch (result.Tag)
|
|
|
|
{
|
|
|
|
case IEcs.WorldResourceResult.NONE:
|
|
|
|
return null;
|
2024-11-14 00:11:26 +00:00
|
|
|
case IEcs.WorldResourceResult.WASM_RESOURCE:
|
|
|
|
var handle = IAsset.AssetManager.FromEcsResource(result.AsWasmResource) ?? throw new MismatchedResourceResultException();
|
|
|
|
return new AssetManager(handle);
|
2024-11-12 23:57:46 +00:00
|
|
|
case IEcs.WorldResourceResult.BYTES:
|
|
|
|
return null;
|
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public UntypedHandle Request(string path)
|
|
|
|
{
|
|
|
|
return new UntypedHandle(inner.Request(path));
|
|
|
|
}
|
|
|
|
|
|
|
|
public Handle<T> Request<T>(string path) where T : IAssetHandle
|
|
|
|
{
|
|
|
|
return Request(path).AsHandle<T>();
|
|
|
|
}
|
|
|
|
}
|