diff --git a/SingleplayerCoopEmotes.csproj b/SingleplayerCoopEmotes.csproj
index f3ef5a7..9cd713d 100644
--- a/SingleplayerCoopEmotes.csproj
+++ b/SingleplayerCoopEmotes.csproj
@@ -34,6 +34,7 @@
Always
+
diff --git a/src/Mod Support/AimAnywhereSupport.cs b/src/Mod Support/AimAnywhereSupport.cs
new file mode 100644
index 0000000..12e5bb5
--- /dev/null
+++ b/src/Mod Support/AimAnywhereSupport.cs
@@ -0,0 +1,21 @@
+using UnityEngine;
+
+namespace SingleplayerCoopEmotes
+{
+ public static class AimAnywhereSupport
+ {
+ // Mostly taken from Aim Anywhere's `WeaponPatch.WeaponThrownPatch()`.
+ public static void UpdatePointDirection(Player self)
+ {
+ if (self.room.game.cameras[0] == null)
+ {
+ return;
+ }
+
+ Vector2 aimDirection = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
+ aimDirection += (self.room.game.cameras[0].pos - self.mainBodyChunk.pos);
+
+ self.pointInput.analogueDir = aimDirection.normalized;
+ }
+ }
+}
diff --git a/src/SingleplayerCoopEmotes.cs b/src/SingleplayerCoopEmotes.cs
index a0d99b0..5b594e1 100644
--- a/src/SingleplayerCoopEmotes.cs
+++ b/src/SingleplayerCoopEmotes.cs
@@ -2,6 +2,7 @@
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using System;
+using System.Linq;
using System.Reflection;
using System.Security.Permissions;
using UnityEngine;
@@ -18,14 +19,18 @@ public class SingleplayerCoopEmotes : BaseUnityPlugin
// The current mod version.
public static string Version;
+ private static bool aimAnywhereEnabled = false;
+
public void OnEnable()
{
// Take the version number that was given to `BepInPlugin()` above.
Version = Info.Metadata.Version.ToString();
On.RainWorld.OnModsInit += Init;
+ On.RainWorld.PostModsInit += PostInit;
}
+
private void Init(On.RainWorld.orig_OnModsInit orig, RainWorld self)
{
orig(self);
@@ -64,6 +69,16 @@ private void Init(On.RainWorld.orig_OnModsInit orig, RainWorld self)
}
+ private void PostInit(On.RainWorld.orig_PostModsInit orig, RainWorld self)
+ {
+ orig(self);
+ if (ModManager.ActiveMods.Any(mod => mod.id == "demo.aimanywhere"))
+ {
+ aimAnywhereEnabled = true;
+ }
+ }
+
+
private void JollyUpdateHK(On.Player.orig_JollyUpdate orig, Player self, bool eu)
{
// If this is hooked then the checks above must have passed, so we don't need to worry about it trying to emote twice.
@@ -116,6 +131,11 @@ private void UpdateJollyButton(Player self)
{
self.jollyButtonDown = Input.GetKey(customKeybind);
}
+
+ if (aimAnywhereEnabled)
+ {
+ AimAnywhereSupport.UpdatePointDirection(self);
+ }
}