#Patching IEnumerator

34 messages · Page 1 of 1 (latest)

stone jackal
#

This is what happens upon making the beamUpPlayer upon making it a void method.

quick sierra
#

@stone jackal what are you trying to do

stone jackal
#

I'm trying to make beamUpPlayer work currently.

#

It seems like there is three teleport methods.

quick sierra
#

Ohhh

#

Check that out

stone jackal
#

I have no clue

#

how to do that with this.

quick sierra
#

Something like

        [HarmonyTranspiler]
        [HarmonyPatch(typeof(ShipTeleporter), "beamUpPlayer", MethodType.Enumerator)]
        private static IEnumerable beamUpPlayer(ShipTeleporter __instance, ref int[] ___playersBeingTeleported)
        {
#

There are a couple options for you there

stone jackal
#

They don't even use int[]

#

just uses the player controller.

stone jackal
#

Its not easy to understand sense there is so much code for beamUpPlayer as is.

quick sierra
#

What do you need to return idk what you're trying to do atm

stone jackal
#

All, I'm trying to do is get it to do what its doing already with beamUpPlayer.

#

Then I will edit the values from there.

quick sierra
#

Well it needs to stay as IEnumerable bc it is called with SartCoroutine

stone jackal
#

But let me ask.

#

If I do this instead of copying the orginal code.

#

I'm just going to copy the code right back into this?

#

Also beamUpPlayer() couldn't use args lol.

quick sierra
#

Yea idk what your plan is there

#

You want to do something after this method is called?

stone jackal
#

It teleports me 2x upon clicking the button or multiple times I should say.

#

Alright, I got it work.

stone jackal
#

I'm still not to sure about this. Its just not shown well in examples and very few.

stone jackal
#
[Error  :  HarmonyX] Failed to patch virtual bool ShipTeleporter+<beamUpPlayer>d__32::MoveNext(): System.ArgumentNullException: Invalid argument for callvirt NULL
Parameter name: operand
  at HarmonyLib.Internal.Patching.ILManipulator.WriteTo (Mono.Cecil.Cil.MethodBody body, System.Reflection.MethodBase original) [0x001b4] in <474744d65d8e460fa08cd5fd82b5d65f>:0
  at HarmonyLib.Public.Patching.HarmonyManipulator.WriteTranspilers () [0x00084] in <474744d65d8e460fa08cd5fd82b5d65f>:0
  at HarmonyLib.Public.Patching.HarmonyManipulator.WriteImpl () [0x0002b] in <474744d65d8e460fa08cd5fd82b5d65f>:0
[Error  : Unity Log] ArgumentNullException: Invalid argument for callvirt NULL
Parameter name: operand
Stack trace:
HarmonyLib.Internal.Patching.ILManipulator.WriteTo (Mono.Cecil.Cil.MethodBody body, System.Reflection.MethodBase original) (at <474744d65d8e460fa08cd5fd82b5d65f>:0)
HarmonyLib.Public.Patching.HarmonyManipulator.WriteTranspilers () (at <474744d65d8e460fa08cd5fd82b5d65f>:0)
HarmonyLib.Public.Patching.HarmonyManipulator.WriteImpl () (at <474744d65d8e460fa08cd5fd82b5d65f>:0)
Rethrow as HarmonyException: IL Compile Error (unknown location)
HarmonyLib.Public.Patching.HarmonyManipulator.WriteImpl () (at <474744d65d8e460fa08cd5fd82b5d65f>:0)
HarmonyLib.Public.Patching.HarmonyManipulator.Process (MonoMod.Cil.ILContext ilContext, System.Reflection.MethodBase originalMethod) (at <474744d65d8e460fa08cd5fd82b5d65f>:0)
HarmonyLib.Public.Patching.HarmonyManipulator.Manipulate (System.Reflection.MethodBase original, HarmonyLib.PatchInfo patchInfo, MonoMod.Cil.ILContext ctx) (at <474744d65d8e460fa08cd5fd82b5d65f>:0)
HarmonyLib.Public.Patching.HarmonyManipulator.Manipulate (System.Reflection.MethodBase original, MonoMod.Cil.ILContext ctx) (at <474744d65d8e460fa08cd5fd82b5d65f>:0)
HarmonyLib.Public.Patching.ManagedMethodPatcher.Manipulator (MonoMod.Cil.ILContext ctx) (at <474744d65d8e460fa08cd5fd82b5d65f>:0)
MonoMod.Cil.ILContext.Invoke (MonoMod.Cil.ILContext+Manipulator manip) (at <6733e342b5b549bba815373898724469>:0)
MonoMod.RuntimeDetour.ILHook+Context.InvokeManipulator (Mono.Cecil.MethodDefinition def, MonoMod.Cil.ILContext+Manipulator cb) (at <4e2760c7517c4ea79c633d67e84b319f>:0)
(wrapper dynamic-method) MonoMod.RuntimeDetour.ILHook+Context.DMD<MonoMod.RuntimeDetour.ILHook+Context::Refresh>(MonoMod.RuntimeDetour.ILHook/Context)
(wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition.Trampoline<MonoMod.RuntimeDetour.ILHook+Context::Refresh>?245389678(object)
HarmonyLib.Internal.RuntimeFixes.StackTraceFixes.OnILChainRefresh (System.Object self) (at <474744d65d8e460fa08cd5fd82b5d65f>:0)
MonoMod.RuntimeDetour.ILHook.Apply () (at <4e2760c7517c4ea79c633d67e84b319f>:0)
HarmonyLib.Public.Patching.ManagedMethodPatcher.DetourTo (System.Reflection.MethodBase replacement) (at <474744d65d8e460fa08cd5fd82b5d65f>:0)
Rethrow as HarmonyException: IL Compile Error (unknown location)
HarmonyLib.Public.Patching.ManagedMethodPatcher.DetourTo (System.Reflection.MethodBase replacement) (at <474744d65d8e460fa08cd5fd82b5d65f>:0)
HarmonyLib.PatchFunctions.UpdateWrapper (System.Reflection.MethodBase original, HarmonyLib.PatchInfo patchInfo) (at <474744d65d8e460fa08cd5fd82b5d65f>:0)
Rethrow as HarmonyException: IL Compile Error (unknown location)
HarmonyLib.PatchClassProcessor.ReportException (System.Exception exception, System.Reflection.MethodBase original) (at <474744d65d8e460fa08cd5fd82b5d65f>:0)
HarmonyLib.PatchClassProcessor.Patch () (at <474744d65d8e460fa08cd5fd82b5d65f>:0)
HarmonyLib.Harmony.PatchAll (System.Type type) (at <474744d65d8e460fa08cd5fd82b5d65f>:0)
BetterShipUpgrades.Plugin.Awake () (at <36e135bfdf4d488a91bc06293726037a>:0)
UnityEngine.GameObject:AddComponent(Type)
BepInEx.Bootstrap.Chainloader:Start()
UnityEngine.Rendering.HighDefinition.HDRenderPipelineAsset:OnEnable()
#

Mainly just copied the Transpiler code from KindTeleporters. I have no idea how code instructions work.