Ejemplo n.º 1
0
        void SpecialItem_getTemporarySpriteForHoldingUp()
        {
            var code = FindCode(
                Instructions.Ldstr("LooseSprites\\Cursors"),
                Instructions.Call_get(typeof(Game1), nameof(Game1.player)),
                Instructions.Ldfld(typeof(Farmer), nameof(Farmer.maxItems)),
                OpCodes.Call,
                Instructions.Ldc_I4_S(36)
                // Beq or Bne_un
                );

            code.Prepend(
                // if (maxItems==48) {
                Instructions.Call_get(typeof(Game1), nameof(Game1.player)),
                Instructions.Ldfld(typeof(Farmer), nameof(Farmer.maxItems)),
                code[3], // Nothing jumps here so reusing this should be OK.
                Instructions.Ldc_I4_S(48),
                Instructions.Bne_Un(AttachLabel(code[0])),
                // return getBackpackSprite(position);
                Instructions.Ldarg_1(),
                Instructions.Call(GetType(), "getBackpackSprite", typeof(Vector2)),
                Instructions.Ret()
                // }
                );
        }