From 0d9415d37744328d8fbc8250d7313745b5d8ce3e Mon Sep 17 00:00:00 2001 From: Aleksandr Date: Sun, 28 Jun 2020 22:56:01 +0500 Subject: [PATCH 1/9] removed TAIcheat folder --- TAIcheat/Properties/AssemblyInfo.cs | 34 -- TAIcheat/TAIcheat.cs | 695 ---------------------------- TAIcheat/TAIcheat.csproj | 109 ----- TAIcheat/default-config.json | 138 ------ TAIcheat/manifest.json | 8 - TAIcheat/packages.config | 4 - 6 files changed, 988 deletions(-) delete mode 100644 TAIcheat/Properties/AssemblyInfo.cs delete mode 100644 TAIcheat/TAIcheat.cs delete mode 100644 TAIcheat/TAIcheat.csproj delete mode 100644 TAIcheat/default-config.json delete mode 100644 TAIcheat/manifest.json delete mode 100644 TAIcheat/packages.config diff --git a/TAIcheat/Properties/AssemblyInfo.cs b/TAIcheat/Properties/AssemblyInfo.cs deleted file mode 100644 index 0a14c65d5..000000000 --- a/TAIcheat/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("OWML.ModInteraction")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OWML.ModInteraction")] -[assembly: AssemblyCopyright("Copyright © 2020")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM - -[assembly: Guid("3212c570-d4c3-4083-a3db-616f80ba5dab")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/TAIcheat/TAIcheat.cs b/TAIcheat/TAIcheat.cs deleted file mode 100644 index a68f9d265..000000000 --- a/TAIcheat/TAIcheat.cs +++ /dev/null @@ -1,695 +0,0 @@ -using OWML.Common; -using OWML.ModHelper; -using OWML.ModHelper.Events; -using OWML.ModHelper.Input; -using System.Reflection; -using UnityEngine; -using UnityEngine.UI; -using UnityEngine.EventSystems; -using UnityEngine.SceneManagement; -using System.Collections; -using System; -using System.Collections.Generic; -using Harmony; - -namespace TAIcheat -{ - public static class MyExtensions - { - public static void TAIcheat_SetTranslationalThrust(this JetpackThrusterModel jet, float newacc) - { - float oldtrst = jet.GetMaxTranslationalThrust(); - float oldbst = jet.GetBoostMaxThrust(); - FieldInfo fiboost = typeof(JetpackThrusterModel).GetField("_boostThrust", BindingFlags.NonPublic | BindingFlags.Instance); - FieldInfo fithrust = typeof(JetpackThrusterModel).GetField("_maxTranslationalThrust", BindingFlags.NonPublic | BindingFlags.Instance); - if (fiboost != null && fithrust != null) - { - fiboost.SetValue(jet, (object)(oldbst * (newacc / oldtrst))); - fithrust.SetValue(jet, (object)(newacc)); - } - } - } - public class DebugInput : ModBehaviour - { - private RelativeLocationData relconstr(Vector3 body_position, Quaternion body_rotation, Vector3 body_velocity, OWRigidbody relativeBody, Transform relativeTransform = null) - { - if (relativeTransform == null) - { - relativeTransform = relativeBody.transform; - } - RelativeLocationData res = new RelativeLocationData(Locator.GetPlayerBody(), relativeBody); - res.localPosition = relativeTransform.InverseTransformPoint(body_position); - res.localRotation = Quaternion.Inverse(relativeTransform.rotation) * body_rotation; - res.localRelativeVelocity = relativeTransform.InverseTransformDirection(body_velocity - relativeBody.GetPointVelocity(body_position)); - return res; - } - - public static IModConsole console; - public static IModLogger logger; - - private void Start() - { - ModHelper.Console.WriteLine("TAICheat ready!"); - } - - public override void Configure(IModConfig config) - { - console = ModHelper.Console; - logger = ModHelper.Logger; - if (inputs != null) - { - foreach (string key in inputs.Keys) - { - ModHelper.Input.UnregisterCombination(inputs[key]); - } - } - inputs = new Dictionary(); - foreach (string name in config.Settings.Keys) - { - if (config.GetSettingsValue(name) != null) - { - var combination = ModHelper.Input.RegisterCombination(this, name, config.GetSettingsValue(name)); - inputs.Add(name, combination); - } - } - } - - Dictionary inputs; - - private void LateUpdate() - { - if (_playerController != null) - this._gForce = this._playerController.GetNormalAccelerationScalar(); - } - - private void OnGUI() - { - if (_playerController == null || _playerForceDetector == null) - { - this._playerForceDetector = Locator.GetPlayerForceDetector(); - this._playerController = Locator.GetPlayerController(); - if (_playerController == null || _playerForceDetector == null) return; - } - float num = 400f; - if (GUIMode.IsHiddenMode() || PlayerState.UsingShipComputer()) - { - return; - } - if (inputHUD == 1) - { - GUI.Label(new Rect(10f + num, 10f, 200f, 20f), "Time Scale: " + Mathf.Round(Time.timeScale * 100f) / 100f); - GUI.Label(new Rect(10f + num, 25f, 200f, 20f), string.Concat(new object[] - { - "Time Remaining: ", - Mathf.Floor(TimeLoop.GetSecondsRemaining() / 60f), - ":", - Mathf.Round(TimeLoop.GetSecondsRemaining() % 60f * 100f / 100f) - })); - GUI.Label(new Rect(10f + num, 40f, 200f, 20f), "Loop Count: " + TimeLoop.GetLoopCount()); - GUI.Label(new Rect(10f + num, 55f, 90f, 40f), "PauseFlags: "); - GUI.Label(new Rect(100f + num, 55f, 50f, 40f), "MENU\n" + ((!OWTime.IsPaused(OWTime.PauseType.Menu)) ? "FALSE" : "TRUE ")); - GUI.Label(new Rect(150f + num, 55f, 50f, 40f), "LOAD\n" + ((!OWTime.IsPaused(OWTime.PauseType.Loading)) ? "FALSE" : "TRUE ")); - GUI.Label(new Rect(200f + num, 55f, 50f, 40f), "READ\n" + ((!OWTime.IsPaused(OWTime.PauseType.Reading)) ? "FALSE" : "TRUE ")); - GUI.Label(new Rect(250f + num, 55f, 50f, 40f), "SLP\n" + ((!OWTime.IsPaused(OWTime.PauseType.Sleeping)) ? "FALSE" : "TRUE ")); - GUI.Label(new Rect(300f + num, 55f, 50f, 40f), "INIT\n" + ((!OWTime.IsPaused(OWTime.PauseType.Initializing)) ? "FALSE" : "TRUE ")); - GUI.Label(new Rect(350f + num, 55f, 50f, 40f), "STRM\n" + ((!OWTime.IsPaused(OWTime.PauseType.Streaming)) ? "FALSE" : "TRUE ")); - GUI.Label(new Rect(400f + num, 55f, 50f, 40f), "SYS\n" + ((!OWTime.IsPaused(OWTime.PauseType.System)) ? "FALSE" : "TRUE ")); - GUI.Label(new Rect(10f + num, 85f, 200f, 20f), "Input Mode: " + OWInput.GetInputMode().ToString()); - this._inputModeArray = OWInput.GetInputModeStack(); - GUI.Label(new Rect(10f + num, 100f, 200f, 20f), "Input Mode Stack: "); - int num2 = 150; - int num3 = 0; - while (num3 < this._inputModeArray.Length && this._inputModeArray[num3] != InputMode.None) - { - GUI.Label(new Rect((float)num2 + num, 100f, 200f, 20f), this._inputModeArray[num3].ToString()); - num2 += 75; - num3++; - } - GUI.Label(new Rect(10f + num, 115f, 300f, 20f), "Net Force Accel: " + Mathf.Round(this._playerForceDetector.GetForceAcceleration().magnitude * 100f) / 100f); - GUI.Label(new Rect(210f + num, 115f, 300f, 20f), "G-Force: " + Mathf.Round(this._gForce * 100f) / 100f); - GUI.Label(new Rect(10f + num, 130f, 200f, 20f), "Load Time: " + LoadTimeTracker.GetLatestLoadTime()); - if (DynamicResolutionManager.isEnabled) - { - GUI.Label(new Rect(10f + num, 145f, 200f, 20f), "Resolution Scale: " + DynamicResolutionManager.currentResolutionScale); - } - GUI.Label(new Rect(10f + num, 160f, 200f, 20f), "Player Speed: " + (Locator.GetCenterOfTheUniverse().GetOffsetVelocity() + Locator.GetPlayerBody().GetVelocity()).magnitude.ToString()); - GUI.Label(new Rect(210f + num, 160f, 200f, 20f), "Player Accel: " + Locator.GetPlayerBody().GetAcceleration().magnitude.ToString()); - if (Locator.GetPlayerSuit().GetComponent()) - { - GUI.Label(new Rect(10f + num, 175f, 200f, 20f), string.Concat(new object[] - { - "Jetpack Max Accel: ", - Locator.GetPlayerSuit().GetComponent().GetMaxTranslationalThrust().ToString(), - "/", - Locator.GetPlayerSuit().GetComponent().GetBoostMaxThrust().ToString() - })); - } - if (Locator.GetShipBody().GetComponent()) - { - GUI.Label(new Rect(210f + num, 175f, 200f, 20f), "Ship Max Accel: " + Locator.GetShipBody().GetComponent().GetMaxTranslationalThrust().ToString()); - } - GUI.Label(new Rect(10f + num, 190f, 400f, 20f), string.Concat(new object[] - { - "Inspector layer: ", - rayMask, - " ", - LayerMask.LayerToName(rayMask) - })); - if (GetWarpOWRigidbody()) - { - GUI.Label(new Rect(10f + num, 205f, 400f, 20f), string.Concat(new string[] - { - "Warp Body: ", - GetWarpOWRigidbody().gameObject.name, - " layer: ", - GetWarpOWRigidbody().gameObject.layer.ToString(), - " ", - LayerMask.LayerToName(GetWarpOWRigidbody().gameObject.layer) - })); - } - if (hit.collider) - { - GUI.Label(new Rect(10f + num, 220f, 400f, 20f), string.Concat(new string[] - { - "Latest hit layer: ", - hit.collider.gameObject.layer.ToString(), - " ", - LayerMask.LayerToName(hit.collider.gameObject.layer) - })); - GUI.Label(new Rect(10f + num, 235f, 600f, 20f), "Name: " + hit.collider.gameObject.name + " Distance: " + (hit.point - Locator.GetPlayerBody().transform.position).magnitude.ToString()); - } - /*if (PadEZ.PadManager.GetActiveController()!=null) - { - GUI.Label(new Rect(10f + num, 250f, 600f, 20f), PadEZ.PadManager.GetActiveController().GetIndex().ToString() + " " + PadEZ.PadManager.GetActiveController().GetPadType().ToString() +" "+ UnityEngine.Input.GetJoystickNames()[PadEZ.PadManager.GetActiveController().GetIndex()]); - }*/ - } - if (inputHUD == 2) - { - GUI.Label(new Rect(10f, 10f, 300f, 2500f), ReadInputManager.ReadCommandInputs(false)); - } - if (inputHUD == 3) - { - GUI.Label(new Rect(0f, 0f, 300f, 2500f), ReadInputManager.ReadCommandInputs(false)); - GUI.Label(new Rect(300f, 0f, 300f, 2500f), ReadInputManager.ReadCommandInputs(true)); - } - if (inputHUD == 4) - { - GUI.Label(new Rect(0f, 0f, 500f, 2500f), ReadInputManager.ReadInputAxes()); - GUI.Label(new Rect(500f, 0f, 500f, 2500f), ReadInputManager.ReadRawInputManagerButtons()); - } - } - - private ForceDetector _playerForceDetector; - private PlayerCharacterController _playerController; - private InputMode[] _inputModeArray; - private MeshRenderer[] _thrusterArrowRenderers; - private float _gForce; - private PlayerSpacesuit playersuit; - - private void FixedUpdate() - { - if (this._gotoWarpPointNextFrame) - { - this._gotoWarpPointNextFrame = false; - Locator.GetPlayerBody().MoveToRelativeLocation(_relativeData[relIndex], _relativeBody[relIndex], null); - } - if (this._engageLudicrousSpeed) - { - this._engageLudicrousSpeed = false; - Locator.GetShipBody().AddVelocityChange(Locator.GetShipBody().transform.forward * this.ludicrousMult * 25000f); - } - } - - private void Update() - { - this.shiftPressed = global::Input.GetKey(KeyCode.LeftShift) || global::Input.GetKey(KeyCode.RightShift); - this.ctrlPressed = global::Input.GetKey(KeyCode.LeftControl) || global::Input.GetKey(KeyCode.RightControl); - this.altPressed = global::Input.GetKey(KeyCode.LeftAlt) || global::Input.GetKey(KeyCode.RightAlt); - if (global::Input.GetKeyDown(KeyCode.BackQuote)) - { - cheatsOn = !cheatsOn; - if (cheatsOn) - AudioSource.PlayClipAtPoint(Locator.GetAudioManager().GetAudioClipArray(global::AudioType.NomaiPowerOn)[0], Locator.GetActiveCamera().transform.position); - else - AudioSource.PlayClipAtPoint(Locator.GetAudioManager().GetAudioClipArray(global::AudioType.NomaiPowerOff)[0], Locator.GetActiveCamera().transform.position); - } - - if (playersuit == null) - playersuit = Locator.GetPlayerSuit(); - if (playersuit == null) - return; - if (!playersuit.enabled) - playersuit = Locator.GetPlayerSuit(); - if (playersuit == null || !playersuit.enabled) - return; - if (cheatsOn) - { - /*if (global::Input.GetKeyDown(DebugKeyCode.destroyTimeline)) - { - Debug.Log("Try DestroyTimeline (Requires NomaiExperimentBlackHole)"); - GlobalMessenger.FireEvent("DebugTimelineDestroyed"); - } - if (global::Input.GetKeyDown(DebugKeyCode.uiTestAndSuicide)) - { - Locator.GetPlayerTransform().GetComponent().SetDebugKillResources(true); - } - if (global::Input.GetKeyUp(DebugKeyCode.uiTestAndSuicide)) - { - Locator.GetPlayerTransform().GetComponent().SetDebugKillResources(false); - }*/ - if (ModHelper.Input.IsNewlyPressed(inputs["(tele) Save probe's pos"])) - { - if (Locator.GetProbe().GetAnchor().IsAnchored()) - { - Transform transform = Locator.GetProbe().transform; - _relativeBody[relIndex] = transform.parent.GetAttachedOWRigidbody(false); - _relativeData[relIndex] = new RelativeLocationData(Locator.GetProbe().GetAnchor().GetAttachedOWRigidbody(), _relativeBody[relIndex], null); - this.COn = true; - } - } - if (ModHelper.Input.IsNewlyPressed(inputs["(tele) Save RayCast pos"])) - { - OWCamera activeCamera = Locator.GetActiveCamera(); - Vector3 position = new Vector3((float)(activeCamera.pixelWidth - 1) / 2f, (float)(activeCamera.pixelHeight - 1) / 2f); - if (!Physics.Raycast(activeCamera.ScreenPointToRay(position), out hit, float.PositiveInfinity, OWLayerMask.BuildPhysicalMask().value)) - { - foreach (RaycastHit raycastHit in Physics.RaycastAll(activeCamera.ScreenPointToRay(position), float.PositiveInfinity, OWLayerMask.BuildPhysicalMask().value | 524288)) - { - hit = raycastHit; - if (raycastHit.collider.GetAttachedOWRigidbody(false)) - { - break; - } - } - if (!hit.collider.GetAttachedOWRigidbody(false)) - { - foreach (RaycastHit raycastHit2 in Physics.RaycastAll(activeCamera.ScreenPointToRay(position))) - { - hit = raycastHit2; - if (raycastHit2.collider.GetAttachedOWRigidbody(false)) - { - break; - } - } - } - } - if (hit.collider.GetAttachedOWRigidbody(false)) - { - _hasSetWarpPoint[relIndex] = true; - _relativeBody[relIndex] = hit.rigidbody.GetAttachedOWRigidbody(false); - _relativeData[relIndex] = relconstr(hit.point, Quaternion.FromToRotation(Locator.GetPlayerBody().transform.up, hit.normal) * Locator.GetPlayerBody().transform.rotation, _relativeBody[relIndex].GetPointVelocity(hit.point), _relativeBody[relIndex], null); - this.COn = true; - } - } - if (ModHelper.Input.IsNewlyPressed(inputs["(tele) Save player's pos"]) && Locator.GetPlayerSectorDetector().GetLastEnteredSector() != null) - { - _hasSetWarpPoint[relIndex] = true; - _relativeBody[relIndex] = Locator.GetPlayerSectorDetector().GetLastEnteredSector().GetOWRigidbody(); - _relativeData[relIndex] = new RelativeLocationData(Locator.GetPlayerBody(), _relativeBody[relIndex], null); - this.COn = true; - } - if (ModHelper.Input.IsNewlyPressed(inputs["(insp) Cycle through layers"])) - { - rayMask++; - rayMask %= 32; - } - if (ModHelper.Input.IsNewlyPressed(inputs["(insp) RayCast"])) - { - OWCamera activeCamera2 = Locator.GetActiveCamera(); - Vector3 position2 = new Vector3((float)(activeCamera2.pixelWidth - 1) / 2f, (float)(activeCamera2.pixelHeight - 1) / 2f); - if (!Physics.Raycast(activeCamera2.ScreenPointToRay(position2), out hit, float.PositiveInfinity, 1 << rayMask) && hit.collider.GetAttachedOWRigidbody(false)) - { - _hasSetWarpPoint[relIndex] = true; - _relativeBody[relIndex] = hit.rigidbody.GetAttachedOWRigidbody(false); - _relativeData[relIndex] = relconstr(hit.point, Quaternion.FromToRotation(Locator.GetPlayerBody().transform.up, hit.normal) * Locator.GetPlayerBody().transform.rotation, _relativeBody[relIndex].GetPointVelocity(hit.point), _relativeBody[relIndex], null); - this.COn = true; - } - } - if (ModHelper.Input.IsNewlyPressed(inputs["(tele) Cycle through pos"])) - { - this.COn = true; - relIndex++; - relIndex %= 10; - } - if (ModHelper.Input.IsNewlyPressed(inputs["(tele) Tele to saved pos"]) && _hasSetWarpPoint[relIndex]) - { - this.COn = true; - this._gotoWarpPointNextFrame = true; - } - if (ModHelper.Input.IsNewlyPressed(inputs["Learn launchcode"])) - { - if (PlayerData.IsLoaded()) - { - PlayerData.LearnLaunchCodes(); - this.COn = true; - } - } - if (ModHelper.Input.IsNewlyPressed(inputs["Toggle spacesuit"])) - { - if (!Locator.GetPlayerSuit().IsWearingSuit(true)) - { - Locator.GetPlayerSuit().SuitUp(false, false); - this.COn = true; - } - else - { - Locator.GetPlayerSuit().RemoveSuit(false); - this.COff = true; - } - } - if (ModHelper.Input.IsNewlyPressed(inputs["Toggle HUD"])) - { - hiddenHUD = !hiddenHUD; - if (hiddenHUD) - { - oldmode = (int)typeof(GUIMode).GetAnyField("_renderMode").GetValue(null); - typeof(GUIMode).GetAnyField("_renderMode").SetValue(null, 7); - this.COn = true; - } - else - { - typeof(GUIMode).GetAnyField("_renderMode").SetValue(null, oldmode); - this.COff = true; - } - GlobalMessenger.FireEvent("OnChangeGUIMode"); - } - if (ModHelper.Input.IsNewlyPressed(inputs["Toggle helmet"]) && Locator.GetPlayerSuit() && Locator.GetPlayerSuit().IsWearingSuit(true)) - { - if (Locator.GetPlayerSuit().IsWearingHelmet()) - { - Locator.GetPlayerSuit().RemoveHelmet(); - this.COff = true; - } - else - { - Locator.GetPlayerSuit().PutOnHelmet(); - this.COn = true; - } - } - if (ModHelper.Input.IsNewlyPressed(inputs["Destroy ship"]) && Locator.GetShipTransform()) - { - UnityEngine.Object.Destroy(Locator.GetShipTransform().gameObject); - this.COn = true; - } - if (ModHelper.Input.IsNewlyPressed(inputs["Damage ship"]) && Locator.GetShipTransform()) - { - ShipComponent[] componentsInChildren = Locator.GetShipTransform().GetComponentsInChildren(); - for (int k = 0; k < componentsInChildren.Length; k++) - { - componentsInChildren[k].SetDamaged(true); - } - this.COn = true; - } - if (ModHelper.Input.IsNewlyPressed(inputs["Fuel+heal"])) - { - Locator.GetPlayerTransform().GetComponent().DebugRefillResources(); - if (Locator.GetShipTransform()) - { - ShipComponent[] componentsInChildren2 = Locator.GetShipTransform().GetComponentsInChildren(); - for (int l = 0; l < componentsInChildren2.Length; l++) - { - componentsInChildren2[l].SetDamaged(false); - } - } - this.COn = true; - } - if (ModHelper.Input.IsPressed(inputs["Increase Ludicrous Speed"])) - { - this.ludicrousMult *= 2f; - this.COn = true; - } - if (ModHelper.Input.IsPressed(inputs["Decrease Ludicrous Speed"])) - { - this.ludicrousMult /= 2f; - this.COff = true; - } - if (ModHelper.Input.IsNewlyPressed(inputs["Engage Ludicrous Speed"])) - { - this._engageLudicrousSpeed = true; - AudioSource.PlayClipAtPoint(Locator.GetAudioManager().GetAudioClipArray(global::AudioType.ToolProbeLaunch)[0], Locator.GetPlayerBody().transform.position); - } - if (ModHelper.Input.IsNewlyPressed(inputs["Toggle superjetpack"]) && Locator.GetPlayerSuit().GetComponent()) - { - if (!this.wasBoosted) - { - this.jetpackStanard = Locator.GetPlayerSuit().GetComponent().GetMaxTranslationalThrust(); - Locator.GetPlayerSuit().GetComponent().TAIcheat_SetTranslationalThrust(50f); - } - else - { - Locator.GetPlayerSuit().GetComponent().TAIcheat_SetTranslationalThrust(this.jetpackStanard); - } - this.wasBoosted = !this.wasBoosted; - if (this.wasBoosted) - { - this.COn = true; - } - else - { - this.COff = true; - } - } - if (ModHelper.Input.IsNewlyPressed(inputs["Toggle PowerOverwhelming"])) - { - Locator.GetPlayerTransform().GetComponent().ToggleInvincibility(); - Locator.GetDeathManager().ToggleInvincibility(); - Transform shipTransform = Locator.GetShipTransform(); - if (shipTransform) - { - shipTransform.GetComponentInChildren().ToggleInvincibility(); - invincible = !invincible; - } - if (invincible) - { - this.COn = true; - } - else - { - this.COff = true; - } - } - if (ModHelper.Input.IsNewlyPressed(inputs["Learn all frequencies"])) - { - if (PlayerData.KnowsMultipleFrequencies()) - { - PlayerData.ForgetFrequency(SignalFrequency.Quantum); - PlayerData.ForgetFrequency(SignalFrequency.EscapePod); - PlayerData.ForgetFrequency(SignalFrequency.Statue); - PlayerData.ForgetFrequency(SignalFrequency.WarpCore); - PlayerData.ForgetFrequency(SignalFrequency.HideAndSeek); - this.COff = true; - } - else - { - this.COn = true; - for (int m = 10; m < 16; m++) - { - PlayerData.LearnSignal((SignalName)m); - } - PlayerData.LearnFrequency(SignalFrequency.Quantum); - for (int n = 20; n < 26; n++) - { - PlayerData.LearnSignal((SignalName)n); - } - PlayerData.LearnFrequency(SignalFrequency.EscapePod); - for (int num = 30; num < 33; num++) - { - PlayerData.LearnSignal((SignalName)num); - } - PlayerData.LearnFrequency(SignalFrequency.Statue); - PlayerData.LearnFrequency(SignalFrequency.WarpCore); - for (int num2 = 40; num2 < 50; num2++) - { - PlayerData.LearnSignal((SignalName)num2); - } - PlayerData.LearnFrequency(SignalFrequency.HideAndSeek); - for (int num3 = 60; num3 < 63; num3++) - { - PlayerData.LearnSignal((SignalName)num3); - } - } - } - if (ModHelper.Input.IsNewlyPressed(inputs["Reveal all facts"])) - { - Locator.GetShipLogManager().RevealAllFacts(this._revealRumorsOnly); - this._revealRumorsOnly = false; - this.COn = true; - } - if (ModHelper.Input.IsNewlyPressed(inputs["Cycle DebugHUD"])) - { - inputHUD++; - inputHUD %= 5; - } - if (ModHelper.Input.IsNewlyPressed(inputs["Toggle player collision extra"])) - { - if (Locator.GetPlayerBody().GetRequiredComponent().detectCollisions) - { - Locator.GetPlayerBody().DisableCollisionDetection(); - this.COn = true; - } - else - { - Locator.GetPlayerBody().EnableCollisionDetection(); - this.COff = true; - } - } - if (ModHelper.Input.IsNewlyPressed(inputs["Toggle player collision"])) - { - foreach (Collider collider in Locator.GetPlayerBody().GetComponentsInChildren()) - { - if (!collider.isTrigger) - { - collider.enabled = !collider.enabled; - if (collider.enabled) - { - this.COff = true; - } - else - { - this.COn = true; - } - } - } - } - if (ModHelper.Input.IsNewlyPressed(inputs["Toggle ship collision extra"])) - { - if (Locator.GetShipBody().GetRequiredComponent().detectCollisions) - { - Locator.GetShipBody().DisableCollisionDetection(); - this.COn = true; - } - else - { - Locator.GetShipBody().EnableCollisionDetection(); - this.COff = true; - } - } - if (ModHelper.Input.IsNewlyPressed(inputs["Toggle ship collision"])) - { - foreach (Collider collider2 in Locator.GetShipTransform().GetComponentsInChildren()) - { - if (!collider2.isTrigger) - { - collider2.enabled = !collider2.enabled; - if (collider2.enabled) - { - this.COff = true; - } - else - { - this.COn = true; - } - } - } - } - if (ModHelper.Input.IsNewlyPressed(inputs["Disable nearby Anglerfishes"])) - { - foreach (AnglerfishController anglerfishController in UnityEngine.Object.FindObjectsOfType()) - { - anglerfishController.gameObject.SetActive(!anglerfishController.gameObject.activeInHierarchy); - if (anglerfishController.gameObject.activeInHierarchy) - { - this.COff = true; - } - else - { - this.COn = true; - } - } - } - if (ModHelper.Input.IsNewlyPressed(inputs["Toggle nearby Anglerfishes AI"])) - { - - foreach (AnglerfishController anglerfishController in UnityEngine.Object.FindObjectsOfType()) - { - anglerfishController.enabled = !anglerfishController.enabled; - if (anglerfishController.enabled) - { - this.COff = true; - } - else - { - this.COn = true; - } - } - } - } - if (ModHelper.Input.IsNewlyPressed(inputs["Break all BH fragments"])) - { - this.COn = true; - FragmentIntegrity[] array2 = UnityEngine.Object.FindObjectsOfType(); - for (int j = 0; j < array2.Length; j++) - { - array2[j].AddDamage(10000f); - } - } - if (ModHelper.Input.IsNewlyPressed(inputs["Trigger Supernova"])) - { - this.COn = true; - GlobalMessenger.FireEvent("TriggerSupernova"); - } - if (ModHelper.Input.IsNewlyPressed(inputs["Debug Vessel Warp"])) - { - if (PlayerData.GetWarpedToTheEye()) PlayerData.SaveEyeCompletion(); - else GlobalMessenger.FireEvent("DebugWarpVessel"); - this.COn = true; - } - if (Mathf.Abs(Time.timeScale - 1f) < 1e-4 || Mathf.Abs(Time.timeScale - 10f) < 1e-4) - { - if (ModHelper.Input.IsNewlyPressed(inputs["Timelapse"])) - { - Time.timeScale = 10f; - } - else if (Mathf.Abs(Time.timeScale - 1f) > 1e-4 && !ModHelper.Input.IsPressed(inputs["Timelapse"])) - { - Time.timeScale = 1f; - } - } - - if (this.COn) - { - AudioClip[] audioClipArray = Locator.GetAudioManager().GetAudioClipArray(global::AudioType.Menu_Confirm); - AudioSource.PlayClipAtPoint(audioClipArray[UnityEngine.Random.Range(0, audioClipArray.Length)], Locator.GetActiveCamera().transform.position); - this.COn = false; - } - if (this.COff) - { - AudioClip[] audioClipArray2 = Locator.GetAudioManager().GetAudioClipArray(global::AudioType.Menu_Cancel); - AudioSource.PlayClipAtPoint(audioClipArray2[UnityEngine.Random.Range(0, audioClipArray2.Length)], Locator.GetActiveCamera().transform.position); - this.COff = false; - } - } - - public OWRigidbody GetWarpOWRigidbody() - { - return _relativeBody[relIndex]; - } - - private bool altPressed, shiftPressed, ctrlPressed; - private bool cheatsOn; - private bool COff, COn, CMOn, CMOff; - - private bool _revealRumorsOnly = true; - - private bool _engageLudicrousSpeed; - private float ludicrousMult = 1f; - - private bool invincible = false; - - private bool wasBoosted; - private float jetpackStanard = 6f; - - - private bool _gotoWarpPointNextFrame; - private RelativeLocationData[] _relativeData = new RelativeLocationData[10]; - private OWRigidbody[] _relativeBody = new OWRigidbody[10]; - private bool[] _hasSetWarpPoint = new bool[10]; - private int relIndex; - private RaycastHit hit; - private int rayMask; - - private int oldmode; - private bool hiddenHUD; - private int inputHUD = 0; - } -} diff --git a/TAIcheat/TAIcheat.csproj b/TAIcheat/TAIcheat.csproj deleted file mode 100644 index e1ac530ce..000000000 --- a/TAIcheat/TAIcheat.csproj +++ /dev/null @@ -1,109 +0,0 @@ - - - - - Debug - AnyCPU - {999B196E-ECFE-4AC2-84D8-EFBCA6B0C2C4} - Library - Properties - TAIcheat - TAIcheat - v3.5 - 512 - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\..\..\..\Games\Outer Wilds\OuterWilds_Data\Managed\0Harmony.dll - - - ..\packages\OW.Unity.Dlls.1.0.7\lib\net35\Assembly-CSharp.dll - - - ..\packages\OW.Unity.Dlls.1.0.7\lib\net35\OW.Unity.Dlls.dll - - - - - - - - - ..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.dll - - - ..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.AudioModule.dll - - - ..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.CoreModule.dll - - - ..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.IMGUIModule.dll - - - ..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.PhysicsModule.dll - - - ..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.TextRenderingModule.dll - - - ..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.UI.dll - - - ..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.UIModule.dll - - - ..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.UnityWebRequestWWWModule.dll - - - - - - - - - {3c00626f-b688-4f32-b493-5b7ec1c879a0} - OWML.Common - - - {b771615e-6b51-44f8-b862-d7543c12c0ff} - OWML.ModHelper.Events - - - {be89bac0-91ff-4558-b093-79328d18ab30} - OWML.ModHelper.Input - - - {b874cc24-8340-4238-ac9d-1bfb41186bb5} - OWML.ModHelper.Menus - - - {cb57bab8-d70e-4fce-9bf1-328a924173a7} - OWML.ModHelper - - - - - - - - - \ No newline at end of file diff --git a/TAIcheat/default-config.json b/TAIcheat/default-config.json deleted file mode 100644 index 9d513356d..000000000 --- a/TAIcheat/default-config.json +++ /dev/null @@ -1,138 +0,0 @@ -{ - "enabled": true, - "requireVR": false, - "settings": { - "(tele) Save probe's pos": { - "type": "input", - "value": "PageDown+LeftShift/PageDown+RightShift" - }, - "(tele) Save RayCast pos": { - "type": "input", - "value": "PageDown+LeftAlt/PageDown+RightAlt" - }, - "(tele) Save player's pos": { - "type": "input", - "value": "PageDown" - }, - "(tele) Cycle through pos": { - "type": "input", - "value": "PageUp+LeftAlt/PageUp+RightAlt" - }, - "(tele) Tele to saved pos": { - "type": "input", - "value": "PageUp" - }, - "(insp) RayCast": { - "type": "input", - "value": "Home" - }, - "(insp) Cycle through layers": { - "type": "input", - "value": "LeftAlt+Home/RightAlt+Home" - }, - "Toggle spacesuit": { - "type": "input", - "value": "G" - }, - "Learn launchcode": { - "type": "input", - "value": "LeftAlt+G/RightAlt+G" - }, - "Toggle helmet": { - "type": "input", - "value": "H" - }, - "Toggle HUD": { - "type": "input", - "value": "LeftAlt+H/RightAlt+H" - }, - "Fuel+heal": { - "type": "input", - "value": "J" - }, - "Damage ship": { - "type": "input", - "value": "LeftAlt+J/RightAlt+J" - }, - "Destroy ship": { - "type": "input", - "value": "LeftAlt+LeftShift+J/RightAlt+RightShift+J" - }, - "Engage Ludicrous Speed": { - "type": "input", - "value": "L" - }, - "Increase Ludicrous Speed": { - "type": "input", - "value": "LeftShift+L/RightShift+L" - }, - "Decrease Ludicrous Speed": { - "type": "input", - "value": "LeftAlt+L/RightAlt+L" - }, - "Toggle PowerOverwhelming": { - "type": "input", - "value": "P" - }, - "Toggle superjetpack": { - "type": "input", - "value": "LeftAlt+P/RightAlt+P" - }, - "Cycle DebugHUD": { - "type": "input", - "value": "Backslash" - }, - "Reveal all facts": { - "type": "input", - "value": "O" - }, - "Learn all frequencies": { - "type": "input", - "value": "LeftAlt+O/RightAlt+O" - }, - "Trigger Supernova": { - "type": "input", - "value": "Delete" - }, - "Break all BH fragments": { - "type": "input", - "value": "LeftAlt+Delete/RightAlt+Delete" - }, - "Timelapse": { - "type": "input", - "value": "Equals" - }, - "Suicide": { - "type": "input", - "value": "Minus" - }, - "Toggle nearby Anglerfishes AI": { - "type": "input", - "value": "K" - }, - "Disable nearby Anglerfishes": { - "type": "input", - "value": "LeftAlt+K/RightAlt+K" - }, - "Toggle player collision": { - "type": "input", - "value": "N" - }, - "Toggle player collision extra": { - "type": "input", - "value": "LeftAlt+N/RightAlt+N" - }, - "Toggle ship collision": { - "type": "input", - "value": "M" - }, - "Toggle ship collision extra": { - "type": "input", - "value": "LeftAlt+M/RightAlt+M" - }, - "Debug Vessel Warp": { - "type": "input", - "value": "E+U" - } - } -} \ No newline at end of file diff --git a/TAIcheat/manifest.json b/TAIcheat/manifest.json deleted file mode 100644 index 1ec89912d..000000000 --- a/TAIcheat/manifest.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "filename": "TAICheat.dll", - "author": "TAImatem", - "name": "TAICheat", - "uniqueName": "TruAI.TAICheat", - "version": "0.9-alpha", - "owmlVersion": "0.3.46" -} \ No newline at end of file diff --git a/TAIcheat/packages.config b/TAIcheat/packages.config deleted file mode 100644 index f38d13b9b..000000000 --- a/TAIcheat/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file From e06a17c12befdd444c833fdc7c39cd55d6ad6833 Mon Sep 17 00:00:00 2001 From: Aleksandr Date: Sun, 28 Jun 2020 23:33:40 +0500 Subject: [PATCH 2/9] removed TAIcheat lines from createrelease (#132) --- createrelease.bat | 5 ----- 1 file changed, 5 deletions(-) diff --git a/createrelease.bat b/createrelease.bat index d920e4efe..6d95177a7 100644 --- a/createrelease.bat +++ b/createrelease.bat @@ -33,11 +33,6 @@ copy "OWML.SampleMods\OWML.EnableDebugMode\bin\Debug\OWML.EnableDebugMode.dll" " copy "OWML.SampleMods\OWML.EnableDebugMode\bin\Debug\manifest.json" "Release\Mods\OWML.EnableDebugMode\manifest.json" copy "OWML.SampleMods\OWML.EnableDebugMode\bin\Debug\default-config.json" "Release\Mods\OWML.EnableDebugMode\default-config.json" -mkdir "Release\Mods\TAIcheat" -copy "TAIcheat\bin\Debug\TAIcheat.dll" "Release\Mods\TAIcheat\TAIcheat.dll" -copy "TAIcheat\manifest.json" "Release\Mods\TAIcheat\manifest.json" -copy "TAIcheat\default-config.json" "Release\Mods\TAIcheat\default-config.json" - mkdir "Release\Mods\OWML.LoadCustomAssets" copy "OWML.SampleMods\OWML.LoadCustomAssets\bin\Debug\OWML.LoadCustomAssets.dll" "Release\Mods\OWML.LoadCustomAssets\OWML.LoadCustomAssets.dll" copy "OWML.SampleMods\OWML.LoadCustomAssets\bin\Debug\manifest.json" "Release\Mods\OWML.LoadCustomAssets\manifest.json" From 1261fc713e1d1c151d622eb0f5a63a9eab819161 Mon Sep 17 00:00:00 2001 From: AmazingAlek Date: Sun, 28 Jun 2020 22:11:55 +0200 Subject: [PATCH 3/9] Asset object fix (#134) * fixed loading of object assets --- OWML.ModHelper.Assets/ModAssets.cs | 3 ++- OWML.ModHelper.Assets/ObjectAsset.cs | 23 +++++++++++++++++++ .../OWML.LoadCustomAssets/LoadCustomAssets.cs | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/OWML.ModHelper.Assets/ModAssets.cs b/OWML.ModHelper.Assets/ModAssets.cs index 80ca911e2..e23247469 100644 --- a/OWML.ModHelper.Assets/ModAssets.cs +++ b/OWML.ModHelper.Assets/ModAssets.cs @@ -93,7 +93,7 @@ private IEnumerator LoadMesh(ObjectAsset modAsset, string objectPath) var meshFilter = modAsset.AddComponent(); meshFilter.mesh = mesh; yield return new WaitForEndOfFrame(); - modAsset.SetAsset(modAsset.gameObject); + modAsset.SetMeshFilter(meshFilter); } private IEnumerator LoadTexture(ObjectAsset modAsset, string imagePath) @@ -111,6 +111,7 @@ private IEnumerator LoadTexture(ObjectAsset modAsset, string imagePath) } var meshRenderer = modAsset.AddComponent(); meshRenderer.material.mainTexture = texture; + modAsset.SetMeshRenderer(meshRenderer); } private IEnumerator LoadMesh(MeshAsset modAsset, string objectPath) diff --git a/OWML.ModHelper.Assets/ObjectAsset.cs b/OWML.ModHelper.Assets/ObjectAsset.cs index 659010f39..349e8d90f 100644 --- a/OWML.ModHelper.Assets/ObjectAsset.cs +++ b/OWML.ModHelper.Assets/ObjectAsset.cs @@ -4,5 +4,28 @@ namespace OWML.ModHelper.Assets { public class ObjectAsset : ModAsset { + private MeshRenderer _meshRenderer; + private MeshFilter _meshFilter; + + public void SetMeshRenderer(MeshRenderer meshRenderer) + { + _meshRenderer = meshRenderer; + SetAssetIfComplete(); + } + + public void SetMeshFilter(MeshFilter meshFilter) + { + _meshFilter = meshFilter; + SetAssetIfComplete(); + } + + private void SetAssetIfComplete() + { + if (_meshFilter != null && _meshRenderer != null) + { + SetAsset(gameObject); + } + } + } } diff --git a/OWML.SampleMods/OWML.LoadCustomAssets/LoadCustomAssets.cs b/OWML.SampleMods/OWML.LoadCustomAssets/LoadCustomAssets.cs index ccb50d5bf..587977349 100644 --- a/OWML.SampleMods/OWML.LoadCustomAssets/LoadCustomAssets.cs +++ b/OWML.SampleMods/OWML.LoadCustomAssets/LoadCustomAssets.cs @@ -68,6 +68,7 @@ private void OnDuckLoaded(GameObject duck) duck.AddComponent(); duck.AddComponent(); _duckBody = duck.AddComponent(); + duck.SetActive(false); } private void OnEvent(MonoBehaviour behaviour, Events ev) @@ -100,6 +101,7 @@ private void Update() private void ShootDuck() { var duckBody = Instantiate(_duckBody); + duckBody.gameObject.SetActive(true); duckBody.SetPosition(_playerTransform.position + _playerTransform.forward * 2f); duckBody.SetRotation(_playerTransform.rotation); From ea7ca89ac6737c4bcaf52a16a76b5f129c83898b Mon Sep 17 00:00:00 2001 From: Ricardo Lopes Date: Mon, 29 Jun 2020 22:46:19 +0200 Subject: [PATCH 4/9] Clearer errors on patch original method not found (#112) --- OWML.ModHelper.Events/HarmonyHelper.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/OWML.ModHelper.Events/HarmonyHelper.cs b/OWML.ModHelper.Events/HarmonyHelper.cs index 5f8dc4aaa..0f4c1ffe2 100644 --- a/OWML.ModHelper.Events/HarmonyHelper.cs +++ b/OWML.ModHelper.Events/HarmonyHelper.cs @@ -42,16 +42,21 @@ private HarmonyInstance CreateInstance() private MethodInfo GetMethod(string methodName) { var targetType = typeof(T); + MethodInfo result = null; try { _logger.Log($"Getting method {methodName} of {targetType.Name}"); - return targetType.GetAnyMethod(methodName); + result = targetType.GetAnyMethod(methodName); } catch (Exception ex) { _console.WriteLine($"Exception while getting method {methodName} of {targetType.Name}: {ex}"); - return null; } + if (result == null) + { + _console.WriteLine($"Error: Original method {methodName} of class {targetType} not found"); + } + return result; } public void AddPrefix(string methodName, Type patchType, string patchMethodName) From 0df846441027ec5aed5935845e57c94e01710cde Mon Sep 17 00:00:00 2001 From: Ricardo Lopes Date: Mon, 29 Jun 2020 22:46:41 +0200 Subject: [PATCH 5/9] Launch game with OpenVR flag if VR is required (#124) * Launch game with openvr flag if VR is enabled --- OWML.Launcher/App.cs | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/OWML.Launcher/App.cs b/OWML.Launcher/App.cs index ae0b4861a..e04ed595a 100644 --- a/OWML.Launcher/App.cs +++ b/OWML.Launcher/App.cs @@ -21,6 +21,8 @@ public class App private readonly OWPatcher _owPatcher; private readonly VRPatcher _vrPatcher; + private const string VrArgument = " -vrmode openvr"; + public App(IOwmlConfig owmlConfig, IModManifest owmlManifest, IModConsole writer, IModFinder modFinder, OutputListener listener, PathFinder pathFinder, OWPatcher owPatcher, VRPatcher vrPatcher) { @@ -55,9 +57,10 @@ public void Run(string[] args) ShowModList(mods); - PatchGame(mods); + var hasVrMod = HasVrMod(mods); + PatchGame(hasVrMod); - StartGame(args); + StartGame(args, hasVrMod); if (hasPortArgument) { @@ -142,13 +145,18 @@ private void OnOutput(string s) } } - private void PatchGame(IList mods) + private bool HasVrMod(IList mods) { - _owPatcher.PatchGame(); - var vrMod = mods.FirstOrDefault(x => x.Config.RequireVR && x.Config.Enabled); - var enableVR = vrMod != null; - _writer.WriteLine(enableVR ? $"{vrMod.Manifest.UniqueName} requires VR." : "No mods require VR."); + var hasVrMod = vrMod != null; + _writer.WriteLine(hasVrMod ? $"{vrMod.Manifest.UniqueName} requires VR." : "No mods require VR."); + return hasVrMod; + } + + private void PatchGame(bool enableVR) + { + _owPatcher.PatchGame(); + _vrPatcher.PatchVR(enableVR); try { _vrPatcher.PatchVR(enableVR); @@ -159,12 +167,17 @@ private void PatchGame(IList mods) } } - private void StartGame(string[] args) + private void StartGame(string[] args, bool enableVR) { _writer.WriteLine("Starting game..."); try { - Process.Start($"{_owmlConfig.GamePath}/OuterWilds.exe", string.Join(" ", args)); + var gameArgs = string.Join(" ", args); + if (enableVR) + { + gameArgs += VrArgument; + } + Process.Start($"{_owmlConfig.GamePath}/OuterWilds.exe", gameArgs); } catch (Exception ex) { From e567e2b91b7bd5d9acdbab3ac40f891ffcae30be Mon Sep 17 00:00:00 2001 From: AmazingAlek Date: Mon, 29 Jun 2020 22:59:55 +0200 Subject: [PATCH 6/9] Just another cleanup (#133) * cleanup of input, interaction and enabledebugmod * cleaned up menu code * fixed bug in debugmode mod * removed bspatch and sharpziplib Co-authored-by: Ricardo Lopes Co-authored-by: Aleksandr --- OWML.Launcher/OWML.Config.json | 2 +- OWML.Launcher/OWML.Manifest.json | 2 +- OWML.ModHelper.Events/ModEvents.cs | 2 +- OWML.ModHelper.Input/BindingChangeListener.cs | 13 +- OWML.ModHelper.Input/ModInputCombination.cs | 38 ++--- OWML.ModHelper.Input/ModInputHandler.cs | 143 +++++++----------- .../InterfaceProxyBuilder.cs | 28 ++-- .../InterfaceProxyFactory.cs | 24 +-- OWML.ModHelper.Interaction/ModInteraction.cs | 4 - OWML.ModHelper.Menus/ModComboInput.cs | 10 +- OWML.ModHelper.Menus/ModLayoutButton.cs | 17 +-- OWML.Patcher/OWML.Patcher.csproj | 4 - OWML.Patcher/VR/ICSharpCode.SharpZipLib.dll | Bin 200704 -> 0 bytes .../OWML.EnableDebugMode/EnableDebugMode.cs | 11 +- .../OWML.EnableDebugMode/manifest.json | 2 +- .../OWML.LoadCustomAssets/manifest.json | 2 +- OWML.sln.DotSettings | 6 +- createrelease.bat | 2 - 18 files changed, 143 insertions(+), 167 deletions(-) delete mode 100644 OWML.Patcher/VR/ICSharpCode.SharpZipLib.dll diff --git a/OWML.Launcher/OWML.Config.json b/OWML.Launcher/OWML.Config.json index 49b33d214..67380528b 100644 --- a/OWML.Launcher/OWML.Config.json +++ b/OWML.Launcher/OWML.Config.json @@ -1,5 +1,5 @@ { "gamePath": "C:/Program Files/Epic Games/OuterWilds", "verbose": false, - "combinationsBlockInput" : false + "combinationsBlockInput": false } diff --git a/OWML.Launcher/OWML.Manifest.json b/OWML.Launcher/OWML.Manifest.json index 93c8391d0..718fa8683 100644 --- a/OWML.Launcher/OWML.Manifest.json +++ b/OWML.Launcher/OWML.Manifest.json @@ -2,6 +2,6 @@ "author": "Alek", "name": "OWML", "uniqueName": "Alek.OWML", - "version": "0.3.57", + "version": "0.3.58", "description": "The mod loader and mod framework for Outer Wilds" } diff --git a/OWML.ModHelper.Events/ModEvents.cs b/OWML.ModHelper.Events/ModEvents.cs index fa84a336b..8256a67e3 100644 --- a/OWML.ModHelper.Events/ModEvents.cs +++ b/OWML.ModHelper.Events/ModEvents.cs @@ -56,7 +56,7 @@ private void SubscribeToEvent(Common.Events ev) var type = typeof(T); if (IsSubscribedTo(type, ev)) { - _console.WriteLine($"Warning: already subscribed to {ev} of {type.Name}"); + _logger.Log($"Already subscribed to {ev} of {type.Name}"); return; } AddToEventList(_subscribedEvents, type, ev); diff --git a/OWML.ModHelper.Input/BindingChangeListener.cs b/OWML.ModHelper.Input/BindingChangeListener.cs index e467cf19b..1af6c104e 100644 --- a/OWML.ModHelper.Input/BindingChangeListener.cs +++ b/OWML.ModHelper.Input/BindingChangeListener.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.ObjectModel; -using System.Collections.Generic; -using OWML.Common; +using OWML.Common; using UnityEngine; namespace OWML.ModHelper.Input @@ -14,13 +11,13 @@ public class BindingChangeListener : MonoBehaviour internal void Initialize(ModInputHandler inputHandler, IModEvents events) { _inputHandler = inputHandler; - events.Subscribe(Common.Events.AfterStart); + events.Subscribe(Events.AfterStart); events.OnEvent += OnEvent; } - private void OnEvent(MonoBehaviour behaviour, Common.Events ev) + private void OnEvent(MonoBehaviour behaviour, Events ev) { - if (behaviour.GetType() == typeof(TitleScreenManager) && ev == Common.Events.AfterStart) + if (behaviour.GetType() == typeof(TitleScreenManager) && ev == Events.AfterStart) { _updateInputsNext = true; } @@ -29,7 +26,7 @@ private void OnEvent(MonoBehaviour behaviour, Common.Events ev) private void Start() { DontDestroyOnLoad(gameObject); - GlobalMessenger.AddListener("KeyBindingsChanged", new Callback(PrepareForUpdate)); + GlobalMessenger.AddListener("KeyBindingsChanged", PrepareForUpdate); } private void PrepareForUpdate() diff --git a/OWML.ModHelper.Input/ModInputCombination.cs b/OWML.ModHelper.Input/ModInputCombination.cs index 6ca5bc96c..e97521047 100644 --- a/OWML.ModHelper.Input/ModInputCombination.cs +++ b/OWML.ModHelper.Input/ModInputCombination.cs @@ -24,8 +24,8 @@ public class ModInputCombination : IModInputCombination private bool _isPressed; private float _firstPressedMoment; - private List _singles = new List(); - private List _hashes = new List(); + private readonly List _singles = new List(); + private readonly List _hashes; internal ModInputCombination(IModManifest mod, string name, string combination) { @@ -36,17 +36,15 @@ internal ModInputCombination(IModManifest mod, string name, string combination) private KeyCode StringToKeyCodeKeyboard(string keyboardKey) { - if (keyboardKey == "control" || keyboardKey == "ctrl") + switch (keyboardKey) { - return KeyCode.LeftControl; - } - if (keyboardKey == "shift") - { - return KeyCode.LeftShift; - } - if (keyboardKey == "alt") - { - return KeyCode.LeftAlt; + case "control": + case "ctrl": + return KeyCode.LeftControl; + case "shift": + return KeyCode.LeftShift; + case "alt": + return KeyCode.LeftAlt; } var code = (KeyCode)Enum.Parse(typeof(KeyCode), keyboardKey, true); return Enum.IsDefined(typeof(KeyCode), code) ? code : KeyCode.None; @@ -54,9 +52,10 @@ private KeyCode StringToKeyCodeKeyboard(string keyboardKey) private KeyCode StringToKeyCodeGamepad(string gamepadKey) { - var gamepadcodeCode = (JoystickButton)Enum.Parse(typeof(JoystickButton), gamepadKey, true); - return (Enum.IsDefined(typeof(JoystickButton), gamepadcodeCode)) ? - InputTranslator.GetButtonKeyCode(gamepadcodeCode) : KeyCode.None; + var gamepadCode = (JoystickButton)Enum.Parse(typeof(JoystickButton), gamepadKey, true); + return Enum.IsDefined(typeof(JoystickButton), gamepadCode) ? + InputTranslator.GetButtonKeyCode(gamepadCode) : + KeyCode.None; } private KeyCode StringToKeyCodeXbox(string xboxKey) @@ -79,8 +78,9 @@ private KeyCode StringToKeyCodeXbox(string xboxKey) private KeyCode StringToKeyCode(string key) { var trimmedKey = key.Trim(); - return trimmedKey.Contains(XboxPrefix) ? StringToKeyCodeXbox(trimmedKey.Substring(XboxPrefix.Length)) - : StringToKeyCodeKeyboard(trimmedKey); + return trimmedKey.Contains(XboxPrefix) ? + StringToKeyCodeXbox(trimmedKey.Substring(XboxPrefix.Length)) : + StringToKeyCodeKeyboard(trimmedKey); } private int[] StringToKeyArray(string stringCombination) @@ -92,7 +92,7 @@ private int[] StringToKeyArray(string stringCombination) var code = StringToKeyCode(key); if ((int)code >= MaxUsefulKey) { - code -= (((int)code - MaxUsefulKey + GamePadKeyDiff) / GamePadKeyDiff) * GamePadKeyDiff; + code -= ((int)code - MaxUsefulKey + GamePadKeyDiff) / GamePadKeyDiff * GamePadKeyDiff; } if (code == KeyCode.None) { @@ -142,7 +142,7 @@ private List StringToHashes(string combinations) if (hash < MaxUsefulKey) { _singles.Add((KeyCode)hash); - } + } } return hashes; } diff --git a/OWML.ModHelper.Input/ModInputHandler.cs b/OWML.ModHelper.Input/ModInputHandler.cs index b3a1f1eb5..ea5718ae5 100644 --- a/OWML.ModHelper.Input/ModInputHandler.cs +++ b/OWML.ModHelper.Input/ModInputHandler.cs @@ -5,7 +5,6 @@ using System.Linq; using OWML.Common; using UnityEngine; -using System.Security.Policy; namespace OWML.ModHelper.Input { @@ -21,12 +20,12 @@ public class ModInputHandler : IModInputHandler internal static ModInputHandler Instance { get; private set; } - private HashSet _singlesPressed = new HashSet(); - private Dictionary _comboRegistry = new Dictionary(); - private HashSet _gameBindingRegistry = new HashSet(); - private HashSet _toResetOnNextFrame = new HashSet(); - private float[] _timeout = new float[MaxUsefulKey]; - private int[] _gameBindingCounter = new int[MaxUsefulKey]; + private readonly HashSet _singlesPressed = new HashSet(); + private readonly Dictionary _comboRegistry = new Dictionary(); + private readonly HashSet _gameBindingRegistry = new HashSet(); + private readonly HashSet _toResetOnNextFrame = new HashSet(); + private readonly float[] _timeout = new float[MaxUsefulKey]; + private readonly int[] _gameBindingCounter = new int[MaxUsefulKey]; private IModInputCombination _currentCombination; private int _lastSingleUpdate; private int _lastCombinationUpdate; @@ -54,9 +53,9 @@ internal bool IsPressedAndIgnored(KeyCode code) { UpdateCurrentCombination(); var intKey = (int)code; - if ((int)code >= MaxUsefulKey) + if (intKey >= MaxUsefulKey) { - intKey -= ((intKey - MaxUsefulKey + GamePadKeyDiff) / GamePadKeyDiff) * GamePadKeyDiff; + intKey -= (intKey - MaxUsefulKey + GamePadKeyDiff) / GamePadKeyDiff * GamePadKeyDiff; } return UnityEngine.Input.GetKey(code) && _currentCombination != null && Time.realtimeSinceStartup - _timeout[intKey] < Cooldown; } @@ -94,7 +93,7 @@ private IModInputCombination CombinationFromKeyboard() { return null; } - long hash = (long)nullableHash; + var hash = (long)nullableHash; if (hash < 0) { countdownTrigger = true; @@ -106,7 +105,7 @@ private IModInputCombination CombinationFromKeyboard() } var combination = _comboRegistry[hash]; - if (!(combination == _currentCombination) && countdownTrigger) + if (combination != _currentCombination && countdownTrigger) { return null; } @@ -162,31 +161,24 @@ public bool IsPressedExact(IModInputCombination combination) public bool IsNewlyPressedExact(IModInputCombination combination) { - if (combination == null) - { - return false; - } - return IsPressedExact(combination) && combination.IsFirst; + return combination != null && + IsPressedExact(combination) && + combination.IsFirst; } public bool WasTappedExact(IModInputCombination combination) { - if (combination == null) - { - return false; - } - return !IsPressedExact(combination) - && (combination.PressDuration < TapDuration) - && combination.IsFirst; + return combination != null && + !IsPressedExact(combination) && + combination.PressDuration < TapDuration && + combination.IsFirst; } public bool WasNewlyReleasedExact(IModInputCombination combination) { - if (combination == null) - { - return false; - } - return !IsPressedExact(combination) && combination.IsFirst; + return combination != null && + !IsPressedExact(combination) && + combination.IsFirst; } private void UpdateSinglesPressed() @@ -222,87 +214,72 @@ private bool IsPressedSingle(IModInputCombination combination) { return true; } - foreach (var key in combination.Singles) + var single = combination.Singles.FirstOrDefault(key => UnityEngine.Input.GetKey(key) && !IsPressedAndIgnored(key)); + if (single == 0) { - if (UnityEngine.Input.GetKey(key) && !IsPressedAndIgnored(key)) - { - _singlesPressed.Add(combination); - combination.InternalSetPressed(); - return true; - } + return false; } - return false; + _singlesPressed.Add(combination); + combination.InternalSetPressed(); + return true; } public bool IsPressed(IModInputCombination combination) { - if (combination == null) - { - return false; - } - return IsPressedExact(combination) || IsPressedSingle(combination); + return combination != null && + (IsPressedExact(combination) || IsPressedSingle(combination)); } public bool IsNewlyPressed(IModInputCombination combination) { - if (combination == null) - { - return false; - } - return IsPressed(combination) && combination.IsFirst; + return combination != null && + IsPressed(combination) && + combination.IsFirst; } public bool WasTapped(IModInputCombination combination) { - if (combination == null) - { - return false; - } - return (!IsPressed(combination)) && (combination.PressDuration < TapDuration) - && combination.IsFirst; + return combination != null && + !IsPressed(combination) && + combination.PressDuration < TapDuration && + combination.IsFirst; } public bool WasNewlyReleased(IModInputCombination combination) { - if (combination == null) - { - return false; - } - return (!IsPressed(combination)) && combination.IsFirst; + return combination != null && + !IsPressed(combination) && + combination.IsFirst; } private RegistrationCode SwapCombination(IModInputCombination combination, bool toUnregister) { - bool taken = false; + var taken = false; if (combination.Hashes[0] <= 0) { return (RegistrationCode)combination.Hashes[0]; } - foreach (long hash in combination.Hashes) + foreach (var hash in combination.Hashes) { if (toUnregister) { _comboRegistry.Remove(hash); continue; } - if (_comboRegistry.ContainsKey(hash) || (hash < MaxUsefulKey && _gameBindingCounter[hash] > 0)) + if (_comboRegistry.ContainsKey(hash) || hash < MaxUsefulKey && _gameBindingCounter[hash] > 0) { taken = true; continue; } _comboRegistry.Add(hash, combination); } - if (taken) - { - return RegistrationCode.CombinationTaken; - } - return RegistrationCode.AllNormal; + return taken ? RegistrationCode.CombinationTaken : RegistrationCode.AllNormal; } private List GetCollisions(ReadOnlyCollection hashes) { - List combos = new List(); - foreach (long hash in hashes) + var combos = new List(); + foreach (var hash in hashes) { if (_comboRegistry.ContainsKey(hash)) { @@ -330,7 +307,7 @@ public IModInputCombination RegisterCombination(IModBehaviour mod, string name, case RegistrationCode.CombinationTaken: _console.WriteLine($"Failed to register \"{combo.FullName}\": already in use by following mods:"); var collisions = GetCollisions(combo.Hashes); - foreach (string collision in collisions) + foreach (var collision in collisions) { _console.WriteLine($"\"{collision}\""); } @@ -358,7 +335,7 @@ public void UnregisterCombination(IModInputCombination combination) _console.WriteLine($"Failed to unregister \"{combination.FullName}\": too long!"); return; case RegistrationCode.AllNormal: - _logger.Log($"succesfully unregistered \"{combination.FullName}\""); + _logger.Log($"Successfully unregistered \"{combination.FullName}\""); return; default: return; @@ -367,29 +344,24 @@ public void UnregisterCombination(IModInputCombination combination) internal void SwapGamesBinding(InputCommand binding, bool toUnregister) { - if ((_gameBindingRegistry.Contains(binding) ^ toUnregister) || binding == null) + if (_gameBindingRegistry.Contains(binding) ^ toUnregister || binding == null) { return; } var fields = binding is SingleAxisCommand ? - typeof(SingleAxisCommand).GetFields(NonPublic) : typeof(DoubleAxisCommand).GetFields(NonPublic); - foreach (var field in fields) + typeof(SingleAxisCommand).GetFields(NonPublic) : + typeof(DoubleAxisCommand).GetFields(NonPublic); + foreach (var field in fields.Where(x => x.FieldType == typeof(List))) { - if (field.FieldType == typeof(List)) + var keys = (List)field.GetValue(binding); + foreach (var key in keys.Where(x => x != KeyCode.None)) { - var keys = (List)(field.GetValue(binding)); - foreach (var key in keys) + var intKey = (int)key; + if (intKey >= MaxUsefulKey) { - if (key != KeyCode.None) - { - var intKey = (int)key; - if ((int)key >= MaxUsefulKey) - { - intKey -= ((intKey - MaxUsefulKey + GamePadKeyDiff) / GamePadKeyDiff) * GamePadKeyDiff; - } - _gameBindingCounter[intKey] += toUnregister ? -1 : 1; - } + intKey -= (intKey - MaxUsefulKey + GamePadKeyDiff) / GamePadKeyDiff * GamePadKeyDiff; } + _gameBindingCounter[intKey] += toUnregister ? -1 : 1; } } if (toUnregister) @@ -414,10 +386,9 @@ internal void UnregisterGamesBinding(InputCommand binding) internal void UpdateGamesBindings() { - Array.ForEach(_gameBindingCounter, x => x = 0); _gameBindingRegistry.Clear(); var inputCommands = typeof(InputLibrary).GetFields(BindingFlags.Public | BindingFlags.Static); - Array.ForEach(inputCommands, field => RegisterGamesBinding(field.GetValue(null) as InputCommand)); + inputCommands.ToList().ForEach(field => RegisterGamesBinding(field.GetValue(null) as InputCommand)); } } } diff --git a/OWML.ModHelper.Interaction/InterfaceProxyBuilder.cs b/OWML.ModHelper.Interaction/InterfaceProxyBuilder.cs index 1a255a11a..9340eb474 100644 --- a/OWML.ModHelper.Interaction/InterfaceProxyBuilder.cs +++ b/OWML.ModHelper.Interaction/InterfaceProxyBuilder.cs @@ -9,16 +9,19 @@ namespace OWML.ModHelper.Interaction { internal class InterfaceProxyBuilder { - private readonly Type TargetType; - - private readonly Type ProxyType; + private readonly Type _targetType; + private readonly Type _proxyType; public InterfaceProxyBuilder(string name, ModuleBuilder moduleBuilder, Type interfaceType, Type targetType) { if (name == null) + { throw new ArgumentNullException(nameof(name)); + } if (targetType == null) + { throw new ArgumentNullException(nameof(targetType)); + } var proxyBuilder = moduleBuilder.DefineType(name, TypeAttributes.Public | TypeAttributes.Class); proxyBuilder.AddInterfaceImplementation(interfaceType); @@ -31,20 +34,23 @@ public InterfaceProxyBuilder(string name, ModuleBuilder moduleBuilder, Type inte { var targetMethod = targetType.GetMethod(proxyMethod.Name, proxyMethod.GetParameters().Select(a => a.ParameterType).ToArray()); if (targetMethod == null) + { throw new InvalidOperationException($"The {interfaceType.FullName} interface defines method {proxyMethod.Name} which doesn't exist in the API."); - - this.ProxyMethod(proxyBuilder, targetMethod, targetField); + } + ProxyMethod(proxyBuilder, targetMethod, targetField); } - this.TargetType = targetType; - this.ProxyType = proxyBuilder.CreateType(); + _targetType = targetType; + _proxyType = proxyBuilder.CreateType(); } public object CreateInstance(object targetInstance) { - var constructor = this.ProxyType.GetConstructor(new[] { this.TargetType }); + var constructor = _proxyType.GetConstructor(new[] { _targetType }); if (constructor == null) - throw new InvalidOperationException($"Couldn't find the constructor for generated proxy type '{this.ProxyType.Name}'."); // should never happen + { + throw new InvalidOperationException($"Couldn't find the constructor for generated proxy type '{_proxyType.Name}'."); // should never happen + } return constructor.Invoke(new[] { targetInstance }); } @@ -68,8 +74,10 @@ private void CreateProxyMethodBody(MethodBuilder methodBuilder, MethodInfo targe il.Emit(OpCodes.Ldfld, instanceField); // invoke target method on instance - for (int i = 0; i < argTypes.Length; i++) + for (var i = 0; i < argTypes.Length; i++) + { il.Emit(OpCodes.Ldarg, i + 1); + } il.Emit(OpCodes.Call, target); // return result diff --git a/OWML.ModHelper.Interaction/InterfaceProxyFactory.cs b/OWML.ModHelper.Interaction/InterfaceProxyFactory.cs index e83b5d2b3..abf88bcb2 100644 --- a/OWML.ModHelper.Interaction/InterfaceProxyFactory.cs +++ b/OWML.ModHelper.Interaction/InterfaceProxyFactory.cs @@ -9,29 +9,33 @@ namespace OWML.ModHelper.Interaction { public class InterfaceProxyFactory { - private readonly ModuleBuilder ModuleBuilder; - - private readonly IDictionary Builders = new Dictionary(); + private readonly ModuleBuilder _moduleBuilder; + private readonly IDictionary _builders = new Dictionary(); public InterfaceProxyFactory() { - var assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName($"OWMLInteraction.Proxies, Version={this.GetType().Assembly.GetName().Version}, Culture=neutral"), AssemblyBuilderAccess.Run); - this.ModuleBuilder = assemblyBuilder.DefineDynamicModule("OWMLInteraction.Proxies"); + var assemblyName = new AssemblyName($"OWMLInteraction.Proxies, Version={GetType().Assembly.GetName().Version}, Culture=neutral"); + var assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run); + _moduleBuilder = assemblyBuilder.DefineDynamicModule("OWMLInteraction.Proxies"); } - public TInterface CreateProxy(object instance, string sourceModID, string targetModID) where TInterface : class + public TInterface CreateProxy(object instance, string sourceModName, string targetModName) where TInterface : class { if (instance == null) + { throw new InvalidOperationException("Can't proxy access to a null API."); + } if (!typeof(TInterface).IsInterface) + { throw new InvalidOperationException("The proxy type must be an interface, not a class."); + } var targetType = instance.GetType(); - var proxyTypeName = $"OWMLInteraction.Proxies.From<{sourceModID}_{typeof(TInterface).FullName}>_To<{targetModID}_{targetType.FullName}>"; - if (!this.Builders.TryGetValue(proxyTypeName, out InterfaceProxyBuilder builder)) + var proxyTypeName = $"OWMLInteraction.Proxies.From<{sourceModName}_{typeof(TInterface).FullName}>_To<{targetModName}_{targetType.FullName}>"; + if (!_builders.TryGetValue(proxyTypeName, out InterfaceProxyBuilder builder)) { - builder = new InterfaceProxyBuilder(proxyTypeName, this.ModuleBuilder, typeof(TInterface), targetType); - this.Builders[proxyTypeName] = builder; + builder = new InterfaceProxyBuilder(proxyTypeName, _moduleBuilder, typeof(TInterface), targetType); + _builders[proxyTypeName] = builder; } return (TInterface)builder.CreateInstance(instance); diff --git a/OWML.ModHelper.Interaction/ModInteraction.cs b/OWML.ModHelper.Interaction/ModInteraction.cs index aed103e1a..fa4b62804 100644 --- a/OWML.ModHelper.Interaction/ModInteraction.cs +++ b/OWML.ModHelper.Interaction/ModInteraction.cs @@ -7,13 +7,9 @@ namespace OWML.ModHelper.Interaction public class ModInteraction : IModInteraction { private readonly IList _modList; - private readonly InterfaceProxyFactory _proxyFactory; - private readonly IModManifest _manifest; - private Dictionary> _dependantDict = new Dictionary>(); - private Dictionary> _dependencyDict = new Dictionary>(); public ModInteraction(IList list, InterfaceProxyFactory proxyFactory, IModManifest manifest) diff --git a/OWML.ModHelper.Menus/ModComboInput.cs b/OWML.ModHelper.Menus/ModComboInput.cs index 208c533ac..cf2b26300 100644 --- a/OWML.ModHelper.Menus/ModComboInput.cs +++ b/OWML.ModHelper.Menus/ModComboInput.cs @@ -16,7 +16,7 @@ public class ModComboInput : ModInput, IModComboInput protected readonly TwoButtonToggleElement ToggleElement; private string _value; - private HorizontalLayoutGroup _layoutGroup; + private readonly HorizontalLayoutGroup _layoutGroup; public ModComboInput(TwoButtonToggleElement element, IModMenu menu, IModInputMenu inputMenu) : base(element, menu) { @@ -27,12 +27,14 @@ public ModComboInput(TwoButtonToggleElement element, IModMenu menu, IModInputMen var noButton = ToggleElement.GetValue