public override void Patch(ReiPatcher.Patch.PatcherArguments args) { try { AssemblyDefinition ta = args.Assembly; AssemblyDefinition da = PatcherHelper.GetAssemblyDefinition(args, "CM3D2.VoiceNormalizer.Managed.dll"); string m = "CM3D2.VoiceNormalizer.Managed."; // 引数の型 string[] targetArgTypes = { "System.String", "System.Boolean" }; string[] calleeArgTypes = { "AudioSourceMgr", "System.String", "System.Boolean" }; PatcherHelper.SetHook( PatcherHelper.HookType.PreCall, ta, "AudioSourceMgr.LoadFromWf", targetArgTypes, da, m + "Callbacks.AudioSourceMgr.LoadFromWf.Invoke", calleeArgTypes); } catch (Exception e) { Helper.ShowException(e); throw; } }
public override void Patch(ReiPatcher.Patch.PatcherArguments args) { try { AssemblyDefinition ta = args.Assembly; AssemblyDefinition da = PatcherHelper.GetAssemblyDefinition(args, "CM3D2.MaidVoicePitch.Managed.dll"); string m = "CM3D2.MaidVoicePitch.Managed."; // TBody.LateUpdateの処理終了後にCM3D2.MaidVoicePitch.Managed.Callbacks.TBody.LateUpdate.Invokeを呼び出す PatcherHelper.SetHook(PatcherHelper.HookType.PostCall, ta, "TBody", "LateUpdate", da, m + "Callbacks.TBody.LateUpdate", "Invoke"); // TBody.MoveHeadAndEyeの処理を完全に乗っ取り、CM3D2.MaidVoicePitch.Managed.Callbacks.TBody.MoveHeadAndEye.Invokeの呼び出しに置き換える PatcherHelper.SetHook(PatcherHelper.HookType.PreJump, ta, "TBody", "MoveHeadAndEye", da, m + "Callbacks.TBody.MoveHeadAndEye", "Invoke"); // BoneMorph_.Blendの処理終了後にCM3D2.MaidVoicePitch.Managed.Callbacks.BoneMorph_.Blend.Invokeを呼び出す PatcherHelper.SetHook(PatcherHelper.HookType.PostCall, ta, "BoneMorph_", "Blend", da, m + "Callbacks.BoneMorph_.Blend", "Invoke"); // AudioSourceMgr.Playの処理終了後にCM3D2.MaidVoicePitch.Managed.Callbacks.AudioSourceMgr.Play.Invokeを呼び出す PatcherHelper.SetHook(PatcherHelper.HookType.PostCall, ta, "AudioSourceMgr", "Play", da, m + "Callbacks.AudioSourceMgr.Play", "Invoke"); // AudioSourceMgr.PlayOneShotの処理終了後にCM3D2.MaidVoicePitch.Managed.Callbacks.AudioSourceMgr.PlayOneShot.Invokeを呼び出す PatcherHelper.SetHook(PatcherHelper.HookType.PostCall, ta, "AudioSourceMgr", "PlayOneShot", da, m + "Callbacks.AudioSourceMgr.PlayOneShot", "Invoke"); SetPatchedAttribute(args.Assembly, patchTag); } catch (Exception e) { Helper.ShowException(e); throw; } }
public override void Patch(ReiPatcher.Patch.PatcherArguments args) { AssemblyDefinition ta = args.Assembly; AssemblyDefinition da = PatcherHelper.GetAssemblyDefinition(args, "CM3D2.ExternalSaveData.Managed.dll"); // GameMain.OnInitializeの処理後、CM3D2.略.ExSaveData.DummyInitializeを呼ぶ PatcherHelper.SetHook( PatcherHelper.HookType.PostCall, ta, "GameMain.OnInitialize", da, "CM3D2.ExternalSaveData.Managed.ExSaveData.DummyInitialize"); // GameMain.Deserializeの処理後、CM3D2.略.GameMainCallbacks.Deserialize.Invokeを呼ぶ PatcherHelper.SetHook( PatcherHelper.HookType.PostCall, ta, "GameMain.Deserialize", da, "CM3D2.ExternalSaveData.Managed.GameMainCallbacks.Deserialize.Invoke"); // GameMain.Deserializeの処理後、CM3D2.略.GameMainCallbacks.Serialize.Invokeを呼ぶ PatcherHelper.SetHook( PatcherHelper.HookType.PostCall, ta, "GameMain.Serialize", da, "CM3D2.ExternalSaveData.Managed.GameMainCallbacks.Serialize.Invoke"); // GameMain.DeleteSerializeDataの処理後、CM3D2.略.GameMainCallbacks.DeleteSerializeData.Invokeを呼ぶ PatcherHelper.SetHook( PatcherHelper.HookType.PostCall, ta, "GameMain.DeleteSerializeData", da, "CM3D2.ExternalSaveData.Managed.GameMainCallbacks.DeleteSerializeData.Invoke"); SetPatchedAttribute(args.Assembly, patchTag); }
private static MethodDefinition GetMethod( AssemblyDefinition assemblyDefinition, string typeName, string methodName, params string[] args) { TypeDefinition td = assemblyDefinition.MainModule.GetType(typeName); return(PatcherHelper.GetMethod(td, methodName, args)); }
MethodDefinition GetMethod( ReiPatcher.Patch.PatcherArguments rpArgs, string dllFileName, string typeName, string methodName, params string[] args) { AssemblyDefinition ad = PatcherHelper.GetAssemblyDefinition(rpArgs, dllFileName); return(GetMethod(ad, typeName, methodName, args)); }
public static void Patch(AssemblyDefinition assembly) { Console.WriteLine("C*M3D2.XtMS.Patcher " + assembly); AssemblyDefinition ta = assembly; var prefix = "COM3D2"; var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string path = ""; if (dir.EndsWith("sybaris", StringComparison.OrdinalIgnoreCase)) { path = @"UnityInjector\"; } else { path = @"..\Plugins\UnityInjector\"; } if (Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().Location).StartsWith("cm3d2", StringComparison.OrdinalIgnoreCase)) { prefix = "CM3D2"; } // Helper使用 try { AssemblyDefinition da = PatcherHelper.GetAssemblyDefinition(string.Format("{0}\\{1}.XtMasterSlave.Plugin.dll", path, prefix)); TypeDefinition typedef = da.MainModule.GetType("CM3D2.XtMasterSlave.Plugin.Hook"); PatcherHelper.SetHook( PatcherHelper.HookType.PreCall, ta, "TBody.AutoTwist", da, "CM3D2.XtMasterSlave.Plugin.Hook.hookPreAutoTwist"); // v5.1 if (prefix == "COM3D2" && ta.MainModule.GetType("FullBodyIKCtrl") != null) { PatcherHelper.SetHook( PatcherHelper.HookType.PreCall, ta, "FullBodyIKCtrl.SolverUpdate", da, "CM3D2.XtMasterSlave.Plugin.Hook.hookPreSolverUpdate"); } /* * PatcherHelper.SetHook( * PatcherHelper.HookType.PostCall, * ta, "FullBodyIKCtrl.IKUpdate", * da, "CM3D2.XtMasterSlave.Plugin.Hook.hookIKPreLateUpdate");*/ /*PatcherHelper.SetHook( * PatcherHelper.HookType.PostCall, * ta, "TBody.LateUpdate", * da, "CM3D2.XtMasterSlave.Plugin.Hook.hookBodyPreLateUpdate");*/ } catch (Exception e) { Console.WriteLine("SetHook例外:" + e); } }
public static void Patch(AssemblyDefinition assembly) { try { AssemblyDefinition ta = assembly; AssemblyDefinition da = PatcherHelper.GetAssemblyDefinition("COM3D2.MaidVoicePitch.Managed.dll"); string m = "CM3D2.MaidVoicePitch.Managed."; // TBody.LateUpdateの処理終了後にCM3D2.MaidVoicePitch.Managed.Callbacks.TBody.LateUpdate.Invokeを呼び出す PatcherHelper.SetHook(PatcherHelper.HookType.PostCall, ta, "TBody", "LateUpdate", da, m + "Callbacks.TBody.LateUpdate", "Invoke"); // TBody.MoveHeadAndEyeの処理を完全に乗っ取り、CM3D2.MaidVoicePitch.Managed.Callbacks.TBody.MoveHeadAndEye.Invokeの呼び出しに置き換える PatcherHelper.SetHook(PatcherHelper.HookType.PreJump, ta, "TBody", "MoveHeadAndEye", da, m + "Callbacks.TBody.MoveHeadAndEye", "Invoke"); // BoneMorph_.Blendの処理終了後にCM3D2.MaidVoicePitch.Managed.Callbacks.BoneMorph_.Blend.Invokeを呼び出す PatcherHelper.SetHook(PatcherHelper.HookType.PostCall, ta, "BoneMorph_", "Blend", da, m + "Callbacks.BoneMorph_.Blend", "Invoke"); // AudioSourceMgr.Playの処理終了後にCM3D2.MaidVoicePitch.Managed.Callbacks.AudioSourceMgr.Play.Invokeを呼び出す PatcherHelper.SetHook(PatcherHelper.HookType.PostCall, ta, "AudioSourceMgr", "Play", da, m + "Callbacks.AudioSourceMgr.Play", "Invoke"); // AudioSourceMgr.PlayOneShotの処理終了後にCM3D2.MaidVoicePitch.Managed.Callbacks.AudioSourceMgr.PlayOneShot.Invokeを呼び出す PatcherHelper.SetHook(PatcherHelper.HookType.PostCall, ta, "AudioSourceMgr", "PlayOneShot", da, m + "Callbacks.AudioSourceMgr.PlayOneShot", "Invoke"); PatcherHelper.SetHook(PatcherHelper.HookType.PreCall, ta, "CharacterMgr", "PresetSet", da, m + "Callbacks.CharacterMgr.PresetSet", "Invoke"); Patch_SceneEdit_SlideCallback(assembly); // スカート調整 PatcherHelper.SetHook( PatcherHelper.HookType.PreCall, ta, "DynamicSkirtBone", "UpdateSelf", da, "CM3D2.MaidVoicePitch.Managed.Callbacks.DynamicSkirtBone.PreUpdateSelf", "Invoke"); PatcherHelper.SetHook( PatcherHelper.HookType.PostCall, ta, "DynamicSkirtBone", "UpdateSelf", da, "CM3D2.MaidVoicePitch.Managed.Callbacks.DynamicSkirtBone.PostUpdateSelf", "Invoke"); // 胸ボーンサイズ用 PatcherHelper.SetHook( PatcherHelper.HookType.PreCall, ta, "jiggleBone", "LateUpdateSelf", da, "CM3D2.MaidVoicePitch.Managed.Callbacks.jiggleBone.PreLateUpdateSelf", "Invoke"); // 胸ボーンサイズ用 PatcherHelper.SetHook( PatcherHelper.HookType.PostCall, ta, "jiggleBone", "LateUpdateSelf", da, "CM3D2.MaidVoicePitch.Managed.Callbacks.jiggleBone.PostLateUpdateSelf", "Invoke"); } catch (Exception e) { Helper.ShowException(e); throw; } }
public override void Patch(ReiPatcher.Patch.PatcherArguments args) { try { AssemblyDefinition ta = args.Assembly; AssemblyDefinition da = PatcherHelper.GetAssemblyDefinition(args, "CM3D2.VoiceNormalizer.Managed.dll"); string m = "CM3D2.VoiceNormalizer.Managed."; PatcherHelper.SetHook( PatcherHelper.HookType.PreCall, ta, "AudioSourceMgr.LoadFromWf", da, m + "Callbacks.AudioSourceMgr.LoadFromWf.Invoke"); } catch (Exception e) { Helper.ShowException(e); throw; } }
public void EquipCustomWeapons(Loadout loadout, WeaponManager wm) { triggered = true; Traverse traverse = Traverse.Create(wm); HPEquippable[] equips = (HPEquippable[])traverse.Field("equips").GetValue(); MassUpdater component = wm.vesselRB.GetComponent <MassUpdater>(); string[] hpLoadout = loadout.hpLoadout; int num = 0; Debug.Log("sLoadout\n" + loadout.hpLoadout.ToString()); // var bundle = AssetBundle.LoadFromFile(resourcePath); while (num < wm.hardpointTransforms.Length && num < hpLoadout.Length) { if (!string.IsNullOrEmpty(hpLoadout[num]) && hpLoadout[num] == "Nuke") { Debug.Log(hpLoadout[num] + " will be tried to be loaded."); GameObject missileObject = PatcherHelper.GetAssetBundle().LoadAsset <GameObject>(hpLoadout[num]); Debug.Log("Got missileObject"); //GameObject missileObject = Instantiate(@object, wm.hardpointTransforms[num]); // toCheckAgainst = wm.hardpointTransforms[num]; Debug.Log("Instantiated custom weapon."); missileObject.name = hpLoadout[num]; Debug.Log("Changed name."); missileObject.transform.localRotation = Quaternion.identity; Debug.Log("Quaternion identity."); missileObject.transform.localPosition = Vector3.zero; Debug.Log("local position."); missileObject.transform.localScale = new Vector3(20f, 20f, 20f); Debug.Log("local scale."); if (missileObject == null) { Debug.LogError("missileObject is null."); } // missileLauncher.SetParentRigidbody(rB); GameObject equipper = Instantiate(new GameObject()); GameObject edgeTransform = missileObject.transform.GetChild(0).gameObject; Nuke nuke = missileObject.AddComponent <Nuke>(); nuke.edgeTransform = edgeTransform; nuke.equipper = equipper; equipper.SetActive(true); Debug.Log("Nuke added."); nuke.init(); Debug.Log("Nuke inited."); if (equipper == null) { Debug.LogError("Equipper is null."); } if (equipper.transform.position == null) { Debug.LogError("Equipper transform posiiton null"); } if (wm.hardpointTransforms[num].position == null) { Debug.LogError("wm hardopint transforms position null"); } equipper.transform.position = wm.hardpointTransforms[num].position; Debug.Log("Equipper transform."); equipper.transform.parent = wm.hardpointTransforms[num]; Debug.Log("Equipper transform parent."); HPEquipBombRack HPEquipper = nuke.HPEquipper; Debug.Log("HPEquipper inited."); HPEquipper.SetWeaponManager(wm); Debug.Log("Weapon Manager."); equips[num] = HPEquipper; Debug.Log("equips = component."); HPEquipper.wasPurchased = true; Debug.Log("was purchased."); HPEquipper.hardpointIdx = num; Debug.Log("hardpointIDX."); HPEquipper.Equip(); Debug.Log("Equip()."); Debug.Log("Tipping nuke"); if (HPEquipper.jettisonable) { Rigidbody component3 = HPEquipper.GetComponent <Rigidbody>(); if (component3) { component3.interpolation = RigidbodyInterpolation.None; } } Debug.Log("jettisonable."); if (HPEquipper.armable) { HPEquipper.armed = true; wm.RefreshWeapon(); } Debug.Log("RefrshWeapon()."); missileObject.SetActive(true); foreach (Component component4 in HPEquipper.gameObject.GetComponentsInChildren <Component>()) { if (component4 is IParentRBDependent) { ((IParentRBDependent)component4).SetParentRigidbody(wm.vesselRB); } if (component4 is IRequiresLockingRadar) { ((IRequiresLockingRadar)component4).SetLockingRadar(wm.lockingRadar); } if (component4 is IRequiresOpticalTargeter) { ((IRequiresOpticalTargeter)component4).SetOpticalTargeter(wm.opticalTargeter); } } Debug.Log("DLZ shit"); MissileLauncher missileLauncher = nuke.missileLauncher; if (missileLauncher.missilePrefab == null) { Debug.LogError("MissilePrefab is null"); } if (missileLauncher.missilePrefab.GetComponent <Missile>() == null) { Debug.LogError("Missile not found on prefab"); } if (missileLauncher.hardpoints[0] == null) { Debug.LogError("Hardpoints null"); } missileLauncher.LoadAllMissiles(); Debug.Log(missileLauncher.missiles[0]); Debug.Log("HEY IT WORKED"); Warhead nyuk = missileLauncher.missiles[0].gameObject.AddComponent <Warhead>(); missileLauncher.missiles[0].OnDetonate = new UnityEvent(); missileLauncher.missiles[0].OnDetonate.AddListener(new UnityAction(() => { Debug.Log("Nuke is now critical."); nyuk.DoNuke(); })); missileLauncher.missiles[0].enabled = true; if (missileLauncher.missiles[0].transform == null) { Debug.LogError("Missile[0] null"); } Debug.Log("Nuke should now have teeth"); if (missileLauncher.overrideDecoupleSpeed > 0f) { missileLauncher.missiles[0].decoupleSpeed = missileLauncher.overrideDecoupleSpeed; } if (missileLauncher.overrideDecoupleDirections != null && missileLauncher.overrideDecoupleDirections.Length > 0 && missileLauncher.overrideDecoupleDirections[0] != null) { missileLauncher.missiles[0].overrideDecoupleDirTf = missileLauncher.overrideDecoupleDirections[0]; } if (missileLauncher.overrideDropTime >= 0f) { missileLauncher.missiles[0].thrustDelay = missileLauncher.overrideDropTime; } // int missileCount = missileLauncher.missileCount; /*GameObject dummyMissile = Instantiate(@object, wm.hardpointTransforms[num]); * dummyMissile.transform.localScale = new Vector3(20f, 20f, 20f); * dummyMissile.transform.eulerAngles = new Vector3(dummyMissile.transform.eulerAngles.x, dummyMissile.transform.eulerAngles.y, dummyMissile.transform.eulerAngles.z + 90f); * dummyMissile.SetActive(true);*/ missileLauncher.missiles[0].transform.localScale = new Vector3(20f, 20f, 20f); missileLauncher.missiles[0].transform.parent = equipper.transform; missileLauncher.missiles[0].transform.position = equipper.transform.position; missileLauncher.missiles[0].transform.eulerAngles = new Vector3(missileLauncher.missiles[0].transform.eulerAngles.x, missileLauncher.missiles[0].transform.eulerAngles.y, missileLauncher.missiles[0].transform.eulerAngles.z + 90f); missileLauncher.missiles[0].gameObject.SetActive(true); // Destroy(dummyMissile); Missile.LaunchEvent launchEvent = new Missile.LaunchEvent(); launchEvent.delay = 0f; launchEvent.launchEvent = new UnityEvent(); launchEvent.launchEvent.AddListener(new UnityAction(() => { Debug.Log("Launch event was called."); // dummyMissile.SetActive(false); /*Destroy(dummyMissile); */ })); missileLauncher.missiles[0].launchEvents = new List <Missile.LaunchEvent>(); missileLauncher.missiles[0].launchEvents.Add(launchEvent); toCheck = missileLauncher.missiles[0]; Debug.Log("Missiles loaded!"); } else { Debug.LogError(hpLoadout[num] + " is null or empty."); } num++; } if (wm.vesselRB) { wm.vesselRB.ResetInertiaTensor(); } Debug.Log("intertia tensor."); if (loadout.cmLoadout != null) { CountermeasureManager componentInChildren = GetComponentInChildren <CountermeasureManager>(); if (componentInChildren) { int num2 = 0; while (num2 < componentInChildren.countermeasures.Count && num2 < loadout.cmLoadout.Length) { componentInChildren.countermeasures[num2].count = Mathf.Clamp(loadout.cmLoadout[num2], 0, componentInChildren.countermeasures[num2].maxCount); componentInChildren.countermeasures[num2].UpdateCountText(); num2++; } } } traverse.Field("weaponIdx").SetValue(0); Debug.Log("weaponIDX."); wm.ToggleMasterArmed(); wm.ToggleMasterArmed(); if (wm.OnWeaponChanged != null) { wm.OnWeaponChanged.Invoke(); } component.UpdateMassObjects(); traverse.Field("rcsAddDirty").SetValue(true); // wm.ReattachWeapons(); Debug.Log("Should be working now..."); wm.RefreshWeapon(); foreach (var equip in wm.GetCombinedEquips()) { Debug.Log(equip); } }
// Patches the assemblies /// <summary> /// /// </summary> /// <param name="assembly"></param> public static void Patch(AssemblyDefinition assembly) { LogError(assembly.Name.Name); AssemblyDefinition ta = assembly; AssemblyDefinition da = PatcherHelper.GetAssemblyDefinition("COM3D2.Lilly.Managed.dll"); TypeDefinition typedef = da.MainModule.GetType("COM3D2.Lilly.Managed,LillyManaged"); try { if (assembly.Name.Name == "Assembly-CSharp") { Log("Assembly-CSharp"); // static은 안되나? //public static void Assert(string message, bool nothrow = false) //PatcherHelper.SetHook( // PatcherHelper.HookType.PreJump, // ta, "NDebug.Assert", // da, "COM3D2.Lilly.Managed.NDebugLilly.AssertPreJump"); // 오류 발생 // private void SetProp(MaidProp mp, string filename, int f_nFileNameRID, bool f_bTemp, bool f_bNoScale = false) //PatcherHelper.SetHook( // PatcherHelper.HookType.PreCall, // ta, "Maid.SetProp", // da, "COM3D2.Lilly.Managed.MaidLilly.SetPropPreCall"); // PresetSet(Maid f_maid, Preset f_prest) PatcherHelper.SetHook( PatcherHelper.HookType.PreCall, ta, "CharacterMgr.PresetSet", da, "COM3D2.Lilly.Managed.CharacterMgrLilly.PresetSetPreCall"); // public Preset PresetSave(Maid f_maid, PresetType f_type) PatcherHelper.SetHook( PatcherHelper.HookType.PostCallRet, ta, "CharacterMgr.PresetSave", da, "COM3D2.Lilly.Managed.CharacterMgrLilly.PresetSavePostCallRet"); // 사운드 파일명 출력용 후킹. PatcherHelper.SetHook( PatcherHelper.HookType.PreCall, ta, "AudioSourceMgr.LoadPlay", da, "COM3D2.Lilly.Managed.AudioSourceMgrLilly.LoadPlayPreCall"); PatcherHelper.SetHook( PatcherHelper.HookType.PostCall, ta, "AudioSourceMgr.LoadPlay", da, "COM3D2.Lilly.Managed.AudioSourceMgrLilly.LoadPlayPostCall"); PatcherHelper.SetHook( PatcherHelper.HookType.PreCall, ta, "ImportC.ReadMaterial", da, "COM3D2.Lilly.Managed.ImportCMLilly.ReadMaterial"); } else if (assembly.Name.Name == "UnityEngine") { Log(" UnityEngine"); } else if (assembly.Name.Name == "Assembly-CSharp-firstpass") { Log(" Assembly-CSharp-firstpass"); } } catch (Exception e) { Log(e); } }
public static void Patch(AssemblyDefinition assembly) { AssemblyDefinition assemblyDefinition = AssemblyDefinition.ReadAssembly(Assembly.GetExecutingAssembly().Location); PatcherHelper.SetHook(PatcherHelper.HookType.ExPreCall, assembly, "SoundMgr.PlayBGM", assemblyDefinition, "COM3D2.LegacyEditBGM.Patcher.LegacyEditBGM.PlayBGM"); }