mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-09 06:13:36 +08:00
Dustbin 1.3.0 WIP
This commit is contained in:
44
DustbinPreloader/DustbinPreloader.cs
Normal file
44
DustbinPreloader/DustbinPreloader.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using BepInEx.Logging;
|
||||
using Mono.Cecil;
|
||||
|
||||
namespace DustbinPreloader;
|
||||
|
||||
public static class Preloader
|
||||
{
|
||||
private static readonly ManualLogSource Logger = BepInEx.Logging.Logger.CreateLogSource("Dustbin Preloader");
|
||||
public static IEnumerable<string> TargetDLLs { get; } = new[] { "Assembly-CSharp.dll" };
|
||||
|
||||
public static void Patch(AssemblyDefinition assembly)
|
||||
{
|
||||
var gameModule = assembly.MainModule;
|
||||
try
|
||||
{
|
||||
// Add field: int StorageComponent.IsDustbin;
|
||||
gameModule.GetType("StorageComponent").AddFied("IsDustbin", gameModule.TypeSystem.Boolean);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError("Failed to add `bool StorageComponent.IsDustbin`!");
|
||||
Logger.LogError(e);
|
||||
}
|
||||
try
|
||||
{
|
||||
// Add field: int TankComponent.IsDustbin;
|
||||
gameModule.GetType("TankComponent").AddFied("IsDustbin", gameModule.TypeSystem.Boolean);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError("Failed to add `bool TankComponent.IsDustbin`!");
|
||||
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);
|
||||
}
|
||||
}
|
||||
26
DustbinPreloader/DustbinPreloader.csproj
Normal file
26
DustbinPreloader/DustbinPreloader.csproj
Normal file
@@ -0,0 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<AssemblyName>DustbinPreloader</AssemblyName>
|
||||
<Description>DSP MOD - Prealoder for Dustbin</Description>
|
||||
<Version>1.3.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 ..\Dustbin\package\patchers (mkdir ..\Dustbin\package\patchers)
copy /y $(TargetPath) ..\Dustbin\package\patchers\" />
|
||||
</Target>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user