Exemplo n.º 1
0
        static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions)
        {
            var codes = instructions.GetEnumerator();

            while (codes.MoveNext())
            {
                var code = codes.Current;
                if (code.opcode == OpCodes.Ldfld && ((FieldInfo)code.operand).Name == "m_mp_team")
                {
                    yield return(code);

                    for (int i = 0; i < 2; i++)
                    {
                        // pass on until color init
                        while (codes.MoveNext() &&
                               (codes.Current.opcode != OpCodes.Ldfld || ((FieldInfo)codes.Current.operand).Name != "m_mp_team"))
                        {
                            yield return(codes.Current);
                        }
                        yield return(codes.Current);

                        foreach (var c in MPTeamsHUDArmor.ChangeTeamColorLoad(codes, i == 0 ? OpCodes.Ldc_I4_1 : OpCodes.Ldc_I4_3))
                        {
                            yield return(c);
                        }
                    }
                    break;
                }
                yield return(code);
            }
            while (codes.MoveNext())
            {
                yield return(codes.Current);
            }
        }
Exemplo n.º 2
0
        static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions)
        {
            var codes = instructions.GetEnumerator();
            int cnt   = 0;

            while (codes.MoveNext())
            {
                var code = codes.Current;
                yield return(code);

                if (code.opcode == OpCodes.Ldfld && ((FieldInfo)code.operand).Name == "m_mp_team" && ++cnt == 1)
                {
                    foreach (var c in MPTeamsHUDArmor.ChangeTeamColorLoad(codes, OpCodes.Ldc_I4_1))
                    {
                        yield return(c);
                    }
                }
            }
        }
Exemplo n.º 3
0
        static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions)
        {
            var codes = instructions.GetEnumerator();
            int cnt   = 0;

            while (codes.MoveNext())
            {
                var code = codes.Current;
                yield return(code);

                if (code.opcode == OpCodes.Ldarg_1 && (++cnt == 2 || cnt == 3))
                {
                    foreach (var c in MPTeamsHUDArmor.ChangeTeamColorLoad(codes, cnt == 2 ? OpCodes.Ldc_I4_1 : OpCodes.Ldc_I4_4))
                    {
                        yield return(c);
                    }
                }
            }
        }