SubmergedAmongUs / Submerged

An Among Us mod which adds a new underwater map
Other
106 stars 17 forks source link

PlayerControl.Exiled() called twice #123

Closed yukieiji closed 1 year ago

yukieiji commented 1 year ago

Describe the bug PlayerControl.Exiled() is called twice when the player is exiled I checked with Skeld and AirShip.

To Reproduce Steps to reproduce the behavior:

  1. Play Skeld or AirShip
  2. Exiled player

Expected behavior It seems correct that this process is called only once at the time of exile.

Version (please complete the following information):

Log file LogOutput.log "[Info :Extreme Roles] Call exiled!!!!!" (PlayerControl.Exied() is called) is called twice, this is the log of one exiled.

Additional context I have another mod installed, but uninstalling only the submerged fixed this problem

yukieiji commented 1 year ago

I applied a Patch to ExileControllerPatches.BeginPatch and this issue no longer occurs. ExileController.Begin to display the number of people in other teams in my mod, so it seems that there was a conflict and this issue was occurring.

Alexejhero commented 1 year ago

Okay I understand the problem. However we need that patch because otherwise the exile text isn't properly displayed sometimes...

Alexejhero commented 1 year ago

Can this issue be closed then?

yukieiji commented 1 year ago

I have confirmed that even with only the Begin patch of my mod working, in rare cases, the exile text is not displayed. I have also confirmed that it always disappears after it is no longer displayed.

Alexejhero commented 1 year ago

So in order to facilitate mod compatibility, I've taken out the Submerged patch on ExileController begin into its own method which you can patch instead of the original ExileController.Begin if Submerged is installed. How is that?

Alexejhero commented 1 year ago

So mod devs would patch this method with the same patch that you would apply to ExileController.Begin

image

yukieiji commented 1 year ago

I have the following patched in my mod, how do I patch it? ExiledPatch

Alexejhero commented 1 year ago

Something like this maybe?

image

Alexejhero commented 1 year ago

If you call Apply from the mod's entry point it might load before submerged and not detect it, in this case you can either make your mod load after submerged by adding [BepInDependency("Submerged", BepInDependency.DependencyFlags.SoftDependency)] to your plugin class or by calling Apply at a later point, such as a patch in AmongUsClient.Awake

yukieiji commented 1 year ago

Thank you, I would think fixes are done with this commit.

Alexejhero commented 1 year ago

I hope this is an acceptable compromise I don't know what else I could do to improve compatibility here.

I thought about checking ExileController.Begin for patches from other mods and unpatching them from there and instead repatching them on ExileControllerPatches.ExileController_Begin, but that's not possible because in one case ExileController is __instance and in the other case its HarmonyArgument(0)

yukieiji commented 3 months ago

In v2024.8.1 this patch has been removed, is it no longer necessary to do anything?

Alexejhero commented 3 months ago

Yeah you don't need to worry about this anymore, it should work just like any other map.