summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Framework/ModRegistry.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2016-12-22 10:48:05 -0500
committerJesse Plamondon-Willard <github@jplamondonw.com>2016-12-22 10:48:05 -0500
commitf7eda265d9dd11af7bc9ce2540d45ba2668e2345 (patch)
tree98cd0cd45ad53ce79f4fbf484eb1057dc034615e /src/StardewModdingAPI/Framework/ModRegistry.cs
parentaf45b0890804fba271294440feee136e2d83f73b (diff)
downloadSMAPI-f7eda265d9dd11af7bc9ce2540d45ba2668e2345.tar.gz
SMAPI-f7eda265d9dd11af7bc9ce2540d45ba2668e2345.tar.bz2
SMAPI-f7eda265d9dd11af7bc9ce2540d45ba2668e2345.zip
track loaded mod instances & manifests via mod registry (#201)
Diffstat (limited to 'src/StardewModdingAPI/Framework/ModRegistry.cs')
-rw-r--r--src/StardewModdingAPI/Framework/ModRegistry.cs18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/StardewModdingAPI/Framework/ModRegistry.cs b/src/StardewModdingAPI/Framework/ModRegistry.cs
index ba56a447..b593142d 100644
--- a/src/StardewModdingAPI/Framework/ModRegistry.cs
+++ b/src/StardewModdingAPI/Framework/ModRegistry.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.Linq;
using System.Reflection;
namespace StardewModdingAPI.Framework
@@ -11,6 +12,9 @@ namespace StardewModdingAPI.Framework
/*********
** Properties
*********/
+ /// <summary>The registered mod data.</summary>
+ private readonly List<IMod> Mods = new List<IMod>();
+
/// <summary>The friendly mod names treated as deprecation warning sources (assembly full name => mod name).</summary>
private readonly IDictionary<string, string> ModNamesByAssembly = new Dictionary<string, string>();
@@ -19,11 +23,17 @@ namespace StardewModdingAPI.Framework
** Public methods
*********/
/// <summary>Register a mod as a possible source of deprecation warnings.</summary>
- /// <param name="manifest">The mod manifest.</param>
- /// <param name="assembly">The mod assembly.</param>
- public void Add(Manifest manifest, Assembly assembly)
+ /// <param name="mod">The mod instance.</param>
+ public void Add(IMod mod)
+ {
+ this.Mods.Add(mod);
+ this.ModNamesByAssembly[mod.GetType().Assembly.FullName] = mod.ModManifest.Name;
+ }
+
+ /// <summary>Get all enabled mods.</summary>
+ public IEnumerable<IMod> GetMods()
{
- this.ModNamesByAssembly[assembly.FullName] = manifest.Name;
+ return (from mod in this.Mods select mod);
}
/// <summary>Get the friendly name for the closest assembly registered as a source of deprecation warnings.</summary>