using StardewModdingAPI.Framework.Models;
namespace StardewModdingAPI.Framework.ModLoading
{
/// Metadata for a mod.
internal class ModMetadata : IModMetadata
{
/*********
** Accessors
*********/
/// The mod's display name.
public string DisplayName { get; }
/// The mod's full directory path.
public string DirectoryPath { get; }
/// The mod manifest.
public IManifest Manifest { get; }
/// Optional metadata about a mod version that SMAPI should assume is compatible or broken, regardless of whether it detects incompatible code.
public ModCompatibility Compatibility { get; }
/// The metadata resolution status.
public ModMetadataStatus Status { get; private set; }
/// The reason the metadata is invalid, if any.
public string Error { get; private set; }
/// The mod instance (if it was loaded).
public IMod Mod { get; private set; }
/*********
** Public methods
*********/
/// Construct an instance.
/// The mod's display name.
/// The mod's full directory path.
/// The mod manifest.
/// Optional metadata about a mod version that SMAPI should assume is compatible or broken, regardless of whether it detects incompatible code.
public ModMetadata(string displayName, string directoryPath, IManifest manifest, ModCompatibility compatibility)
{
this.DisplayName = displayName;
this.DirectoryPath = directoryPath;
this.Manifest = manifest;
this.Compatibility = compatibility;
}
/// Set the mod status.
/// The metadata resolution status.
/// The reason the metadata is invalid, if any.
/// Return the instance for chaining.
public IModMetadata SetStatus(ModMetadataStatus status, string error = null)
{
this.Status = status;
this.Error = error;
return this;
}
/// Set the mod instance.
/// The mod instance to set.
public IModMetadata SetMod(IMod mod)
{
this.Mod = mod;
return this;
}
}
}