Skip to content

Commit 0c4103b

Browse files
committed
feature: 增加提高收益倍率的Mod
1 parent c6b6049 commit 0c4103b

File tree

9 files changed

+94
-2
lines changed

9 files changed

+94
-2
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
- name: Build
1919
run: |
2020
dotnet build UnlimitedReroll -o bin --configuration Release
21+
dotnet build MultipleGain -o bin --configuration Release
2122
echo ${{ github.sha }} > Release.txt
2223
cat Release.txt
2324
- name: Release
@@ -27,3 +28,4 @@ jobs:
2728
files: |
2829
Release.txt
2930
bin/UnlimitedReroll.dll
31+
bin/MultipleGain.dll

MultipleGain/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bin
2+
obj

MultipleGain/MultipleGain.csproj

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<AssemblyName>MultipleGain</AssemblyName>
6+
<Description>My first plugin</Description>
7+
<Version>1.0.0</Version>
8+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
9+
<LangVersion>9.0</LangVersion>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="BepInEx.Analyzers" Version="1.*" PrivateAssets="all" />
14+
<PackageReference Include="BepInEx.Core" Version="5.*" />
15+
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
16+
<PackageReference Include="UnityEngine.Modules" Version="2018.4.36" IncludeAssets="compile" />
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<Reference Include="TheLastStand">
21+
<HintPath>../lib/TheLastStand.dll</HintPath>
22+
</Reference>
23+
</ItemGroup>
24+
25+
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
26+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="all" />
27+
</ItemGroup>
28+
</Project>

MultipleGain/NuGet.Config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<add key="BepInEx" value="https://nuget.bepinex.dev/v3/index.json" />
5+
</packageSources>
6+
</configuration>

MultipleGain/Plugin.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System;
2+
using BepInEx;
3+
using BepInEx.Configuration;
4+
using HarmonyLib;
5+
using TheLastStand.Definition.Unit.Enemy;
6+
7+
namespace MultipleGain
8+
{
9+
[BepInPlugin("cn.shabywu.the_last_stand.multiple_gain", "多倍收益", "1.0.0")]
10+
public class Plugin : BaseUnityPlugin
11+
{
12+
static ConfigEntry<float> ExperiencePercentage;
13+
static ConfigEntry<float> DamnedSoulsPercentage;
14+
15+
private void Awake()
16+
{
17+
// Plugin startup logic
18+
Logger.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded!");
19+
20+
ExperiencePercentage = Config.Bind("TheLastStand.MultipleGain", "ExperiencePercentage", 1.5f, "经验倍率");
21+
DamnedSoulsPercentage = Config.Bind("TheLastStand.MultipleGain", "DamnedSoulsPercentage", 10f, "污秽精华倍率");
22+
Harmony.CreateAndPatchAll(typeof(Plugin));
23+
}
24+
25+
[HarmonyPatch(typeof(EnemyUnitTemplateDefinition), "ExperienceGain", MethodType.Setter)] // Specify target method with HarmonyPatch attribute
26+
[HarmonyPrefix] // There are different patch types. Prefix code runs before original code
27+
static bool patchExperienceGain(ref float value)
28+
{
29+
value *= ExperiencePercentage.Value;
30+
Console.WriteLine($"patchExperienceGain: {value}");
31+
return true;
32+
}
33+
34+
[HarmonyPatch(typeof(EnemyUnitTemplateDefinition), "DamnedSoulsEarned", MethodType.Setter)] // Specify target method with HarmonyPatch attribute
35+
[HarmonyPrefix] // There are different patch types. Prefix code runs before original code
36+
static bool patchDamnedSoulsEarned(ref int value)
37+
{
38+
value = Convert.ToInt32(value * DamnedSoulsPercentage.Value);
39+
Console.WriteLine($"patchDamnedSoulsEarned: {value}");
40+
return true;
41+
}
42+
}
43+
44+
}

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,13 @@
55
# Mod 介绍
66
## UnlimitedReroll(无限重投)
77
使用该 Mod 后, 升级后将可无限刷新加点选项.
8+
9+
## MultipleGain(多倍收益)
10+
使用该 Mod 后, 可根据配置提高每晚的收益(经验和污秽精华)
11+
12+
13+
# FAQ
14+
1. 如何开发新的 Mod
15+
```bash
16+
dotnet new bepinex5plugin -T netstandard2.0 -U 2018.4.36 -n MultipleExperience
17+
```

UnlimitedReroll/Plugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace UnlimitedReroll
66
{
7-
[BepInPlugin("cn.shabywu.the_last_stand.unlimited_reroll", "Unlimited Reroll", "0.0.1")]
7+
[BepInPlugin("cn.shabywu.the_last_stand.unlimited_reroll", "无限重投", "1.0.0")]
88
public class Plugin : BaseUnityPlugin
99
{
1010
private void Awake()

UnlimitedReroll/UnlimitedReroll.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<ItemGroup>
2020
<Reference Include="TheLastStand">
21-
<HintPath>./TheLastStand.dll</HintPath>
21+
<HintPath>../lib/TheLastStand.dll</HintPath>
2222
</Reference>
2323
</ItemGroup>
2424

File renamed without changes.

0 commit comments

Comments
 (0)