예제 #1
0
        public static IEnumerable <CodeInstruction> MultiplyTechValues(IEnumerable <CodeInstruction> instructions)
        {
            CodeMatcher matcher = new CodeMatcher(instructions)
                                  .MatchForward(false, new CodeMatch(OpCodes.Switch));

            Label[] jumpTable = (Label[])matcher.Operand;

            matcher.MoveToLabel(jumpTable[17]) // 18 - 1
            .MatchForward(false, new CodeMatch(OpCodes.Add))
            .InsertAndAdvance(Transpilers.EmitDelegate <Func <int> >(() => GigaStationsPlugin.droneCapacityMultiplier))
            .InsertAndAdvance(new CodeInstruction(OpCodes.Mul));

            matcher.MoveToLabel(jumpTable[18]) // 19 - 1
            .MatchForward(false, new CodeMatch(OpCodes.Add))
            .InsertAndAdvance(Transpilers.EmitDelegate <Func <int> >(() => GigaStationsPlugin.vesselCapacityMultiplier))
            .InsertAndAdvance(new CodeInstruction(OpCodes.Mul));

            return(matcher.InstructionEnumeration());
        }