Moved OnDunGenExtenderLoad function to a GeneratorPrefixPatch before LLL
Added Loadstone compatibility
This commit is contained in:
		
							parent
							
								
									cc019aef1c
								
							
						
					
					
						commit
						8970edffe8
					
				
					 9 changed files with 311 additions and 18 deletions
				
			
		
							
								
								
									
										76
									
								
								LoadstonePatch/LoadstoneNighty/LoadstoneNighty.csproj
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										76
									
								
								LoadstonePatch/LoadstoneNighty/LoadstoneNighty.csproj
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,76 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||||
|   <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||||
|   <PropertyGroup> | ||||
|     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||||
|     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||||
|     <ProjectGuid>{B7C6EABD-16DB-4DE8-8013-1FA7DA6E8DE8}</ProjectGuid> | ||||
|     <OutputType>Library</OutputType> | ||||
|     <AppDesignerFolder>Properties</AppDesignerFolder> | ||||
|     <RootNamespace>LoadstoneNighty</RootNamespace> | ||||
|     <AssemblyName>LoadstoneNighty</AssemblyName> | ||||
|     <TargetFrameworkVersion>v4.8</TargetFrameworkVersion> | ||||
|     <FileAlignment>512</FileAlignment> | ||||
|     <Deterministic>true</Deterministic> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||||
|     <DebugSymbols>true</DebugSymbols> | ||||
|     <DebugType>full</DebugType> | ||||
|     <Optimize>false</Optimize> | ||||
|     <OutputPath>bin\Debug\</OutputPath> | ||||
|     <DefineConstants>DEBUG;TRACE</DefineConstants> | ||||
|     <ErrorReport>prompt</ErrorReport> | ||||
|     <WarningLevel>4</WarningLevel> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||||
|     <DebugType>pdbonly</DebugType> | ||||
|     <Optimize>true</Optimize> | ||||
|     <OutputPath>bin\Release\</OutputPath> | ||||
|     <DefineConstants>TRACE</DefineConstants> | ||||
|     <ErrorReport>prompt</ErrorReport> | ||||
|     <WarningLevel>4</WarningLevel> | ||||
|   </PropertyGroup> | ||||
|   <ItemGroup> | ||||
|     <Reference Include="0Harmony"> | ||||
|       <HintPath>..\..\..\Libraries\0Harmony.dll</HintPath> | ||||
|     </Reference> | ||||
|     <Reference Include="Assembly-CSharp-firstpass"> | ||||
|       <HintPath>..\..\..\Libraries\Assembly-CSharp-firstpass.dll</HintPath> | ||||
|     </Reference> | ||||
|     <Reference Include="Assembly-CSharp-publicized"> | ||||
|       <HintPath>..\..\..\Libraries\Assembly-CSharp-publicized.dll</HintPath> | ||||
|     </Reference> | ||||
|     <Reference Include="BepInEx"> | ||||
|       <HintPath>..\..\..\Libraries\BepInEx.dll</HintPath> | ||||
|     </Reference> | ||||
|     <Reference Include="BepInEx.Harmony"> | ||||
|       <HintPath>..\..\..\Libraries\BepInEx.Harmony.dll</HintPath> | ||||
|     </Reference> | ||||
|     <Reference Include="com.adibtw.loadstone"> | ||||
|       <HintPath>..\..\..\Libraries\com.adibtw.loadstone.dll</HintPath> | ||||
|     </Reference> | ||||
|     <Reference Include="DunGenPlus"> | ||||
|       <HintPath>..\..\..\Libraries\DunGenPlus.dll</HintPath> | ||||
|     </Reference> | ||||
|     <Reference Include="System" /> | ||||
|     <Reference Include="System.Core" /> | ||||
|     <Reference Include="System.Xml.Linq" /> | ||||
|     <Reference Include="System.Data.DataSetExtensions" /> | ||||
|     <Reference Include="Microsoft.CSharp" /> | ||||
|     <Reference Include="System.Data" /> | ||||
|     <Reference Include="System.Net.Http" /> | ||||
|     <Reference Include="System.Xml" /> | ||||
|     <Reference Include="UnityEngine"> | ||||
|       <HintPath>..\..\..\Libraries\UnityEngine.dll</HintPath> | ||||
|     </Reference> | ||||
|     <Reference Include="UnityEngine.CoreModule"> | ||||
|       <HintPath>..\..\..\Libraries\UnityEngine.CoreModule.dll</HintPath> | ||||
|     </Reference> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <Compile Include="Patch.cs" /> | ||||
|     <Compile Include="Plugin.cs" /> | ||||
|     <Compile Include="Properties\AssemblyInfo.cs" /> | ||||
|   </ItemGroup> | ||||
|   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||||
| </Project> | ||||
							
								
								
									
										83
									
								
								LoadstonePatch/LoadstoneNighty/Patch.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										83
									
								
								LoadstonePatch/LoadstoneNighty/Patch.cs
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,83 @@ | |||
| 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; | ||||
| 
 | ||||
| namespace LoadstoneNighty { | ||||
| 
 | ||||
|   public class Patch { | ||||
| 
 | ||||
|     public static void Activate(){ | ||||
|       Loadstone.Patches.DungenOptimizationPatches.tileCollectors.Add(GetTiles); | ||||
|     } | ||||
| 
 | ||||
|     private static HashSet<Tile> GetTiles(DungeonGenerator generator) { | ||||
|       var flow = generator.DungeonFlow; | ||||
|       var extender = API.GetDunGenExtender(flow); | ||||
|       var hashset = new HashSet<Tile>(); | ||||
|        | ||||
|       if (API.IsDunGenExtenderActive(extender)){ | ||||
|         Plugin.logger.LogDebug("Creating custom hashset for Loadstone"); | ||||
|         var props = extender.Properties; | ||||
|         GenerateTileHashSet(ref hashset, props.MainPathProperties.MainPathDetails); | ||||
|         GenerateTileHashSet(ref hashset, props.AdditionalTilesProperties.AdditionalTileSets); | ||||
|         GenerateTileHashSet(ref hashset, props.NormalNodeArchetypesProperties.NormalNodeArchetypes); | ||||
|         GenerateTileHashSet(ref hashset, props.LineRandomizerProperties.Archetypes); | ||||
|       } | ||||
|       return hashset; | ||||
|     } | ||||
| 
 | ||||
|     static void GenerateTileHashSet(ref HashSet<Tile> tiles, List<NodeArchetype> nodes) { | ||||
| 		  foreach (var n in nodes) { | ||||
|         GenerateTileHashSet(ref tiles, n.Archetypes); | ||||
| 		  } | ||||
| 	  } | ||||
| 
 | ||||
|     static void GenerateTileHashSet(ref HashSet<Tile> tiles, List<AdditionalTileSetList> list) { | ||||
| 		  foreach (var l in list) { | ||||
|         GenerateTileHashSet(ref tiles, l.TileSets); | ||||
| 		  } | ||||
| 	  } | ||||
| 
 | ||||
|     static void GenerateTileHashSet(ref HashSet<Tile> tiles, List<MainPathExtender> extenders) { | ||||
| 		  foreach (var ext in extenders) { | ||||
|         GenerateTileHashSet(ref tiles, ext.Nodes.Value); | ||||
|         GenerateTileHashSet(ref tiles, ext.Lines.Value); | ||||
| 		  } | ||||
| 	  } | ||||
| 
 | ||||
|     static void GenerateTileHashSet(ref HashSet<Tile> tiles, List<GraphNode> nodes) { | ||||
| 		  foreach (var n in nodes) { | ||||
|         GenerateTileHashSet(ref tiles, n.TileSets); | ||||
| 		  } | ||||
| 	  } | ||||
| 
 | ||||
|     static void GenerateTileHashSet(ref HashSet<Tile> tiles, List<GraphLine> lines) { | ||||
| 		  foreach (var l in lines) { | ||||
|         GenerateTileHashSet(ref tiles, l.DungeonArchetypes); | ||||
| 		  } | ||||
| 	  } | ||||
| 
 | ||||
|     static void GenerateTileHashSet(ref HashSet<Tile> tiles, List<DungeonArchetype> archetypes) { | ||||
| 		  foreach (var a in archetypes) { | ||||
|         GenerateTileHashSet(ref tiles, a.TileSets); | ||||
| 				GenerateTileHashSet(ref tiles, a.BranchCapTileSets); | ||||
| 		  } | ||||
| 	  } | ||||
| 
 | ||||
|     static void GenerateTileHashSet(ref HashSet<Tile> tiles, List<TileSet> tileSets) { | ||||
| 		  foreach (var tileSet in tileSets) { | ||||
| 			  foreach (var tileChance in tileSet.TileWeights.Weights) { | ||||
| 				  var tile = tileChance.Value.GetComponent<Tile>(); | ||||
| 				  if (tile != null) tiles.Add(tile); | ||||
| 			  } | ||||
| 		  } | ||||
| 	  } | ||||
| 
 | ||||
|   } | ||||
| } | ||||
							
								
								
									
										54
									
								
								LoadstonePatch/LoadstoneNighty/Plugin.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								LoadstonePatch/LoadstoneNighty/Plugin.cs
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,54 @@ | |||
| using BepInEx.Bootstrap; | ||||
| using BepInEx.Logging; | ||||
| using BepInEx; | ||||
| using HarmonyLib; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Text; | ||||
| using System.Threading.Tasks; | ||||
| 
 | ||||
