Skip to content

Commit

Permalink
Better mod compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
SabreML committed Feb 15, 2023
1 parent f22fe20 commit 0c8a446
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
25 changes: 19 additions & 6 deletions SingleplayerCoopEmotes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace SingleplayerCoopEmotes
{
[BepInPlugin("sabreml.singleplayercoopemotes", "SingleplayerCoopEmotes", "1.1.1")]
[BepInPlugin("sabreml.singleplayercoopemotes", "SingleplayerCoopEmotes", "1.1.2")]
public class SingleplayerCoopEmotes : BaseUnityPlugin
{
public void OnEnable()
Expand Down Expand Up @@ -101,19 +101,32 @@ private static void JollyPointUpdateHK(On.Player.orig_JollyPointUpdate orig, Pla
// point in the direction indicated by the player.
private static void GraphicsModuleUpdatedHK(On.Player.orig_GraphicsModuleUpdated orig, Player self, bool actuallyViewed, bool eu)
{
// Temporarily make the method think that Jolly Co-op is loaded so that it properly checks for `jollyButtonDown`.
// (Doing it this way is a lot easier than trying to edit the method.)
ModManager.CoopAvailable = true;
orig(self, actuallyViewed, eu);
ModManager.CoopAvailable = false;

// Recreation of the checks that need to pass in the base method to point a spear, but with the `ModManager.CoopAvailable` check removed.
for (int i = 0; i < self.grasps.Length; i++)
{
if (self.grasps[i] == null || !actuallyViewed || !self.jollyButtonDown || self.handPointing != i)
{
return;
}
if (!(self.grasps[i].grabbed is Spear) || self.bodyMode == Player.BodyModeIndex.Crawl || self.animation == Player.AnimationIndex.ClimbOnBeam)
{
return;
}
Spear playerSpear = self.grasps[i].grabbed as Spear;

playerSpear.setRotation = self.PointDir();
playerSpear.rotationSpeed = 0f;
}
}


// When Jolly Co-op is active and the jolly button is held, the `checkInput()` method skips opening the map
// and sets the player's movement input as the pointing direction.
private static void checkInputHK(On.Player.orig_checkInput orig, Player self)
{
// And a similar thing as above here. It's a bit hacky, but it works.
// Temporarily make the method think that Jolly Co-op is loaded so that it checks for `jollyButtonDown`.
if (!self.isNPC)
{
ModManager.CoopAvailable = true; // Don't do this for NPCs because it can break their AI.
Expand Down
2 changes: 1 addition & 1 deletion SingleplayerCoopEmotes/modinfo.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "sabreml.singleplayercoopemotes",
"name": "Singleplayer Co-op Emotes",
"version": "1.1.1",
"version": "1.1.2",
"target_game_version": "v1.9.05",
"authors": "SabreML",
"description": "Makes the Jolly Co-op emotes work in singleplayer!"
Expand Down

0 comments on commit 0c8a446

Please sign in to comment.