// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
using System;
using FlaxEngine;
using FlaxEngine.Utilities;
namespace FlaxEditor.Content
{
///
/// Base class for all binary asset proxy objects used to manage .
///
///
public abstract class BinaryAssetProxy : AssetProxy
{
///
/// The binary asset files extension.
///
public static readonly string Extension = "flax";
///
public override bool IsProxyFor(ContentItem item)
{
return item is BinaryAssetItem binaryAssetItem && TypeName == binaryAssetItem.TypeName;
}
///
public override string FileExtension => Extension;
///
public override string TypeName => AssetType.FullName;
///
public override bool IsProxyFor()
{
return typeof(T) == AssetType;
}
///
/// Gets the type of the asset.
///
public abstract Type AssetType { get; }
///
public override AssetItem ConstructItem(string path, string typeName, ref Guid id)
{
var type = TypeUtils.GetType(typeName).Type;
if (typeof(TextureBase).IsAssignableFrom(type))
return new TextureAssetItem(path, ref id, typeName, type);
if (typeof(Model).IsAssignableFrom(type))
return new ModelItem(path, ref id, typeName, type);
if (typeof(SkinnedModel).IsAssignableFrom(type))
return new SkinnedModeItem(path, ref id, typeName, type);
ContentItemSearchFilter searchFilter;
if (typeof(MaterialBase).IsAssignableFrom(type))
searchFilter = ContentItemSearchFilter.Material;
else if (typeof(Prefab).IsAssignableFrom(type))
searchFilter = ContentItemSearchFilter.Prefab;
else if (typeof(SceneAsset).IsAssignableFrom(type))
searchFilter = ContentItemSearchFilter.Scene;
else if (typeof(Animation).IsAssignableFrom(type))
searchFilter = ContentItemSearchFilter.Animation;
else if (typeof(ParticleEmitter).IsAssignableFrom(type))
searchFilter = ContentItemSearchFilter.Particles;
else
searchFilter = ContentItemSearchFilter.Other;
return new BinaryAssetItem(path, ref id, typeName, type, searchFilter);
}
}
}