Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using HarmonyLib;
- using GameNetcodeStuff;
- using System.Reflection;
- using System.Reflection.Emit;
- using BepInEx.Logging;
- using UnityEngine;
- namespace ScarletMansion.GamePatch {
- public class SpawnScrapInLevelPatch {
- [HarmonyTranspiler]
- [HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")]
- public static IEnumerable<CodeInstruction> ConnectOverlappingDoorwaysPatch(IEnumerable<CodeInstruction> instructions){
- var variable = typeof(RoundManager).GetField("scrapAmountMultiplier", BindingFlags.Instance | BindingFlags.Public);
- var sequence = new InstructionSequence("scrap", false, "The Loot Multiplier config will not work.");
- sequence.AddBasicWithAlternateMethodName(OpCodes.Ldfld, variable, "GetScrapValueModifier");
- sequence.AddBasic(OpCodes.Mul);
- sequence.AddBasic(OpCodes.Conv_I4);
- foreach(var instruction in instructions){
- if (sequence.VerifyStage(instruction)){
- var method = typeof(SpawnScrapInLevelPatch).GetMethod("ModifyScrapCount", BindingFlags.Static | BindingFlags.Public);
- yield return new CodeInstruction(OpCodes.Call, method);
- yield return instruction;
- continue;
- }
- yield return instruction;
- }
- sequence.ReportComplete();
- }
- public static float ModifyScrapCount(float count){
- if (DunGenPatch.Patch.active == false) return count;
- return count * PluginConfig.Instance.dunGenLootMultiplierValue;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment