81 lines
2.2 KiB
C#
81 lines
2.2 KiB
C#
using System;
|
|
|
|
namespace PerfectWorld.Addressable
|
|
{
|
|
/// <summary>
|
|
/// Download progress information
|
|
/// </summary>
|
|
public struct DownloadProgress
|
|
{
|
|
// Bytes downloaded so far
|
|
public long BytesDownloaded;
|
|
|
|
// Total bytes to download
|
|
public long TotalBytes;
|
|
|
|
// Download percentage (0-100)
|
|
public float Percentage;
|
|
|
|
// Currently downloading file
|
|
public string CurrentFile;
|
|
|
|
// Current state description
|
|
public string Status;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Events for addressable system
|
|
/// </summary>
|
|
public static class AddressableEvents
|
|
{
|
|
// Fired when download starts
|
|
public static event Action OnDownloadStarted;
|
|
|
|
// Fired when download progresses
|
|
public static event Action<DownloadProgress> OnDownloadProgress;
|
|
|
|
// Fired when download completes successfully
|
|
public static event Action OnDownloadCompleted;
|
|
|
|
// Fired when download fails
|
|
public static event Action<string> OnDownloadFailed;
|
|
|
|
// Fired when an asset is loaded successfully
|
|
public static event Action<string> OnAssetLoaded;
|
|
|
|
// Fired when an asset fails to load
|
|
public static event Action<string, string> OnAssetLoadFailed;
|
|
|
|
internal static void InvokeDownloadStarted()
|
|
{
|
|
OnDownloadStarted?.Invoke();
|
|
}
|
|
|
|
internal static void InvokeDownloadProgress(DownloadProgress progress)
|
|
{
|
|
OnDownloadProgress?.Invoke(progress);
|
|
}
|
|
|
|
internal static void InvokeDownloadCompleted()
|
|
{
|
|
OnDownloadCompleted?.Invoke();
|
|
}
|
|
|
|
internal static void InvokeDownloadFailed(string error)
|
|
{
|
|
OnDownloadFailed?.Invoke(error);
|
|
}
|
|
|
|
internal static void InvokeAssetLoaded(string address)
|
|
{
|
|
OnAssetLoaded?.Invoke(address);
|
|
}
|
|
|
|
internal static void InvokeAssetLoadFailed(string address, string error)
|
|
{
|
|
OnAssetLoadFailed?.Invoke(address, error);
|
|
}
|
|
}
|
|
}
|
|
|