Skip to content

Commit

Permalink
Added code for map matchmaking and fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
legoandmars committed Mar 2, 2021
1 parent 6650359 commit dcce780
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 5 deletions.
11 changes: 9 additions & 2 deletions Utilla/Events/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ public static class Events

internal static void TriggerRoomJoin(bool isPrivate)
{
UnityEngine.Debug.Log("Joining a room!");
UnityEngine.Debug.Log($"Private: {isPrivate}");
try
{
UnityEngine.Debug.Log("Joining a room!");
UnityEngine.Debug.Log($"Private: {isPrivate}");
}
catch(Exception e)
{
isPrivate = false;
}
RoomJoined(isPrivate);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@ internal class PhotonNetworkControllerPatch
private static void Postfix(PhotonNetworkController __instance)
{
// trigger events
bool isPrivate = __instance.isPrivate;
bool isPrivate = false;
if(PhotonNetwork.CurrentRoom != null)
{
isPrivate = !PhotonNetwork.CurrentRoom.IsVisible;
}
Events.TriggerRoomJoin(isPrivate);

// handle forcing private lobbies
bool forcePrivateLobbies = false;
var infos = BepInEx.Bootstrap.Chainloader.PluginInfos;
foreach(var info in infos)
{
if (info.Value == null) continue;
BaseUnityPlugin plugin = info.Value.Instance;
if (plugin == null) continue;
var attribute = plugin.GetType().GetCustomAttribute<ForcePrivateLobbyAttribute>();
Expand Down
2 changes: 1 addition & 1 deletion Utilla/Utilla.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace Utilla
{

[BepInPlugin("org.legoandmars.gorillatag.utilla", "Utilla", "1.0.0")]
[BepInPlugin("org.legoandmars.gorillatag.utilla", "Utilla", "1.1.0")]
public class Utilla : BaseUnityPlugin
{
void Awake()
Expand Down
3 changes: 3 additions & 0 deletions Utilla/Utilla.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
<Reference Include="BepInEx.Harmony">
<HintPath>..\Libs\BepInEx.Harmony.dll</HintPath>
</Reference>
<Reference Include="Photon3Unity3D">
<HintPath>..\..\GorillaCosmetics\Libs\Photon3Unity3D.dll</HintPath>
</Reference>
<Reference Include="PhotonRealtime">
<HintPath>..\Libs\PhotonRealtime.dll</HintPath>
</Reference>
Expand Down
33 changes: 32 additions & 1 deletion Utilla/Utils/RoomUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,36 @@ public static void JoinPrivateLobby(string code, PhotonNetworkController __insta
UnityEngine.Debug.Log("attempting to connect");
}
}
}

public static void JoinModdedLobby(string map)
{
string gameModeName = "infection_MOD_" + map;
PhotonNetworkController photonNetworkController = PhotonNetworkController.instance;
if (PhotonNetwork.InRoom && (string)PhotonNetwork.CurrentRoom.CustomProperties["gameMode"] != gameModeName)
{
photonNetworkController.currentGameType = gameModeName;
photonNetworkController.attemptingToConnect = true;
SkinnedMeshRenderer[] offlineVRRig = photonNetworkController.offlineVRRig;
for (int i = 0; i < offlineVRRig.Length; i++)
{
offlineVRRig[i].enabled = true;
}
PhotonNetwork.Disconnect();
return;
}
if (!PhotonNetwork.InRoom && !photonNetworkController.attemptingToConnect)
{
try
{
photonNetworkController.currentGameType = gameModeName;
photonNetworkController.attemptingToConnect = true;
photonNetworkController.AttemptToConnectToRoom();
Debug.Log("attempting to connect");
}
catch(Exception e) {
Debug.Log(e);
}
}
}
}
}

0 comments on commit dcce780

Please sign in to comment.