From 524e2b62f0efbc77497f330cf8131033c21bf6d7 Mon Sep 17 00:00:00 2001 From: SSSSSSSan Date: Sun, 23 Nov 2025 21:53:59 +0800 Subject: [PATCH] Remove spaces --- Dustbin/Dustbin.cs | 1 - Dustbin/StoragePatch.cs | 20 ++++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Dustbin/Dustbin.cs b/Dustbin/Dustbin.cs index 8d8f1f6..0f9efe9 100644 --- a/Dustbin/Dustbin.cs +++ b/Dustbin/Dustbin.cs @@ -62,7 +62,6 @@ public class Dustbin : BaseUnityPlugin, IModCanSave, IMultiplayerMod { var sandsPerItem = itemId <= 12000 ? Dustbin.SandsFactors[itemId] : 0; if (sandsPerItem <= 0) return count; - var player = GameMain.mainPlayer; var addCount = count * sandsPerItem; player.sandCount += addCount; diff --git a/Dustbin/StoragePatch.cs b/Dustbin/StoragePatch.cs index 248c21e..85f4aa0 100644 --- a/Dustbin/StoragePatch.cs +++ b/Dustbin/StoragePatch.cs @@ -156,15 +156,15 @@ public static class StoragePatch { var codes = new List(instructions); var matcher = new CodeMatcher(codes, generator); - + // 找到方法开始处 // Find the beginning of the method matcher.Start(); - + // 定义标签用于跳转 // Define label for jump var skipDustbinLogic = generator.DefineLabel(); - + // 在方法开始处插入安全检查 // Insert safety checks at the beginning of the method matcher.InsertAndAdvance( @@ -172,41 +172,41 @@ public static class StoragePatch // Safety check: Ensure StorageComponent instance is not null new CodeInstruction(OpCodes.Ldarg_0), new CodeInstruction(OpCodes.Brfalse, skipDustbinLogic), - + // 检查是否是垃圾桶 // Check if it's a dustbin new CodeInstruction(OpCodes.Ldarg_0), new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(StorageComponent), nameof(StorageComponent.IsDustbin))), new CodeInstruction(OpCodes.Brfalse, skipDustbinLogic), - + // 检查count是否大于0 // Check if count is greater than 0 new CodeInstruction(OpCodes.Ldarg_2), new CodeInstruction(OpCodes.Ldc_I4_0), new CodeInstruction(OpCodes.Ble, skipDustbinLogic), - + // 调用CalcGetSands处理物品销毁和沙子生成 // Call CalcGetSands to handle item destruction and sand generation new CodeInstruction(OpCodes.Ldarg_1), new CodeInstruction(OpCodes.Ldarg_2), new CodeInstruction(OpCodes.Ldarg_3), new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(Dustbin), nameof(Dustbin.CalcGetSands))), - + // 设置remainInc为0(第5个参数,索引4) // Set remainInc to 0 (5th parameter, index 4) new CodeInstruction(OpCodes.Ldarg, 4), new CodeInstruction(OpCodes.Ldc_I4_0), new CodeInstruction(OpCodes.Stind_I4), - + // 返回count表示成功销毁 // Return count to indicate successful destruction new CodeInstruction(OpCodes.Ret), - + // 跳过垃圾桶逻辑的标签 // Label to skip dustbin logic new CodeInstruction(OpCodes.Nop).WithLabels(skipDustbinLogic) ); - + return matcher.InstructionEnumeration(); }