diff --git a/VRTRAKILL.Plugin/New Unity Project/.vsconfig b/VRTRAKILL.Plugin/New Unity Project/.vsconfig new file mode 100644 index 00000000..d70cd98b --- /dev/null +++ b/VRTRAKILL.Plugin/New Unity Project/.vsconfig @@ -0,0 +1,6 @@ +{ + "version": "1.0", + "components": [ + "Microsoft.VisualStudio.Workload.ManagedGame" + ] +} diff --git a/VRTRAKILL.Plugin/New Unity Project/Assets/OtherAssets/Scenes/things.unity b/VRTRAKILL.Plugin/New Unity Project/Assets/OtherAssets/Scenes/things.unity index f44e8d43..b96cbada 100644 --- a/VRTRAKILL.Plugin/New Unity Project/Assets/OtherAssets/Scenes/things.unity +++ b/VRTRAKILL.Plugin/New Unity Project/Assets/OtherAssets/Scenes/things.unity @@ -153,6 +153,85 @@ Transform: m_Father: {fileID: 1538946043} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &116757281 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 116757287} + - component: {fileID: 116757286} + - component: {fileID: 116757285} + m_Layer: 0 + m_Name: Cube (1) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!23 &116757285 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 116757281} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &116757286 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 116757281} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &116757287 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 116757281} + m_LocalRotation: {x: -0.17410773, y: -1.7763568e-15, z: 5.3290705e-15, w: 0.98472667} + m_LocalPosition: {x: 0, y: -0.120412536, z: 0.049287483} + m_LocalScale: {x: 0.15, y: 0.15, z: 0.15} + m_Children: [] + m_Father: {fileID: 467667341} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: -20.053001, y: 0, z: 0} --- !u!1 &219724640 GameObject: m_ObjectHideFlags: 0 @@ -322,6 +401,100 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 281756062} m_CullTransparentMesh: 0 +--- !u!1 &467667340 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 467667341} + - component: {fileID: 467667342} + m_Layer: 0 + m_Name: massive schlonger + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &467667341 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 467667340} + m_LocalRotation: {x: 0.7144619, y: -0.000000030583735, z: -0.000000031230122, w: 0.6996743} + m_LocalPosition: {x: 0, y: -0.00092, z: 0.0088} + m_LocalScale: {x: 0.011974436, y: 0.011974436, z: 0.011974436} + m_Children: + - {fileID: 486669280} + - {fileID: 116757287} + - {fileID: 1844406600} + - {fileID: 1241016940} + m_Father: {fileID: 2468436929421570197} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &467667342 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 467667340} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: aec9260cef9f6114684d463b4a9e28e0, type: 3} + m_Name: + m_EditorClassIdentifier: + m_RootBones: + - {fileID: 467667341} + m_EndBones: [] + m_Material: {fileID: 0} + m_StartDepth: 0 + m_SiblingConstraints: 0 + m_ClosedSiblings: 0 + m_SiblingRotationConstraints: 1 + m_LengthUnification: 0 + m_CollisionLayers: + serializedVersion: 2 + m_Bits: 1 + m_ExtraColliders: [] + m_Radius: 0 + m_RadiusCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + - serializedVersion: 3 + time: 1 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_DeltaTimeMode: 0 + m_ConstantDeltaTime: 0.03 + m_Iterations: 1 + m_SleepThreshold: 0.005 + m_GravityAligner: {fileID: 0} + m_Gravity: {x: 0, y: 0, z: 0} + m_ForceModule: {fileID: 0} + m_ForceScale: 1 + m_SimulateSpace: {fileID: 0} --- !u!1 &478575341 GameObject: m_ObjectHideFlags: 0 @@ -352,6 +525,85 @@ Transform: m_Father: {fileID: 6937786763829708858} m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &486669275 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 486669280} + - component: {fileID: 486669279} + - component: {fileID: 486669278} + m_Layer: 0 + m_Name: Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!23 &486669278 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 486669275} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &486669279 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 486669275} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &486669280 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 486669275} + m_LocalRotation: {x: -0.31455958, y: -0, z: 2.664535e-15, w: 0.9492377} + m_LocalPosition: {x: 0.00000023236605, y: -0.003000051, z: -0.010999987} + m_LocalScale: {x: 0.15, y: 0.15, z: 0.15} + m_Children: [] + m_Father: {fileID: 467667341} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: -36.668003, y: 0, z: 0} --- !u!1 &513232099 GameObject: m_ObjectHideFlags: 0 @@ -1088,6 +1340,85 @@ Transform: m_Father: {fileID: 513232100} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 13.966687, y: 1.6858784, z: -10.219963} +--- !u!1 &1241016939 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1241016940} + - component: {fileID: 1241016945} + - component: {fileID: 1241016944} + m_Layer: 0 + m_Name: Cube (3) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1241016940 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1241016939} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: -0.39641252, z: 0.07228819} + m_LocalScale: {x: 0.15, y: 0.15, z: 0.15} + m_Children: [] + m_Father: {fileID: 467667341} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &1241016944 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1241016939} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &1241016945 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1241016939} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} --- !u!1 &1297785111 GameObject: m_ObjectHideFlags: 0 @@ -1849,6 +2180,85 @@ Transform: m_Father: {fileID: 1297785112} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1844406594 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1844406600} + - component: {fileID: 1844406599} + - component: {fileID: 1844406598} + m_Layer: 0 + m_Name: Cube (2) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!23 &1844406598 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1844406594} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &1844406599 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1844406594} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &1844406600 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1844406594} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: -0.24541253, z: 0.06928795} + m_LocalScale: {x: 0.15, y: 0.15, z: 0.15} + m_Children: [] + m_Father: {fileID: 467667341} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!4 &1895777035 stripped Transform: m_CorrespondingSourceObject: {fileID: 8471540563007137412, guid: a8a1e3b51f8c7614f96d9a1c1c08b13e, @@ -6611,6 +7021,7 @@ Transform: - {fileID: 7586083640551384664} - {fileID: 3993690346802337327} - {fileID: 2280992145295790687} + - {fileID: 467667341} m_Father: {fileID: 1065721872399604619} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/VRTRAKILL.Plugin/Plugin/Plugin.cs b/VRTRAKILL.Plugin/Plugin/Plugin.cs index 20a300aa..719f289f 100644 --- a/VRTRAKILL.Plugin/Plugin/Plugin.cs +++ b/VRTRAKILL.Plugin/Plugin/Plugin.cs @@ -1,15 +1,13 @@ using BepInEx; using BepInEx.Logging; +using UnityEngine; using Valve.VR; using VRBasePlugin.ULTRAKILL; using VRTRAKILL.Utilities; namespace VRBasePlugin { - /* If you're reading this and don't plan on stopping, then - * welcome to the codebase where all hopes and dreams go die. - * This is a dumpster fire of spaghetti, inconsistent - * naming, questionable life choices and shitty performance. Amen. */ + // note: i will NEVER use transpilers IN THIS LIFETIME!! OVER MY DEAD BODY!! [BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)] public sealed partial class Plugin : BaseUnityPlugin @@ -19,6 +17,7 @@ public sealed partial class Plugin : BaseUnityPlugin public void Awake() { PLog = Logger; + Debug.unityLogger.filterLogType = LogType.Warning; Versioning.CheckForUpdates(); diff --git a/VRTRAKILL.Plugin/Plugin/PluginInfo.cs b/VRTRAKILL.Plugin/Plugin/PluginInfo.cs index cf686b11..6ea3abaf 100644 --- a/VRTRAKILL.Plugin/Plugin/PluginInfo.cs +++ b/VRTRAKILL.Plugin/Plugin/PluginInfo.cs @@ -9,12 +9,12 @@ public static class PluginInfo public const string PLUGIN_GUID = "VRTRAKILL", // do not change this string EVER PLUGIN_NAME = "VRTRAKILL", - PLUGIN_VERSION = "0.19.0"; // never use spaces + PLUGIN_VERSION = "0.20.0"; // never use spaces public static readonly string - PluginPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), // ".../BepInEx/plugins/VRTRAKILL" - FullGamePath = Process.GetCurrentProcess().MainModule.FileName, // ".../ULTRAKILL/ULTRAKILL.exe" - GamePath = Path.GetDirectoryName(FullGamePath); // ".../ULTRAKILL" + PluginPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), // "~/BepInEx/plugins/VRTRAKILL" + FullGamePath = Process.GetCurrentProcess().MainModule.FileName, // "~/ULTRAKILL/ULTRAKILL.exe" + GamePath = Path.GetDirectoryName(FullGamePath); // "~/ULTRAKILL" public const string GithubRepoLink = "https://api.github.com/repos/whateverusername0/VRTRAKILL", diff --git a/VRTRAKILL.Plugin/Plugin/Prefs/NewConfig.cs b/VRTRAKILL.Plugin/Plugin/Prefs/NewConfig.cs index 96ab22de..8bcc2187 100644 --- a/VRTRAKILL.Plugin/Plugin/Prefs/NewConfig.cs +++ b/VRTRAKILL.Plugin/Plugin/Prefs/NewConfig.cs @@ -87,7 +87,7 @@ public _UIInteraction() public NewConfig() { - UKBinds = UKBindings.GetBinds().Actions; + UKBinds = UKBindings.GetBinds(); VRBinds = new _VRBinds(); Controllers = new _Controllers(); CBS = new _CBS(); diff --git a/VRTRAKILL.Plugin/Plugin/Prefs/UKBindings.cs b/VRTRAKILL.Plugin/Plugin/Prefs/UKBindings.cs index a02b9799..ba4455c7 100644 --- a/VRTRAKILL.Plugin/Plugin/Prefs/UKBindings.cs +++ b/VRTRAKILL.Plugin/Plugin/Prefs/UKBindings.cs @@ -91,11 +91,13 @@ public ModifiedAction(string LocalPath) [JsonProperty("controlScheme")] public string ControlScheme { get; set; } = "Keyboard & Mouse"; [JsonProperty("modifiedActions")] public ModifiedActions Actions { get; set; } - public static UKBindings GetBinds() + public static ModifiedActions GetBinds() { UKBindings Json = JsonConvert.DeserializeObject(File.ReadAllText($"{PluginInfo.GamePath}\\Preferences\\Binds.json")); var Binds = new ModifiedActions(); + if (Json == null) return Binds; + // What this does is basically scroll thru all the properties in the Binds object // For each property in Binds scroll through all the properties in the Json.Actions obejct // If it has the matching names (as stated in the JsonProperty) and different values, @@ -109,7 +111,7 @@ public static UKBindings GetBinds() PropInfo[i].SetValue(Binds, JsonPropInfo.GetValue(Json.Actions)); } Json.Actions = Binds; - return Json; + return Json.Actions; } } } diff --git a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Arms/Patches/PunchP.cs b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Arms/Patches/PunchP.cs index 52e3086f..f41d316e 100644 --- a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Arms/Patches/PunchP.cs +++ b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Arms/Patches/PunchP.cs @@ -350,9 +350,9 @@ [HarmonyPrefix] [HarmonyPatch(nameof(Punch.BlastCheck))] static bool BlastCheck( { __instance.holdingInput = false; __instance.anim.SetTrigger("PunchBlast"); - Vector3 position = Vars.NonDominantHand.transform.position + Thing * 2f; - if (Physics.Raycast(Vars.NonDominantHand.transform.position, Thing, out var hitInfo, - 2f, LayerMaskDefaults.Get(LMD.EnvironmentAndBigEnemies))) position = hitInfo.point - Thing * 0.1f; + Vector3 position = Vars.NonDominantHand.transform.position + Vars.NonDominantHand.transform.forward * 2f; + if (Physics.Raycast(Vars.NonDominantHand.transform.position, Vars.NonDominantHand.transform.forward, out var hitInfo, + 2f, LayerMaskDefaults.Get(LMD.EnvironmentAndBigEnemies))) position = hitInfo.point - Vars.NonDominantHand.transform.forward * 0.1f; Object.Instantiate(__instance.blastWave, position, Vars.NonDominantHand.transform.rotation); } diff --git a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Arms/Patches/SandboxArmP.cs b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Arms/Patches/SandboxArmP.cs index 96b93ced..054501ba 100644 --- a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Arms/Patches/SandboxArmP.cs +++ b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Arms/Patches/SandboxArmP.cs @@ -59,7 +59,7 @@ [HarmonyPrefix] [HarmonyPatch(typeof(MoveMode), nameof(MoveMode.Update))] static if (ExperimentalArmRotation.Enabled) { Quaternion lhs; - if (MonoSingleton.Instance.InputSource.ChangeVariation.IsPressed) + if (MonoSingleton.Instance.InputSource.NextVariation.IsPressed) { Vector2 vector = Input.InputVars.TurnVector; lhs = Quaternion.AngleAxis(vector.x * -0.1f, Vector3.up) * Quaternion.AngleAxis(vector.y * 0.1f, Vector3.right); diff --git a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Arms/Patches/Whiplash/HookArmP.cs b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Arms/Patches/Whiplash/HookArmP.cs index 1a8d3f70..00063e05 100644 --- a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Arms/Patches/Whiplash/HookArmP.cs +++ b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Arms/Patches/Whiplash/HookArmP.cs @@ -1,8 +1,6 @@ using HarmonyLib; using UnityEngine; using VRBasePlugin.ULTRAKILL.VRAvatar.Armature; -using static UnityEngine.Random; -using Valve.VR.InteractionSystem; namespace VRBasePlugin.ULTRAKILL.Arms.Patches.Whiplash { @@ -140,15 +138,15 @@ [HarmonyPrefix] [HarmonyPatch(nameof(HookArm.StopThrow))] static bool StopThrow( MonoSingleton.Instance.StopVibration(RumbleProperties.WhiplashPull); if (animationTime == 0f) { - UnityEngine.Object.Instantiate(__instance.pullSound); + Object.Instantiate(__instance.pullSound); __instance.aud.clip = __instance.pullLoop; - __instance.aud.pitch = UnityEngine.Random.Range(0.9f, 1.1f); + __instance.aud.pitch = Random.Range(0.9f, 1.1f); __instance.aud.panStereo = -0.5f; __instance.aud.Play(); } else { - UnityEngine.Object.Instantiate(__instance.pullDoneSound); + Object.Instantiate(__instance.pullDoneSound); } if (__instance.forcingGroundCheck) @@ -182,27 +180,18 @@ [HarmonyPrefix] [HarmonyPatch(nameof(HookArm.StopThrow))] static bool StopThrow( if (sparks) { - UnityEngine.Object.Instantiate(__instance.clinkSparks, __instance.hookPoint, Quaternion.LookRotation(__instance.transform.position - __instance.hookPoint)); + Object.Instantiate(__instance.clinkSparks, __instance.hookPoint, Quaternion.LookRotation(__instance.transform.position - __instance.hookPoint)); } __instance.state = HookState.Ready; __instance.anim.Play("Pull", -1, animationTime); - //__instance.hand.transform.localPosition = new Vector3(-0.015f, 0.071f, 0.04f); - //if (MonoSingleton.Instance.defaultFov > 105f) - //{ - // __instance.hand.transform.localPosition += new Vector3(0.25f * ((MonoSingleton.Instance.defaultFov - 105f) / 55f), 0f, 0.05f * ((MonoSingleton.Instance.defaultFov - 105f) / 60f)); - //} - //else if (MonoSingleton.Instance.defaultFov < 105f) - //{ - // __instance.hand.transform.localPosition -= new Vector3(0.05f * ((105f - MonoSingleton.Instance.defaultFov) / 60f), 0.075f * ((105f - MonoSingleton.Instance.defaultFov) / 60f), 0.125f * ((105f - MonoSingleton.Instance.defaultFov) / 60f)); - //} __instance.returnDistance = Mathf.Max(Vector3.Distance(__instance.transform.position, __instance.hookPoint), 25f); __instance.returning = true; __instance.throwWarp = 0f; if ((bool)__instance.currentWoosh) { - UnityEngine.Object.Destroy(__instance.currentWoosh); + Object.Destroy(__instance.currentWoosh); } return false; diff --git a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Guns/Patches/AddHandsP.cs b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Guns/Patches/AddHandsP.cs index 50c7d33a..f159e4dc 100644 --- a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Guns/Patches/AddHandsP.cs +++ b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Guns/Patches/AddHandsP.cs @@ -14,9 +14,11 @@ [HarmonyPatch] internal sealed class AddHandsP [HarmonyPostfix] [HarmonyPatch(nameof(Shotgun.Start))] static void AddHand(Shotgun __instance) { Transform Hand = Object.Instantiate(Assets.HandPose_Shotgun.transform); - // Shotgun ******(Clone)/Shotgun_New/GunArmature/MainBone - Hand.SetParent(__instance.transform.GetChild(2).GetChild(2).GetChild(0), false); + // Shotgun ******(Clone)/ShogunNewAnims/GunArmature/MainBone + Hand.SetParent(__instance.transform.GetChild(2).GetChild(0).GetChild(0), false); Hand.localPosition = Vector3.zero; + Hand.localEulerAngles = new Vector3(0, 0, 270); + Hand.localScale = new Vector3(.1f, .1f, .1f); Hand.GetChild(1).GetChild(0).localPosition = Position; Hand.GetChild(1).GetChild(0).localEulerAngles = Rotation; diff --git a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Guns/Patches/AimingP.cs b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Guns/Patches/AimingP.cs index 01cd956e..c33d866d 100644 --- a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Guns/Patches/AimingP.cs +++ b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Guns/Patches/AimingP.cs @@ -1,4 +1,5 @@ using HarmonyLib; +using ULTRAKILL.Cheats; using UnityEngine; namespace VRBasePlugin.ULTRAKILL.Guns.Patches @@ -6,83 +7,61 @@ namespace VRBasePlugin.ULTRAKILL.Guns.Patches [HarmonyPatch] internal sealed class AimingP { // Replaces all guns shooting raycasts directions with controller directions - - // Revolver [HarmonyPrefix] [HarmonyPatch(typeof(Revolver), nameof(Revolver.Shoot))] static bool RevolverA(int shotType, Revolver __instance) { - __instance.cc.StopShake(); __instance.shootReady = false; __instance.shootCharge = 0f; - - Vector3 AltShootPos; - if (__instance.altVersion) { MonoSingleton.Instance.revaltpickupcharges[__instance.gunVariation] = 2f; } - AltShootPos = Vars.DominantHand.transform.position + (Vars.DominantHand.transform.forward * 1.25f) + new Vector3(0, .035f, 0); + if (__instance.altVersion) MonoSingleton.Instance.revaltpickupcharges[__instance.gunVariation] = 2f; + var altShootPos = Vars.DominantHand.transform.position + (Vars.DominantHand.transform.forward * 1.25f) + new Vector3(0, .035f, 0); switch (shotType) { case 1: { - GameObject gameObject2 = - Object.Instantiate(__instance.revolverBeam, - Vars.DominantHand.transform.position, - Vars.DominantHand.transform.rotation); - gameObject2.transform.localScale *= .5f; - + GameObject gameObject2 = Object.Instantiate(__instance.revolverBeam, Vars.DominantHand.transform.position, Vars.DominantHand.transform.rotation); if ((bool)__instance.targeter.CurrentTarget && __instance.targeter.IsAutoAimed) gameObject2.transform.LookAt(__instance.targeter.CurrentTarget.bounds.center); RevolverBeam component2 = gameObject2.GetComponent(); component2.sourceWeapon = __instance.gc.currentWeapon; - component2.alternateStartPoint = AltShootPos; + component2.alternateStartPoint = altShootPos; component2.gunVariation = __instance.gunVariation; - if (__instance.anim.GetCurrentAnimatorStateInfo(0).IsName("PickUp")) component2.quickDraw = true; __instance.currentGunShot = Random.Range(0, __instance.gunShots.Length); - __instance.gunAud.clip = __instance.gunShots[__instance.currentGunShot]; __instance.gunAud.volume = 0.55f; __instance.gunAud.pitch = Random.Range(0.9f, 1.1f); __instance.gunAud.Play(); - - //__instance.cam.fieldOfView += __instance.cc.defaultFov / 40f; - MonoSingleton.Instance.SetVibrationTracked(RumbleProperties.GunFire, __instance.gameObject); break; } case 2: { - GameObject gameObject = - Object.Instantiate(__instance.revolverBeamSuper, - Vars.DominantHand.transform.position, - Vars.DominantHand.transform.rotation); - gameObject.transform.localScale *= .5f; - + GameObject gameObject = Object.Instantiate(__instance.revolverBeamSuper, Vars.DominantHand.transform.position, Vars.DominantHand.transform.rotation); if ((bool)__instance.targeter.CurrentTarget && __instance.targeter.IsAutoAimed) + { gameObject.transform.LookAt(__instance.targeter.CurrentTarget.bounds.center); + } RevolverBeam component = gameObject.GetComponent(); component.sourceWeapon = __instance.gc.currentWeapon; - component.alternateStartPoint = AltShootPos; + component.alternateStartPoint = __instance.gunBarrel.transform.position; component.gunVariation = __instance.gunVariation; - if (__instance.gunVariation == 2) component.ricochetAmount = Mathf.Min(3, Mathf.FloorToInt(__instance.pierceShotCharge / 25f)); __instance.pierceShotCharge = 0f; - if (__instance.anim.GetCurrentAnimatorStateInfo(0).IsName("PickUp")) component.quickDraw = true; __instance.pierceReady = false; __instance.pierceCharge = 0f; - if (__instance.gunVariation == 0) { __instance.screenAud.clip = __instance.chargingSound; __instance.screenAud.loop = true; - if (__instance.altVersion) __instance.screenAud.pitch = 0.5f; else __instance.screenAud.pitch = 1f; @@ -92,29 +71,20 @@ [HarmonyPrefix] [HarmonyPatch(typeof(Revolver), nameof(Revolver.Shoot))] static else if (!__instance.wid || __instance.wid.delay == 0f) __instance.wc.rev2charge -= (__instance.altVersion ? 300 : 100); - if ((bool)__instance.superGunAud) - { - __instance.currentGunShot = Random.Range(0, __instance.superGunShots.Length); - - __instance.superGunAud.clip = __instance.superGunShots[__instance.currentGunShot]; - __instance.superGunAud.volume = 0.5f; - __instance.superGunAud.pitch = Random.Range(0.9f, 1.1f); - __instance.superGunAud.Play(); - } + if ((bool)__instance.superGunSound) + Object.Instantiate(__instance.superGunSound); if (__instance.gunVariation == 2 && (bool)__instance.twirlShotSound) Object.Instantiate(__instance.twirlShotSound, __instance.transform.position, Quaternion.identity); - - __instance.cam.fieldOfView += __instance.cc.defaultFov / 20f; MonoSingleton.Instance.SetVibrationTracked(RumbleProperties.GunFireStrong, __instance.gameObject); break; } } - if (!__instance.altVersion) __instance.cylinder.DoTurn(); + if (!__instance.altVersion) + __instance.cylinder.DoTurn(); __instance.anim.SetFloat("RandomChance", Random.Range(0f, 1f)); - if (shotType == 1) __instance.anim.SetTrigger("Shoot"); else __instance.anim.SetTrigger("ChargeShoot"); @@ -122,7 +92,6 @@ [HarmonyPrefix] [HarmonyPatch(typeof(Revolver), nameof(Revolver.Shoot))] static return false; } - // Coin toss [HarmonyPrefix] [HarmonyPatch(typeof(Revolver), nameof(Revolver.ThrowCoin))] static bool RevolverCoin(Revolver __instance) { if (__instance.punch == null || !__instance.punch.gameObject.activeInHierarchy) @@ -159,8 +128,6 @@ [HarmonyPrefix] [HarmonyPatch(typeof(Revolver), nameof(Revolver.ThrowCoin))] sta return false; } - // Shotgun - // Normal fire [HarmonyPrefix] [HarmonyPatch(typeof(Shotgun), nameof(Shotgun.Shoot))] static bool ShotgunA(Shotgun __instance) { __instance.gunReady = false; @@ -187,7 +154,6 @@ [HarmonyPrefix] [HarmonyPatch(typeof(Shotgun), nameof(Shotgun.Shoot))] static bo break; } } - MonoSingleton.Instance.StopShake(); Vector3 direction = Vars.DominantHand.transform.forward; if (__instance.targeter.CurrentTarget && __instance.targeter.IsAutoAimed) { @@ -289,7 +255,6 @@ [HarmonyPrefix] [HarmonyPatch(typeof(Shotgun), nameof(Shotgun.Shoot))] static bo __instance.gunAud.volume = 0.45f; __instance.gunAud.panStereo = 0f; __instance.gunAud.Play(); - __instance.cc.CameraShake(1f); if (__instance.variation == 1) { __instance.anim.SetTrigger("PumpFire"); @@ -312,21 +277,20 @@ [HarmonyPrefix] [HarmonyPatch(typeof(Shotgun), nameof(Shotgun.Shoot))] static bo return false; } - // Grenade (core eject) (BA - set grenade vector to controller, BB - same thing but in diferent method) [HarmonyPrefix] [HarmonyPatch(typeof(Shotgun), nameof(Shotgun.Update))] static bool ShotgunBA(Shotgun __instance) { + if (!MonoSingleton.Instance.PerformingCheatMenuCombo() && MonoSingleton.Instance.InputSource.Fire1.IsPressed && __instance.gunReady && __instance.gc.activated && !GameStateManager.Instance.PlayerInputLocked && !__instance.charging) { if (!__instance.wid || __instance.wid.delay == 0f) - { __instance.Shoot(); - } else { __instance.gunReady = false; __instance.Invoke("Shoot", __instance.wid.delay); } } + if (MonoSingleton.Instance.InputSource.Fire2.IsPressed && __instance.variation == 1 && __instance.gunReady && __instance.gc.activated && !GameStateManager.Instance.PlayerInputLocked) { __instance.gunReady = false; @@ -339,25 +303,34 @@ [HarmonyPrefix] [HarmonyPatch(typeof(Shotgun), nameof(Shotgun.Update))] static b __instance.Invoke("Pump", __instance.wid.delay); } } - if (MonoSingleton.Instance.InputSource.Fire2.IsPressed && __instance.variation == 0 && __instance.gunReady && __instance.gc.activated && !GameStateManager.Instance.PlayerInputLocked) + + if (MonoSingleton.Instance.InputSource.Fire2.IsPressed && __instance.variation != 1 && __instance.gunReady && __instance.gc.activated && !GameStateManager.Instance.PlayerInputLocked && (__instance.variation != 2 || MonoSingleton.Instance.shoSawCharge >= 1f)) { __instance.charging = true; if (__instance.grenadeForce < 60f) { __instance.grenadeForce = Mathf.MoveTowards(__instance.grenadeForce, 60f, Time.deltaTime * 60f); } + __instance.grenadeVector = new Vector3(Vars.DominantHand.transform.forward.x, Vars.DominantHand.transform.forward.y, Vars.DominantHand.transform.forward.z); - if (__instance.targeter.CurrentTarget && __instance.targeter.IsAutoAimed) + if ((bool)__instance.targeter.CurrentTarget && __instance.targeter.IsAutoAimed) { __instance.grenadeVector = Vector3.Normalize(__instance.targeter.CurrentTarget.bounds.center - Vars.DominantHand.transform.position); } + __instance.grenadeVector += new Vector3(0f, __instance.grenadeForce * 0.002f, 0f); - __instance.transform.localPosition = new Vector3(__instance.wpos.currentDefault.x + Random.Range(__instance.grenadeForce / 3000f * -1f, __instance.grenadeForce / 3000f), __instance.wpos.currentDefault.y + Random.Range(__instance.grenadeForce / 3000f * -1f, __instance.grenadeForce / 3000f), __instance.wpos.currentDefault.z + Random.Range(__instance.grenadeForce / 3000f * -1f, __instance.grenadeForce / 3000f)); + float num = 3000f; + if (__instance.variation == 2) + { + num = 12000f; + } + + __instance.transform.localPosition = new Vector3(__instance.wpos.currentDefault.x + Random.Range(__instance.grenadeForce / num * -1f, __instance.grenadeForce / num), __instance.wpos.currentDefault.y + Random.Range(__instance.grenadeForce / num * -1f, __instance.grenadeForce / num), __instance.wpos.currentDefault.z + Random.Range(__instance.grenadeForce / num * -1f, __instance.grenadeForce / num)); if (__instance.tempChargeSound == null) { - GameObject gameObject = Object.Instantiate(__instance.chargeSoundBubble); + GameObject gameObject = Object.Instantiate(__instance.chargeSoundBubble); __instance.tempChargeSound = gameObject.GetComponent(); - if (__instance.wid && __instance.wid.delay > 0f) + if ((bool)__instance.wid && __instance.wid.delay > 0f) { __instance.tempChargeSound.volume -= __instance.wid.delay * 2f; if (__instance.tempChargeSound.volume < 0f) @@ -366,28 +339,97 @@ [HarmonyPrefix] [HarmonyPatch(typeof(Shotgun), nameof(Shotgun.Update))] static b } } } + MonoSingleton.Instance.SetVibrationTracked(RumbleProperties.ShotgunCharge, __instance.tempChargeSound.gameObject).intensityMultiplier = __instance.grenadeForce / 60f; - __instance.tempChargeSound.pitch = __instance.grenadeForce / 60f; + if (__instance.variation == 0) + { + __instance.tempChargeSound.pitch = __instance.grenadeForce / 60f; + } + else + { + __instance.tempChargeSound.pitch = (__instance.grenadeForce / 2f + 30f) / 60f; + } } - if ((MonoSingleton.Instance.InputSource.Fire2.WasCanceledThisFrame || (!MonoSingleton.Instance.PerformingCheatMenuCombo() && !GameStateManager.Instance.PlayerInputLocked && MonoSingleton.Instance.InputSource.Fire1.WasPerformedThisFrame)) && __instance.variation == 0 && __instance.gunReady && __instance.gc.activated && __instance.charging) + + if ((MonoSingleton.Instance.InputSource.Fire2.WasCanceledThisFrame + || (!MonoSingleton.Instance.PerformingCheatMenuCombo() + && !GameStateManager.Instance.PlayerInputLocked + && MonoSingleton.Instance.InputSource.Fire1.WasPerformedThisFrame)) + && __instance.variation != 1 && __instance.gunReady && __instance.gc.activated && __instance.charging) { __instance.charging = false; + if (__instance.variation == 2) + { + MonoSingleton.Instance.shoSawCharge = 0f; + } + if (!__instance.wid || __instance.wid.delay == 0f) { - __instance.ShootSinks(); + if (__instance.variation == 0) + { + __instance.ShootSinks(); + } + else + { + __instance.ShootSaw(); + } } else { __instance.gunReady = false; - __instance.Invoke("ShootSinks", __instance.wid.delay); + __instance.Invoke((__instance.variation == 0) ? "ShootSinks" : "ShootSaw", __instance.wid.delay); } + Object.Destroy(__instance.tempChargeSound.gameObject); } + + if (__instance.variation == 2) + { + if (__instance.charging && __instance.chainsawBladeScroll.scrollSpeedX == 0f) + { + __instance.chainsawBladeRenderer.material = __instance.chainsawBladeMotionMaterial; + } + else if (!__instance.charging && __instance.chainsawBladeScroll.scrollSpeedX > 0f) + { + __instance.chainsawBladeRenderer.material = __instance.chainsawBladeMaterial; + } + + __instance.chainsawBladeScroll.scrollSpeedX = __instance.grenadeForce / 6f; + __instance.anim.SetBool("Sawing", __instance.charging); + __instance.sawZone.enabled = __instance.charging; + if (__instance.charging && Physics.Raycast(Vars.DominantHand.transform.position, Vars.DominantHand.transform.forward, out var hitInfo, 3f, LayerMaskDefaults.Get(LMD.Environment), QueryTriggerInteraction.Ignore)) + { + ((Component)(object)__instance.environmentalSawSpark).transform.position = hitInfo.point; + if (!__instance.environmentalSawSpark.isEmitting) + { + __instance.environmentalSawSpark.Play(); + } + + if (!__instance.environmentalSawSound.isPlaying) + { + __instance.environmentalSawSound.Play(); + } + } + else + { + if (__instance.environmentalSawSpark.isEmitting) + { + __instance.environmentalSawSpark.Stop(); + } + + if (__instance.environmentalSawSound.isPlaying) + { + __instance.environmentalSawSound.Stop(); + } + } + } + if (__instance.releasingHeat) { - __instance.tempColor.a = __instance.tempColor.a - Time.deltaTime * 2.5f; + __instance.tempColor.a -= Time.deltaTime * 2.5f; __instance.heatSinkSMR.sharedMaterials[3].SetColor("_TintColor", __instance.tempColor); } + __instance.UpdateMeter(); return false; @@ -410,7 +452,6 @@ [HarmonyPrefix] [HarmonyPatch(typeof(Shotgun), nameof(Shotgun.ShootSinks))] stat __instance.gunAud.panStereo = 0f; __instance.gunAud.pitch = Random.Range(0.75f, 0.85f); __instance.gunAud.Play(); - __instance.cc.CameraShake(1f); __instance.meterOverride = true; __instance.chargeSlider.value = 0f; __instance.sliderFill.color = Color.black; @@ -425,161 +466,775 @@ [HarmonyPrefix] [HarmonyPatch(typeof(Shotgun), nameof(Shotgun.ShootSinks))] stat return false; } + [HarmonyPrefix] [HarmonyPatch(typeof(Shotgun), nameof(Shotgun.ShootSaw))] static bool ShotgunBC(Shotgun __instance) + { + __instance.gunReady = true; + Transform[] array = __instance.shootPoints; + for (int i = 0; i < array.Length; i++) + { + _ = array[i]; + Vector3 position = Vars.DominantHand.transform.position + Vars.DominantHand.transform.forward * 0.5f; + if (Physics.Raycast(Vars.DominantHand.transform.position, Vars.DominantHand.transform.forward, out var hitInfo, 5f, LayerMaskDefaults.Get(LMD.EnvironmentAndBigEnemies))) + position = hitInfo.point - Vars.DominantHand.transform.forward * 5f; - // Nailgun - // Normal fire / saw - [HarmonyPrefix] [HarmonyPatch(typeof(Nailgun), nameof(Nailgun.Shoot))] static bool NailgunA(Nailgun __instance) + Chainsaw chainsaw = Object.Instantiate(__instance.chainsaw, position, Random.rotation); + chainsaw.weaponType = "shotgun" + __instance.variation; + chainsaw.CheckMultipleRicochets(onStart: true); + chainsaw.sourceWeapon = __instance.gc.currentWeapon; + chainsaw.attachedTransform = MonoSingleton.Instance.GetTarget(); + chainsaw.lineStartTransform = __instance.chainsawAttachPoint; + chainsaw.GetComponent().AddForce(Vars.DominantHand.transform.forward * (__instance.grenadeForce + 10f) * 1.5f, ForceMode.VelocityChange); + __instance.currentChainsaws.Add(chainsaw); + } + + __instance.chainsawBladeRenderer.material = __instance.chainsawBladeMaterial; + __instance.chainsawBladeScroll.scrollSpeedX = 0f; + __instance.chainsawAttachPoint.gameObject.SetActive(value: false); + Object.Instantiate(__instance.grenadeSoundBubble).GetComponent().volume = 0.45f * Mathf.Sqrt(Mathf.Pow(1f, 2f) - Mathf.Pow(__instance.grenadeForce, 2f) / Mathf.Pow(60f, 2f)); + __instance.anim.Play("FireNoReload"); + __instance.gunAud.clip = __instance.shootSound; + __instance.gunAud.volume = 0.45f * Mathf.Max(0.5f, __instance.grenadeForce / 60f); + __instance.gunAud.panStereo = 0f; + __instance.gunAud.pitch = Random.Range(0.75f, 0.85f); + __instance.gunAud.Play(); + __instance.releasingHeat = false; + __instance.grenadeForce = 0f; + return false; + } + + [HarmonyPrefix] [HarmonyPatch(typeof(ShotgunHammer), nameof(ShotgunHammer.Impact))] static bool HammerA(ShotgunHammer __instance) { - __instance.UpdateAnimationWeight(); - __instance.fireCooldown = __instance.currentFireRate; - __instance.shotSuccesfully = true; - if (__instance.variation == 1 && (!__instance.wid || __instance.wid.delay == 0f)) + bool hasHitProjectile = false; + __instance.hitEnemy = null; + __instance.hitGrenade = null; + __instance.target = null; + __instance.hitPosition = Vector3.zero; + __instance.hammerCooldown = 0.5f; + Vector3 position = __instance.transform.position; + __instance.direction = __instance.transform.forward; + if (MonoSingleton.Instance.grenadeList.Count > 0 || MonoSingleton.Instance.shoSawAmount > 0 || MonoSingleton.Instance.landmineList.Count > 0) { - if (__instance.altVersion) - { - __instance.wc.naiSaws -= 1f; - } - else + Collider[] cols = Physics.OverlapSphere(position, 0.01f); + if (cols.Length != 0) { - __instance.wc.naiAmmo -= 1f; + for (int j = 0; j < cols.Length; j++) + { + Transform transform = cols[j].transform; + if (transform.TryGetComponent(out var component)) + { + transform = component.target; + } + + if (MonoSingleton.Instance.grenadeList.Count > 0 && transform.gameObject.layer == 10) + { + Grenade componentInParent = transform.GetComponentInParent(); + if ((bool)componentInParent) + { + hasHitProjectile = true; + __instance.hitGrenade = componentInParent; + cols[j].enabled = false; + Object.Instantiate(__instance.hitSound, __instance.transform.position, Quaternion.identity); + MonoSingleton.Instance.TrueStop(0.25f); + __instance.HitNade(); + } + } + else if (MonoSingleton.Instance.shoSawAmount > 0 || MonoSingleton.Instance.landmineList.Count > 0) + { + if (MonoSingleton.Instance.shoSawAmount > 0 && transform.TryGetComponent(out var component2)) + { + hasHitProjectile = true; + Object.Instantiate(__instance.hitSound, __instance.transform.position, Quaternion.identity); + component2.GetPunched(); + component2.transform.position = Vars.DominantHand.transform.position + Vars.DominantHand.transform.forward; + component2.rb.velocity = (Punch.GetParryLookTarget() - component2.transform.position).normalized * 105f; + } + else if (MonoSingleton.Instance.landmineList.Count > 0 && transform.TryGetComponent(out Landmine component3)) + { + hasHitProjectile = true; + component3.transform.LookAt(Punch.GetParryLookTarget()); + component3.Parry(); + Object.Instantiate(__instance.hitSound, __instance.transform.position, Quaternion.identity); + __instance.anim.Play("Fire", -1, 0f); + MonoSingleton.Instance.TrueStop(0.25f); + } + } + } } } - __instance.anim.SetTrigger("Shoot"); - __instance.barrelNum++; - if (__instance.barrelNum >= __instance.shootPoints.Length) - { - __instance.barrelNum = 0; - } - GameObject gameObject; - if (__instance.burnOut) - { - gameObject = Object.Instantiate(__instance.muzzleFlash2, __instance.shootPoints[__instance.barrelNum].transform); - } - else - { - gameObject = Object.Instantiate(__instance.muzzleFlash, __instance.shootPoints[__instance.barrelNum].transform); - } - if (!__instance.altVersion) + + if (MonoSingleton.Instance.shoSawAmount > 0 || MonoSingleton.Instance.landmineList.Count > 0) { - AudioSource component = gameObject.GetComponent(); - if (__instance.burnOut) + RaycastHit[] rhits = Physics.RaycastAll(position, __instance.direction, 8f, 16384, QueryTriggerInteraction.Collide); + for (int j = 0; j < rhits.Length; j++) { - component.volume = 0.65f - __instance.wid.delay * 2f; - if (component.volume < 0f) + Transform transform2 = rhits[j].transform; + if (transform2.TryGetComponent(out var component4)) { - component.volume = 0f; + transform2 = component4.target; + } + + Landmine component6; + if (transform2.TryGetComponent(out var component5)) + { + hasHitProjectile = true; + Object.Instantiate(__instance.hitSound, __instance.transform.position, Quaternion.identity); + component5.GetPunched(); + component5.transform.position = __instance.transform.position + __instance.transform.forward; + component5.rb.velocity = (Punch.GetParryLookTarget() - component5.transform.position).normalized * 105f; + } + else if (transform2.TryGetComponent(out component6)) + { + hasHitProjectile = true; + component6.transform.LookAt(Punch.GetParryLookTarget()); + component6.Parry(); + Object.Instantiate(__instance.hitSound, __instance.transform.position, Quaternion.identity); + __instance.anim.Play("Fire", -1, 0f); + MonoSingleton.Instance.TrueStop(0.25f); + } - component.pitch = 2f; - __instance.currentSpread = __instance.spread * 2f; } - else + } + + if (!hasHitProjectile && Physics.Raycast(position, __instance.direction, out var rhit, 8f, LayerMaskDefaults.Get(LMD.EnemiesAndEnvironment), QueryTriggerInteraction.Collide)) + { + if (rhit.transform.gameObject.layer == 11 || rhit.transform.gameObject.layer == 10) { - if (__instance.heatSinks < 1f) + EnemyIdentifierIdentifier component10; + if (rhit.transform.gameObject.TryGetComponent(out var component7)) { - component.pitch = 0.25f; - component.volume = 0.25f - __instance.wid.delay * 2f; - if (component.volume < 0f) + EnemyIdentifier component9; + if (component7.target.TryGetComponent(out var component8) && (bool)component8.eid && !component8.eid.dead) + { + __instance.hitEnemy = component8.eid; + } + else if (component7.target.TryGetComponent(out component9) && !component9.dead) { - component.volume = 0f; + __instance.hitEnemy = component9; } } - else + else if (rhit.transform.TryGetComponent(out component10) && (bool)component10.eid && !component10.eid.dead) { - component.volume = 0.65f - __instance.wid.delay * 2f; - if (component.volume < 0f) + __instance.hitEnemy = component10.eid; + } + else if (MonoSingleton.Instance.grenadeList.Count > 0 && rhit.transform.gameObject.layer == 10) + { + Grenade componentInParent2 = rhit.transform.GetComponentInParent(); + if ((bool)componentInParent2) { - component.volume = 0f; + hasHitProjectile = true; + __instance.hitGrenade = componentInParent2; + rhit.collider.enabled = false; + Object.Instantiate(__instance.hitSound, __instance.transform.position, Quaternion.identity); + __instance.anim.Play("Fire", -1, 0f); + MonoSingleton.Instance.TrueStop(0.25f); + __instance.HitNade(); } } - __instance.currentSpread = __instance.spread; } + + __instance.target = rhit.transform; + __instance.hitPosition = rhit.point; } - else if (__instance.burnOut) - { - __instance.currentSpread = 45f; - } - else if (__instance.altVersion && __instance.variation == 0) + + if (!hasHitProjectile && __instance.hitEnemy == null) { - if (__instance.heatSinks < 1f) + Vector3 vector = position + __instance.direction * 2.5f; + Collider[] array = Physics.OverlapSphere(vector, 2.5f); + if (array.Length != 0) { - __instance.currentSpread = 45f; + float num = 2.5f; + for (int k = 0; k < array.Length; k++) + { + if (array[k].TryGetComponent(out var component11) && component11.target.TryGetComponent(out var component12)) + { + array[k] = component12; + } + + if (array[k].gameObject.layer != 10 && array[k].gameObject.layer != 11) + { + continue; + } + + Vector3 vector2 = array[k].ClosestPoint(vector); + if (Physics.Raycast(position, vector2 - position, out rhit, Vector3.Distance(vector2, position), LayerMaskDefaults.Get(LMD.Environment))) + { + continue; + } + + float num2 = Vector3.Distance(vector, vector2); + if (num2 < num) + { + Transform transform3 = ((array[k].attachedRigidbody != null) ? array[k].attachedRigidbody.transform : array[k].transform); + EnemyIdentifier component13 = null; + if (transform3.TryGetComponent(out var component14)) + { + component13 = component14.eid; + } + else + { + transform3.TryGetComponent(out component13); + } + + if ((bool)component13 && (!component13.dead || __instance.hitEnemy == null)) + { + __instance.hitEnemy = component14.eid; + num = num2; + __instance.target = transform3; + __instance.hitPosition = vector2; + } + } + } } - else + + RaycastHit[] array2 = Physics.SphereCastAll(position + __instance.direction * 2.5f, 2.5f, __instance.direction, 3f, LayerMaskDefaults.Get(LMD.Enemies)); + if (array2.Length != 0) { - __instance.currentSpread = Mathf.Lerp(0f, 45f, Mathf.Max(0f, __instance.heatUp - 0.25f)); + float num3 = -1f; + if (__instance.hitEnemy != null) + { + num3 = Vector3.Dot(__instance.direction, __instance.hitPosition - position); + } + + for (int l = 0; l < array2.Length; l++) + { + if (Physics.Raycast(position, array2[l].point - position, out rhit, Vector3.Distance(array2[l].point, position), LayerMaskDefaults.Get(LMD.Environment))) + { + continue; + } + + float num4 = Vector3.Dot(__instance.direction, array2[l].point - position); + if (num4 > num3) + { + Transform transform4 = array2[l].transform; + Vector3 point = array2[l].point; + if (transform4.TryGetComponent(out var component15)) + { + transform4 = component15.target.transform; + } + + EnemyIdentifier component16 = null; + if (transform4.TryGetComponent(out var component17)) + { + component16 = component17.eid; + } + else + { + transform4.TryGetComponent(out component16); + } + + if ((bool)component16 && (!component16.dead || __instance.hitEnemy == null)) + { + __instance.hitEnemy = component16; + num3 = num4; + __instance.target = transform4; + __instance.hitPosition = point; + } + } + } } } - else + + __instance.forceWeakHit = true; + if (__instance.target != null) { - __instance.currentSpread = 0f; + if (__instance.hitEnemy != null) + { + float num5 = 0.05f; + __instance.damage = 3f; + if (__instance.tier == 2) + { + num5 = 0.5f; + __instance.damage = 12f; + } + else if (__instance.tier == 1) + { + num5 = 0.25f; + __instance.damage = 6f; + } + + if (__instance.hitEnemy.dead) + { + num5 = 0f; + } + + if (num5 > 0f) + { + __instance.forceWeakHit = false; + __instance.launchPlayer = true; + Object.Instantiate(__instance.hitSound, __instance.transform.position, Quaternion.identity); + MonoSingleton.Instance.TrueStop(num5); + } + else + { + __instance.launchPlayer = false; + } + + __instance.DeliverDamage(); + } + else if (__instance.target.TryGetComponent(out Breakable component18) && !component18.precisionOnly && !component18.unbreakable) + { + component18.Break(); + } + else if (__instance.target.TryGetComponent(out Glass component19) && !component19.broken) + { + component19.Shatter(); + } } - GameObject gameObject2; - if (__instance.burnOut) + + if (!__instance.hitGrenade && __instance.hitEnemy == null && __instance.target != null && (__instance.target.gameObject.layer == 8 || __instance.target.gameObject.layer == 24)) { - gameObject2 = Object.Instantiate(__instance.heatedNail, Vars.DominantHand.transform.position + Vars.DominantHand.transform.forward, __instance.transform.rotation); + MonoSingleton.Instance.Launch(-__instance.direction * ((float)(100 * __instance.tier + 300) / ((float)(MonoSingleton.Instance.hammerJumps + 3) / 3f))); + MonoSingleton.Instance.hammerJumps++; } + + __instance.ImpactEffects(); + __instance.hitEnemy = null; + __instance.hitGrenade = null; + + return false; + } + [HarmonyPrefix] [HarmonyPatch(typeof(ShotgunHammer), nameof(ShotgunHammer.HitNade))] static bool HammerHitNade(ShotgunHammer __instance) + { + if (Physics.Raycast(__instance.transform.position, __instance.direction, out var hitInfo, float.PositiveInfinity, LayerMaskDefaults.Get(LMD.EnemiesAndEnvironment), QueryTriggerInteraction.Ignore)) + __instance.hitGrenade.GrenadeBeam(hitInfo.point); else + __instance.hitGrenade.GrenadeBeam(__instance.transform.position + __instance.direction * 1000f); + return false; + } + [HarmonyPrefix] [HarmonyPatch(typeof(ShotgunHammer), nameof(ShotgunHammer.ImpactEffects))] static bool HammerIE(ShotgunHammer __instance) + { + Vector3 position = ((__instance.hitPosition != Vector3.zero) ? (__instance.hitPosition - (__instance.hitPosition - __instance.transform.position).normalized) : (__instance.transform.position + __instance.direction * 2.5f)); + if (__instance.primaryCharge > 0) { - gameObject2 = Object.Instantiate(__instance.nail, Vars.DominantHand.transform.position + Vars.DominantHand.transform.forward, __instance.transform.rotation); - } - if (__instance.altVersion && __instance.variation == 0 && __instance.heatSinks >= 1f) - { - __instance.heatUp = Mathf.MoveTowards(__instance.heatUp, 1f, 0.125f); - } - gameObject2.transform.forward = Vars.DominantHand.transform.forward; - if (Physics.Raycast(Vars.DominantHand.transform.position, Vars.DominantHand.transform.forward, 1f, LayerMaskDefaults.Get(LMD.Environment))) - { - gameObject2.transform.position = Vars.DominantHand.transform.position; - } - if (__instance.targeter.CurrentTarget && __instance.targeter.IsAutoAimed) - { - gameObject2.transform.position = Vars.DominantHand.transform.position + (__instance.targeter.CurrentTarget.bounds.center - Vars.DominantHand.transform.position).normalized; - gameObject2.transform.LookAt(__instance.targeter.CurrentTarget.bounds.center); - } - gameObject2.transform.Rotate(Random.Range(-__instance.currentSpread / 3f, __instance.currentSpread / 3f), Random.Range(-__instance.currentSpread / 3f, __instance.currentSpread / 3f), Random.Range(-__instance.currentSpread / 3f, __instance.currentSpread / 3f)); - Rigidbody rigidbody; - if (gameObject2.TryGetComponent(out rigidbody)) - { - rigidbody.velocity = gameObject2.transform.forward * 200f; - } - Nail nail; - if (gameObject2.TryGetComponent(out nail)) - { - nail.sourceWeapon = __instance.gc.currentWeapon; - nail.weaponType = __instance.projectileVariationTypes[__instance.variation]; - if (__instance.altVersion && __instance.variation == 0) + GameObject gameObject = Object.Instantiate((__instance.primaryCharge == 3) ? __instance.overPumpExplosion : __instance.pumpExplosion, position, Quaternion.LookRotation(__instance.direction)); + Explosion[] componentsInChildren = gameObject.GetComponentsInChildren(); + foreach (Explosion explosion in componentsInChildren) { - if (__instance.heatSinks >= 1f) - { - nail.hitAmount = Mathf.Lerp(3f, 1f, __instance.heatUp); - } - else + explosion.sourceWeapon = __instance.gameObject; + explosion.hitterWeapon = "hammer"; + if (__instance.primaryCharge == 2) { - nail.hitAmount = 1f; + explosion.maxSize *= 2f; } } - if (nail.sawblade) + + if (__instance.primaryCharge == 2 && gameObject.TryGetComponent(out var component)) { - nail.ForceCheckSawbladeRicochet(); + component.volume = 1f; + component.pitch -= 0.4f; } + + __instance.primaryCharge = 0; } - if (!__instance.burnOut) + + if (__instance.forceWeakHit || __instance.tier == 0) { - __instance.cc.CameraShake(0.1f); + __instance.anim.Play("Fire", -1, 0f); } - else + else if (__instance.tier == 1) { - __instance.cc.CameraShake(0.35f); + __instance.anim.Play("FireStrong", -1, 0f); } - if (__instance.altVersion) + else { - MonoSingleton.Instance.SetVibration(RumbleProperties.Sawblade); + __instance.anim.Play("FireStrongest", -1, 0f); } + Object.Instantiate(__instance.hitImpactParticle[(!__instance.forceWeakHit) ? __instance.tier : 0], position, __instance.transform.rotation); return false; } - // Supersaw - [HarmonyPrefix] [HarmonyPatch(typeof(Nailgun), nameof(Nailgun.SuperSaw))] static bool NailgunB(Nailgun __instance) + [HarmonyPrefix] [HarmonyPatch(typeof(ShotgunHammer), nameof(ShotgunHammer.ThrowNade))] static bool HammerTN(ShotgunHammer __instance) + { + __instance.grenadeCooldown = 0f; + __instance.pulledOut = 0.3f; + __instance.gunReady = false; + __instance.aboutToSecondary = false; + Vector3 up = __instance.transform.up; + if (Vector3.Dot(__instance.transform.forward, Vector3.up) > Vector3.Dot(__instance.transform.forward, up)) + { + up = Vector3.up; + } + + GameObject obj = Object.Instantiate(__instance.grenade, __instance.transform.position + __instance.transform.forward * 2f - up * 0.5f, Random.rotation); + if (obj.TryGetComponent(out var component)) + { + component.velocity = MonoSingleton.Instance.GetPlayerVelocity() + __instance.transform.forward * 3f + up * (MonoSingleton.Instance.inWater ? 4 : 10); + } + + if (obj.TryGetComponent(out var component2)) + { + component2.sourceWeapon = __instance.gameObject; + } + + __instance.anim.Play("NadeSpawn", -1, 0f); + Object.Instantiate(__instance.nadeSpawnSound); + return false; + } + [HarmonyPrefix] [HarmonyPatch(typeof(ShotgunHammer), nameof(ShotgunHammer.ShootSaw))] static bool HammerSS(ShotgunHammer __instance) + { + __instance.gunReady = true; + __instance.transform.localPosition = __instance.wpos.currentDefault; + Vector3 position = __instance.transform.position + __instance.transform.forward * 0.5f; + if (Physics.Raycast(Vars.DominantHand.transform.position, __instance.transform.forward, out var hitInfo, 5f, LayerMaskDefaults.Get(LMD.EnvironmentAndBigEnemies))) + { + position = hitInfo.point - __instance.transform.forward * 5f; + } + + Chainsaw chainsaw = Object.Instantiate(__instance.chainsaw, position, Random.rotation); + chainsaw.weaponType = "hammer" + __instance.variation; + chainsaw.CheckMultipleRicochets(onStart: true); + chainsaw.sourceWeapon = __instance.gc.currentWeapon; + chainsaw.attachedTransform = MonoSingleton.Instance.GetTarget(); + chainsaw.lineStartTransform = __instance.chainsawAttachPoint; + chainsaw.GetComponent().AddForce(__instance.transform.forward * (__instance.chargeForce + 10f) * 1.5f, ForceMode.VelocityChange); + __instance.currentChainsaws.Add(chainsaw); + __instance.chainsawBladeRenderer.material = __instance.chainsawBladeMaterial; + __instance.chainsawBladeScroll.scrollSpeedX = 0f; + __instance.chainsawAttachPoint.gameObject.SetActive(value: false); + Object.Instantiate(__instance.nadeSpawnSound); + __instance.anim.Play("SawingShot"); + __instance.chargeForce = 0f; + return false; + } + [HarmonyPrefix] [HarmonyPatch(typeof(ShotgunHammer), nameof(ShotgunHammer.Update))] static bool HammerUpdate(ShotgunHammer __instance) + { + __instance.overheated = MonoSingleton.Instance.shoaltcooldowns[__instance.variation] > 0f; + if (__instance.overheated && !__instance.overheatAud.isPlaying) + { + __instance.overheatAud.Play(); + __instance.overheatParticle.Play(); + __instance.anim.SetBool("Cooldown", value: true); + } + else if (!__instance.overheated && __instance.overheatAud.isPlaying) + { + __instance.overheatAud.Stop(); + __instance.overheatParticle.Stop(); + __instance.anim.SetBool("Cooldown", value: false); + } + + float num = Mathf.Min(MonoSingleton.Instance.GetPlayerVelocity().magnitude / 60f, 1f); + __instance.currentSpeed = (__instance.overheated ? 0f : Mathf.MoveTowards(__instance.currentSpeed, num, Time.deltaTime * 2f)); + if (MonoSingleton.Instance.beingPulled) + { + __instance.currentSpeed = Mathf.Min(__instance.currentSpeed, 0.5f); + } + + __instance.UpdateMeter(); + if ((float)__instance.pulledOut >= 0.5f) + { + __instance.gunReady = true; + } + + if (!MonoSingleton.Instance.PerformingCheatMenuCombo() && !__instance.chargingSwing && __instance.hammerCooldown <= 0f && !__instance.overheated && MonoSingleton.Instance.InputSource.Fire1.IsPressed && (!__instance.fireHeldOnPullOut || (float)__instance.pulledOut >= 0.25f) && __instance.gc.activated) + { + __instance.fireHeldOnPullOut = false; + __instance.chargingSwing = true; + } + else if (!MonoSingleton.Instance.PerformingCheatMenuCombo() && !MonoSingleton.Instance.InputSource.Fire1.IsPressed && __instance.swingCharge == 1f && __instance.gunReady && __instance.gc.activated && !GameStateManager.Instance.PlayerInputLocked) + { + __instance.chargingSwing = false; + __instance.swingCharge = 0f; + if (!__instance.wid || __instance.wid.delay == 0f) + { + __instance.Impact(); + } + else + { + __instance.gunReady = false; + __instance.Invoke("Impact", __instance.wid.delay); + } + } + + if (MonoSingleton.Instance.InputSource.Fire2.IsPressed && __instance.variation == 2 && __instance.gunReady && __instance.gc.activated && !GameStateManager.Instance.PlayerInputLocked && MonoSingleton.Instance.shoSawCharge >= 1f) + { + __instance.charging = true; + if (__instance.chargeForce < 60f) + { + __instance.chargeForce = Mathf.MoveTowards(__instance.chargeForce, 60f, Time.deltaTime * 60f); + } + + float num2 = 12000f; + __instance.transform.localPosition = new Vector3(__instance.wpos.currentDefault.x + Random.Range(__instance.chargeForce / num2 * -1f, __instance.chargeForce / num2), __instance.wpos.currentDefault.y + Random.Range(__instance.chargeForce / num2 * -1f, __instance.chargeForce / num2), __instance.wpos.currentDefault.z + Random.Range(__instance.chargeForce / num2 * -1f, __instance.chargeForce / num2)); + if (__instance.tempChargeSound == null) + { + GameObject gameObject = Object.Instantiate(__instance.chargeSoundBubble); + __instance.tempChargeSound = gameObject.GetComponent(); + if ((bool)__instance.wid && __instance.wid.delay > 0f) + { + __instance.tempChargeSound.volume -= __instance.wid.delay * 2f; + if (__instance.tempChargeSound.volume < 0f) + { + __instance.tempChargeSound.volume = 0f; + } + } + } + + MonoSingleton.Instance.SetVibrationTracked(RumbleProperties.ShotgunCharge, __instance.tempChargeSound.gameObject).intensityMultiplier = __instance.chargeForce / 60f; + __instance.tempChargeSound.pitch = (__instance.chargeForce / 2f + 30f) / 60f; + } + + if (!MonoSingleton.Instance.InputSource.Fire2.IsPressed && __instance.variation == 2 && __instance.gunReady && __instance.gc.activated && __instance.charging) + { + __instance.charging = false; + MonoSingleton.Instance.shoSawCharge = 0f; + if (!__instance.wid || __instance.wid.delay == 0f) + { + __instance.ShootSaw(); + } + else + { + __instance.gunReady = false; + __instance.Invoke("ShootSaw", __instance.wid.delay); + } + + if ((bool)__instance.tempChargeSound) + { + Object.Destroy(__instance.tempChargeSound.gameObject); + } + } + + if (__instance.variation == 2) + { + if (__instance.charging && __instance.chainsawBladeScroll.scrollSpeedX == 0f) + { + __instance.chainsawBladeRenderer.material = __instance.chainsawBladeMotionMaterial; + } + else if (!__instance.charging && __instance.chainsawBladeScroll.scrollSpeedX > 0f) + { + __instance.chainsawBladeRenderer.material = __instance.chainsawBladeMaterial; + } + + __instance.chainsawBladeScroll.scrollSpeedX = __instance.chargeForce / 6f; + __instance.anim.SetBool("Sawing", __instance.charging); + __instance.sawZone.enabled = __instance.charging; + if (__instance.charging && Physics.Raycast(__instance.transform.position, __instance.transform.forward, out var hitInfo, 3f, LayerMaskDefaults.Get(LMD.Environment), QueryTriggerInteraction.Ignore)) + { + __instance.environmentalSawSpark.transform.position = hitInfo.point; + if (!__instance.environmentalSawSpark.isEmitting) + { + __instance.environmentalSawSpark.Play(); + } + + if (!__instance.environmentalSawSound.isPlaying) + { + __instance.environmentalSawSound.Play(); + } + } + else + { + if (__instance.environmentalSawSpark.isEmitting) + { + __instance.environmentalSawSpark.Stop(); + } + + if (__instance.environmentalSawSound.isPlaying) + { + __instance.environmentalSawSound.Stop(); + } + } + } + + if (__instance.chargingSwing) + { + __instance.swingCharge = Mathf.MoveTowards(__instance.swingCharge, 1f, Time.deltaTime * 2f); + } + + __instance.modelTransform.localPosition = new Vector3(__instance.defaultModelPosition.x + Random.Range((0f - __instance.swingCharge) / 30f, __instance.swingCharge / 30f), __instance.defaultModelPosition.y + Random.Range((0f - __instance.swingCharge) / 30f, __instance.swingCharge / 30f), __instance.defaultModelPosition.z + Random.Range((0f - __instance.swingCharge) / 30f, __instance.swingCharge / 30f)); + if (MonoSingleton.Instance.InputSource.Fire2.IsPressed && __instance.variation != 2 && (__instance.variation == 1 || (float)__instance.grenadeCooldown >= 2f) && !__instance.aboutToSecondary && __instance.gunReady && __instance.gc.activated && !GameStateManager.Instance.PlayerInputLocked) + { + __instance.gunReady = false; + if (!__instance.wid || __instance.wid.delay == 0f) + { + if (__instance.variation == 0) + { + __instance.ThrowNade(); + } + else + { + __instance.Pump(); + } + } + else + { + __instance.aboutToSecondary = true; + __instance.Invoke((__instance.variation == 0) ? "ThrowNade" : "Pump", __instance.wid.delay); + } + } + + if (__instance.secondaryMeterFill >= 1f) + { + __instance.secondaryMeter.fillAmount = 1f; + } + else if (__instance.secondaryMeterFill <= 0f) + { + __instance.secondaryMeter.fillAmount = 0f; + } + else + { + __instance.secondaryMeter.fillAmount = Mathf.Lerp(0.275f, 0.625f, __instance.secondaryMeterFill); + } + + if (__instance.hammerCooldown > 0f) + { + __instance.hammerCooldown = Mathf.MoveTowards(__instance.hammerCooldown, 0f, Time.deltaTime); + } + + if (NoWeaponCooldown.NoCooldown) + { + __instance.grenadeCooldown = 2f; + } + + if ((float)__instance.grenadeCooldown < 2f) + { + __instance.nadeCharging = true; + } + else if (__instance.nadeCharging) + { + __instance.nadeCharging = false; + Object.Instantiate(__instance.nadeReadySound); + } + + return false; + } + + [HarmonyPostfix] [HarmonyPatch(typeof(ShotgunHammer), nameof(ShotgunHammer.LateUpdate))] static void Hammer_VRIK(ShotgunHammer __instance) + { + if (VRAvatar.VRigController.Instance != null) + { + __instance.transform.position = VRAvatar.VRigController.Instance.Rig.FeedbackerB.Forearm.position; + __instance.transform.LookAt(VRAvatar.VRigController.Instance.Rig.FeedbackerB.Hand.Root.position); + } + } + + [HarmonyPrefix] [HarmonyPatch(typeof(Nailgun), nameof(Nailgun.Shoot))] static bool NailgunA(Nailgun __instance) + { + __instance.UpdateAnimationWeight(); + __instance.fireCooldown = __instance.currentFireRate; + __instance.shotSuccesfully = true; + if (__instance.variation == 1 && (!__instance.wid || __instance.wid.delay == 0f)) + { + if (__instance.altVersion) __instance.wc.naiSaws -= 1f; + else __instance.wc.naiAmmo -= 1f; + } + + __instance.anim.SetTrigger("Shoot"); + __instance.barrelNum++; + if (__instance.barrelNum >= __instance.shootPoints.Length) + __instance.barrelNum = 0; + + GameObject gameObject = ((!__instance.burnOut) + ? Object.Instantiate(__instance.muzzleFlash, __instance.shootPoints[__instance.barrelNum].transform) + : Object.Instantiate(__instance.muzzleFlash2, __instance.shootPoints[__instance.barrelNum].transform)); + + if (!__instance.altVersion) + { + AudioSource component = gameObject.GetComponent(); + if (__instance.burnOut) + { + component.volume = 0.65f - __instance.wid.delay * 2f; + if (component.volume < 0f) component.volume = 0f; + component.pitch = 2f; + __instance.currentSpread = __instance.spread * 2f; + } + else + { + if (__instance.heatSinks < 1f) + { + component.pitch = 0.75f; + component.volume = 0.25f - __instance.wid.delay * 2f; + if (component.volume < 0f) component.volume = 0f; + } + else + { + component.volume = 0.65f - __instance.wid.delay * 2f; + if (component.volume < 0f) component.volume = 0f; + } + + __instance.currentSpread = __instance.spread; + } + } + else if (__instance.burnOut) + { + __instance.currentSpread = 45f; + } + else if (__instance.altVersion && __instance.variation == 0) + { + if (__instance.heatSinks < 1f) + { + __instance.currentSpread = 45f; + } + else + { + __instance.currentSpread = Mathf.Lerp(0f, 45f, Mathf.Max(0f, __instance.heatUp - 0.25f)); + } + } + else __instance.currentSpread = 0f; + + GameObject gameObject2 = ((!__instance.burnOut) + ? Object.Instantiate(__instance.nail, Vars.DominantHand.transform.position + Vars.DominantHand.transform.forward, __instance.transform.rotation) + : Object.Instantiate(__instance.heatedNail, Vars.DominantHand.transform.position + Vars.DominantHand.transform.forward, __instance.transform.rotation)); + if (__instance.altVersion && __instance.variation == 0 && __instance.heatSinks >= 1f) + __instance.heatUp = Mathf.MoveTowards(__instance.heatUp, 1f, 0.125f); + + gameObject2.transform.forward = Vars.DominantHand.transform.forward; + if (Physics.Raycast(Vars.DominantHand.transform.position, Vars.DominantHand.transform.forward, 1f, LayerMaskDefaults.Get(LMD.Environment))) + gameObject2.transform.position = Vars.DominantHand.transform.position; + + if ((bool)__instance.targeter.CurrentTarget && __instance.targeter.IsAutoAimed) + { + gameObject2.transform.position = Vars.DominantHand.transform.position + (__instance.targeter.CurrentTarget.bounds.center - Vars.DominantHand.transform.position).normalized; + gameObject2.transform.LookAt(__instance.targeter.CurrentTarget.bounds.center); + } + + gameObject2.transform.Rotate(Random.Range((0f - __instance.currentSpread) / 3f, __instance.currentSpread / 3f), Random.Range((0f - __instance.currentSpread) / 3f, __instance.currentSpread / 3f), Random.Range((0f - __instance.currentSpread) / 3f, __instance.currentSpread / 3f)); + if (gameObject2.TryGetComponent(out var component2)) + component2.velocity = gameObject2.transform.forward * 200f; + + if (gameObject2.TryGetComponent(out var component3)) + { + component3.sourceWeapon = __instance.gc.currentWeapon; + component3.weaponType = __instance.projectileVariationTypes[__instance.variation]; + if (__instance.altVersion && __instance.variation != 1) + { + if (__instance.heatSinks >= 1f && __instance.variation != 2) + component3.hitAmount = Mathf.Lerp(3f, 1f, __instance.heatUp); + else component3.hitAmount = 1f; + } + + if (component3.sawblade) + component3.ForceCheckSawbladeRicochet(); + } + + if (__instance.altVersion) + MonoSingleton.Instance.SetVibration(RumbleProperties.Sawblade); + + return false; + } + [HarmonyPrefix] [HarmonyPatch(typeof(Nailgun), nameof(Nailgun.ShootMagnet))] static bool NailgunBA(Nailgun __instance) + { + __instance.UpdateAnimationWeight(); + GameObject gameObject = Object.Instantiate(__instance.magnetNail, Vars.DominantHand.transform.position, __instance.transform.rotation); + gameObject.transform.forward = __instance.transform.forward; + if ((bool)__instance.targeter.CurrentTarget && __instance.targeter.IsAutoAimed) + { + gameObject.transform.LookAt(__instance.targeter.CurrentTarget.bounds.center); + } + + gameObject.GetComponent().AddForce(gameObject.transform.forward * 100f, ForceMode.VelocityChange); + if (__instance.canShoot) + { + __instance.anim.SetTrigger("Shoot"); + } + + Object.Instantiate(__instance.magnetShotSound); + Magnet componentInChildren = gameObject.GetComponentInChildren(); + if ((bool)componentInChildren) __instance.wc.magnets.Add(componentInChildren); + + __instance.wc.naiMagnetCharge -= 1f; + MonoSingleton.Instance.SetVibration(RumbleProperties.Magnet); + return false; + } + [HarmonyPrefix] [HarmonyPatch(typeof(Nailgun), nameof(Nailgun.SuperSaw))] static bool NailgunBB(Nailgun __instance) { __instance.fireCooldown = __instance.currentFireRate; __instance.shotSuccesfully = true; @@ -591,40 +1246,68 @@ [HarmonyPrefix] [HarmonyPatch(typeof(Nailgun), nameof(Nailgun.SuperSaw))] static { __instance.barrelNum = 0; } - Object.Instantiate(__instance.muzzleFlash2, __instance.shootPoints[__instance.barrelNum].transform); + + Object.Instantiate(__instance.muzzleFlash2, __instance.shootPoints[__instance.barrelNum].transform); __instance.currentSpread = 0f; - GameObject gameObject = Object.Instantiate(__instance.heatedNail, Vars.DominantHand.transform.position + Vars.DominantHand.transform.forward, __instance.transform.rotation); + GameObject gameObject = Object.Instantiate(__instance.heatedNail, Vars.DominantHand.transform.position + Vars.DominantHand.transform.forward, __instance.transform.rotation); gameObject.transform.forward = Vars.DominantHand.transform.forward; if (Physics.Raycast(Vars.DominantHand.transform.position, Vars.DominantHand.transform.forward, 1f, LayerMaskDefaults.Get(LMD.Environment))) { gameObject.transform.position = Vars.DominantHand.transform.position; } - if (__instance.targeter.CurrentTarget && __instance.targeter.IsAutoAimed) + + if ((bool)__instance.targeter.CurrentTarget && __instance.targeter.IsAutoAimed) { gameObject.transform.position = Vars.DominantHand.transform.position + (__instance.targeter.CurrentTarget.bounds.center - Vars.DominantHand.transform.position).normalized; gameObject.transform.LookAt(__instance.targeter.CurrentTarget.bounds.center); } - Rigidbody rigidbody; - if (gameObject.TryGetComponent(out rigidbody)) + + if (gameObject.TryGetComponent(out var component)) { - rigidbody.velocity = gameObject.transform.forward * 200f; + component.velocity = gameObject.transform.forward * 200f; } - Nail nail; - if (gameObject.TryGetComponent(out nail)) + + if (gameObject.TryGetComponent(out var component2)) { - nail.weaponType = __instance.projectileVariationTypes[__instance.variation]; - nail.multiHitAmount = Mathf.RoundToInt(__instance.heatUp * 3f); - nail.ForceCheckSawbladeRicochet(); - nail.sourceWeapon = __instance.gc.currentWeapon; + component2.weaponType = __instance.projectileVariationTypes[__instance.variation]; + component2.multiHitAmount = Mathf.RoundToInt(__instance.heatUp * 3f); + component2.ForceCheckSawbladeRicochet(); + component2.sourceWeapon = __instance.gc.currentWeapon; } + __instance.heatSinks -= 1f; __instance.heatUp = 0f; - __instance.cc.CameraShake(0.5f); + return false; + } + [HarmonyPrefix] [HarmonyPatch(typeof(Nailgun), nameof(Nailgun.ShootZapper))] static bool NailgunBC(Nailgun __instance) + { + __instance.UpdateAnimationWeight(); + if ((bool)__instance.currentZapper) + { + __instance.currentZapper.Break(); + } + __instance.currentZapper = Object.Instantiate(__instance.zapper, Vars.DominantHand.transform.position, __instance.transform.rotation); + __instance.currentZapper.transform.forward = __instance.transform.forward; + if ((bool)__instance.targeter.CurrentTarget && __instance.targeter.IsAutoAimed) + { + __instance.currentZapper.transform.LookAt(__instance.targeter.CurrentTarget.bounds.center); + } + + __instance.currentZapper.GetComponent().AddForce(__instance.currentZapper.transform.forward * 100f, ForceMode.VelocityChange); + if (__instance.canShoot) + { + __instance.anim.SetTrigger("Shoot"); + } + + Object.Instantiate(__instance.magnetShotSound); + __instance.currentZapper.lineStartTransform = __instance.zapperAttachTransform; + __instance.currentZapper.connectedRB = MonoSingleton.Instance.rb; + __instance.currentZapper.sourceWeapon = __instance.gameObject; + MonoSingleton.Instance.SetVibration(RumbleProperties.Magnet); return false; } - // Railgun (railing enemies in ultrakill :O) [HarmonyPrefix] [HarmonyPatch(typeof(Railcannon), nameof(Railcannon.Shoot))] static bool RailgunA(Railcannon __instance) { GameObject gameObject = Object.Instantiate(__instance.beam, Vars.DominantHand.transform.position, Vars.DominantHand.transform.rotation); @@ -647,22 +1330,11 @@ [HarmonyPrefix] [HarmonyPatch(typeof(Railcannon), nameof(Railcannon.Shoot))] sta } Object.Instantiate(__instance.fireSound); __instance.anim.SetTrigger("Shoot"); - __instance.cc.CameraShake(2f); MonoSingleton.Instance.SetVibration(RumbleProperties.GunFireStrong); return false; } - // Rocket launcher - // Normal fire - [HarmonyPostfix] [HarmonyPatch(typeof(RocketLauncher), nameof(RocketLauncher.Update))] static void RL_VRIK(RocketLauncher __instance) - { - if (VRAvatar.VRigController.Instance != null) - { - __instance.transform.position = VRAvatar.VRigController.Instance.Rig.FeedbackerB.Forearm.position; - __instance.transform.LookAt(VRAvatar.VRigController.Instance.Rig.FeedbackerB.Hand.Root); - } - } [HarmonyPrefix] [HarmonyPatch(typeof(RocketLauncher), nameof(RocketLauncher.Shoot))] static bool RocketLauncherA(RocketLauncher __instance) { if (__instance.aud) @@ -688,13 +1360,11 @@ [HarmonyPrefix] [HarmonyPatch(typeof(RocketLauncher), nameof(RocketLauncher.Shoo { component.sourceWeapon = MonoSingleton.Instance.currentWeapon; } - MonoSingleton.Instance.CameraShake(0.75f); MonoSingleton.Instance.SetVibrationTracked(RumbleProperties.GunFire, __instance.gameObject); return false; } - // Cannonball - [HarmonyPrefix] [HarmonyPatch(typeof(RocketLauncher), nameof(RocketLauncher.ShootCannonball))] static bool RocketLauncherB(RocketLauncher __instance) + [HarmonyPrefix] [HarmonyPatch(typeof(RocketLauncher), nameof(RocketLauncher.ShootCannonball))] static bool RocketLauncherBA(RocketLauncher __instance) { if (__instance.aud) { @@ -715,10 +1385,247 @@ [HarmonyPrefix] [HarmonyPatch(typeof(RocketLauncher), nameof(RocketLauncher.Shoo { cannonball.sourceWeapon = MonoSingleton.Instance.currentWeapon; } - MonoSingleton.Instance.CameraShake(0.75f); __instance.cbCharge = 0f; return false; } + [HarmonyPrefix] [HarmonyPatch(typeof(RocketLauncher), nameof(RocketLauncher.ShootNapalm))] static bool RocketLauncherBB(RocketLauncher __instance) + { + __instance.anim.SetTrigger("Spray"); + __instance.napalmProjectileCooldown = 0.02f; + MonoSingleton.Instance.rocketNapalmFuel -= 0.015f; + Rigidbody rigidbody = Object.Instantiate(__instance.napalmProjectile, Vars.DominantHand.transform.position + __instance.transform.forward, __instance.transform.rotation); + if ((bool)MonoSingleton.Instance.CurrentTarget && MonoSingleton.Instance.IsAutoAimed) + { + rigidbody.transform.LookAt(MonoSingleton.Instance.CurrentTarget.bounds.center); + } + + rigidbody.transform.Rotate(new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f), Random.Range(-1f, 1f))); + rigidbody.velocity = rigidbody.transform.forward * 150f; + + return false; + } + [HarmonyPostfix] [HarmonyPatch(typeof(RocketLauncher), nameof(RocketLauncher.Update))] static void RL_VRIK(RocketLauncher __instance) + { + if (VRAvatar.VRigController.Instance != null) + { + __instance.transform.position = VRAvatar.VRigController.Instance.Rig.FeedbackerB.Forearm.position; + __instance.transform.LookAt(Vars.DominantHand.transform/*VRAvatar.VRigController.Instance.Rig.FeedbackerB.Hand.Root*/); + } + } + + [HarmonyPrefix] [HarmonyPatch(typeof(Chainsaw), nameof(Chainsaw.Update))] static bool ChainsawA(Chainsaw __instance) + { + __instance.lr.SetPosition(0, Vars.DominantHand.transform.position); + __instance.lr.SetPosition(1, __instance.transform.position); + if ((bool)__instance.rb) + { + if (__instance.inPlayer) + { + __instance.transform.forward = Vars.DominantHand.transform.forward * -1f; + } + else + { + __instance.transform.LookAt(__instance.transform.position + (__instance.transform.position - __instance.attachedTransform.position)); + } + } + + if (__instance.sameEnemyHitCooldown > 0f && !__instance.stopped) + { + __instance.sameEnemyHitCooldown = Mathf.MoveTowards(__instance.sameEnemyHitCooldown, 0f, Time.deltaTime); + if (__instance.sameEnemyHitCooldown <= 0f) + { + __instance.currentHitEnemy = null; + } + } + + if (__instance.inPlayer) + { + __instance.transform.position = __instance.attachedTransform.position; + __instance.playerHitTimer = Mathf.MoveTowards(__instance.playerHitTimer, 0.25f, Time.deltaTime); + __instance.stoppedAud.pitch = 0.5f; + __instance.stoppedAud.volume = 1f; + if (__instance.playerHitTimer >= 0.25f && !__instance.beingPunched) + { + Object.Destroy(__instance.gameObject); + } + } + else + { + if (__instance.hitAmount <= 1) + { + return false; + } + + if (__instance.multiHitCooldown > 0f) + { + __instance.multiHitCooldown = Mathf.MoveTowards(__instance.multiHitCooldown, 0f, Time.deltaTime); + } + else if (__instance.stopped) + { + if (!__instance.currentHitEnemy.dead && __instance.currentHitAmount > 0) + { + __instance.currentHitAmount--; + __instance.DamageEnemy(__instance.hitTarget, __instance.currentHitEnemy); + } + + if (__instance.currentHitEnemy.dead || __instance.currentHitAmount <= 0) + { + __instance.stopped = false; + __instance.rb.velocity = __instance.originalVelocity.normalized * Mathf.Max(__instance.originalVelocity.magnitude, 35f); + return false; + } + + __instance.multiHitCooldown = 0.05f; + } + + if ((bool)__instance.stoppedAud) + { + if (__instance.stopped) + { + __instance.stoppedAud.pitch = 1.1f; + __instance.stoppedAud.volume = 1f; + } + else + { + __instance.stoppedAud.pitch = 0.85f; + __instance.stoppedAud.volume = 0.66f; + } + } + } + + return false; + } + + + [HarmonyPrefix] [HarmonyPatch(typeof(Washer), nameof(Washer.Update))] static bool WasherA(Washer __instance) + { + Transform transform = Vars.DominantHand.transform; + if (Physics.Raycast(transform.position, transform.forward, out var hitInfo, 50f, LayerMaskDefaults.Get(LMD.Environment))) + { + if (hitInfo.distance < 2.25f) + { + __instance.transform.position = transform.position; + __instance.transform.rotation = transform.rotation; + __instance.correctCameraView.canModifyTarget = false; + } + else + { + __instance.correctCameraView.canModifyTarget = true; + } + } + + if (MonoSingleton.Instance.activated && !GameStateManager.Instance.PlayerInputLocked) + { + if (__instance.inputManager.InputSource.Fire1.IsPressed && !__instance.isSpraying) + { + __instance.StartWashing(); + } + else if (!__instance.inputManager.InputSource.Fire1.IsPressed && __instance.isSpraying) + { + __instance.StopWashing(); + } + + if (__instance.inputManager.InputSource.Fire2.WasPerformedThisFrame) + { + __instance.SwitchNozzle(); + } + } + + float f = (float)((double)Time.time % 6.283185); + __instance.aud.pitch = ((__instance.nozzleMode == 2) ? 2.1f : 1.1f) + Mathf.Sin(f) * 0.025f; + return false; + } + [HarmonyPrefix] [HarmonyPatch(typeof(Vacuum), nameof(Vacuum.SuckObjects))] static bool VacuumSO(Vacuum __instance) + { + if ((!__instance._isSucking && !__instance._isBlowing) || __instance._stuckObject.rigidbody != null) + { + return false; + } + + __instance.UpdateColliders(); + int i = __instance._colliders.Offset; + for (int num = i + __instance._colliders.Count; i < num; i++) + { + Collider collider = __instance._colliders.Array[i]; + if (collider == null || collider.attachedRigidbody == null || collider.attachedRigidbody.TryGetComponent(out var _)) + { + continue; + } + + Rigidbody attachedRigidbody = collider.attachedRigidbody; + if (__instance._isSucking && attachedRigidbody.TryGetComponent(out var component2)) + { + component2.StartWiggle(); + } + + if (__instance._isSucking && collider.TryGetComponent(out var component3)) + { + component3.ActivateBookShelf(); + } + + GhostDrone component4 = null; + if (__instance._isSucking && attachedRigidbody.TryGetComponent(out component4)) + { + Vector3 vacuumVelocity = Vector3.Normalize(__instance._suckPoint.position - attachedRigidbody.position) * __instance._suckStrength; + component4.vacuumVelocity = vacuumVelocity; + } + + if (__instance._isSucking) + { + attachedRigidbody.velocity = Vector3.Normalize(__instance._suckPoint.position - attachedRigidbody.worldCenterOfMass) * __instance._suckStrength; + } + else + { + attachedRigidbody.velocity = Vars.DominantHand.transform.forward.normalized * __instance._suckStrength * 2f; + } + + if (__instance._isBlowing || Vector3.Distance(attachedRigidbody.worldCenterOfMass, __instance._suckPoint.position) >= __instance._stuckDistance) + { + continue; + } + + if (!attachedRigidbody.TryGetComponent(out var component5)) + { + if ((bool)component4) + { + component4.KillGhost(); + continue; + } + + __instance.SetStuckObject(attachedRigidbody); + break; + } + + if (!__instance.musicStarted) + { + if ((bool)__instance.music) + { + __instance.music.SetActive(value: true); + } + + __instance.musicStarted = true; + } + + __instance._consumeSound.pitch = UnityEngine.Random.Range(0.9f, 1.1f); + __instance._consumeSound.PlayOneShot(__instance._consumeSound.clip); + component5.Repool(); + } + + return false; + } + [HarmonyPrefix] [HarmonyPatch(typeof(Vacuum), nameof(Vacuum.UpdateStuckObject))] static bool VacuumUSO(Vacuum __instance) + { + if (!(__instance._stuckObject.rigidbody == null)) + { + Vector3 vector = __instance._suckPoint.position - __instance._stuckObject.rigidbody.worldCenterOfMass; + __instance._stuckObject.rigidbody.velocity = vector / Time.fixedDeltaTime; + float num = Vars.DominantHand.transform.eulerAngles.y - __instance._lastCameraRotation.y; + num *= Mathf.PI / 180f; + __instance._stuckObject.rigidbody.angularVelocity = new Vector3(0f, num / Time.fixedDeltaTime, 0f); + __instance._lastCameraRotation = Vars.DominantHand.transform.eulerAngles; + } + return false; + } } } diff --git a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Guns/Patches/AutoAimP.cs b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Guns/Patches/AutoAimP.cs new file mode 100644 index 00000000..dff81b2f --- /dev/null +++ b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Guns/Patches/AutoAimP.cs @@ -0,0 +1,20 @@ +using HarmonyLib; +using UnityEngine; + +namespace VRBasePlugin.ULTRAKILL.Guns.Patches +{ + [HarmonyPatch] internal sealed class AutoAimP + { + [HarmonyPrefix] [HarmonyPatch(typeof(RotateToFaceFrustumTarget), nameof(RotateToFaceFrustumTarget.Update))] static bool Update(RotateToFaceFrustumTarget __instance) + { + __instance.targeter.camera = VRGunsController.Instance.TargeterCamera; + + Quaternion to = Vars.DominantHand.transform.rotation; + if ((bool)__instance.targeter && __instance.targeter.isActiveAndEnabled && CameraFrustumTargeter.IsEnabled && (bool)__instance.targeter.CurrentTarget) + to = Quaternion.LookRotation(__instance.targeter.CurrentTarget.bounds.center - __instance.transform.position); + + __instance.transform.rotation = to; + return false; + } + } +} diff --git a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Guns/Patches/GunsP.cs b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Guns/Patches/GunsP.cs index 6671596b..1538b460 100644 --- a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Guns/Patches/GunsP.cs +++ b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Guns/Patches/GunsP.cs @@ -5,19 +5,12 @@ namespace VRBasePlugin.ULTRAKILL.Guns.Patches { [HarmonyPatch] internal sealed class GunsP { - // Disables FRT (update method will no longer be called) and adds vrgunscontroller - [HarmonyPrefix] [HarmonyPatch(typeof(RotateToFaceFrustumTarget), nameof(RotateToFaceFrustumTarget.Update))] - static bool DisableFrustumRotation(RotateToFaceFrustumTarget __instance) + [HarmonyPostfix] [HarmonyPatch(typeof(GunControl), nameof(GunControl.Start))] static void RLPGC(GunControl __instance) { - __instance.enabled = false; - __instance.GetComponent().enabled = false; __instance.gameObject.AddComponent(); - return false; + __instance.GetComponent().enabled = false; + __instance.transform.localPosition = Vector3.zero; } - - // idk if this is needed, but i'm not removing it - [HarmonyPostfix] [HarmonyPatch(typeof(GunControl), nameof(GunControl.Start))] static void RLPGC(GunControl __instance) - { __instance.transform.localPosition = Vector3.zero; } [HarmonyPostfix] [HarmonyPatch(typeof(GunSetter), nameof(GunSetter.ResetWeapons))] static void RLPGS(GunSetter __instance, bool firstTime = false) { __instance.transform.localPosition = Vector3.zero; } [HarmonyPostfix] [HarmonyPatch(typeof(GunSetter), nameof(GunSetter.Start))] static void MakeThemUndisappear(GunSetter __instance) diff --git a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Guns/Patches/TransformP.cs b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Guns/Patches/TransformP.cs index d2d3e0e3..a05d70f8 100644 --- a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Guns/Patches/TransformP.cs +++ b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Guns/Patches/TransformP.cs @@ -7,12 +7,10 @@ namespace VRBasePlugin.ULTRAKILL.Guns.Patches [HarmonyPatch] internal class TransformP { /* Template for transform values: - static Vector3 Position = new Vector3(), - Rotation = new Vector3(), - Scale = new Vector3(), - AltPosition = new Vector3(), - AltRotation = new Vector3(), - AltScale = new Vector3(); + static Vector3 + Position = new Vector3(), + Rotation = new Vector3(), + Scale = new Vector3(); */ [HarmonyPatch(typeof(Revolver))] static class RevolverT { @@ -37,16 +35,42 @@ [HarmonyPostfix] [HarmonyPatch(nameof(Revolver.Start))] static void Retransform( } [HarmonyPatch(typeof(Shotgun))] static class ShotgunT { - static Vector3 Position = new Vector3(-.02f, .2f, .26f), - Rotation = new Vector3(), - Scale = new Vector3(.1f, .1f, .1f), - AltPosition = new Vector3(), - AltRotation = new Vector3(), - AltScale = new Vector3(); + static Vector3 + Position = new Vector3(-.02f, .2f, .26f), + Rotation = new Vector3(), + Scale = new Vector3(.1f, .1f, .1f); + + [HarmonyPostfix] [HarmonyPatch(nameof(Shotgun.Start))] + static void Retransform(Shotgun __instance) + { + ApplyTransform(ref __instance.wpos, Position, Rotation, Scale); + } + + [HarmonyPostfix] [HarmonyPatch(nameof(Shotgun.Update))] static void Update(Shotgun __instance) + { + if (__instance.anim.GetBool("Sawing")) + __instance.transform.GetChild(2).localEulerAngles = new Vector3(__instance.transform.GetChild(2).localEulerAngles.x, __instance.transform.GetChild(2).localEulerAngles.y, 25); + else + __instance.transform.GetChild(2).localEulerAngles = new Vector3(__instance.transform.GetChild(2).localEulerAngles.x, __instance.transform.GetChild(2).localEulerAngles.y, 0); + } + } + [HarmonyPatch(typeof(ShotgunHammer))] static class ShotgunHammerT + { + static Vector3 + Position = new Vector3(0, -.15f, .25f), + Rotation = new Vector3(), + Scale = new Vector3(.45f, .45f, .45f); - [HarmonyPostfix] [HarmonyPatch(nameof(Shotgun.Start))] static void Retransform(Shotgun __instance) + [HarmonyPostfix] [HarmonyPatch(nameof(ShotgunHammer.OnEnable))] static void Retransform(ShotgunHammer __instance) { ApplyTransform(ref __instance.wpos, Position, Rotation, Scale); + __instance.transform.GetChild(1).localRotation = Quaternion.Euler(0, 180, 0); + __instance.gameObject.GetComponent().enabled = false; + } + [HarmonyPostfix] [HarmonyPatch(nameof(ShotgunHammer.LateUpdate))] static void More(ShotgunHammer __instance) + { + __instance.transform.GetChild(1).GetChild(0).localPosition = new Vector3(.375f, .415f, .3f); + __instance.transform.GetChild(1).GetChild(0).localEulerAngles = new Vector3(60,0,0); } } [HarmonyPatch(typeof(Nailgun))] static class NailgunT @@ -91,6 +115,13 @@ [HarmonyPostfix] [HarmonyPatch(nameof(RocketLauncher.Start))] static void Retran __instance.transform.GetChild(0).localPosition = Vector3.zero; } } + [HarmonyPatch(typeof(Chainsaw))] static class ChainsawT + { + [HarmonyPostfix] [HarmonyPatch(nameof(Chainsaw.Start))] static void ChainSaw(Chainsaw __instance) + { + __instance.lineStartTransform = GunControl.Instance?.currentWeapon != null ? GunControl.Instance?.currentWeapon.transform : Vars.DominantHand.transform; + } + } [HarmonyPatch(typeof(Sandbox.Arm.SandboxArm))] static class SandboxArmT { @@ -121,6 +152,54 @@ [HarmonyPostfix] [HarmonyPatch(nameof(FishingRodWeapon.Awake))] static void Retr WAC.Arm = A; WAC.OffsetPos = Vector3.zero; } } + [HarmonyPatch(typeof(WeaponIdentifier))] static class WasherT + { + static Vector3 + Position = new Vector3(0.065f, -0.075f, -0.175f), + Rotation = new Vector3(10, 90, 20), + Scale = new Vector3(-.0025f, .0025f, .0025f); + [HarmonyPostfix] [HarmonyPatch(nameof(WeaponIdentifier.Start))] static void Retransform(WeaponIdentifier __instance) + { + var washer = __instance.GetComponentInChildren(); + if (washer) + { + ApplyTransform(__instance.GetComponent(), Position, Rotation, Scale); + + var WAC = __instance.gameObject.AddComponent(); + var A = Arm.FeedbackerPreset(__instance.transform); + WAC.Arm = A; WAC.OffsetPos = Vector3.zero; + + washer.defaultSprayPos = new Vector3(.35f, -4.25f, -.675f); + washer.defaultSprayRot = Quaternion.Euler(90, 0, 0); + + var sprayStart = __instance.GetComponentInChildren(); + if (sprayStart) + { + sprayStart.transform.localPosition = new Vector3(.35f, -4.25f, -.675f); + sprayStart.transform.localEulerAngles = new Vector3(90, 0, 0); + sprayStart.enabled = false; + } + } + } + } + [HarmonyPatch(typeof(WeaponIdentifier))] static class VacuumT + { + static Vector3 + Position = new Vector3(0, -.35f, 2.15f), + Rotation = new Vector3(0, 90, 20), + Scale = new Vector3(.125f, .125f, .125f); + [HarmonyPostfix] [HarmonyPatch(nameof(WeaponIdentifier.Start))] static void Retransform(WeaponIdentifier __instance) + { + if (__instance.GetComponentInChildren()) + { + ApplyTransform(__instance.GetComponent(), Position, Rotation, Scale); + + var WAC = __instance.gameObject.AddComponent(); + var A = Arm.FeedbackerPreset(__instance.transform); + WAC.Arm = A; WAC.OffsetPos = Vector3.zero; + } + } + } [HarmonyPrefix] [HarmonyPatch(typeof(WeaponPos), nameof(WeaponPos.Start))] static void Start(WeaponPos __instance) { diff --git a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Guns/VRGunsController.cs b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Guns/VRGunsController.cs index 3dfb38f6..403df246 100644 --- a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Guns/VRGunsController.cs +++ b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Guns/VRGunsController.cs @@ -4,9 +4,34 @@ namespace VRBasePlugin.ULTRAKILL.Guns { internal class VRGunsController : MonoSingleton { + public Camera TargeterCamera; + + public void Start() + { + if (TargeterCamera == null || TargeterCamera is null) + { + TargeterCamera = new GameObject("TargeterCamera").AddComponent(); + TargeterCamera.enabled = false; + TargeterCamera.stereoTargetEye = StereoTargetEyeMask.None; + TargeterCamera.clearFlags = CameraClearFlags.Nothing; + TargeterCamera.depth = 99; + TargeterCamera.fieldOfView = 90; + TargeterCamera.nearClipPlane = .01f; + TargeterCamera.cullingMask = -1; + + TargeterCamera.transform.parent = transform; + TargeterCamera.transform.localPosition = Vector3.zero; + TargeterCamera.transform.localEulerAngles = Vector3.zero; + } + CameraFrustumTargeter.Instance.camera = TargeterCamera; + } + public void Update() { + TargeterCamera.transform.position = Vars.DominantHand.transform.position; transform.position = Vars.DominantHand.transform.position; + if ((bool)CameraFrustumTargeter.Instance?.isActiveAndEnabled && CameraFrustumTargeter.IsEnabled && (bool)CameraFrustumTargeter.Instance?.CurrentTarget) + return; transform.rotation = Vars.DominantHand.transform.rotation; } } diff --git a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Movement/Patches/NewMovementP.cs b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Movement/Patches/NewMovementP.cs index b9104ca4..c1aa81c7 100644 --- a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Movement/Patches/NewMovementP.cs +++ b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Movement/Patches/NewMovementP.cs @@ -1,11 +1,11 @@ using HarmonyLib; -using UnityEngine.InputSystem; +using ULTRAKILL.Cheats; using UnityEngine; +using VRBasePlugin.ULTRAKILL.Input; namespace VRBasePlugin.ULTRAKILL.Movement.Patches { - // change move vector to joystick axis, fix dash, jump, etc. - [HarmonyPatch(typeof(NewMovement))] internal class NewMovementP + [HarmonyPatch(typeof(NewMovement))] internal sealed class NewMovementP { [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.Start))] static void Start(NewMovement __instance) { @@ -13,47 +13,38 @@ [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.Start))] static void Start(NewM __instance.jumpPower *= Vars.Config.MovementMultiplier; __instance.wallJumpPower *= Vars.Config.MovementMultiplier; } - - // why the fuck player physics are in Update()? [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.Update))] static bool Update(NewMovement __instance) { + + if (__instance.gc.onGround) + __instance.CheckForGasoline(); + else if (__instance.oilSlideEffect.gameObject.activeSelf) + __instance.oilSlideEffect.gameObject.SetActive(value: false); + Vector2 vector = Vector2.zero; if (__instance.activated) { - vector = Input.InputVars.MoveVector; - - __instance.cc.movementHor = vector.x; - __instance.cc.movementVer = vector.y; - + vector = InputVars.MoveVector; __instance.movementDirection = Vector3.ClampMagnitude(vector.x * __instance.transform.right + vector.y * __instance.transform.forward, 1f); - - if (__instance.punch == null) __instance.punch = __instance.GetComponentInChildren(); - else if (!__instance.punch.enabled) __instance.punch.YesFist(); + if (__instance.punch == null) + __instance.punch = __instance.GetComponentInChildren(); + else if (!__instance.punch.enabled) + __instance.punch.YesFist(); } else { - __instance.rb.velocity = new Vector3(0f, __instance.rb.velocity.y, 0f); - - if (__instance.currentFallParticle != null) Object.Destroy(__instance.currentFallParticle); - - if (__instance.currentSlideParticle != null) Object.Destroy(__instance.currentSlideParticle); - else if (__instance.slideScrape != null) Object.Destroy(__instance.slideScrape); - - if (__instance.punch == null) __instance.punch = __instance.GetComponentInChildren(); - + if (__instance.currentFallParticle != null) + Object.Destroy(__instance.currentFallParticle); + if (__instance.currentSlideParticle != null) + Object.Destroy(__instance.currentSlideParticle); + else if (__instance.slideScrape != null) + Object.Destroy(__instance.slideScrape); + + if (__instance.punch == null) + __instance.punch = __instance.GetComponentInChildren(); else __instance.punch.NoFist(); } - if (MonoSingleton.Instance.LastButtonDevice is Gamepad && __instance.gamepadFreezeCount > 0) - { - vector = Vector2.zero; - __instance.rb.velocity = new Vector3(0f, __instance.rb.velocity.y, 0f); - __instance.cc.movementHor = 0f; - __instance.cc.movementVer = 0f; - __instance.movementDirection = Vector3.zero; - return false; - } - if (__instance.dead && !__instance.endlessMode) { __instance.currentAllPitch -= 0.1f * Time.deltaTime; @@ -84,7 +75,8 @@ [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.Update))] static bool Update(Ne __instance.fallTime += Time.deltaTime * 5f; if (__instance.fallTime > 1f) __instance.falling = true; } - else if (__instance.rb.velocity.y < -2f) __instance.fallSpeed = __instance.rb.velocity.y; + else if (__instance.rb.velocity.y < -2f) + __instance.fallSpeed = __instance.rb.velocity.y; } else if (__instance.gc.onGround) { @@ -95,7 +87,8 @@ [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.Update))] static bool Update(Ne if (!__instance.gc.onGround && __instance.rb.velocity.y < -20f) { __instance.aud3.pitch = __instance.rb.velocity.y * -1f / 120f; - if (__instance.activated) __instance.aud3.volume = __instance.rb.velocity.y * -1f / 80f; + if (__instance.activated) + __instance.aud3.volume = __instance.rb.velocity.y * -1f / 80f; else __instance.aud3.volume = __instance.rb.velocity.y * -1f / 240f; } else if (__instance.rb.velocity.y > -20f) @@ -104,7 +97,8 @@ [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.Update))] static bool Update(Ne __instance.aud3.volume = 0f; } - if (__instance.rb.velocity.y < -100f) __instance.rb.velocity = new Vector3(__instance.rb.velocity.x, -100f, __instance.rb.velocity.z); + if (__instance.rb.velocity.y < -100f) + __instance.rb.velocity = new Vector3(__instance.rb.velocity.x, -100f, __instance.rb.velocity.z); if (__instance.gc.onGround && __instance.falling && !__instance.jumpCooldown) { @@ -114,7 +108,7 @@ [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.Update))] static bool Update(Ne { __instance.aud2.clip = __instance.landingSound; __instance.aud2.volume = 0.5f + __instance.fallSpeed * -0.01f; - __instance.aud2.pitch = Random.Range(0.9f, 1.1f); + __instance.aud2.pitch = UnityEngine.Random.Range(0.9f, 1.1f); __instance.aud2.Play(); } else @@ -124,15 +118,18 @@ [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.Update))] static bool Update(Ne MonoSingleton.Instance.SetVibration(RumbleProperties.FallImpact); } - __instance.fallSpeed = 0f; __instance.gc.heavyFall = false; - if (__instance.currentFallParticle != null) Object.Destroy(__instance.currentFallParticle); + __instance.fallSpeed = 0f; + __instance.gc.heavyFall = false; + if (__instance.currentFallParticle != null) + Object.Destroy(__instance.currentFallParticle); } if (!__instance.gc.onGround && __instance.activated && MonoSingleton.Instance.InputSource.Slide.WasPerformedThisFrame && !GameStateManager.Instance.PlayerInputLocked) { - if (__instance.sliding) __instance.StopSlide(); + if (__instance.sliding) + __instance.StopSlide(); if (__instance.boost) { @@ -140,11 +137,8 @@ [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.Update))] static bool Update(Ne __instance.boost = false; } - RaycastHit val = default(RaycastHit); if (__instance.fallTime > 0.5f - && !Physics.Raycast(__instance.gc.transform.position + __instance.transform.up, - __instance.transform.up * -1f, out val, 3f, - (int)__instance.lmask) && !__instance.gc.heavyFall) + && !Physics.Raycast(__instance.gc.transform.position + __instance.transform.up, __instance.transform.up * -1f, out var _, 3f, __instance.lmask) && !__instance.gc.heavyFall) { __instance.stillHolding = true; __instance.rb.velocity = new Vector3(0f, -100f, 0f); @@ -153,7 +147,9 @@ [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.Update))] static bool Update(Ne __instance.gc.heavyFall = true; __instance.slamForce = 1f; if (__instance.currentFallParticle != null) + { Object.Destroy(__instance.currentFallParticle); + } __instance.currentFallParticle = Object.Instantiate(__instance.fallParticle, __instance.transform); } @@ -162,23 +158,18 @@ [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.Update))] static bool Update(Ne if (__instance.gc.heavyFall && !__instance.slamStorage) __instance.rb.velocity = new Vector3(0f, -100f, 0f); - if (__instance.gc.heavyFall || __instance.sliding) Physics.IgnoreLayerCollision(2, 12, true); - else Physics.IgnoreLayerCollision(2, 12, false); + if (__instance.gc.heavyFall || __instance.sliding) + Physics.IgnoreLayerCollision(2, 12, ignore: true); + else + Physics.IgnoreLayerCollision(2, 12, ignore: false); - if (!__instance.slopeCheck.onGround - && __instance.slopeCheck.forcedOff <= 0 - && !__instance.jumping && !__instance.boost) + if (!__instance.slopeCheck.onGround && __instance.slopeCheck.forcedOff <= 0 && __instance.modForcedFrictionMultip != 0f && !__instance.jumping && !__instance.boost) { float num = __instance.playerCollider.height / 2f - __instance.playerCollider.center.y; - RaycastHit val2 = default(RaycastHit); - if (__instance.rb.velocity != Vector3.zero - && Physics.Raycast(__instance.transform.position, __instance.transform.up * -1f, out val2, num + 1f, (int)__instance.lmask)) - { - Vector3 target = new Vector3(__instance.transform.position.x, - __instance.transform.position.y - ((RaycastHit)(val2)).distance + num, - __instance.transform.position.z); - __instance.transform.position = Vector3.MoveTowards(__instance.transform.position, target, - ((RaycastHit)(val2)).distance * Time.deltaTime * 10f); + if (__instance.rb.velocity != Vector3.zero && Physics.Raycast(__instance.transform.position, __instance.transform.up * -1f, out var hitInfo2, num + 1f, __instance.lmask, QueryTriggerInteraction.Ignore)) + { + Vector3 target = new Vector3(__instance.transform.position.x, __instance.transform.position.y - hitInfo2.distance + num, __instance.transform.position.z); + __instance.transform.position = Vector3.MoveTowards(__instance.transform.position, target, hitInfo2.distance * Time.deltaTime * 10f); if (__instance.rb.velocity.y > 0f) __instance.rb.velocity = new Vector3(__instance.rb.velocity.x, 0f, __instance.rb.velocity.z); } @@ -187,36 +178,40 @@ [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.Update))] static bool Update(Ne if (__instance.gc.heavyFall) { __instance.slamForce += Time.deltaTime * 5f; - RaycastHit val3 = default(RaycastHit); - if (Physics.Raycast(__instance.gc.transform.position + __instance.transform.up, __instance.transform.up * -1f, out val3, 5f, (int)__instance.lmask) - || Physics.SphereCast(__instance.gc.transform.position + __instance.transform.up, 1f, __instance.transform.up * -1f, - out val3, 5f, (int)__instance.lmask)) + if (Physics.Raycast(__instance.gc.transform.position + __instance.transform.up, __instance.transform.up * -1f, out var hitInfo3, 5f, __instance.lmask) + || Physics.SphereCast(__instance.gc.transform.position + __instance.transform.up, 1f, __instance.transform.up * -1f, out hitInfo3, 5f, __instance.lmask)) { - Breakable component = ((Component)(object)((RaycastHit)(val3)).collider).GetComponent(); - if (component != null && component.weak && !component.precisionOnly) + Breakable component = hitInfo3.collider.GetComponent(); + if (component != null && (component.weak || component.forceGroundSlammable) && !component.precisionOnly && !component.unbreakable) { - Object.Instantiate(__instance.impactDust, ((RaycastHit)(val3)).point, Quaternion.identity); + Object.Instantiate(__instance.impactDust, hitInfo3.point, Quaternion.identity); component.Break(); } - if (((Component)(object)((RaycastHit)(val3)).collider).gameObject.TryGetComponent(out var component2)) - component2.GetHit(((RaycastHit)(val3)).point, GoreType.Head); + if (hitInfo3.collider.gameObject.TryGetComponent(out var component2)) + { + component2.GetHit(hitInfo3.point, GoreType.Head); + } - if (((RaycastHit)(val3)).transform.TryGetComponent(out var component3)) component3.Death(); + if (hitInfo3.transform.TryGetComponent(out var component3)) + { + component3.Death(); + } } } - if (__instance.stillHolding && MonoSingleton.Instance.InputSource.Slide.WasCanceledThisFrame) __instance.stillHolding = false; + if (__instance.stillHolding && MonoSingleton.Instance.InputSource.Slide.WasCanceledThisFrame) + __instance.stillHolding = false; if (__instance.activated) { - if (!GameStateManager.Instance.PlayerInputLocked && MonoSingleton.Instance.InputSource.Jump.WasPerformedThisFrame - && (!__instance.falling || __instance.gc.canJump || __instance.wc.CheckForEnemyCols()) && !__instance.jumpCooldown) + if (!GameStateManager.Instance.PlayerInputLocked && MonoSingleton.Instance.InputSource.Jump.WasPerformedThisFrame && (!__instance.falling || __instance.gc.canJump || __instance.wc.CheckForEnemyCols()) && !__instance.jumpCooldown) { if (__instance.gc.canJump || __instance.wc.CheckForEnemyCols()) { __instance.currentWallJumps = 0; __instance.rocketJumps = 0; + __instance.hammerJumps = 0; __instance.clingFade = 0f; __instance.rocketRides = 0; } @@ -226,19 +221,16 @@ [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.Update))] static bool Update(Ne if (!__instance.gc.onGround && __instance.wc.onWall) { - RaycastHit val4 = default(RaycastHit); - if (Physics.Raycast(__instance.transform.position, __instance.movementDirection, out val4, 1f, (int)__instance.lmask)) + if (!__instance.sliding && Physics.Raycast(__instance.transform.position, __instance.movementDirection, out var hitInfo4, 1f, __instance.lmask)) { if (__instance.rb.velocity.y < -1f && !__instance.gc.heavyFall) { - __instance.rb.velocity = (new Vector3(Mathf.Clamp(__instance.rb.velocity.x, -1f, 1f), -2f * __instance.clingFade, Mathf.Clamp(__instance.rb.velocity.z, -1f, 1f))); + __instance.rb.velocity = new Vector3(Mathf.Clamp(__instance.rb.velocity.x, -1f, 1f), -2f * __instance.clingFade, Mathf.Clamp(__instance.rb.velocity.z, -1f, 1f)); if (__instance.scrapeParticle == null) - { - __instance.scrapeParticle = Object.Instantiate(__instance.scrapePrefab, ((RaycastHit)(val4)).point, Quaternion.identity); - } + __instance.scrapeParticle = Object.Instantiate(__instance.scrapePrefab, hitInfo4.point, Quaternion.identity); - __instance.scrapeParticle.transform.position = new Vector3(((RaycastHit)(val4)).point.x, ((RaycastHit)(val4)).point.y + 1f, ((RaycastHit)(val4)).point.z); - __instance.scrapeParticle.transform.forward = ((RaycastHit)(val4)).normal; + __instance.scrapeParticle.transform.position = new Vector3(hitInfo4.point.x, hitInfo4.point.y + 1f, hitInfo4.point.z); + __instance.scrapeParticle.transform.forward = hitInfo4.normal; __instance.clingFade = Mathf.MoveTowards(__instance.clingFade, 50f, Time.deltaTime * 4f); } } @@ -248,9 +240,11 @@ [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.Update))] static bool Update(Ne __instance.scrapeParticle = null; } - if (!GameStateManager.Instance.PlayerInputLocked && MonoSingleton.Instance.InputSource.Jump.WasPerformedThisFrame - && !__instance.jumpCooldown && __instance.currentWallJumps < 3 && (bool)__instance.wc && __instance.wc.CheckForCols()) - __instance.WallJump(); + if (!GameStateManager.Instance.PlayerInputLocked + && MonoSingleton.Instance.InputSource.Jump.WasPerformedThisFrame + && !__instance.jumpCooldown && __instance.currentWallJumps < 3 + && (bool)__instance.wc && __instance.wc.CheckForCols()) + __instance.WallJump(); } else if (__instance.scrapeParticle != null) { @@ -258,48 +252,48 @@ [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.Update))] static bool Update(Ne __instance.scrapeParticle = null; } } - if (MonoSingleton.Instance.InputSource.Slide.WasPerformedThisFrame && __instance.gc.onGround && __instance.activated - && (!__instance.slowMode || __instance.crouching) && !GameStateManager.Instance.PlayerInputLocked && !__instance.sliding) + + if (!GameStateManager.Instance.PlayerInputLocked && !GameStateManager.Instance.IsStateActive("alter-menu")) + { + if (MonoSingleton.Instance.InputSource.Slide.WasPerformedThisFrame + && (__instance.gc.onGround || (float)__instance.gc.sinceLastGrounded < 0.03f) && __instance.activated + && (!__instance.slowMode || __instance.crouching) && !GameStateManager.Instance.PlayerInputLocked && !__instance.sliding) __instance.StartSlide(); - RaycastHit val5 = default(RaycastHit); - if (MonoSingleton.Instance.InputSource.Slide.WasPerformedThisFrame && !__instance.gc.onGround && !__instance.sliding && !__instance.jumping - && __instance.activated && !__instance.slowMode && !GameStateManager.Instance.PlayerInputLocked - && Physics.Raycast(__instance.gc.transform.position + __instance.transform.up, __instance.transform.up * -1f, out val5, 2f, (int)__instance.lmask)) + if (MonoSingleton.Instance.InputSource.Slide.WasPerformedThisFrame + && !__instance.gc.onGround && !__instance.sliding && !__instance.jumping && __instance.activated && !__instance.slowMode + && !GameStateManager.Instance.PlayerInputLocked + && Physics.Raycast(__instance.gc.transform.position + __instance.transform.up, __instance.transform.up * -1f, out var _, 2f, __instance.lmask, QueryTriggerInteraction.Ignore)) __instance.StartSlide(); - if ((MonoSingleton.Instance.InputSource.Slide.WasCanceledThisFrame || (__instance.slowMode && !__instance.crouching)) && __instance.sliding) __instance.StopSlide(); + } + + if ((MonoSingleton.Instance.InputSource.Slide.WasCanceledThisFrame + || (__instance.slowMode && !__instance.crouching)) && __instance.sliding) + __instance.StopSlide(); if (__instance.sliding && __instance.activated) { __instance.standing = false; __instance.slideLength += Time.deltaTime; - if (__instance.cc.defaultPos.y != __instance.cc.originalPos.y - 0.625f) + + Vector3 normalized = Vector3.ProjectOnPlane(__instance.rb.velocity.normalized, Vector3.up).normalized; + if (__instance.currentSlideParticle != null) { - Vector3 vector2 = new Vector3(__instance.cc.originalPos.x, __instance.cc.originalPos.y - 0.625f, __instance.cc.originalPos.z); - __instance.cc.defaultPos = Vector3.MoveTowards(__instance.cc.defaultPos, vector2, ((__instance.cc.defaultPos - vector2).magnitude + 0.5f) * Time.deltaTime * 20f); + __instance.currentSlideParticle.transform.position = __instance.transform.position + normalized * 10f; + __instance.currentSlideParticle.transform.forward = -__instance.dodgeDirection; } - if (__instance.currentSlideParticle != null) __instance.currentSlideParticle.transform.position = __instance.transform.position + __instance.dodgeDirection * 10f; + if (__instance.slideSafety > 0f) + __instance.slideSafety -= Time.deltaTime * 5f; - if (__instance.slideSafety > 0f) __instance.slideSafety -= Time.deltaTime * 5f; - - if (__instance.gc.onGround) + if (__instance.gc.onGround || __instance.wc.onWall) { - __instance.slideScrape.transform.position = __instance.transform.position + __instance.dodgeDirection; + __instance.slideScrape.transform.position = __instance.transform.position + normalized; + __instance.slideScrape.transform.forward = -normalized; __instance.cc.CameraShake(0.1f); } - else __instance.slideScrape.transform.position = Vector3.one * 5000f; - - if (__instance.rising) - { - if (__instance.cc.defaultPos != __instance.cc.originalPos - Vector3.up * 0.625f) - { - __instance.cc.defaultPos = - Vector3.MoveTowards(__instance.cc.defaultPos, __instance.cc.originalPos, - ((__instance.cc.originalPos - __instance.cc.defaultPos).magnitude + 0.5f) * Time.deltaTime * 10f); - } - else __instance.rising = false; - } + else + __instance.slideScrape.transform.position = Vector3.one * 5000f; } else if ((bool)__instance.groundProperties && __instance.groundProperties.forceCrouch) { @@ -311,110 +305,78 @@ [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.Update))] static bool Update(Ne __instance.transform.position = new Vector3(__instance.transform.position.x, __instance.transform.position.y - 1.125f, __instance.transform.position.z); __instance.gc.transform.localPosition = __instance.groundCheckPos + Vector3.up * 1.125f; } - - if (__instance.cc.defaultPos != __instance.cc.originalPos - Vector3.up * 0.625f) - { - __instance.cc.defaultPos = Vector3.MoveTowards(__instance.cc.defaultPos, __instance.cc.originalPos - Vector3.up * 0.625f, - ((__instance.cc.originalPos - Vector3.up * 0.625f - __instance.cc.defaultPos).magnitude + 0.5f) * Time.deltaTime * 10f); - } } else { if (__instance.activated) { - if (!__instance.standing) + if ((bool)__instance.playerCollider && __instance.playerCollider.height != 3.5f) { - if ((bool)(Object)(object)__instance.playerCollider && __instance.playerCollider.height != 3.5f) + if (!Physics.Raycast(__instance.transform.position, Vector3.up, 2.25f, __instance.lmask, QueryTriggerInteraction.Ignore) + && !Physics.SphereCast(new Ray(__instance.transform.position, Vector3.up), 0.5f, 2f, __instance.lmask, QueryTriggerInteraction.Ignore)) { - if (!Physics.Raycast(__instance.transform.position, Vector3.up, 2.25f, (int)__instance.lmask, (QueryTriggerInteraction)1) - && !Physics.SphereCast(new Ray(__instance.transform.position, Vector3.up), 0.5f, 2f, (int)__instance.lmask, (QueryTriggerInteraction)1)) + __instance.playerCollider.height = 3.5f; + __instance.gc.transform.localPosition = __instance.groundCheckPos; + if (Physics.Raycast(__instance.transform.position, Vector3.up * -1f, 2.25f, __instance.lmask, QueryTriggerInteraction.Ignore)) + __instance.transform.position = new Vector3(__instance.transform.position.x, __instance.transform.position.y + 1.125f, __instance.transform.position.z); + else { - __instance.playerCollider.height = 3.5f; - __instance.gc.transform.localPosition = __instance.groundCheckPos; - if (Physics.Raycast(__instance.transform.position, Vector3.up * -1f, 2.25f, (int)__instance.lmask, (QueryTriggerInteraction)1)) - { - __instance.transform.position = new Vector3(__instance.transform.position.x, - __instance.transform.position.y + 1.125f, - __instance.transform.position.z); - } - else - { - __instance.transform.position = new Vector3(__instance.transform.position.x, - __instance.transform.position.y - 0.625f, - __instance.transform.position.z); - __instance.cc.defaultPos = __instance.cc.originalPos; - __instance.standing = true; - } - - if (__instance.crouching) - { - __instance.crouching = false; - __instance.slowMode = false; - } + __instance.transform.position = new Vector3(__instance.transform.position.x, __instance.transform.position.y - 0.625f, __instance.transform.position.z); + __instance.standing = true; } - else + + if (__instance.crouching) { - __instance.crouching = true; - __instance.slowMode = true; + __instance.crouching = false; + __instance.slowMode = false; } } - else if (__instance.cc.defaultPos.y != __instance.cc.originalPos.y) - __instance.cc.defaultPos = Vector3.MoveTowards(__instance.cc.defaultPos, __instance.cc.originalPos, - (__instance.cc.originalPos.y - __instance.cc.defaultPos.y + 0.5f) * Time.deltaTime * 10f); - else __instance.standing = true; - } - else if (__instance.rising) - { - if (__instance.cc.defaultPos != __instance.cc.originalPos) - __instance.cc.defaultPos = Vector3.MoveTowards(__instance.cc.defaultPos, __instance.cc.originalPos, - ((__instance.cc.originalPos - __instance.cc.defaultPos).magnitude + 0.5f) * Time.deltaTime * 10f); - else __instance.rising = false; + else + { + __instance.crouching = true; + __instance.slowMode = true; + } } + else + __instance.standing = true; } - if (__instance.currentSlideParticle != null) Object.Destroy(__instance.currentSlideParticle); - - if (__instance.slideScrape != null) Object.Destroy(__instance.slideScrape); - } + if (__instance.currentSlideParticle != null) + Object.Destroy(__instance.currentSlideParticle); - if (__instance.rising && Vector3.Distance(__instance.cc.defaultPos, __instance.cc.originalPos) > 10f) - { - __instance.rising = false; - __instance.cc.defaultPos = __instance.cc.originalPos; + if (__instance.slideScrape != null) + Object.Destroy(__instance.slideScrape); } - // Dash - if (MonoSingleton.Instance.InputSource.Dodge.WasPerformedThisFrame - && __instance.activated && !__instance.slowMode && !GameStateManager.Instance.PlayerInputLocked) + if (MonoSingleton.Instance.InputSource.Dodge.WasPerformedThisFrame && __instance.activated && !__instance.slowMode && !GameStateManager.Instance.PlayerInputLocked) { if (((bool)__instance.groundProperties && !__instance.groundProperties.canDash) || __instance.modNoDashSlide) - if (__instance.modNoDashSlide || !__instance.groundProperties.silentDashFail) Object.Instantiate(__instance.staminaFailSound); - if (__instance.boostCharge >= 100f) { - if (__instance.sliding) __instance.StopSlide(); + if (__instance.modNoDashSlide || !__instance.groundProperties.silentDashFail) + Object.Instantiate(__instance.staminaFailSound); + } + else if (__instance.boostCharge >= 100f) + { + if (__instance.sliding) + __instance.StopSlide(); __instance.boostLeft = 100f; + __instance.dashStorage = 1f; __instance.boost = true; - __instance.dodgeDirection = __instance.movementDirection.normalized; if (__instance.dodgeDirection == Vector3.zero) - __instance.dodgeDirection = __instance.transform.forward; + __instance.dodgeDirection = __instance.transform.forward.normalized; Quaternion identity = Quaternion.identity; identity.SetLookRotation(__instance.dodgeDirection * -1f); Object.Instantiate(__instance.dodgeParticle, __instance.transform.position + __instance.dodgeDirection * 10f, identity); - - if (!__instance.asscon.majorEnabled || !__instance.asscon.infiniteStamina) __instance.boostCharge -= 100f; - - if (__instance.dodgeDirection == __instance.transform.forward) __instance.cc.dodgeDirection = 0; // what the fuck, hakita? - else if (__instance.dodgeDirection == __instance.transform.forward * -1f) __instance.cc.dodgeDirection = 1; - else __instance.cc.dodgeDirection = 2; + if (!__instance.asscon.majorEnabled || !__instance.asscon.infiniteStamina) + __instance.boostCharge -= 100f; __instance.aud.clip = __instance.dodgeSound; __instance.aud.volume = 1f; __instance.aud.pitch = 1f; __instance.aud.Play(); - MonoSingleton.Instance.SetVibration(RumbleProperties.Dash); if (__instance.gc.heavyFall) { @@ -424,40 +386,40 @@ [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.Update))] static bool Update(Ne Object.Destroy(__instance.currentFallParticle); } } - else Object.Instantiate(__instance.staminaFailSound); + else + Object.Instantiate(__instance.staminaFailSound); } if (!__instance.walking && vector.sqrMagnitude > 0f && !__instance.sliding && __instance.gc.onGround) { __instance.walking = true; - __instance.anim.SetBool("WalkF", true); + __instance.anim.SetBool("WalkF", value: true); } else if ((__instance.walking && Mathf.Approximately(vector.sqrMagnitude, 0f)) || !__instance.gc.onGround || __instance.sliding) { __instance.walking = false; - __instance.anim.SetBool("WalkF", false); + __instance.anim.SetBool("WalkF", value: false); } if (__instance.hurting && __instance.hp > 0) { __instance.currentColor.a -= Time.deltaTime; __instance.hurtScreen.color = __instance.currentColor; - if (__instance.currentColor.a <= 0f) __instance.hurting = false; + if (__instance.currentColor.a <= 0f) + __instance.hurting = false; } + if (__instance.safeExplosionLaunchCooldown > 0f) + __instance.safeExplosionLaunchCooldown = Mathf.MoveTowards(__instance.safeExplosionLaunchCooldown, 0f, Time.deltaTime); + if (__instance.boostCharge != 300f && !__instance.sliding && !__instance.slowMode) { float num2 = 1f; if (__instance.difficulty == 1) num2 = 1.5f; else if (__instance.difficulty == 0) num2 = 2f; - __instance.boostCharge = Mathf.MoveTowards(__instance.boostCharge, 300f, 70f * Time.deltaTime * num2); } - Vector3 vector3 = __instance.hudOriginalPos - __instance.cc.transform.InverseTransformDirection(__instance.rb.velocity) / 1000f; - float num3 = Vector3.Distance(vector3, __instance.screenHud.transform.localPosition); - __instance.screenHud.transform.localPosition = Vector3.MoveTowards(__instance.screenHud.transform.localPosition, vector3, Time.deltaTime * 15f * num3); - int rankIndex = MonoSingleton.Instance.rankIndex; if (rankIndex == 7 || __instance.difficulty <= 1) { @@ -475,11 +437,12 @@ [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.Update))] static bool Update(Ne else __instance.antiHp = Mathf.MoveTowards(__instance.antiHp, 0f, Time.deltaTime * 15f); } - if (!__instance.gc.heavyFall && __instance.currentFallParticle != null) Object.Destroy(__instance.currentFallParticle); + if (!__instance.gc.heavyFall && __instance.currentFallParticle != null) + Object.Destroy(__instance.currentFallParticle); return false; } - [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.Dodge))] static bool Dash(NewMovement __instance) + [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.Dodge))] static bool Dodge(NewMovement __instance) { if (__instance.sliding) { @@ -492,11 +455,12 @@ [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.Dodge))] static bool Dash(NewMo float num = 1f; if (__instance.preSlideSpeed > 1f) { - if (__instance.preSlideSpeed > 3f) __instance.preSlideSpeed = 3f; + if (__instance.preSlideSpeed > 3f) + __instance.preSlideSpeed = 3f; num = __instance.preSlideSpeed; - if (__instance.gc.onGround) - __instance.preSlideSpeed -= Time.fixedDeltaTime * __instance.preSlideSpeed; + if (__instance.gc.onGround && __instance.friction != 0f) + __instance.preSlideSpeed -= Time.fixedDeltaTime * __instance.preSlideSpeed * __instance.friction; __instance.preSlideDelay = 0f; } @@ -514,12 +478,11 @@ [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.Dodge))] static bool Dash(NewMo __instance.StopSlide(); return false; } + num *= __instance.groundProperties.speedMultiplier; } - Vector3 vector = new Vector3(__instance.dodgeDirection.x * __instance.walkSpeed * Time.deltaTime * 4f * num, - __instance.rb.velocity.y, - __instance.dodgeDirection.z * __instance.walkSpeed * Time.deltaTime * 4f * num); + Vector3 vector = new Vector3(__instance.dodgeDirection.x * __instance.walkSpeed * Time.deltaTime * 4f * num, __instance.rb.velocity.y, __instance.dodgeDirection.z * __instance.walkSpeed * Time.deltaTime * 4f * num); if ((bool)__instance.groundProperties && __instance.groundProperties.push) { Vector3 vector2 = __instance.groundProperties.pushForce; @@ -529,211 +492,252 @@ [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.Dodge))] static bool Dash(NewMo vector += vector2; } - __instance.movementDirection = Vector3.ClampMagnitude(Input.InputVars.MoveVector.x * __instance.transform.right, 1f) * 5f - * Vars.Config.MovementMultiplier; + if (__instance.boostLeft > 0f) + { + __instance.dashStorage = Mathf.MoveTowards(__instance.dashStorage, 0f, Time.fixedDeltaTime); + if (__instance.dashStorage <= 0f) __instance.boostLeft = 0f; + } + + __instance.movementDirection = Vector3.ClampMagnitude(InputVars.MoveVector.x * __instance.transform.right, 1f) * 5f; if (!MonoSingleton.Instance || !MonoSingleton.Instance.beingPulled) - __instance.rb.velocity = vector + __instance.pushForce + __instance.movementDirection.normalized; + __instance.rb.velocity = vector + __instance.pushForce + __instance.movementDirection; else __instance.StopSlide(); return false; } float y = 0f; - if (__instance.slideEnding) y = __instance.rb.velocity.y; + if (__instance.slideEnding) + y = __instance.rb.velocity.y; float num2 = 2.75f; - __instance.movementDirection2 = new Vector3(__instance.dodgeDirection.x * __instance.walkSpeed * Time.deltaTime * num2, - y, - __instance.dodgeDirection.z * __instance.walkSpeed * Time.deltaTime * num2); - if (!__instance.slideEnding || (__instance.gc.onGround && !__instance.jumping)) - __instance.rb.velocity = __instance.movementDirection2 * 3f; - + __instance.movementDirection2 = new Vector3(__instance.dodgeDirection.x * __instance.walkSpeed * Time.deltaTime * num2, y, __instance.dodgeDirection.z * __instance.walkSpeed * Time.deltaTime * num2); __instance.gameObject.layer = 15; - __instance.boostLeft -= 4f; - if (__instance.boostLeft <= 0f) + if (__instance.slideEnding) { - __instance.boost = false; - if (!__instance.gc.onGround && !__instance.slideEnding) - __instance.rb.velocity = __instance.movementDirection2; + __instance.slideEnding = false; + if (!__instance.gc.onGround || __instance.friction == 0f) + { + __instance.boost = false; + return false; + } } - __instance.slideEnding = false; + if (__instance.boostLeft > 0f) + { + __instance.rb.velocity = __instance.movementDirection2 * 3f; + __instance.boostLeft -= 4f; + return false; + } + + if (!__instance.gc.onGround || __instance.friction != 0f) + __instance.rb.velocity = __instance.movementDirection2; + __instance.boost = false; return false; } - [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.StartSlide))] static bool Slide(NewMovement __instance) + [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.Launch))] static bool Launch(NewMovement __instance, Vector3 direction) { - if (__instance.currentSlideParticle != null) Object.Destroy(__instance.currentSlideParticle); + if (((bool)__instance.groundProperties && !__instance.groundProperties.launchable) || (direction == Vector3.down && __instance.gc.onGround)) + { + return false; + } - if (__instance.slideScrape != null) Object.Destroy(__instance.slideScrape); + __instance.jumping = true; + __instance.Invoke("NotJumping", 0.5f); + __instance.jumpCooldown = true; + __instance.Invoke("JumpReady", 0.2f); + __instance.boost = false; + if (__instance.gc.heavyFall) + { + __instance.fallSpeed = 0f; + __instance.gc.heavyFall = false; + if (__instance.currentFallParticle != null) + { + Object.Destroy(__instance.currentFallParticle); + } + } - if (__instance.modNoDashSlide) __instance.StopSlide(); - else + if (direction.magnitude > 0f) { - if ((bool)MonoSingleton.Instance && MonoSingleton.Instance.beingPulled) return false; + __instance.rb.velocity = Vector3.zero; + } - if ((bool)__instance.groundProperties && !__instance.groundProperties.canSlide) + direction *= 1000f; + __instance.rb.AddForce(Vector3.ClampMagnitude(direction, 1000000f * Vars.Config.MovementMultiplier)); + return false; + } + [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.LaunchFromPoint))] static bool LaunchFromPoint(NewMovement __instance, Vector3 position, float strength, float maxDistance = 1) + { + if (!__instance.groundProperties || __instance.groundProperties.launchable) + { + bool flag = false; + if (__instance.jumping) { - if (!__instance.groundProperties.silentSlideFail) __instance.StopSlide(); - return false; + flag = true; } - if (!__instance.crouching) + Vector3 vector = (__instance.transform.position - position).normalized; + if (position == __instance.transform.position) { - __instance.playerCollider.height = 1.25f; - __instance.transform.position = new Vector3(__instance.transform.position.x, - __instance.transform.position.y - 1.125f, - __instance.transform.position.z); - __instance.gc.transform.localPosition = __instance.groundCheckPos + Vector3.up * 1.125f; + vector = Vector3.up; } - __instance.slideSafety = 1f; - __instance.sliding = true; - __instance.boost = true; - __instance.dodgeDirection = __instance.movementDirection.normalized; - if (__instance.dodgeDirection == Vector3.zero) __instance.dodgeDirection = __instance.transform.forward; - - Quaternion identity = Quaternion.identity; - identity.SetLookRotation(__instance.dodgeDirection * -1f); - __instance.currentSlideParticle = Object.Instantiate(__instance.slideParticle, __instance.transform.position + __instance.dodgeDirection * 10f, identity); - __instance.slideScrape = Object.Instantiate(__instance.slideScrapePrefab, __instance.transform.position + __instance.dodgeDirection * 2f, identity); - if (__instance.dodgeDirection == __instance.transform.forward) __instance.cc.dodgeDirection = 0; - else if (__instance.dodgeDirection == __instance.transform.forward * -1f) __instance.cc.dodgeDirection = 1; - else __instance.cc.dodgeDirection = 2; - - MonoSingleton.Instance.SetVibration(RumbleProperties.Slide); + int num = 1; + Vector3 vector2 = ((!flag) ? new Vector3(vector.x * (maxDistance - Vector3.Distance(__instance.transform.position, position)) * strength * 1000f, strength * 500f * (maxDistance - Vector3.Distance(__instance.transform.position, position)) * (float)num, vector.z * (maxDistance - Vector3.Distance(__instance.transform.position, position)) * strength * 1000f) : new Vector3(vector.x * maxDistance * strength * 1000f, strength * 500f * maxDistance * (float)num, vector.z * maxDistance * strength * 1000f)); + __instance.Launch(vector2 / 1000f * Vars.Config.MovementMultiplier); } + return false; } - - // Dying thingamajig fix - [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.GetHurt))] static bool GetHurt(int damage, bool invincible, float scoreLossMultiplier, bool explosion, bool instablack, NewMovement __instance) + [HarmonyPrefix] [HarmonyPatch(nameof(NewMovement.GetHurt))] static bool GetHurt(NewMovement __instance, int damage, bool invincible, float scoreLossMultiplier = 1f, bool explosion = false, bool instablack = false, float hardDamageMultiplier = 0.35f, bool ignoreInvincibility = false) { - if (!__instance.dead && (!invincible || __instance.gameObject.layer != 15) && damage > 0) + if (__instance.dead || !(!invincible || __instance.gameObject.layer != 15 || ignoreInvincibility) || damage <= 0) { - if (explosion) - { - __instance.exploded = true; - } - if (__instance.asscon.majorEnabled) - { - damage = Mathf.RoundToInt((float)damage * __instance.asscon.damageTaken); - } - if (invincible) - { - __instance.gameObject.layer = 15; - } - if (damage >= 50) - { - __instance.currentColor.a = 0.8f; - } - else - { - __instance.currentColor.a = 0.5f; - } - __instance.hurting = true; - __instance.cc.CameraShake((float)(damage / 20)); - __instance.hurtAud.pitch = Random.Range(0.8f, 1f); - __instance.hurtAud.PlayOneShot(__instance.hurtAud.clip); - if (__instance.hp - damage > 0) + return false; + } + + if (explosion) + { + __instance.exploded = true; + } + + if (__instance.asscon.majorEnabled) + { + damage = Mathf.RoundToInt((float)damage * __instance.asscon.damageTaken); + } + + if (Invincibility.Enabled) + { + damage = 0; + } + + if (invincible) + { + __instance.gameObject.layer = 15; + } + + if (damage >= 50) + { + __instance.currentColor.a = 0.8f; + } + else + { + __instance.currentColor.a = 0.5f; + } + + __instance.hurting = true; + __instance.cc.CameraShake(damage / 20); + __instance.hurtAud.pitch = UnityEngine.Random.Range(0.8f, 1f); + __instance.hurtAud.PlayOneShot(__instance.hurtAud.clip); + if (__instance.hp - damage > 0) + { + __instance.hp -= damage; + } + else + { + __instance.hp = 0; + } + + if (invincible && scoreLossMultiplier != 0f && __instance.difficulty >= 2 && (!__instance.asscon.majorEnabled || !__instance.asscon.disableHardDamage) && __instance.hp <= 100) + { + if (__instance.antiHp + (float)damage * hardDamageMultiplier < 99f) { - __instance.hp -= damage; + __instance.antiHp += (float)damage * hardDamageMultiplier; } else { - __instance.hp = 0; - } - if (invincible && scoreLossMultiplier != 0f && __instance.difficulty >= 2 && (!__instance.asscon.majorEnabled || !__instance.asscon.disableHardDamage) && __instance.hp <= 100) - { - float num = 0.35f; - if (__instance.difficulty >= 4) - { - num = 0.5f; - } - if (__instance.antiHp + (float)damage * num < 99f) - { - __instance.antiHp += (float)damage * num; - } - else - { - __instance.antiHp = 99f; - } - if (__instance.antiHpCooldown == 0f) - { - __instance.antiHpCooldown += 1f; - } - if (__instance.difficulty >= 3) - { - __instance.antiHpCooldown += 1f; - } - __instance.antiHpFlash.Flash(1f); - __instance.antiHpCooldown += (float)(damage / 20); - } - if (__instance.shud == null) - { - __instance.shud = MonoSingleton.Instance; + __instance.antiHp = 99f; } - if (scoreLossMultiplier > 0.5f) - { - __instance.shud.RemovePoints(0); - __instance.shud.DescendRank(); - } - else + + if (__instance.antiHpCooldown == 0f) { - __instance.shud.RemovePoints(Mathf.RoundToInt((float)damage)); + __instance.antiHpCooldown += 1f; } - StatsManager instance = MonoSingleton.Instance; - if (damage <= 200) + + if (__instance.difficulty >= 3) { - instance.stylePoints -= Mathf.RoundToInt((float)(damage * 5) * scoreLossMultiplier); + __instance.antiHpCooldown += 1f; } - else + + __instance.antiHpFlash.Flash(1f); + __instance.antiHpCooldown += damage / 20; + } + + if (__instance.shud == null) + { + __instance.shud = MonoSingleton.Instance; + } + + if (scoreLossMultiplier > 0.5f) + { + __instance.shud.RemovePoints(0); + __instance.shud.DescendRank(); + } + else + { + __instance.shud.RemovePoints(Mathf.RoundToInt(damage)); + } + + StatsManager statsManager = MonoSingleton.Instance; + if (damage <= 200) + { + statsManager.stylePoints -= Mathf.RoundToInt((float)(damage * 5) * scoreLossMultiplier); + } + else + { + statsManager.stylePoints -= Mathf.RoundToInt(1000f * scoreLossMultiplier); + } + + statsManager.tookDamage = true; + if (__instance.hp != 0) + { + return false; + } + + if (!__instance.endlessMode) + { + __instance.blackScreen.gameObject.SetActive(value: true); + MonoSingleton.Instance.controlPitch = false; + if (instablack) { - instance.stylePoints -= Mathf.RoundToInt(1000f * scoreLossMultiplier); + __instance.blackColor.a = 1f; } - instance.tookDamage = true; - if (__instance.hp == 0) + + __instance.screenHud.SetActive(value: false); + } + else + { + __instance.GetComponentInChildren().GameOver(); + CrowdReactions crowdReactions = MonoSingleton.Instance; + if (crowdReactions != null) { - if (!__instance.endlessMode) - { - __instance.blackScreen.gameObject.SetActive(true); - MonoSingleton.Instance.controlPitch = false; - if (instablack) - { - __instance.blackColor.a = 1f; - } - __instance.screenHud.SetActive(false); - } - else - { - __instance.GetComponentInChildren().GameOver(); - CrowdReactions instance2 = MonoSingleton.Instance; - if (instance2 != null) - { - instance2.React(instance2.aww); - } - } - //__instance.rb.constraints = RigidbodyConstraints.None; - if (MonoSingleton.Instance) - { - MonoSingleton.Instance.juice = 0f; - } - __instance.cc.enabled = false; - if (__instance.gunc == null) - { - __instance.gunc = __instance.GetComponentInChildren(); - } - __instance.gunc.NoWeapon(); - //__instance.rb.constraints = RigidbodyConstraints.None; - __instance.dead = true; - __instance.activated = false; - if (__instance.punch == null) - { - __instance.punch = __instance.GetComponentInChildren(); - } - __instance.punch.NoFist(); + crowdReactions.React(crowdReactions.aww); } } + + //rb.constraints = RigidbodyConstraints.None; + if ((bool)MonoSingleton.Instance) + { + MonoSingleton.Instance.juice = 0f; + } + + __instance.cc.enabled = false; + if (__instance.gunc == null) + { + __instance.gunc = __instance.GetComponentInChildren(); + } + + __instance.gunc.NoWeapon(); + //rb.constraints = RigidbodyConstraints.None; + __instance.dead = true; + __instance.activated = false; + if (__instance.punch == null) + { + __instance.punch = __instance.GetComponentInChildren(); + } + + __instance.punch.NoFist(); return false; } } diff --git a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Movement/Patches/PlatformerMovementP.cs b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Movement/Patches/PlatformerMovementP.cs index 70dbd7ee..31d3c4ed 100644 --- a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Movement/Patches/PlatformerMovementP.cs +++ b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Movement/Patches/PlatformerMovementP.cs @@ -6,7 +6,7 @@ namespace VRBasePlugin.ULTRAKILL.Movement.Patches { // change move vector to joystick axis, fix dash, jump, etc. // CHANGE THIS - [HarmonyPatch(typeof(PlatformerMovement))] internal class PlatformerMovementP + /*[HarmonyPatch(typeof(PlatformerMovement))]*/ internal class PlatformerMovementP { // change movement vector to vr one [HarmonyPrefix] [HarmonyPatch(nameof(PlatformerMovement.Update))] static bool Update(PlatformerMovement __instance) diff --git a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/UI/CrosshairController.cs b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/UI/CrosshairController.cs index c0cfed3b..7ea3c873 100644 --- a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/UI/CrosshairController.cs +++ b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/UI/CrosshairController.cs @@ -1,4 +1,5 @@ using UnityEngine; +using VRBasePlugin.ULTRAKILL.Guns; using VRTRAKILL.Utilities; namespace VRBasePlugin.ULTRAKILL.UI @@ -19,8 +20,12 @@ public void LateUpdate() transform.position = Vars.MainCamera.transform.position + (Vars.MainCamera.transform.forward * Length * .25f) + Offset; else { - if (GunControl.Instance != null && GunControl.Instance.currentWeapon.HasComponent()) - Target = GunControl.Instance.currentWeapon.transform; + if (GunControl.Instance != null) + { + if (GunControl.Instance.currentWeapon?.GetComponent() || GunControl.Instance.currentWeapon?.GetComponent()) + Target = GunControl.Instance.currentWeapon.transform; + else Target = GunControl.Instance.transform; + } else Target = Vars.DominantHand.transform; transform.position = Target.position + (Target.forward * Length) + Offset; diff --git a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/VRAvatar/IKChain.cs b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/VRAvatar/IKChain.cs index 906fccf0..3e619221 100644 --- a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/VRAvatar/IKChain.cs +++ b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/VRAvatar/IKChain.cs @@ -47,7 +47,7 @@ internal class IKChain : MonoBehaviour // Start is called before the first frame update public void Start() => Init(); - void Init() + public void Init() { //initial array Bones = new Transform[ChainLength + 1]; diff --git a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/VRAvatar/VRigController.cs b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/VRAvatar/VRigController.cs index 29ca7724..b5b2b44f 100644 --- a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/VRAvatar/VRigController.cs +++ b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/VRAvatar/VRigController.cs @@ -2,6 +2,7 @@ using VRTRAKILL.Utilities; using VRBasePlugin.Util.Libraries.EZhex1991.EZSoftBone; using UnityEngine; +using Valve.VR; namespace VRBasePlugin.ULTRAKILL.VRAvatar { @@ -40,7 +41,7 @@ public void Start() Rig.GameObjectT.localRotation = Quaternion.Euler(Vector3.zero); Rig.Root.localScale *= 3; - Rig.Root.GetChild(0).localPosition = new Vector3(0, -.015f, -.0005f); + Rig.Root.GetChild(0).localPosition = new Vector3(0, -.015f, -.001f); if (Vars.Config.VRBody.EnableArmsIK) @@ -119,6 +120,7 @@ public void LateUpdate() HandleAnimations(); HandlePelvisRotation(); } + MakeArmCannonsFun(); } private void HandleBodyTransform() @@ -236,5 +238,29 @@ private void HandlePelvisRotation() if (Input.InputVars.MoveVector.y < 0) Rotation = Quaternion.Euler(0, -Rotation.eulerAngles.y - 180, 0); Rig.Pelvis.rotation = Quaternion.Lerp(Rig.Pelvis.rotation, Rotation, Time.deltaTime * 5); } + + private bool macf = false; + private void MakeArmCannonsFun() + { + if (!GunControl.Instance || !GunControl.Instance.currentWeapon) return; + if (GunControl.Instance.currentWeapon.HasComponent()) + { + macf = true; + //Rig.FeedbackerB.Forearm.localScale = new Vector3(.5f, .5f, .5f); + //Rig.FeedbackerB.Hand.Root.gameObject.GetComponent().Init(); + } + else if (GunControl.Instance.currentWeapon.HasComponent()) + { + macf = true; + //Rig.FeedbackerB.Forearm.localScale = new Vector3(.85f, .85f, .85f); + //Rig.FeedbackerB.Hand.Root.gameObject.GetComponent().Init(); + } + else if (macf) + { + macf = false; + //Rig.FeedbackerB.Forearm.localScale = Vector3.one; + //Rig.FeedbackerB.Hand.Root.gameObject.GetComponent().Init(); + } + } } } diff --git a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/VRCamera/Patches/CameraConverterP.cs b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/VRCamera/Patches/CameraConverterP.cs index b0caf577..fc9d684e 100644 --- a/VRTRAKILL.Plugin/Plugin/ULTRAKILL/VRCamera/Patches/CameraConverterP.cs +++ b/VRTRAKILL.Plugin/Plugin/ULTRAKILL/VRCamera/Patches/CameraConverterP.cs @@ -69,12 +69,12 @@ [HarmonyPrefix] [HarmonyPatch(typeof(CameraController), nameof(CameraController. GameObject.Find("Virtual Camera").SetActive(false); } [HarmonyPostfix] [HarmonyPatch(typeof(CameraController), nameof(CameraController.Start))] static void AddSVRCam(CameraController __instance) - { __instance.gameObject.AddComponent(); } + { + __instance.gameObject.AddComponent(); + } [HarmonyPrefix] [HarmonyPatch(typeof(CameraController), nameof(CameraController.Update))] - [HarmonyPatch(typeof(CameraFrustumTargeter), nameof(CameraFrustumTargeter.Update))] - [HarmonyPatch(typeof(CameraFrustumTargeter), nameof(CameraFrustumTargeter.LateUpdate))] static bool DoNothing() { // do nothing diff --git a/VRTRAKILL.Plugin/Plugin/VRTRAKILL.Plugin.csproj b/VRTRAKILL.Plugin/Plugin/VRTRAKILL.Plugin.csproj index 72adaf3f..7e67bd0c 100644 --- a/VRTRAKILL.Plugin/Plugin/VRTRAKILL.Plugin.csproj +++ b/VRTRAKILL.Plugin/Plugin/VRTRAKILL.Plugin.csproj @@ -132,6 +132,10 @@ ..\..\lib\Unity\UnityEngine.InputModule.dll False + + ..\..\lib\Unity\UnityEngine.ParticleSystemModule.dll + False + ..\..\lib\Unity\UnityEngine.PhysicsModule.dll False @@ -152,6 +156,7 @@ + diff --git a/VRTRAKILL.Plugin/Plugin/Versioning.cs b/VRTRAKILL.Plugin/Plugin/Versioning.cs index bb783d7f..e8186d2e 100644 --- a/VRTRAKILL.Plugin/Plugin/Versioning.cs +++ b/VRTRAKILL.Plugin/Plugin/Versioning.cs @@ -19,7 +19,7 @@ public static void CheckForUpdates() using (HttpClient HC = new HttpClient()) { var HRQM = new HttpRequestMessage(HttpMethod.Get, $"{PluginInfo.GithubRepoLink}/releases/latest"); - HRQM.Headers.Add("User-Agent", "User-Agent"); + HRQM.Headers.Add("User-Agent", "GamingToilet-HondaCivic2007"); var Response = HC.SendAsync(HRQM, HttpCompletionOption.ResponseContentRead); Response.Wait(); var Stream = Response.Result.Content.ReadAsStringAsync(); Stream.Wait(); diff --git a/lib/Assembly-CSharp.dll b/lib/Assembly-CSharp.dll index 48a0ca18..39368d12 100644 Binary files a/lib/Assembly-CSharp.dll and b/lib/Assembly-CSharp.dll differ diff --git a/lib/Unity/UnityEngine.ParticleSystemModule.dll b/lib/Unity/UnityEngine.ParticleSystemModule.dll new file mode 100644 index 00000000..8bb192fa Binary files /dev/null and b/lib/Unity/UnityEngine.ParticleSystemModule.dll differ