Exemple #1
0
        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]);
                }
            });
        }