Fixed Loadstone compability to properly target version 16 and 17+
This commit is contained in:
		
							parent
							
								
									ef4ce26491
								
							
						
					
					
						commit
						b472d9db59
					
				
					 4 changed files with 52 additions and 20 deletions
				
			
		|  | @ -68,7 +68,8 @@ | |||
|     </Reference> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <Compile Include="Patch.cs" /> | ||||
|     <Compile Include="PatchVer16.cs" /> | ||||
|     <Compile Include="PatchVer17.cs" /> | ||||
|     <Compile Include="Plugin.cs" /> | ||||
|     <Compile Include="Properties\AssemblyInfo.cs" /> | ||||
|   </ItemGroup> | ||||
|  |  | |||
							
								
								
									
										33
									
								
								LoadstonePatch/LoadstoneNighty/PatchVer16.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								LoadstonePatch/LoadstoneNighty/PatchVer16.cs
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,33 @@ | |||
| using DunGen.Graph; | ||||
| using DunGen; | ||||
| using DunGenPlus.Collections; | ||||
| using DunGenPlus; | ||||
| using HarmonyLib; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Text; | ||||
| using System.Threading.Tasks; | ||||
| 
 | ||||
| namespace LoadstoneNighty { | ||||
| 
 | ||||
|   // patch 16 and below probably requires me to patch the function no matter what | ||||
|   public class PatchVer16 { | ||||
| 
 | ||||
|     public static void Activate(){ | ||||
|       try { | ||||
|         Plugin.Instance.harmony.PatchAll(typeof(PatchVer16)); | ||||
|       } catch { | ||||
|            | ||||
|       } | ||||
|       Plugin.logger.LogInfo($"FromProxyEnd function has been patched!"); | ||||
|     } | ||||
| 
 | ||||
|     [HarmonyPrefix] | ||||
|     [HarmonyPatch(typeof(Loadstone.Patches.FromProxyPatches), "FromProxyEnd")] | ||||
|     public static void FromProxyEndPatch(Dictionary<TileProxy, Tile> dictionary){ | ||||
|       DunGenPlus.API.AddTileToMainPathDictionary(dictionary); | ||||
|     } | ||||
| 
 | ||||
|   } | ||||
| } | ||||
|  | @ -1,20 +1,23 @@ | |||
| using System; | ||||
| using DunGen.Graph; | ||||
| using DunGen; | ||||
| using DunGenPlus.Collections; | ||||
| using DunGenPlus; | ||||
| using HarmonyLib; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Text; | ||||
| using System.Threading.Tasks; | ||||
| using DunGen; | ||||
| using DunGen.Graph; | ||||
| using DunGenPlus; | ||||
| using DunGenPlus.Collections; | ||||
| using HarmonyLib; | ||||
| 
 | ||||
| namespace LoadstoneNighty { | ||||
| 
 | ||||
|   public class Patch { | ||||
| 
 | ||||
|   // patch 17 has the patch functions for me to use | ||||
|   public class PatchVer17 { | ||||
| 
 | ||||
|     public static void Activate(){ | ||||
|       Loadstone.Patches.DungenOptimizationPatches.tileCollectors.Add(GetTiles); | ||||
|       Plugin.logger.LogInfo($"DungenOptimizationPatches function has been patched!"); | ||||
|     } | ||||
| 
 | ||||
|     private static HashSet<Tile> GetTiles(DungeonGenerator generator) { | ||||
|  | @ -20,8 +20,8 @@ namespace LoadstoneNighty { | |||
|     private const string modName = "Dungeon Generation Plus Loadstone Patch"; | ||||
|     private const string modVersion = "1.0.0"; | ||||
| 
 | ||||
|     public const string targetModGUID = "com.adibtw.loadstone.Nightly"; | ||||
|     public const string targetModVersion = "0.1.16"; | ||||
|     public const string targetModGUID = "com.adibtw.loadstone"; | ||||
|     public const string targetModVersion = "0.1.17"; | ||||
| 
 | ||||
|     public readonly Harmony harmony = new Harmony(modGUID); | ||||
|     public static Plugin Instance {get; private set;} | ||||
|  | @ -32,9 +32,12 @@ namespace LoadstoneNighty { | |||
|       | ||||
|       logger = BepInEx.Logging.Logger.CreateLogSource(modGUID); | ||||
| 
 | ||||
|        var modLoaded = Chainloader.PluginInfos.ContainsKey(targetModGUID); | ||||
|       var modLoaded = Chainloader.PluginInfos.ContainsKey(targetModGUID); | ||||
|       if (!modLoaded) return; | ||||
| 
 | ||||
|       logger.LogInfo($"Plugin {modName} has been added!"); | ||||
|       PatchVer16.Activate(); | ||||
| 
 | ||||
|       bool validVersion; | ||||
|       var pluginInfo = Chainloader.PluginInfos[targetModGUID]; | ||||
|       var loadedVersion = pluginInfo.Metadata.Version; | ||||
|  | @ -46,15 +49,7 @@ namespace LoadstoneNighty { | |||
|       } | ||||
| 
 | ||||
|       if (validVersion){ | ||||
|         logger.LogInfo($"Plugin {modName} has been added!"); | ||||
| 
 | ||||
|         try { | ||||
|           harmony.PatchAll(typeof(Patch)); | ||||
|         } catch { | ||||
|            | ||||
|         } | ||||
| 
 | ||||
|         Patch.Activate(); | ||||
|         PatchVer17.Activate(); | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue