mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-11-19 17:05:20 +08:00
fix(dustbin): restore belt disposal on the current game loop
Replace the obsolete GameData.GameTick transpiler with the serial factory-frame hook. Build current preloader-injected references instead of using the bundled 2023 game DLL. Refs #70, #69, #91
This commit is contained in:
1 parent
ac16794f07
commit
2cb351ebd3
6 files changed
+92
-43
No files matched your search
@@ -0,0 +1,36 @@
|
||||
param(
|
||||
[Parameter(Mandatory = $true)][string]$InputAssembly,
|
||||
[Parameter(Mandatory = $true)][string]$OutputAssembly,
|
||||
[Parameter(Mandatory = $true)][string]$PreloaderAssembly,
|
||||
[Parameter(Mandatory = $true)][string]$CecilAssembly,
|
||||
[Parameter(Mandatory = $true)][string]$BepInExAssembly,
|
||||
[Parameter(Mandatory = $true)][string]$UnityAssembly
|
||||
)
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
[void][Reflection.Assembly]::LoadFrom($CecilAssembly)
|
||||
[void][Reflection.Assembly]::LoadFrom($BepInExAssembly)
|
||||
$preloader = [Reflection.Assembly]::LoadFrom($PreloaderAssembly)
|
||||
$resolver = [Mono.Cecil.DefaultAssemblyResolver]::new()
|
||||
foreach ($assemblyPath in @($InputAssembly, $UnityAssembly, $BepInExAssembly, $CecilAssembly)) {
|
||||
$resolver.AddSearchDirectory([IO.Path]::GetDirectoryName($assemblyPath))
|
||||
}
|
||||
$parameters = [Mono.Cecil.ReaderParameters]::new()
|
||||
$parameters.AssemblyResolver = $resolver
|
||||
$reference = [Mono.Cecil.AssemblyDefinition]::ReadAssembly($InputAssembly, $parameters)
|
||||
try {
|
||||
$preloader.GetType('DustbinPreloader.Preloader').GetMethod('Patch').Invoke($null, @($reference)) | Out-Null
|
||||
foreach ($typeName in @('StorageComponent', 'TankComponent')) {
|
||||
$fields = $reference.MainModule.GetType($typeName).Fields
|
||||
if (-not ($fields | Where-Object { $_.Name -eq 'IsDustbin' -and $_.FieldType.FullName -eq 'System.Boolean' })) {
|
||||
throw "Dustbin preloader did not inject $typeName.IsDustbin."
|
||||
}
|
||||
}
|
||||
[void][IO.Directory]::CreateDirectory([IO.Path]::GetDirectoryName($OutputAssembly))
|
||||
$reference.Write($OutputAssembly)
|
||||
} finally {
|
||||
$reference.Dispose()
|
||||
$resolver.Dispose()
|
||||
}
|
||||
Reference in new issue
Block a user