ыыы
This commit is contained in:
parent
8f1d328afd
commit
cee33368be
1 changed files with 36 additions and 1 deletions
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
using HarmonyLib;
|
||||
|
||||
|
|
@ -21,7 +22,41 @@ public sealed class PatchManager
|
|||
var harmony = new Harmony("sussy.sus");
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
|
||||
harmony.PatchAll(assembly);
|
||||
try
|
||||
{
|
||||
// Применяем патчи только к типам из текущей сборки
|
||||
var types = assembly.GetTypes();
|
||||
var patchedCount = 0;
|
||||
var failedCount = 0;
|
||||
|
||||
foreach (var type in types)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Проверяем, что тип из текущей сборки и имеет атрибуты Harmony
|
||||
if (type.Assembly != assembly)
|
||||
continue;
|
||||
|
||||
// Применяем патчи к типу
|
||||
harmony.CreateClassProcessor(type).Patch();
|
||||
patchedCount++;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Логируем ошибку, но продолжаем применять патчи к другим типам
|
||||
sawmill.Warning($"Failed to patch type {type.FullName}: {ex.Message}");
|
||||
failedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
sawmill.Info($"Patches applied: {patchedCount} successful, {failedCount} failed");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
sawmill.Error($"Critical error during patching: {ex}");
|
||||
throw;
|
||||
}
|
||||
|
||||
PatchApplied = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue