mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-03-22 10:33:25 +08:00
Remove spaces
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -156,15 +156,15 @@ public static class StoragePatch
|
||||
{
|
||||
var codes = new List<CodeInstruction>(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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user