From 593544c8e736b635ddf4ae431f998befee707f91 Mon Sep 17 00:00:00 2001 From: Aleksandr Trubin Date: Tue, 24 Dec 2019 03:21:53 +0500 Subject: [PATCH] SmoothThrust now supports more than one simulteneous controller some code cleanup --- ControllerFix/ControllerFix.cs | 41 +++++--------------- ControllerFix/ControllerFix.csproj | 20 ++++++---- ControllerFix/manifest.json | 13 ++++--- SmoothThrust/SmoothThrust.cs | 53 ++++++++++++++++---------- SmoothThrust/SmoothThrust.csproj | 22 ++++++----- SmoothThrust/manifest.json | 13 ++++--- TAIcheat/TAIcheat.cs | 61 ++++++++---------------------- TAIcheat/TAIcheat.csproj | 52 +++++++++++++++++-------- TAIcheat/buttons.txt | 50 ++++++++++++++++++++++++ TAIcheat/manifest.json | 13 ++++--- 10 files changed, 190 insertions(+), 148 deletions(-) create mode 100644 TAIcheat/buttons.txt diff --git a/ControllerFix/ControllerFix.cs b/ControllerFix/ControllerFix.cs index ae68adb..061c733 100644 --- a/ControllerFix/ControllerFix.cs +++ b/ControllerFix/ControllerFix.cs @@ -1,22 +1,16 @@ using OWML.Common; -using OWML.Events; -using System; -using UnityEngine; -using Harmony; -using System.Reflection; using PadEZ; using System.Collections.Generic; using System.Runtime.InteropServices; -using System.Collections; namespace XBoxCOntrollerFix { class GamePad_PC_XB1_Fix { - public static void Postfix(GamePad_PC_XB1 __instance, ref uint ___m_xb1Index, ref XboxControllerFix.XINPUT_State ___m_padState) + public static void SetUp_Postfix(GamePad_PC_XB1 __instance, ref uint ___m_xb1Index, ref XboxControllerFix.XINPUT_State ___m_padState) { - XboxControllerFix.ModHelper.Console.WriteLine($"controller SetUp normal index: {___m_xb1Index}"); + uint chck = ___m_xb1Index; for (uint num = 0u; num < 4u; num += 1u) { if (XboxControllerFix.XInputGetState(num, out ___m_padState) == 0u && !XboxControllerFix.occInds.Contains(num)) @@ -25,12 +19,12 @@ public static void Postfix(GamePad_PC_XB1 __instance, ref uint ___m_xb1Index, re } } XboxControllerFix.occInds.Add(___m_xb1Index); - XboxControllerFix.ModHelper.Console.WriteLine($"controller SetUp patched index: {___m_xb1Index}"); + if (chck != ___m_xb1Index) + XboxControllerFix.ModHelper.Logger.Log($"patch fixed index from {chck} to {___m_xb1Index}"); } - + public static void Destr_Prefix(GamePad_PC_XB1 __instance, ref uint ___m_xb1Index) { - XboxControllerFix.ModHelper.Console.WriteLine("entered patched controller destroy"); XboxControllerFix.occInds.Remove(___m_xb1Index); } } @@ -51,60 +45,43 @@ public static bool Prefix(ThrusterModel __instance, ref GamePad __result, int pa { result = new GamePad_PC_XB1(padIndex, GamePad.PadType.X360); } - } if (result != null) { - XboxControllerFix.ModHelper.Console.WriteLine($"patched controller type: #{padIndex} \"{name}\"; resulting type = {result.GetPadType()}"); + XboxControllerFix.ModHelper.Logger.Log($"patched controller type: #{padIndex} \"{name}\"; resulting type = {result.GetPadType()}"); __result = result; return false; } else { - XboxControllerFix.ModHelper.Console.WriteLine($"normal controller type: #{padIndex} \"{name}\""); + XboxControllerFix.ModHelper.Logger.Log($"normal controller type: #{padIndex} \"{name}\""); return true; } } } - public class XboxControllerFix:ModBehaviour + public class XboxControllerFix : ModBehaviour { private void Start() { - ModHelper.HarmonyHelper.AddPostfix("SetUp", typeof(GamePad_PC_XB1_Fix), "Postfix"); + ModHelper.HarmonyHelper.AddPostfix("SetUp", typeof(GamePad_PC_XB1_Fix), "SetUp_Postfix"); ModHelper.HarmonyHelper.AddPrefix("Destroy", typeof(GamePad_PC_XB1_Fix), "Destr_Prefix"); ModHelper.HarmonyHelper.AddPrefix("CreateController", typeof(PadManager_Fix), "Prefix"); ModHelper.Console.WriteLine("Controller Fix ready!"); } public static HashSet occInds = new HashSet(); - public static bool looppreventer; [DllImport("XINPUT9_1_0.DLL")] public static extern uint XInputGetState(uint userIndex, out XboxControllerFix.XINPUT_State state); public struct XINPUT_State { - // Token: 0x040000C3 RID: 195 public uint PacketNumber; - - // Token: 0x040000C4 RID: 196 public ushort Buttons; - - // Token: 0x040000C5 RID: 197 public byte LeftTrigger; - - // Token: 0x040000C6 RID: 198 public byte RightTrigger; - - // Token: 0x040000C7 RID: 199 public short ThumbLX; - - // Token: 0x040000C8 RID: 200 public short ThumbLY; - - // Token: 0x040000C9 RID: 201 public short ThumbRX; - - // Token: 0x040000CA RID: 202 public short ThumbRY; } } diff --git a/ControllerFix/ControllerFix.csproj b/ControllerFix/ControllerFix.csproj index 29f8ee5..921ae0b 100644 --- a/ControllerFix/ControllerFix.csproj +++ b/ControllerFix/ControllerFix.csproj @@ -18,7 +18,7 @@ true full false - bin\Debug\ + bin\debug\ DEBUG;TRACE prompt 4 @@ -39,23 +39,26 @@ D:\Games\Outer Wilds\OuterWilds_Data\Managed\0Harmony.dll + False False D:\Games\Outer Wilds\OuterWilds_Data\Managed\Assembly-CSharp.dll + False - - False + D:\Games\Outer Wilds\OuterWilds_Data\Managed\OWML.Common.dll + False False D:\Games\Outer Wilds\OuterWilds_Data\Managed\OWML.Events.dll + False - - False - ..\..\..\..\..\..\..\Program Files (x86)\Outer Wilds\OuterWilds_Data\Managed\UnityEngine.CoreModule.dll + + D:\Games\Outer Wilds\OuterWilds_Data\Managed\UnityEngine.CoreModule.dll + False @@ -69,7 +72,8 @@ - - + xcopy /Y "$(TargetPath)" "$(SolutionDir)releases\$(ProjectName)\" +xcopy /Y "$(TargetDir)manifest.json" "$(SolutionDir)releases\$(ProjectName)\" +7z a -tzip -mx5 -r0 $(SolutionDir)releases\$(ProjectName).zip $(SolutionDir)releases\$(ProjectName)\*.* \ No newline at end of file diff --git a/ControllerFix/manifest.json b/ControllerFix/manifest.json index 32c88b4..38abb6d 100644 --- a/ControllerFix/manifest.json +++ b/ControllerFix/manifest.json @@ -1,8 +1,9 @@ { - "filename": "OWML.TestMod.dll", - "author": "Alek", - "name": "TestMod", - "uniqueName": "Alek.TestMod", - "version": "0.1", - "enabled": false + "filename": "ControllerFix.dll", + "author": "TAImatem", + "name": "XBoxControllerFix", + "uniqueName": "TruAI.XBoxControllerFix", + "version": "1.0", + "owmlVersion": "0.2.1", + "enabled": true } \ No newline at end of file diff --git a/SmoothThrust/SmoothThrust.cs b/SmoothThrust/SmoothThrust.cs index 4bfa53f..8db16ff 100644 --- a/SmoothThrust/SmoothThrust.cs +++ b/SmoothThrust/SmoothThrust.cs @@ -1,42 +1,57 @@ using OWML.Common; -using OWML.Events; -using System; +using System.Collections.Generic; using UnityEngine; -using Harmony; -using System.Reflection; -namespace SmoothThrustContainer +namespace TAI_SmoothThrust { - - //[HarmonyPatch(typeof(ThrusterModel), "AddTranslationalInput")] - class ThrusterModel_AddTranslationalInput + class ThrusterModel_SmoothPatch { public static void Prefix(ThrusterModel __instance, ref Vector3 input) { + if (!SmoothThrust.container.ContainsKey(__instance)) + { + SmoothThrust.container.Add(__instance, new SmoothThrust.SmoothCont()); + } + SmoothThrust.SmoothCont iter = SmoothThrust.container[__instance]; if (OWInput.IsNewlyPressed(InputLibrary.interact, InputMode.All)) { - SmoothThrustContainer._prevTranslation = input; - SmoothThrustContainer._buildupVelocity = Vector3.zero; + iter._prevTranslation = input; + iter._buildupVelocity = Vector3.zero; } if (input.magnitude > 0.0001f && OWInput.IsHeld(InputLibrary.interact, 0.05f, InputMode.All)) { - SmoothThrustContainer._prevTranslation.x = Mathf.SmoothDamp(SmoothThrustContainer._prevTranslation.x, input.x, ref SmoothThrustContainer._buildupVelocity.x, SmoothThrustContainer._analogSmoothTime); - SmoothThrustContainer._prevTranslation.z = Mathf.SmoothDamp(SmoothThrustContainer._prevTranslation.z, input.z, ref SmoothThrustContainer._buildupVelocity.z, SmoothThrustContainer._analogSmoothTime); - SmoothThrustContainer._prevTranslation.y = Mathf.SmoothDamp(SmoothThrustContainer._prevTranslation.y, input.y, ref SmoothThrustContainer._buildupVelocity.y, SmoothThrustContainer._analogSmoothTime); - input = SmoothThrustContainer._prevTranslation; + iter._prevTranslation.x = Mathf.SmoothDamp(iter._prevTranslation.x, input.x, ref iter._buildupVelocity.x, SmoothThrust._analogSmoothTime); + iter._prevTranslation.z = Mathf.SmoothDamp(iter._prevTranslation.z, input.z, ref iter._buildupVelocity.z, SmoothThrust._analogSmoothTime); + iter._prevTranslation.y = Mathf.SmoothDamp(iter._prevTranslation.y, input.y, ref iter._buildupVelocity.y, SmoothThrust._analogSmoothTime); + input = iter._prevTranslation; + } + iter._prevTranslation = input; + SmoothThrust.container[__instance] = iter; + } + + public static void Postfix(ThrusterModel __instance) + { + if (SmoothThrust.container.ContainsKey(__instance)) + { + SmoothThrust.container.Remove(__instance); } - SmoothThrustContainer._prevTranslation = input; } } - public class SmoothThrustContainer:ModBehaviour + public class SmoothThrust : ModBehaviour { private void Start() { - ModHelper.HarmonyHelper.AddPrefix("AddTranslationalInput", typeof(ThrusterModel_AddTranslationalInput), "Prefix"); + ModHelper.HarmonyHelper.AddPrefix("AddTranslationalInput", typeof(ThrusterModel_SmoothPatch), "Prefix"); + ModHelper.HarmonyHelper.AddPostfix("OnDestroy", typeof(ThrusterModel_SmoothPatch), "Postfix"); ModHelper.Console.WriteLine("Smooth Thrust Ready!"); } - public static Vector3 _prevTranslation; - public static Vector3 _buildupVelocity; + + public static Dictionary container = new Dictionary(); public static float _analogSmoothTime = 0.3f; + public struct SmoothCont + { + public Vector3 _prevTranslation; + public Vector3 _buildupVelocity; + } } } diff --git a/SmoothThrust/SmoothThrust.csproj b/SmoothThrust/SmoothThrust.csproj index 9c5649b..15e79cf 100644 --- a/SmoothThrust/SmoothThrust.csproj +++ b/SmoothThrust/SmoothThrust.csproj @@ -18,7 +18,7 @@ true full false - bin\Debug\ + bin\debug\ DEBUG;TRACE prompt 4 @@ -39,23 +39,26 @@ D:\Games\Outer Wilds\OuterWilds_Data\Managed\0Harmony.dll + False - - False - ..\..\..\..\..\..\..\Program Files (x86)\Outer Wilds\OuterWilds_Data\Managed\Assembly-CSharp.dll + + D:\Games\Outer Wilds\OuterWilds_Data\Managed\Assembly-CSharp.dll + False False D:\Games\Outer Wilds\OuterWilds_Data\Managed\OWML.Common.dll + False False D:\Games\Outer Wilds\OuterWilds_Data\Managed\OWML.Events.dll + False - - False - ..\..\..\..\..\..\..\Program Files (x86)\Outer Wilds\OuterWilds_Data\Managed\UnityEngine.CoreModule.dll + + D:\Games\Outer Wilds\OuterWilds_Data\Managed\UnityEngine.CoreModule.dll + False @@ -69,7 +72,8 @@ - - + xcopy /Y "$(TargetPath)" "$(SolutionDir)releases\$(ProjectName)\" +xcopy /Y "$(TargetDir)manifest.json" "$(SolutionDir)releases\$(ProjectName)\" +7z a -tzip -mx5 -r0 $(SolutionDir)releases\$(ProjectName).zip $(SolutionDir)releases\$(ProjectName)\*.* \ No newline at end of file diff --git a/SmoothThrust/manifest.json b/SmoothThrust/manifest.json index 32c88b4..01149c7 100644 --- a/SmoothThrust/manifest.json +++ b/SmoothThrust/manifest.json @@ -1,8 +1,9 @@ { - "filename": "OWML.TestMod.dll", - "author": "Alek", - "name": "TestMod", - "uniqueName": "Alek.TestMod", - "version": "0.1", - "enabled": false + "filename": "KeyboardSmoothThrust.dll", + "author": "TAImatem & Schinken", + "name": "SmoothThrust", + "uniqueName": "TruAI.SmoothThrust", + "version": "1.0", + "owmlVersion": "0.2.1", + "enabled": true } \ No newline at end of file diff --git a/TAIcheat/TAIcheat.cs b/TAIcheat/TAIcheat.cs index 2c5370c..46454c5 100644 --- a/TAIcheat/TAIcheat.cs +++ b/TAIcheat/TAIcheat.cs @@ -1,16 +1,13 @@ using OWML.Common; using OWML.Events; -using System; -using UnityEngine; using System.Reflection; -using Harmony; -using System.Collections; +using UnityEngine; namespace TAICheats { public static class MyExtensions { - public static void TAISetTranslationalThrust(this JetpackThrusterModel jet, float newacc) + public static void TAIcheat_SetTranslationalThrust(this JetpackThrusterModel jet, float newacc) { float oldtrst = jet.GetMaxTranslationalThrust(); float oldbst = jet.GetBoostMaxThrust(); @@ -24,14 +21,14 @@ public static void TAISetTranslationalThrust(this JetpackThrusterModel jet, floa } } public class DebugInput : ModBehaviour - { + { private RelativeLocationData relconstr(Vector3 body_position, Quaternion body_rotation, Vector3 body_velocity, OWRigidbody relativeBody, Transform relativeTransform = null) { if (relativeTransform == null) { relativeTransform = relativeBody.transform; } - RelativeLocationData res = new RelativeLocationData(Locator.GetPlayerBody(),relativeBody); + RelativeLocationData res = new RelativeLocationData(Locator.GetPlayerBody(), relativeBody); res.localPosition = relativeTransform.InverseTransformPoint(body_position); res.localRotation = Quaternion.Inverse(relativeTransform.rotation) * body_rotation; res.localRelativeVelocity = relativeTransform.InverseTransformDirection(body_velocity - relativeBody.GetPointVelocity(body_position)); @@ -193,30 +190,11 @@ private void FixedUpdate() private void Update() { - if (global::Input.GetKeyDown(KeyCode.LeftShift) || global::Input.GetKeyDown(KeyCode.RightShift)) - { - this.shiftPressed = true; - } - if (global::Input.GetKeyUp(KeyCode.LeftShift) || global::Input.GetKeyUp(KeyCode.RightShift)) - { - this.shiftPressed = false; - } - if (global::Input.GetKeyDown(KeyCode.LeftControl) || global::Input.GetKeyDown(KeyCode.RightControl)) - { - this.ctrlPressed = true; - } - if (global::Input.GetKeyUp(KeyCode.LeftControl) || global::Input.GetKeyUp(KeyCode.RightControl)) - { - this.ctrlPressed = false; - } - if (global::Input.GetKeyDown(KeyCode.LeftAlt) || global::Input.GetKeyDown(KeyCode.RightAlt)) - { - this.altPressed = true; - } - if (global::Input.GetKeyUp(KeyCode.LeftAlt) || global::Input.GetKeyUp(KeyCode.RightAlt)) - { - this.altPressed = false; - } + this.shiftPressed = global::Input.GetKey(KeyCode.LeftShift) || global::Input.GetKey(KeyCode.RightShift); + this.ctrlPressed = global::Input.GetKey(KeyCode.LeftControl) || global::Input.GetKey(KeyCode.RightControl); + this.altPressed = global::Input.GetKey(KeyCode.LeftAlt) || global::Input.GetKey(KeyCode.RightAlt); + if (!Locator.GetPlayerController()) + return; if (!Locator.GetPlayerController().enabled) return; if (global::Input.GetKeyDown(KeyCode.BackQuote)) @@ -224,11 +202,12 @@ private void Update() DebugInput.cheatsOn = !DebugInput.cheatsOn; if (DebugInput.cheatsOn) { - this.CMOn = true; + + AudioSource.PlayClipAtPoint(Locator.GetAudioManager().GetAudioClipArray(global::AudioType.NomaiPowerOn)[0], Locator.GetActiveCamera().transform.position); } else { - this.CMOff = true; + AudioSource.PlayClipAtPoint(Locator.GetAudioManager().GetAudioClipArray(global::AudioType.NomaiPowerOff)[0], Locator.GetActiveCamera().transform.position); } } if (DebugInput.cheatsOn) @@ -467,7 +446,7 @@ private void Update() AudioSource.PlayClipAtPoint(Locator.GetAudioManager().GetAudioClipArray(global::AudioType.ToolProbeLaunch)[0], Locator.GetPlayerBody().transform.position); } } - if (global::Input.GetKeyDown(DebugKeyCode.powerOverwhelming) || global::Input.GetKeyDown(KeyCode.P)) + if (global::Input.GetKeyDown(KeyCode.P)) { if (this.altPressed) { @@ -476,11 +455,11 @@ private void Update() if (!this.wasBoosted) { this.jetpackStanard = Locator.GetPlayerSuit().GetComponent().GetMaxTranslationalThrust(); - Locator.GetPlayerSuit().GetComponent().TAISetTranslationalThrust(50f); + Locator.GetPlayerSuit().GetComponent().TAIcheat_SetTranslationalThrust(50f); } else { - Locator.GetPlayerSuit().GetComponent().TAISetTranslationalThrust(this.jetpackStanard); + Locator.GetPlayerSuit().GetComponent().TAIcheat_SetTranslationalThrust(this.jetpackStanard); } this.wasBoosted = !this.wasBoosted; if (this.wasBoosted) @@ -667,16 +646,6 @@ private void Update() } } } - if (this.CMOn) - { - AudioSource.PlayClipAtPoint(Locator.GetAudioManager().GetAudioClipArray(global::AudioType.NomaiPowerOn)[0], Locator.GetPlayerBody().transform.position); - this.CMOn = false; - } - if (this.CMOff) - { - AudioSource.PlayClipAtPoint(Locator.GetAudioManager().GetAudioClipArray(global::AudioType.NomaiPowerOff)[0], Locator.GetPlayerBody().transform.position); - this.CMOff = false; - } if (this.COn) { AudioClip[] audioClipArray = Locator.GetAudioManager().GetAudioClipArray(global::AudioType.Menu_Confirm); diff --git a/TAIcheat/TAIcheat.csproj b/TAIcheat/TAIcheat.csproj index bc8718c..276d788 100644 --- a/TAIcheat/TAIcheat.csproj +++ b/TAIcheat/TAIcheat.csproj @@ -17,10 +17,11 @@ true full false - bin\Debug\ + bin\debug\ DEBUG;TRACE prompt 4 + On pdbonly @@ -31,42 +32,56 @@ 4 - - ..\..\packages\Lib.Harmony.1.2.0.1\lib\net35\0Harmony.dll + + D:\Games\Outer Wilds\OuterWilds_Data\Managed\0Harmony.dll + False - - False + D:\Games\Outer Wilds\OuterWilds_Data\Managed\Assembly-CSharp.dll + False - - False + D:\Games\Outer Wilds\OuterWilds_Data\Managed\OWML.Common.dll + False False D:\Games\Outer Wilds\OuterWilds_Data\Managed\OWML.Events.dll + False + + + False + + + False - - - - + + False + + + False + D:\Games\Outer Wilds\OuterWilds_Data\Managed\UnityEngine.AudioModule.dll + False - ..\..\..\..\..\..\..\Program Files (x86)\Outer Wilds\OuterWilds_Data\Managed\UnityEngine.CoreModule.dll + D:\Games\Outer Wilds\OuterWilds_Data\Managed\UnityEngine.CoreModule.dll + False D:\Games\Outer Wilds\OuterWilds_Data\Managed\UnityEngine.IMGUIModule.dll + False - - False + D:\Games\Outer Wilds\OuterWilds_Data\Managed\UnityEngine.PhysicsModule.dll + False D:\Games\Outer Wilds\OuterWilds_Data\Managed\UnityEngine.UI.dll + False @@ -78,9 +93,14 @@ Always + + + - - + xcopy /Y "$(TargetPath)" "$(SolutionDir)releases\$(ProjectName)\" +xcopy /Y "$(TargetDir)manifest.json" "$(SolutionDir)releases\$(ProjectName)\" +xcopy /Y "$(ProjectDir)buttons.txt" "$(SolutionDir)releases\$(ProjectName)\" +7z a -tzip -mx5 -r0 $(SolutionDir)releases\$(ProjectName).zip $(SolutionDir)releases\$(ProjectName)\*.* \ No newline at end of file diff --git a/TAIcheat/buttons.txt b/TAIcheat/buttons.txt new file mode 100644 index 0000000..f111f44 --- /dev/null +++ b/TAIcheat/buttons.txt @@ -0,0 +1,50 @@ +enable cheat mode = ` or ~ + +VesselWarp (requires reload) = E + U + +suitUp = G +learnLaunchCodes = Alt + G + +toggle Helmet = H +toggle HUD = Alt + H + +refillResources, heal and repair ship = J +damage ship components = Alt + J +destroy ship = Alt + Shift + J + +EngageLudicrousSpeed = L +increase ludicrousness = Shift + L +decrease ludicrousness = Alt + L + +powerOverwhelming (invincibility) = P +toggle superjetpack = Alt + P + +revealAllShipLogFacts = O +learnForgetFrequencies = Alt + O + +cycle through DebugHUD types = \ + +toggle player collision = N +toggle player collision AND gravity (separate mechanism) = Alt + N +toggle ship collision = M +toggle ship collision AND gravity (separate mechanism) = Alt + M + +triggerSupernova = Delete +break all Brittle Hollow's Fragments = Alt + Delete + +timeLapse = Equals + +uiTestAndSuicide = Minus + +raycast single layer inspector (crosshair, can be used for teleportation too) = Home +switch filter = Home + Alt + +set warp point: + player's position = PageDown + player's crosshair (mostly works) = Alt + PageDown + scout's position (somewhat buggy) = (Shift or Ctrl) + PageDown +teleport to warp point = PageUp +cycle warp point (10 slots available) = Alt + PageUp + +toggle nearby anglerfishes' AI = K +disable nearby anglerfishes = Alt + K \ No newline at end of file diff --git a/TAIcheat/manifest.json b/TAIcheat/manifest.json index e3f3072..8d04cbd 100644 --- a/TAIcheat/manifest.json +++ b/TAIcheat/manifest.json @@ -1,8 +1,9 @@ { - "filename": "OWML.EnableDebugMode.dll", - "author": "Alek", - "name": "EnableDebugMode", - "uniqueName": "Alek.EnableDebugMode", - "version": "0.1", - "enabled": true + "filename": "TAICheat.dll", + "author": "TAImatem", + "name": "TAICheat", + "uniqueName": "TruAI.TAICheat", + "version": "1.0", + "owmlVersion": "0.2.1", + "enabled": true } \ No newline at end of file