1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2026-03-22 10:03:27 +08:00

Remove spaces

This commit is contained in:
SSSSSSSan
2025-11-23 21:53:59 +08:00
committed by Soar Qin
parent 2487a099c1
commit 524e2b62f0
2 changed files with 10 additions and 11 deletions

View File

@@ -62,7 +62,6 @@ public class Dustbin : BaseUnityPlugin, IModCanSave, IMultiplayerMod
{ {
var sandsPerItem = itemId <= 12000 ? Dustbin.SandsFactors[itemId] : 0; var sandsPerItem = itemId <= 12000 ? Dustbin.SandsFactors[itemId] : 0;
if (sandsPerItem <= 0) return count; if (sandsPerItem <= 0) return count;
var player = GameMain.mainPlayer; var player = GameMain.mainPlayer;
var addCount = count * sandsPerItem; var addCount = count * sandsPerItem;
player.sandCount += addCount; player.sandCount += addCount;

View File

@@ -156,15 +156,15 @@ public static class StoragePatch
{ {
var codes = new List<CodeInstruction>(instructions); var codes = new List<CodeInstruction>(instructions);
var matcher = new CodeMatcher(codes, generator); var matcher = new CodeMatcher(codes, generator);
// 找到方法开始处 // 找到方法开始处
// Find the beginning of the method // Find the beginning of the method
matcher.Start(); matcher.Start();
// 定义标签用于跳转 // 定义标签用于跳转
// Define label for jump // Define label for jump
var skipDustbinLogic = generator.DefineLabel(); var skipDustbinLogic = generator.DefineLabel();
// 在方法开始处插入安全检查 // 在方法开始处插入安全检查
// Insert safety checks at the beginning of the method // Insert safety checks at the beginning of the method
matcher.InsertAndAdvance( matcher.InsertAndAdvance(
@@ -172,41 +172,41 @@ public static class StoragePatch
// Safety check: Ensure StorageComponent instance is not null // Safety check: Ensure StorageComponent instance is not null
new CodeInstruction(OpCodes.Ldarg_0), new CodeInstruction(OpCodes.Ldarg_0),
new CodeInstruction(OpCodes.Brfalse, skipDustbinLogic), new CodeInstruction(OpCodes.Brfalse, skipDustbinLogic),
// 检查是否是垃圾桶 // 检查是否是垃圾桶
// Check if it's a dustbin // Check if it's a dustbin
new CodeInstruction(OpCodes.Ldarg_0), new CodeInstruction(OpCodes.Ldarg_0),
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(StorageComponent), nameof(StorageComponent.IsDustbin))), new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(StorageComponent), nameof(StorageComponent.IsDustbin))),
new CodeInstruction(OpCodes.Brfalse, skipDustbinLogic), new CodeInstruction(OpCodes.Brfalse, skipDustbinLogic),
// 检查count是否大于0 // 检查count是否大于0
// Check if count is greater than 0 // Check if count is greater than 0
new CodeInstruction(OpCodes.Ldarg_2), new CodeInstruction(OpCodes.Ldarg_2),
new CodeInstruction(OpCodes.Ldc_I4_0), new CodeInstruction(OpCodes.Ldc_I4_0),
new CodeInstruction(OpCodes.Ble, skipDustbinLogic), new CodeInstruction(OpCodes.Ble, skipDustbinLogic),
// 调用CalcGetSands处理物品销毁和沙子生成 // 调用CalcGetSands处理物品销毁和沙子生成
// Call CalcGetSands to handle item destruction and sand generation // Call CalcGetSands to handle item destruction and sand generation
new CodeInstruction(OpCodes.Ldarg_1), new CodeInstruction(OpCodes.Ldarg_1),
new CodeInstruction(OpCodes.Ldarg_2), new CodeInstruction(OpCodes.Ldarg_2),
new CodeInstruction(OpCodes.Ldarg_3), new CodeInstruction(OpCodes.Ldarg_3),
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(Dustbin), nameof(Dustbin.CalcGetSands))), new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(Dustbin), nameof(Dustbin.CalcGetSands))),
// 设置remainInc为0第5个参数索引4 // 设置remainInc为0第5个参数索引4
// Set remainInc to 0 (5th parameter, index 4) // Set remainInc to 0 (5th parameter, index 4)
new CodeInstruction(OpCodes.Ldarg, 4), new CodeInstruction(OpCodes.Ldarg, 4),
new CodeInstruction(OpCodes.Ldc_I4_0), new CodeInstruction(OpCodes.Ldc_I4_0),
new CodeInstruction(OpCodes.Stind_I4), new CodeInstruction(OpCodes.Stind_I4),
// 返回count表示成功销毁 // 返回count表示成功销毁
// Return count to indicate successful destruction // Return count to indicate successful destruction
new CodeInstruction(OpCodes.Ret), new CodeInstruction(OpCodes.Ret),
// 跳过垃圾桶逻辑的标签 // 跳过垃圾桶逻辑的标签
// Label to skip dustbin logic // Label to skip dustbin logic
new CodeInstruction(OpCodes.Nop).WithLabels(skipDustbinLogic) new CodeInstruction(OpCodes.Nop).WithLabels(skipDustbinLogic)
); );
return matcher.InstructionEnumeration(); return matcher.InstructionEnumeration();
} }