using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace DataServer.Data.Entities;
///
/// Tracks all client-side files that can be hot-updated from CDN.
/// Files are stored at: https://assets.aeternalisgames.com/downloads/{FilePath}
///
[Table("client_assets")]
public class ClientAsset
{
[Key]
public int Id { get; set; }
///
/// Path relative to client root (e.g., "scenes/mobs/skeleton.tscn", "scripts/ui/hud.gd")
/// This is where the file will be saved on the client
///
[Required]
[MaxLength(256)]
public string FilePath { get; set; } = "";
///
/// Type of asset for categorization and loading behavior
///
public ClientAssetType AssetType { get; set; } = ClientAssetType.Texture;
///
/// MD5 hash of file contents for change detection
///
[Required]
[MaxLength(32)]
public string FileHash { get; set; } = "";
///
/// File size in bytes (for download progress)
///
public long FileSize { get; set; } = 0;
///
/// Version number - increment when file changes
///
public int Version { get; set; } = 1;
///
/// If true, must be downloaded before game can start
/// If false, can be lazy-loaded when needed
///
public bool IsRequired { get; set; } = false;
///
/// Minimum client version required to use this asset
/// Clients below this version will be told to update
/// Format: "1.0.0"
///
[MaxLength(16)]
public string? MinClientVersion { get; set; }
///
/// Optional CDN path if different from FilePath
/// If null, uses FilePath as CDN path
///
[MaxLength(256)]
public string? CdnPath { get; set; }
///
/// When the file was last updated
///
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
///
/// When the file was first added
///
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public bool IsEnabled { get; set; } = true;
///
/// Get the CDN download path
///
[NotMapped]
public string DownloadPath => CdnPath ?? FilePath;
}
public enum ClientAssetType
{
/// Scene file (.tscn) - mobs, UI, effects
Scene = 0,
/// GDScript file (.gd)
Script = 1,
/// Image file (.png, .jpg, .webp)
Texture = 2,
/// Resource file (.tres) - themes, materials, etc.
Resource = 3,
/// Audio file (.ogg, .wav, .mp3)
Audio = 4,
/// Shader file (.gdshader)
Shader = 5,
/// Font file (.ttf, .otf)
Font = 6,
/// JSON data file
Data = 7
}