Skip to content

Commit

Permalink
Update for OWML 2.X
Browse files Browse the repository at this point in the history
  • Loading branch information
TAImatem committed Nov 1, 2021
1 parent b6c6506 commit 4336412
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 33 deletions.
36 changes: 23 additions & 13 deletions OW_SmoothThrust/OW_SmoothThrust.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OW_SmoothThrust</RootNamespace>
<AssemblyName>OW_SmoothThrust</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -32,34 +33,43 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony, Version=1.2.0.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Lib.Harmony.1.2.0.1\lib\net35\0Harmony.dll</HintPath>
<HintPath>..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\..\..\Games\Outer Wilds\OuterWilds_Data\Managed\Assembly-CSharp.dll</HintPath>
<HintPath>..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="NAudio-Unity, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.0.3.46\lib\net35\NAudio-Unity.dll</HintPath>
<HintPath>..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\NAudio-Unity.dll</HintPath>
</Reference>
<Reference Include="netstandard">
<HintPath>..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\netstandard.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Json.Net.Unity3D.9.0.1\lib\net35\Newtonsoft.Json.dll</HintPath>
<HintPath>..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="OWML, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.0.3.46\lib\net35\OWML.dll</HintPath>
</Reference>
<Reference Include="OWML.Abstractions">
<HintPath>..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\OWML.Abstractions.dll</HintPath>
</Reference>
<Reference Include="OWML.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.0.3.46\lib\net35\OWML.Common.dll</HintPath>
<HintPath>..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\OWML.Common.dll</HintPath>
</Reference>
<Reference Include="OWML.ModHelper, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.0.3.46\lib\net35\OWML.ModHelper.dll</HintPath>
<Reference Include="OWML.ModHelper">
<HintPath>..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\OWML.ModHelper.dll</HintPath>
</Reference>
<Reference Include="OWML.ModHelper.Assets, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.0.3.46\lib\net35\OWML.ModHelper.Assets.dll</HintPath>
<HintPath>..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\OWML.ModHelper.Assets.dll</HintPath>
</Reference>
<Reference Include="OWML.ModHelper.Events, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.0.3.46\lib\net35\OWML.ModHelper.Events.dll</HintPath>
<HintPath>..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\OWML.ModHelper.Events.dll</HintPath>
</Reference>
<Reference Include="OWML.ModHelper.Menus, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OWML.0.3.46\lib\net35\OWML.ModHelper.Menus.dll</HintPath>
<HintPath>..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\OWML.ModHelper.Menus.dll</HintPath>
</Reference>
<Reference Include="OWML.Utils">
<HintPath>..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\OWML.Utils.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -68,10 +78,10 @@
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>..\..\..\..\Games\Outer Wilds\OuterWilds_Data\Managed\UnityEngine.dll</HintPath>
<HintPath>..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\..\..\Games\Outer Wilds\OuterWilds_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
<HintPath>..\..\..\..\..\..\Games\Steam\steamapps\common\Outer Wilds\OuterWilds_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
42 changes: 24 additions & 18 deletions OW_SmoothThrust/SmoothThrust.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@ namespace TAI_SmoothThrust
{
class ThrusterModel_SmoothPatch
{
public static void Prefix(ThrusterModel __instance, ref Vector3 input)
public static void Prefix(ThrusterModel __instance, ref Vector3 ____translationalInput)
{
if (!SmoothThrust.container.ContainsKey(__instance))
{
SmoothThrust.container.Add(__instance, new SmoothThrust.SmoothCont());
}
SmoothThrust.SmoothCont iter = SmoothThrust.container[__instance];
if (OWInput.IsNewlyPressed(InputLibrary.interact, InputMode.All))
if (OWInput.IsNewlyPressed(InputLibrary.interact))
{
iter._prevTranslation = input;
iter._prevTranslation = ____translationalInput;
iter._buildupVelocity = Vector3.zero;
}
if (input.magnitude > 0.0001f && OWInput.IsHeld(InputLibrary.interact, 0.05f, InputMode.All))
if (OWInput.IsPressed(InputLibrary.interact, 0.05f))
{
iter._prevTranslation.x = Mathf.SmoothDamp(iter._prevTranslation.x, input.x, ref iter._buildupVelocity.x, SmoothThrust._analogSmoothTime);
iter._prevTranslation.z = Mathf.SmoothDamp(iter._prevTranslation.z, input.z, ref iter._buildupVelocity.z, SmoothThrust._analogSmoothTime);
iter._prevTranslation.y = Mathf.SmoothDamp(iter._prevTranslation.y, input.y, ref iter._buildupVelocity.y, SmoothThrust._analogSmoothTime);
input = iter._prevTranslation;
iter._prevTranslation.x = Mathf.SmoothDamp(iter._prevTranslation.x, ____translationalInput.x, ref iter._buildupVelocity.x, SmoothThrust._analogSmoothTime);
iter._prevTranslation.z = Mathf.SmoothDamp(iter._prevTranslation.z, ____translationalInput.z, ref iter._buildupVelocity.z, SmoothThrust._analogSmoothTime);
iter._prevTranslation.y = Mathf.SmoothDamp(iter._prevTranslation.y, ____translationalInput.y, ref iter._buildupVelocity.y, SmoothThrust._analogSmoothTime);
____translationalInput = iter._prevTranslation;
}
if (SmoothThrust.anglerSafety)
if (SmoothThrust.anglerSafety && (SmoothThrust.ShipNMBody != null || SmoothThrust.PlayerNMBody != null))
{
Vector3 myPos;
if (__instance is ShipThrusterModel)
Expand All @@ -55,24 +55,24 @@ public static void Prefix(ThrusterModel __instance, ref Vector3 input)
{
if (mindist <= 400.1f)
{
if (input.magnitude * __instance.GetMaxTranslationalThrust() >= mindist / 20f)
if (____translationalInput.magnitude * __instance.GetMaxTranslationalThrust() >= mindist / 20f)
{
input = input.normalized * (mindist / 21f) / __instance.GetMaxTranslationalThrust();
____translationalInput = ____translationalInput.normalized * (mindist / 21f) / __instance.GetMaxTranslationalThrust();
}
}
}
else
{
if (mindist <= 210f)
{
if (input.magnitude * 100f * __instance.GetMaxTranslationalThrust() >= mindist * 3f)
if (____translationalInput.magnitude * 100f * __instance.GetMaxTranslationalThrust() >= mindist * 3f)
{
input = input.normalized * (mindist / 35f) / __instance.GetMaxTranslationalThrust();
____translationalInput = ____translationalInput.normalized * (mindist / 35f) / __instance.GetMaxTranslationalThrust();
}
}
}
}
iter._prevTranslation = input;
iter._prevTranslation = ____translationalInput;
SmoothThrust.container[__instance] = iter;
}

Expand Down Expand Up @@ -100,9 +100,11 @@ public class SmoothThrust : ModBehaviour
{
private void Start()
{
ModHelper.HarmonyHelper.AddPrefix<ThrusterModel>("AddTranslationalInput", typeof(ThrusterModel_SmoothPatch), "Prefix");
ModHelper.HarmonyHelper.AddPrefix<ShipThrusterModel>("FireTranslationalThrusters", typeof(ThrusterModel_SmoothPatch), "Prefix");
ModHelper.HarmonyHelper.AddPrefix<JetpackThrusterModel>("FireTranslationalThrusters", typeof(ThrusterModel_SmoothPatch), "Prefix");
ModHelper.HarmonyHelper.AddPostfix<ThrusterModel>("OnDestroy", typeof(ThrusterModel_SmoothPatch), "Postfix");
ModHelper.HarmonyHelper.AddPostfix<AnglerfishController>("OnSectorOccupantsUpdated", typeof(ThrusterModel_SmoothPatch), "Angler_Postfix");
console = ModHelper.Console;
ModHelper.Console.WriteLine("Smooth Thrust Ready!");
}
public override void Configure(IModConfig config)
Expand All @@ -116,15 +118,18 @@ private void Update()
if (LoadManager.GetCurrentScene() == OWScene.SolarSystem || LoadManager.GetCurrentScene() == OWScene.EyeOfTheUniverse)
{
if (PlayerNMBody == null)
PlayerNMBody = GameObject.FindObjectOfType<PlayerNoiseMaker>().GetAttachedBody();

{
PlayerNMBody = GameObject.FindObjectOfType<PlayerNoiseMaker>()?.GetAttachedBody();
}
}
else
PlayerNMBody = null;
if (LoadManager.GetCurrentScene() == OWScene.SolarSystem)
{
if (ShipNMBody == null)
ShipNMBody = GameObject.FindObjectOfType<ShipNoiseMaker>().GetAttachedBody();
{
ShipNMBody = GameObject.FindObjectOfType<ShipNoiseMaker>()?.GetAttachedBody();
}
}
else
{
Expand All @@ -141,6 +146,7 @@ private void Update()

public static float limiter;
public static Vector3 latest;
public static IModConsole console;

public struct SmoothCont
{
Expand Down
4 changes: 2 additions & 2 deletions OW_SmoothThrust/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"author": "TAImatem & Schinken",
"name": "SmoothThrust",
"uniqueName": "TruAI.SmoothThrust",
"version": "1.5",
"owmlVersion": "0.3.46"
"version": "2.0",
"owmlVersion": "2.1.0"
}

0 comments on commit 4336412

Please sign in to comment.