Ejemplo n.º 1
0
        static CIEnumerable Transpiler(CIEnumerable cins)
        {
            var list = cins.ToList();

            list.ciInsert(ci => ci.isLDC <double>(0.03f), CIUtils.speedClamped01, OpCodes.Mul);   // do not change to 0.03d !
            list.ciInsert(ci => ci.isLDC(500f), CIUtils.speedClamped01, OpCodes.Div);             // changing only first '500f'

            return(list);
        }
Ejemplo n.º 2
0
        static CIEnumerable Transpiler(CIEnumerable cins)
        {
            var list = cins.ToList();

            ciInsert(list, ci => ci.isLDC <double>(0.03f), _dnsClamped01.ci, OpCodes.Mul);   // do not change to 0.03d !
            ciInsert(list, ci => ci.isLDC(500f), _dnsClamped01.ci, OpCodes.Div);             // changing only first '500f'

            return(list);
        }
Ejemplo n.º 3
0
        static CIEnumerable F1_F3_disabler(CIEnumerable cins)
        {
            var list = cins.ToList();

            CIHelper.MemberMatch match = new (OpCodes.Call, Mod.Consts.isGameSN? "get_isShippingRelease": "get_isConsolePlatform");
            int[] i = list.ciFindIndexes(match, match, ci => ci.isOp(Mod.Consts.isGameSN? OpCodes.Blt: OpCodes.Ret));

            return(i == null? cins: list.ciRemoveRange(i[0], i[2]));
        }
Ejemplo n.º 4
0
            static CIEnumerable Transpiler(CIEnumerable cins, ILGenerator ilg)
            {
                var list = cins.ToList();
                var field_lastBindedIndex = typeof(BindingPatches).field(nameof(lastBindedIndex));

#if GAME_SN && BRANCH_STABLE
                var cinsCompare = CIHelper.toCIList(OpCodes.Ldloc_S, 4,
                                                    OpCodes.Ldsfld, field_lastBindedIndex);
#else
                var cinsCompare = CIHelper.toCIList(OpCodes.Ldarg_1, CIHelper.emitCall <Func <KeyCode> >(_lastBindedKeyCode));
Ejemplo n.º 5
0
        static CIEnumerable Transpiler(CIEnumerable cins, ILGenerator ilg)
        {
            var list = cins.ToList();

            void _changeVal(float val, string cfgVar) => constToCfgVar <float, GrapplingArmUpgraded>(list, val, cfgVar, ilg);

            _changeVal(35f, nameof(Main.config.hookMaxDistance));
            _changeVal(15f, nameof(Main.config.acceleration));
            _changeVal(400f, nameof(Main.config.force));

            return(list);
        }
Ejemplo n.º 6
0
            static void saveLastBind() => lastBindedIndex = GameInput.lastInputPressed[0];             // for keyboard

            static CIEnumerable Transpiler(CIEnumerable cins)
            {
                var list = cins.ToList();

                // saving binded keycode to check later in GameInput.UpdateKeyInputs patch
                list.ciInsert(new CIHelper.MemberMatch(nameof(GameInput.ClearInput)), CIHelper.emitCall <Action>(saveLastBind));
#if GAME_SN
                if (Main.config.easyBindRemove)
                {
                    int index = list.FindIndex(new CIHelper.MemberMatch($"get_{nameof(EventSystem.current)}"));
                    Common.Debug.assert(index != -1);

                    var get_hoveredObject = typeof(BindCheckPointer).property(nameof(BindCheckPointer.hoveredObject)).GetGetMethod();
                    list.RemoveRange(index, 2);
                    list.Insert(index, new CodeInstruction(OpCodes.Call, get_hoveredObject));
                }
#endif
                return(list);
            }
Ejemplo n.º 7
0
 // for just first predicate match (insert right after finded instruction)
 public static CIList ciInsert(CIEnumerable cins, CIPredicate predicate, params object[] cinsToInsert) =>
 ciInsert(cins.ToList(), predicate, cinsToInsert);
Ejemplo n.º 8
0
 // maxMatchCount = 0 for all predicate matches
 // indexDelta - change actual index from matched for insertion
 // if indexDelta is 0 than cinsToInsert will be inserted right before finded instruction
 // throws assert exception if there were no matches at all or if maxMatchCount > 0 and there were less predicate matches
 public static CIList ciInsert(CIEnumerable cins, CIPredicate predicate, int indexDelta, int maxMatchCount, params object[] cinsToInsert) =>
 ciInsert(cins.ToList(), predicate, indexDelta, maxMatchCount, cinsToInsert);
Ejemplo n.º 9
0
 // replaces first matched CodeInstruction with cinsForReplace CodeInstructions
 public static CIList ciReplace(CIEnumerable cins, CIPredicate predicate, params object[] cinsForReplace) =>
 ciReplace(cins.ToList(), predicate, cinsForReplace);
Ejemplo n.º 10
0
 public static CIList ciRemove(CIEnumerable cins, int index, int countToRemove) =>
 ciRemove(cins.ToList(), index, countToRemove);
Ejemplo n.º 11
0
 // indexDelta - change actual index from matched for removing
 // countToRemove - instructions count to be removed
 public static CIList ciRemove(CIEnumerable cins, CIPredicate predicate, int indexDelta, int countToRemove) =>
 ciRemove(cins.ToList(), predicate, indexDelta, countToRemove);
Ejemplo n.º 12
0
 // changing constant to config field if gameobject have component C
 public static CIList constToCfgVar <T, C>(CIEnumerable cins, T val, string cfgVarName, ILGenerator ilg) where C : Component =>
 constToCfgVar <T, C>(cins.ToList(), val, cfgVarName, ilg);
Ejemplo n.º 13
0
        // warning: nested classes are not supported for cfgVarName!

        // changing constant to config field
        public static CIList constToCfgVar <T>(CIEnumerable cins, T val, string cfgVarName) =>
        constToCfgVar(cins.ToList(), val, cfgVarName);