|
| 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 | +} |
0 commit comments