using System;
using System.Collections.Generic;
namespace UnityEngine.ResourceManagement.ResourceLocations
{
///
/// Contains enough information to load an asset (what/where/how/dependencies)
///
public interface IResourceLocation
{
///
/// Internal name used by the provider to load this location
///
/// The identifier.
string InternalId { get; }
///
/// Matches the provider used to provide/load this location
///
/// The provider id.
string ProviderId { get; }
///
/// Gets the dependencies of other IResourceLocations.
///
/// The dependencies.
IList Dependencies { get; }
///
/// The hash of this location combined with the specified type.
///
/// The type of the result.
/// The combined hash of the location and the type.
int Hash(Type resultType);
///
/// The precomputed hash code of the dependencies.
///
int DependencyHashCode { get; }
///
/// Checks the dependencies of other IResourceLocations
///
/// The dependencies.
bool HasDependencies { get; }
///
/// Gets any data object associated with this locations
///
/// The object.
object Data { get; }
///
/// Primary address for this location.
///
string PrimaryKey { get; }
///
/// The type of the resource for th location.
///
Type ResourceType { get; }
}
///
/// An IEqualityComparerer to check if two IResourceLocations are the same
///
public class ResourceLocationComparer : IEqualityComparer
{
///
/// Check if two Resource locations are equal
///
/// First location to compare
/// Second location to compare
/// True if they're equal, false otherwise
public bool Equals(IResourceLocation x, IResourceLocation y)
{
return GetHashCode(x) == GetHashCode(y);
}
///
/// Calculates the hash code for a Resource Location
///
/// The resource location to compute
/// A hash code of the data in a Resource Location
public int GetHashCode(IResourceLocation obj)
{
return obj.InternalId.GetHashCode() * 31 + obj.ResourceType.GetHashCode();
}
}
}