Skip to content

Commit

Permalink
just use base path instead
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaPiggy committed Sep 9, 2024
1 parent 3a625f4 commit 9478fe1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Winch.Examples/ExampleItems/Loader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ namespace ExampleItems;

public static class Loader
{
public static string BasePath => ModAssemblyLoader.GetCurrentMod().BasePath;

public static ExampleSaveParticipant Participant = new ExampleSaveParticipant();

public static ItemData MilkBucket => ItemUtil.GetModdedItemData("exampleitems.milk");
Expand Down
9 changes: 4 additions & 5 deletions Winch/Core/ModAssembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ public class ModAssembly
public Assembly? LoadedAssembly { get; private set; }

public string AssetsPath => Path.Combine(BasePath, "Assets");
public string AssemblyLocation => LoadedAssembly != null ? ReflectionUtil.GetAssemblyDirectoryPath(LoadedAssembly) : string.Empty;
public string AssemblyFolderName => LoadedAssembly != null ? ReflectionUtil.GetAssemblyDirectoryName(LoadedAssembly) : string.Empty;
public string AssemblyName => LoadedAssembly != null ? LoadedAssembly.GetName().Name : string.Empty;
public string BasePathFolderName => Path.GetFileName(BasePath);
public string GUID => Metadata.ContainsKey("ModGUID") ? Metadata["ModGUID"].ToString() : throw new MissingFieldException("No 'ModGUID' field found in Mod Metadata.");
public string AssemblyRelativePath => Metadata.ContainsKey("ModAssembly") ? Metadata["ModAssembly"].ToString() : throw new MissingFieldException("Property 'ModAssembly' not found in mod_meta.json");
public string Name => Metadata.ContainsKey("Name") ? Metadata["Name"].ToString().Spaced() : string.Empty;
Expand All @@ -32,9 +31,9 @@ public class ModAssembly
public string Preload => Metadata.ContainsKey("Preload") ? Metadata["Preload"].ToString() : string.Empty;
public string Entrypoint => Metadata.ContainsKey("Entrypoint") ? Metadata["Entrypoint"].ToString() : string.Empty;
public bool ApplyPatches => Metadata.ContainsKey("ApplyPatches") && (bool)Metadata["ApplyPatches"];
public ModConfig? Config => ModConfig.TryGetConfig(AssemblyFolderName, out var config) ? config : null;
public bool DefaultConfig => ModConfig.HasDefaultConfig(AssemblyFolderName);
public ModConfig GetConfig() => ModConfig.GetConfig(AssemblyFolderName);
public ModConfig? Config => ModConfig.TryGetConfig(BasePathFolderName, out var config) ? config : null;
public bool DefaultConfig => ModConfig.HasDefaultConfig(BasePathFolderName);
public ModConfig GetConfig() => ModConfig.GetConfig(BasePathFolderName);

private ModAssembly(string basePath) {
BasePath = basePath;
Expand Down
6 changes: 3 additions & 3 deletions Winch/Core/ModAssemblyLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static class ModAssemblyLoader

static ModAssemblyLoader()
{
ModConfig.GetRelevantModName = GetCurrentModAssemblyFolderName;
ModConfig.GetRelevantModName = GetCurrentModFolderName;
}

internal static void LoadModAssemblies()
Expand Down Expand Up @@ -185,9 +185,9 @@ public static ModAssembly GetCurrentMod()
return ReflectionUtil.GetRelevantModAssembly();
}

internal static string GetCurrentModAssemblyFolderName()
internal static string GetCurrentModFolderName()
{
return GetCurrentMod()?.AssemblyFolderName ?? string.Empty;
return GetCurrentMod()?.BasePathFolderName ?? string.Empty;
}

/// <summary>
Expand Down

0 comments on commit 9478fe1

Please sign in to comment.