using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using Steamworks;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ArifRios1st")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright © 2025 ArifRios1st")]
[assembly: AssemblyDescription("A Mod for redirecting custom photon R.E.P.O server.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+66eb37fb302a2e9fd5f1efacda3fbf76e2eb9612")]
[assembly: AssemblyProduct("RepoCustomPhotonServer")]
[assembly: AssemblyTitle("RepoCustomPhotonServer")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/ArifRios1st/RepoCustomPhotonServer")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace RepoCustomPhotonServer
{
[BepInPlugin("RepoCustomPhotonServer", "RepoCustomPhotonServer", "1.0.0")]
internal sealed class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(NetworkConnect))]
public class NetworkConnectPatch
{
[HarmonyPatch("Start")]
[HarmonyPrefix]
public static void Start()
{
if (isActive.Value)
{
logger.LogInfo((object)"Updating Photon Settings");
UpdatePhotonSettings();
}
}
}
[HarmonyPatch(typeof(SteamManager))]
public class SteamManagerPatch
{
[HarmonyPatch("Awake")]
[HarmonyPrefix]
public static void Awake()
{
if (isChangeSteamAppId.Value)
{
logger.LogInfo((object)$"Change appid to {480u}");
SteamClient.Init(480u, true);
}
}
[HarmonyPatch("SendSteamAuthTicket")]
[HarmonyPrefix]
public static bool SendSteamAuthTicket()
{
if (isActive.Value)
{
logger.LogInfo((object)"Updating Auth Method");
UpdateAuthMethod();
return false;
}
return true;
}
}
internal static readonly ManualLogSource logger = Logger.CreateLogSource("RepoCustomPhotonServer");
internal static ConfigEntry<bool> isActive;
internal static ConfigEntry<bool> isChangeSteamAppId;
internal static ConfigEntry<string> AppIdRealtime;
internal static ConfigEntry<string> AppIdVoice;
internal static ConfigEntry<string> FixedRegion;
internal static AuthTicket steamAuthTicket;
private void Awake()
{
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Expected O, but got Unknown
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Expected O, but got Unknown
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Expected O, but got Unknown
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Expected O, but got Unknown
logger.LogInfo((object)"RepoCustomPhotonServer Loaded !");
isActive = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Enable", false, (ConfigDescription)null);
isChangeSteamAppId = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Change SteamAppId", false, (ConfigDescription)null);
AppIdRealtime = ((BaseUnityPlugin)this).Config.Bind<string>("Photon", "AppIdRealtime", "99515094-45b7-4c98-ab70-a448c548c83d", new ConfigDescription("Photon Realtime App ID", (AcceptableValueBase)null, new object[1] { "HideFromREPOConfig" }));
AppIdVoice = ((BaseUnityPlugin)this).Config.Bind<string>("Photon", "AppIdVoice", "dfc40a01-c3a4-4395-9707-b71118816d2b", new ConfigDescription("Photon Voice App ID", (AcceptableValueBase)null, new object[1] { "HideFromREPOConfig" }));
FixedRegion = ((BaseUnityPlugin)this).Config.Bind<string>("Photon", "Region", "", new ConfigDescription("Region", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[16]
{
"", "asia", "au", "cae", "eu", "hk", "in", "jp", "za", "sa",
"kr", "tr", "uae", "us", "usw", "ussc"
}), Array.Empty<object>()));
Harmony val = new Harmony("RepoCustomPhotonServer");
val.PatchAll();
}
private static string GetSteamAuthTicket(out AuthTicket ticket)
{
logger.LogInfo((object)"Getting Steam Auth Ticket...");
ticket = SteamUser.GetAuthSessionTicket();
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < ticket.Data.Length; i++)
{
stringBuilder.AppendFormat("{0:x2}", ticket.Data[i]);
}
return stringBuilder.ToString();
}
private static void UpdatePhotonSettings()
{
ServerSettings val = Object.FindObjectOfType<ServerSettings>() ?? Resources.Load<ServerSettings>("PhotonServerSettings");
if ((Object)(object)val != (Object)null)
{
val.AppSettings.AppIdRealtime = AppIdRealtime.Value ?? ((ConfigEntryBase)AppIdRealtime).DefaultValue.ToString();
val.AppSettings.AppIdVoice = AppIdVoice.Value ?? ((ConfigEntryBase)AppIdVoice).DefaultValue.ToString();
val.AppSettings.FixedRegion = FixedRegion.Value;
logger.LogDebug((object)("AppIdRealtime : " + val.AppSettings.AppIdRealtime));
logger.LogDebug((object)("AppIdVoice : " + val.AppSettings.AppIdVoice));
logger.LogDebug((object)("Region : " + val.AppSettings.FixedRegion));
PhotonNetwork.ConnectUsingSettings();
}
}
private static void UpdateAuthMethod()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Expected O, but got Unknown
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
PhotonNetwork.AuthValues = new AuthenticationValues();
AuthenticationValues authValues = PhotonNetwork.AuthValues;
SteamId steamId = SteamClient.SteamId;
authValues.UserId = ((object)(SteamId)(ref steamId)).ToString();
PhotonNetwork.AuthValues.AuthType = (CustomAuthenticationType)255;
string text = GetSteamAuthTicket(out steamAuthTicket);
logger.LogDebug((object)("SteamAuthTicket: " + text));
PhotonNetwork.AuthValues.AddAuthParameter("ticket", text);
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "RepoCustomPhotonServer";
public const string PLUGIN_NAME = "RepoCustomPhotonServer";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}