public static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions) { List <CodeInstruction> codeInstructions = new List <CodeInstruction>(instructions); var foodWaterTranspiler = new BaseTranspilerPatch(codeInstructions, new List <OpCode>() { OpCodes.Add }); var baseRegenTranspiler = new BaseTranspilerPatch(codeInstructions, new List <OpCode>() { OpCodes.Mul }); bool setFoodWater = false; bool setBaseRegen = false; for (int i = 0; i < codeInstructions.Count; i++) { int offsetToInstruction = 0; var instruction = codeInstructions[i]; if (!setFoodWater && foodWaterTranspiler.IsCurrentInstructionGood(i)) { instruction = foodWaterTranspiler.CreateNewCodeInstruction <Survival_UpdateHunger> (nameof(GetFoodWaterHealThreshold)); offsetToInstruction = 1; setFoodWater = true; } else if (!setBaseRegen && baseRegenTranspiler.IsCurrentInstructionGood(i)) { instruction = baseRegenTranspiler.CreateNewCodeInstruction <Survival_UpdateHunger> (nameof(GetBaseRegen_HealthToAdd)); setBaseRegen = true; } codeInstructions[i + offsetToInstruction] = instruction; } return(codeInstructions); }
public static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions) { List <CodeInstruction> codeInstructions = new List <CodeInstruction>(instructions); var getTargetTranspiler = new BaseTranspilerPatch(codeInstructions, new List <OpCode>() { OpCodes.Call, OpCodes.Pop }); for (int i = 0; i < codeInstructions.Count; i++) { if (!getTargetTranspiler.IsCurrentInstructionGood(i)) { continue; } codeInstructions[i] = getTargetTranspiler.CreateNewCodeInstruction <BuilderTool_HandleInput> (nameof(GetConstructionRange)); break; } #if BelowZero getTargetTranspiler = new BaseTranspilerPatch(codeInstructions, new List <OpCode>() { OpCodes.Call, OpCodes.Brfalse_S, OpCodes.Ldloc_1, OpCodes.Ldc_R4, OpCodes.Bgt_Un_S }); for (int i = 0; i < codeInstructions.Count; i++) { if (!getTargetTranspiler.IsCurrentInstructionGood(i)) { continue; } const int offsetToInstruction = 0; codeInstructions[i + offsetToInstruction] = getTargetTranspiler.CreateNewCodeInstruction <BuilderTool_HandleInput> (nameof(GetDeconstructionRange)); break; } #endif return(codeInstructions); }
public static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions) { List <CodeInstruction> codeInstructions = new List <CodeInstruction>(instructions); var transpiler = new BaseTranspilerPatch(codeInstructions, new List <OpCode>() { OpCodes.Div, OpCodes.Call }); for (int i = 0; i < codeInstructions.Count; i++) { if (!transpiler.IsCurrentInstructionGood(i)) { continue; } var newInstruction = transpiler.CreateNewCodeInstruction <uGUIWaterBar_OnDrink>(nameof(GetCurrentWater)); codeInstructions[i] = newInstruction; break; } return(codeInstructions.AsEnumerable()); }
public static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions) { List <CodeInstruction> codeInstructions = new List <CodeInstruction>(instructions); var maxHealthTranspiler = new BaseTranspilerPatch(codeInstructions, new List <OpCode>() { OpCodes.Div }); for (int i = 0; i < codeInstructions.Count; i++) { if (!maxHealthTranspiler.IsCurrentInstructionGood(i)) { continue; } codeInstructions[i] = maxHealthTranspiler.CreateNewCodeInstruction <Player_OnTakeDamage>(nameof(GetHealthPercent)); break; } return(codeInstructions); }
public static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions) { List <CodeInstruction> codeInstructions = new List <CodeInstruction>(instructions); var maxOxygenTranspiler = new BaseTranspilerPatch(codeInstructions, new List <OpCode>() { OpCodes.Div }); for (int i = 0; i < codeInstructions.Count; i++) { if (!maxOxygenTranspiler.IsCurrentInstructionGood(i)) { continue; } codeInstructions[i] = maxOxygenTranspiler.CreateNewCodeInstruction <AirBladder_OnEnable> (nameof(ReplaceMaxOxygen)); break; } return(codeInstructions); }
public static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions) { List <CodeInstruction> codeInstructions = new List <CodeInstruction>(instructions); var baseResourceTranspiler = new BaseTranspilerPatch(codeInstructions, new List <OpCode>() { OpCodes.Call, OpCodes.Ret }); for (int i = 0; i < codeInstructions.Count; i++) { if (!baseResourceTranspiler.IsCurrentInstructionGood(i)) { continue; } var newInstruction = baseResourceTranspiler.CreateNewCodeInstruction <Knife_GiveResourceOnDamage> (nameof(GetBaseResourceOnDamage)); codeInstructions[i] = newInstruction; } return(codeInstructions); }
public static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions) { List <CodeInstruction> codeInstructions = new List <CodeInstruction>(instructions); var tempDamageHealRateTranspiler = new BaseTranspilerPatch(codeInstructions, new List <OpCode>() { OpCodes.Ldc_R4, OpCodes.Add, OpCodes.Ble_Un }); for (int i = 0; i < codeInstructions.Count; i++) { if (!tempDamageHealRateTranspiler.IsCurrentInstructionGood(i)) { continue; } const int offsetToInstruction = 1; codeInstructions[i + offsetToInstruction] = tempDamageHealRateTranspiler.CreateNewCodeInstruction <LiveMixin_TakeDamage> (nameof(GetNewTempDamageHealRate)); break; } return(codeInstructions); }
public static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions) { List <CodeInstruction> codeInstructions = new List <CodeInstruction>(instructions); var transpiler = new BaseTranspilerPatch(codeInstructions, new List <OpCode>() { OpCodes.Div }); for (int i = 0; i < codeInstructions.Count; i++) { if (!transpiler.IsCurrentInstructionGood(i)) { continue; } var newInstruction = transpiler.CreateNewCodeInstruction <Flare_UpdateLight>(nameof(GetFlickerInterval)); const int offsetToInstruction = 0; codeInstructions[i + offsetToInstruction] = newInstruction; break; } return(codeInstructions.AsEnumerable()); }