private static void GenericCharacterMain_FixedUpdate(ILContext il) { ILCursor c = new ILCursor(il); Mono.Collections.Generic.Collection <Instruction> instructions = il.Method.Body.Instructions; for (int i = 0; i < instructions.Count; i++) { // Match with ln170 in GenericCharacterMain.FixedUpdate (right after the last Instruction inst = instructions[i]; if (ILPatternMatchingExt.MatchCallvirt(inst, typeof(EffectManager), "SpawnEffect")) { c.Goto(inst, MoveType.After); } } // Load base name token onto the stack c.Emit(OpCodes.Ldarg_0); c.Emit(OpCodes.Call, "instance class RoR2.CharacterBody EntityState::get_characterBody()"); c.Emit(OpCodes.Ldfld, "string RoR2.CharacterBody::baseNameToken"); // Load state machine onto the stack c.Emit(OpCodes.Ldarg_0); c.Emit(OpCodes.Ldfld, "class RoR2.EntityStateMachine EntityStates.EntityState::outer"); c.EmitDelegate <Action <string, EntityStateMachine> >(delegate(string baseNameToken, EntityStateMachine stateMachine) { if (JumpOverrides.ContainsKey(baseNameToken)) { stateMachine.SetNextState(JumpOverrides[baseNameToken]); } }); }
private static void CostTypeCatalog_GetCostTypeDef(ILContext il) { ILCursor ilcursor = new ILCursor(il); ILCursor ilcursor2 = ilcursor; Func <Instruction, bool>[] array = new Func <Instruction, bool> [1]; array[0] = ((Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 13)); bool flag = ilcursor2.TryGotoNext(array); bool flag2 = flag; if (flag2) { ilcursor.Remove(); ilcursor.Emit(OpCodes.Call, typeof(CostTypeCatalog).GetProperty("costTypeCount").GetGetMethod()); } }
private void TitleMusicIL(ILContext il) { ILCursor ilcursor = new ILCursor(il); ILCursor ilcursor2 = ilcursor; MoveType moveType = MoveType.After; Func <Instruction, bool>[] array = new Func <Instruction, bool> [1]; array[0] = ((Instruction i) => ILPatternMatchingExt.MatchLdfld <Main>(i, "newMusic")); ilcursor2.GotoNext(moveType, array); ilcursor.EmitDelegate <Func <int, int> >(delegate(int newMusic) { if (newMusic != 6) { return(newMusic); } return(customTitleMusicSlot); }); }
private void NewDrawMenu(ILContext il) { ILCursor c = new ILCursor(il).Goto(0, 0, false); ILCursor ilcursor = c; Func <Instruction, bool>[] array = new Func <Instruction, bool> [1]; array[0] = ((Instruction i) => ILPatternMatchingExt.MatchLdsfld(i, typeof(Main).GetField("dayTime"))); bool flag = !ilcursor.TryGotoNext(array); if (flag) { Logger.Info("Failed to change main menu."); } else { c.Emit(OpCodes.Call, typeof(SpookyTerraria).GetMethod("DrawMenuNew", BindingFlags.NonPublic | BindingFlags.Static)); } }