-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
121 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using HarmonyLib; | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Reflection.Emit; | ||
using UnboundLib.GameModes; | ||
using UnityEngine; | ||
|
||
namespace UnboundLib.Patches | ||
{ | ||
[HarmonyPatch(typeof(LoadingScreen), "IDoLoading")] | ||
class LoadingScreen_Patch_IDoLoading | ||
{ | ||
static void ActivateGameMode() | ||
{ | ||
GameModeManager.CurrentHandler.SetActive(true); | ||
} | ||
|
||
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) | ||
{ | ||
// Remove the default player joined and died -hooks. We'll add them back through the GameMode abstraction layer. | ||
var list = instructions.ToList(); | ||
var newInstructions = new List<CodeInstruction>(); | ||
|
||
var f_gameMode = ExtensionMethods.GetFieldInfo(typeof(LoadingScreen), "gameMode"); | ||
var m_objectSetActive = ExtensionMethods.GetMethodInfo(typeof(GameObject), "SetActive"); | ||
var m_gmSetActive = ExtensionMethods.GetMethodInfo(typeof(LoadingScreen_Patch_IDoLoading), "ActivateGameMode"); | ||
|
||
for (int i = 0; i < list.Count; i++) | ||
{ | ||
if (list[i].LoadsField(f_gameMode) && list[i + 2].Calls(m_objectSetActive)) | ||
{ | ||
newInstructions.Add(new CodeInstruction(OpCodes.Call, m_gmSetActive)); | ||
i += 2; | ||
} | ||
else | ||
{ | ||
newInstructions.Add(list[i]); | ||
} | ||
} | ||
|
||
return newInstructions; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using HarmonyLib; | ||
using UnboundLib.GameModes; | ||
|
||
namespace UnboundLib.Patches | ||
{ | ||
[HarmonyPatch(typeof(NetworkConnectionHandler), "QuickMatch")] | ||
class NetworkConnectionHandler_Patch_QuickMatch | ||
{ | ||
static void Prefix() | ||
{ | ||
GameModeManager.SetGameMode("ArmsRace", false); | ||
} | ||
} | ||
|
||
[HarmonyPatch(typeof(NetworkConnectionHandler), "TwitchJoin")] | ||
class NetworkConnectionHandler_Patch_TwitchJoin | ||
{ | ||
static void Prefix() | ||
{ | ||
GameModeManager.SetGameMode("ArmsRace", false); | ||
} | ||
} | ||
|
||
[HarmonyPatch(typeof(NetworkConnectionHandler), "HostPrivateAndInviteFriend")] | ||
class NetworkConnectionHandler_Patch_HostPrivateAndInviteFriend | ||
{ | ||
static void Prefix() | ||
{ | ||
GameModeManager.SetGameMode("ArmsRace", false); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters