示例#1
0
        void GameLocation_answerDialogueAction()
        {
            var code = FindCode(
                // else if ((int)Game1.player.maxItems != 36) {
                Instructions.Call_get(typeof(Game1), nameof(Game1.player)),
                Instructions.Ldfld(typeof(Farmer), nameof(Farmer.maxItems)),
                OpCodes.Call,
                Instructions.Ldc_I4_S(36),
                OpCodes.Beq
                );
            var get_player = Instructions.Call_get(typeof(Game1), nameof(Game1.player));

            code.Replace(
                // else if ((int)Game1.player.maxItems < 36
                Instructions.Call_get(typeof(Game1), nameof(Game1.player)),
                Instructions.Ldfld(typeof(Farmer), nameof(Farmer.maxItems)),
                code[2],
                Instructions.Ldc_I4_S(48),
                Instructions.Bge(AttachLabel(get_player)),
                //   && Game1.player.Money >= 50000) {
                Instructions.Call_get(typeof(Game1), nameof(Game1.player)),
                Instructions.Callvirt_get(typeof(Farmer), nameof(Farmer.Money)),
                Instructions.Ldc_I4(50000),
                Instructions.Blt(AttachLabel(get_player)),
                //   buyBackpack();
                Instructions.Call(GetType(), "buyBackpack"),
                // }
                // else if ((int)Game1.player.maxItems != 48) {
                get_player,
                Instructions.Ldfld(typeof(Farmer), nameof(Farmer.maxItems)),
                code[2],
                Instructions.Ldc_I4_S(48),
                code[4]
                );
        }