1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2026-02-04 15:12:17 +08:00

WIP: LabOpt

This commit is contained in:
2023-07-26 21:49:41 +08:00
parent 4883166faf
commit 17d80ea199
10 changed files with 441 additions and 1 deletions

View File

@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using BepInEx.Logging;
using HarmonyLib;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Cecil.Rocks;
using MonoMod.Utils;
namespace LabOptPreloader;
public static class Preloader
{
private static readonly ManualLogSource Logger = BepInEx.Logging.Logger.CreateLogSource("ModFixerOne Preloader");
public static IEnumerable<string> TargetDLLs { get; } = new[] { "Assembly-CSharp.dll" };
public static void Patch(AssemblyDefinition assembly)
{
AddMemebers(assembly);
}
private static void AddMemebers(AssemblyDefinition assembly)
{
try
{
var gameModule = assembly.MainModule;
// Add field: int LabComponent.rootLabId;
gameModule.GetType("LabComponent").AddFied("rootLabId", gameModule.TypeSystem.Int32);
}
catch (Exception e)
{
Logger.LogError("Failed to add `int LabComponent.rootLabId`!");
Logger.LogError(e);
}
}
private static void AddFied(this TypeDefinition typeDefinition, string fieldName, TypeReference fieldType)
{
var newField = new FieldDefinition(fieldName, FieldAttributes.Public, fieldType);
typeDefinition.Fields.Add(newField);
Logger.LogDebug("Add " + newField);
}
}

View File

@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<AssemblyName>LabOptPreloader</AssemblyName>
<Description>DSP MOD - Prealoder for LabOpt</Description>
<Version>0.1.0</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BepInEx.Core" Version="5.*" />
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
<PackageReference Include="DysonSphereProgram.GameLibs" Version="*-r.*" />
<PackageReference Include="UnityEngine.Modules" Version="2018.4.12" IncludeAssets="compile" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="IF NOT EXIST ..\LabOpt\package\patchers (mkdir ..\LabOpt\package\patchers)&#xA;copy /y $(TargetPath) ..\LabOpt\package\patchers\" />
</Target>
</Project>

View File

@@ -0,0 +1,4 @@
# HideTips
#### Optimize Lab performance
#### 优化研究站性能