immcrab/Lasting-Utilla
Ownership not verified 1
Viewing main at commit a6a25ac430“Add files via upload”· 11 months ago
91 lines · 3.6 KBRaw on GitHub
// Decompiled with JetBrains decompiler
// Type: Utilla.Patches.DesiredGameModePatches
// Assembly: Utilla, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: FDD08D98-E155-49FA-85BC-1930928C3BAA
// Assembly location: C:\Program Files (x86)\Steam\steamapps\common\Gorilla Tag\BepInEx\plugins\Utilla\Utilla.dll
using GorillaGameModes;
using GorillaNetworking;
using HarmonyLib;
using System;
using Utilla.Models;
using Utilla.Tools;
using Utilla.Utils;
#nullable disable
namespace Utilla.Patches;
[HarmonyPatch(typeof (GorillaNetworkJoinTrigger))]
internal class DesiredGameModePatches
{
[HarmonyPatch("GetDesiredGameType")]
[HarmonyPrefix]
public static bool DesiredGameTypePatch(
GorillaNetworkJoinTrigger __instance,
ref string __result,
ref GTZone ___zone)
{
Type type = __instance.GetType();
Logging.Info((object) (type.Name + ".GetDesiredGameType"));
// ISSUE: cast to a reference type
// ISSUE: explicit reference operation
if (type == typeof (GorillaNetworkRankedJoinTrigger) || ^(int&) ref ___zone == 27)
{
Logging.Message((object) "Ranked JoinTrigger resorting to hardcoded infection mode");
__result = ((GameModeType) 10).ToString();
return false;
}
string id = GorillaComputer.instance.currentGameMode.Value;
if (!Enum.IsDefined(typeof (GameModeType), (object) id))
{
Gamemode gamemodeFromId = GameModeUtils.GetGamemodeFromId(id);
if (gamemodeFromId != null)
{
GameModeType? baseGamemode = gamemodeFromId.BaseGamemode;
if (baseGamemode.HasValue)
{
baseGamemode = gamemodeFromId.BaseGamemode;
if (baseGamemode.Value < 12)
{
baseGamemode = gamemodeFromId.BaseGamemode;
GameModeType gameModeType1 = baseGamemode.Value;
GameModeType gameModeType2 = GameMode.GameModeZoneMapping.VerifyModeForZone(__instance.zone, gameModeType1, NetworkSystem.Instance.SessionIsPrivate);
if (gameModeType2 == gameModeType1)
{
// ISSUE: cast to a reference type
// ISSUE: explicit reference operation
Logging.Message((object) $"JoinTrigger of {EnumUtilExt.GetName<GTZone>((GTZone) ^(int&) ref ___zone)} allowing generic game mode: {id} under {gameModeType1}");
__result = id;
return false;
}
// ISSUE: cast to a reference type
// ISSUE: explicit reference operation
Logging.Message((object) $"JoinTrigger of {EnumUtilExt.GetName<GTZone>((GTZone) ^(int&) ref ___zone)} changing unsupported game mode: {id} under {gameModeType1}");
__result = gameModeType2.ToString();
return false;
}
}
}
// ISSUE: cast to a reference type
// ISSUE: explicit reference operation
Logging.Message((object) $"JoinTrigger of {EnumUtilExt.GetName<GTZone>((GTZone) ^(int&) ref ___zone)} allowing custom game mode: {id}");
__result = id;
return false;
}
// ISSUE: cast to a reference type
// ISSUE: explicit reference operation
Logging.Message((object) $"JoinTrigger of {EnumUtilExt.GetName<GTZone>((GTZone) ^(int&) ref ___zone)} naturally allows game mode: {id}");
return true;
}
[HarmonyPatch("GetDesiredGameTypeLocalized")]
[HarmonyPrefix]
public static bool DesiredLocalizedGameTypePatch(
GorillaNetworkJoinTrigger __instance,
ref string __result,
ref GTZone ___zone)
{
return DesiredGameModePatches.DesiredGameTypePatch(__instance, ref __result, ref ___zone);
}
}
Code is shown from GitHub as-is. Linking a repository doesn’t prove that a release file on Canopy was built from it.