Skip to content

Commit

Permalink
fix: game end triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
olavim committed Aug 24, 2021
1 parent 47e4a15 commit e8512dd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 16 deletions.
44 changes: 29 additions & 15 deletions RoundsWithFriends/RoundEndHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,47 +88,61 @@ private void OnGameOverChoose(string choice)

[UnboundRPC]
public static void Rematch()
{
RoundEndHandler.instance.StartCoroutine(RoundEndHandler.RematchCoroutine());
}

[UnboundRPC]
public static void Continue()
{
var gm = GameModeManager.CurrentHandler;

if (RoundEndHandler.instance.gmOriginalMaxRounds != -1)
int maxRounds = (int) gm.Settings["roundsToWinGame"];

if (RoundEndHandler.instance.gmOriginalMaxRounds == -1)
{
gm.ChangeSetting("roundsToWinGame", RoundEndHandler.instance.gmOriginalMaxRounds);
RoundEndHandler.instance.gmOriginalMaxRounds = -1;
RoundEndHandler.instance.gmOriginalMaxRounds = maxRounds;
}

UIHandler.instance.DisableTexts(1f);

GameManager.instance.isPlaying = false;
gm.GameMode.StopAllCoroutines();
gm.ResetGame();
gm.StartGame();
gm.ChangeSetting("roundsToWinGame", maxRounds + 2);

RoundEndHandler.instance.waitingForHost = false;
}

[UnboundRPC]
public static void Continue()
public static void Exit()
{
var gm = GameModeManager.CurrentHandler;
RoundEndHandler.instance.StartCoroutine(RoundEndHandler.ExitCoroutine());
}

int maxRounds = (int) gm.Settings["roundsToWinGame"];
private static IEnumerator RematchCoroutine()
{
yield return GameModeManager.TriggerHook(GameModeHooks.HookGameEnd);

if (RoundEndHandler.instance.gmOriginalMaxRounds == -1)
var gm = GameModeManager.CurrentHandler;

if (RoundEndHandler.instance.gmOriginalMaxRounds != -1)
{
RoundEndHandler.instance.gmOriginalMaxRounds = maxRounds;
gm.ChangeSetting("roundsToWinGame", RoundEndHandler.instance.gmOriginalMaxRounds);
RoundEndHandler.instance.gmOriginalMaxRounds = -1;
}

UIHandler.instance.DisableTexts(1f);

gm.ChangeSetting("roundsToWinGame", maxRounds + 2);
GameManager.instance.isPlaying = false;
gm.GameMode.StopAllCoroutines();
gm.ResetGame();
gm.StartGame();

RoundEndHandler.instance.waitingForHost = false;
}

[UnboundRPC]
public static void Exit()
private static IEnumerator ExitCoroutine()
{
yield return GameModeManager.TriggerHook(GameModeHooks.HookGameEnd);

var gm = GameModeManager.CurrentHandler;

if (RoundEndHandler.instance.gmOriginalMaxRounds != -1)
Expand Down
2 changes: 1 addition & 1 deletion RoundsWithFriends/RoundsWithFriends.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static DebugOptions Deserialize(byte[] data)
public class RWFMod : BaseUnityPlugin
{
private const string ModId = "io.olavim.rounds.rwf";
public const string Version = "1.3.7";
public const string Version = "1.3.8";

#if DEBUG
public static readonly bool DEBUG = true;
Expand Down

0 comments on commit e8512dd

Please sign in to comment.