summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Constants.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/StardewModdingAPI/Constants.cs')
-rw-r--r--src/StardewModdingAPI/Constants.cs52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/StardewModdingAPI/Constants.cs b/src/StardewModdingAPI/Constants.cs
index 05e410ab..66eb1336 100644
--- a/src/StardewModdingAPI/Constants.cs
+++ b/src/StardewModdingAPI/Constants.cs
@@ -2,6 +2,8 @@
using System.IO;
using System.Linq;
using System.Reflection;
+using StardewModdingAPI.Framework;
+using StardewModdingAPI.Framework.AssemblyRewriting;
using StardewValley;
namespace StardewModdingAPI
@@ -63,6 +65,56 @@ namespace StardewModdingAPI
/*********
+ ** Internal field
+ *********/
+ /// <summary>Get metadata for mapping assemblies to the current platform.</summary>
+ /// <param name="targetPlatform">The target game platform.</param>
+ internal static PlatformAssemblyMap GetAssemblyMap(Platform targetPlatform)
+ {
+ // get assembly changes needed for platform
+ string[] removeAssemblyReferences;
+ Assembly[] targetAssemblies;
+ switch (targetPlatform)
+ {
+ case Platform.Mono:
+ removeAssemblyReferences = new[]
+ {
+ "Stardew Valley",
+ "Microsoft.Xna.Framework",
+ "Microsoft.Xna.Framework.Game",
+ "Microsoft.Xna.Framework.Graphics"
+ };
+ targetAssemblies = new[]
+ {
+ typeof(StardewValley.Game1).Assembly,
+ typeof(Microsoft.Xna.Framework.Vector2).Assembly
+ };
+ break;
+
+ case Platform.Windows:
+ removeAssemblyReferences = new[]
+ {
+ "StardewValley",
+ "MonoGame.Framework"
+ };
+ targetAssemblies = new[]
+ {
+ typeof(StardewValley.Game1).Assembly,
+ typeof(Microsoft.Xna.Framework.Vector2).Assembly,
+ typeof(Microsoft.Xna.Framework.Game).Assembly,
+ typeof(Microsoft.Xna.Framework.Graphics.SpriteBatch).Assembly
+ };
+ break;
+
+ default:
+ throw new InvalidOperationException($"Unknown target platform '{targetPlatform}'.");
+ }
+
+ return new PlatformAssemblyMap(targetPlatform, removeAssemblyReferences, targetAssemblies);
+ }
+
+
+ /*********
** Private field
*********/
/// <summary>Get the name of a save directory for the current player.</summary>