| namespace LoadstoneNighty { | ||||
|   [BepInPlugin(modGUID, modName, modVersion)] | ||||
|    | ||||
|   [BepInDependency("dev.ladyalice.dungenplus", "1.2.1")] | ||||
|   [BepInDependency(targetModGUID, BepInDependency.DependencyFlags.SoftDependency)] | ||||
| 
 | ||||
|   public class Plugin : BaseUnityPlugin { | ||||
| 
 | ||||
|     public const string modGUID = "dev.ladyalice.dungenplus.loadstonepatch"; | ||||
|     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 readonly Harmony harmony = new Harmony(modGUID); | ||||
|     public static Plugin Instance {get; private set;} | ||||
|     public static ManualLogSource logger { get; internal set; } | ||||
| 
 | ||||
|     void Awake(){ | ||||
|       if (Instance == null) Instance = this; | ||||
|       | ||||
|       logger = BepInEx.Logging.Logger.CreateLogSource(modGUID); | ||||
| 
 | ||||
|        var modLoaded = Chainloader.PluginInfos.ContainsKey(targetModGUID); | ||||
|       if (!modLoaded) return; | ||||
| 
 | ||||
|       bool validVersion; | ||||
|       var pluginInfo = Chainloader.PluginInfos[targetModGUID]; | ||||
|       var loadedVersion = pluginInfo.Metadata.Version; | ||||
|       if (string.IsNullOrWhiteSpace(targetModVersion)){ | ||||
|         validVersion = true; | ||||
|       } else { | ||||
|         var requiredVersion = new Version(targetModVersion); | ||||
|         validVersion = loadedVersion >= requiredVersion; | ||||
|       } | ||||
| 
 | ||||
|       if (validVersion){ | ||||
|         logger.LogInfo($"Plugin {modName} has been added!"); | ||||
|         Patch.Activate(); | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| } | ||||
							
								
								
									
										36
									
								
								LoadstonePatch/LoadstoneNighty/Properties/AssemblyInfo.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								LoadstonePatch/LoadstoneNighty/Properties/AssemblyInfo.cs
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,36 @@ | |||
| using System.Reflection; | ||||
| using System.Runtime.CompilerServices; | ||||
| using System.Runtime.InteropServices; | ||||
| 
 | ||||
| // アセンブリに関する一般情報は以下を通して制御されます | ||||
| // 制御されます。アセンブリに関連付けられている情報を変更するには、 | ||||
| // これらの属性値を変更してください。 | ||||
| [assembly: AssemblyTitle("LoadstoneNighty")] | ||||
| [assembly: AssemblyDescription("")] | ||||
| [assembly: AssemblyConfiguration("")] | ||||
| [assembly: AssemblyCompany("")] | ||||
| [assembly: AssemblyProduct("LoadstoneNighty")] | ||||
| [assembly: AssemblyCopyright("Copyright ©  2024")] | ||||
| [assembly: AssemblyTrademark("")] | ||||
| [assembly: AssemblyCulture("")] | ||||
| 
 | ||||
| // ComVisible を false に設定すると、このアセンブリ内の型は COM コンポーネントから | ||||
| // 参照できなくなります。COM からこのアセンブリ内の型にアクセスする必要がある場合は、 | ||||
| // その型の ComVisible 属性を true に設定してください。 | ||||
| [assembly: ComVisible(false)] | ||||
| 
 | ||||
| // このプロジェクトが COM に公開される場合、次の GUID が typelib の ID になります | ||||
| [assembly: Guid("b7c6eabd-16db-4de8-8013-1fa7da6e8de8")] | ||||
| 
 | ||||
| // アセンブリのバージョン情報は、以下の 4 つの値で構成されています: | ||||
| // | ||||
| //      メジャー バージョン | ||||
| //      マイナー バージョン | ||||
| //      ビルド番号 | ||||
| //      リビジョン | ||||
| // | ||||
| // すべての値を指定するか、次を使用してビルド番号とリビジョン番号を既定に設定できます | ||||
| // 既定値にすることができます: | ||||
| // [assembly: AssemblyVersion("1.0.*")] | ||||
| [assembly: AssemblyVersion("1.0.0.0")] | ||||
| [assembly: AssemblyFileVersion("1.0.0.0")] | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue