using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using Discord.Sdk;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Steamworks;
using Steamworks.Data;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RepoDRP")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RepoDRP")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7accc35c-a204-4f1b-989c-d6a939192d01")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
}
}
}
namespace RepoDRP
{
public class DiscordManager : MonoBehaviour
{
private enum GameState
{
None,
MainMenu,
MenuMultiplayerLobby,
Tutorial,
LevelLoading,
LevelStart,
LevelActive,
LevelExtracting,
LevelFinalExtract,
LevelSearchingForExtract,
Shop,
TruckLobby,
GameOver
}
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static UpdateRichPresenceCallback <>9__41_0;
internal void <SetPresence>b__41_0(ClientResult <p0>)
{
}
}
public static long startupTime;
public Client discord;
public Activity activity;
public ActivityParty party;
private GameState lastState = GameState.None;
private bool partyValid = false;
private float lastPartySet = 0f;
private bool ingameRichPresenceSetToFull = false;
private int lastPlayerCount = -1;
private static int lastMoney = -1;
private int lastPlayersAlive = -1;
private int lastHaul = -1;
private int lastHaulQuickUpdate = -1;
private float lastHaulUpdateTimer = 0f;
public static string CurrentVersion => BuildManager.instance?.version.title ?? "";
public static int CurrentLevel => (RunManager.instance?.levelsCompleted ?? 0) + 1;
public static string CurrentLevelName
{
get
{
if (Debug.isDebugBuild)
{
return "???";
}
return RunManager.instance?.levelCurrent.NarrativeName ?? "???";
}
}
public static Lobby? CurrentLobby
{
get
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)SteamManager.instance == (Object)null)
{
return null;
}
return Traverse.Create((object)SteamManager.instance).Field("currentLobby").GetValue<Lobby>();
}
}
public static int ArenaPlayersRemaining
{
get
{
if ((Object)(object)Arena.instance == (Object)null || !SemiFunc.IsMultiplayer())
{
return -1;
}
return Traverse.Create((object)Arena.instance).Field("playersAlive").GetValue<int>();
}
}
public static int ExtractionPointsCompleted
{
get
{
if ((Object)(object)RoundDirector.instance == (Object)null)
{
return 0;
}
return Traverse.Create((object)RoundDirector.instance).Field("extractionPointsCompleted").GetValue<int>();
}
}
public static int ExtractionPointsTotal
{
get
{
if ((Object)(object)RoundDirector.instance == (Object)null)
{
return 0;
}
return Traverse.Create((object)RoundDirector.instance).Field("extractionPoints").GetValue<int>();
}
}
public static bool ExtractionPointActive
{
get
{
if ((Object)(object)RoundDirector.instance == (Object)null)
{
return false;
}
return Traverse.Create((object)RoundDirector.instance).Field("extractionPointActive").GetValue<bool>();
}
}
public static ExtractionPoint ExtractionPointCurrent
{
get
{
if ((Object)(object)RoundDirector.instance == (Object)null)
{
return null;
}
return Traverse.Create((object)RoundDirector.instance).Field("extractionPointCurrent").GetValue<ExtractionPoint>();
}
}
public static State CurrentExtractionPointState
{
get
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)ExtractionPointCurrent == (Object)null)
{
return (State)0;
}
return (State)Traverse.Create((object)ExtractionPointCurrent).Field("currentState").GetValue<int>();
}
}
public static bool ExtractionPointTubeHit
{
get
{
if ((Object)(object)ExtractionPointCurrent == (Object)null)
{
return false;
}
return Traverse.Create((object)ExtractionPointCurrent).Field("tubeHit").GetValue<bool>();
}
}
public static int CurrentHaulGoal
{
get
{
if ((Object)(object)RoundDirector.instance == (Object)null)
{
return 0;
}
return Mathf.Max(0, Traverse.Create((object)RoundDirector.instance).Field("extractionHaulGoal").GetValue<int>());
}
}
public static int CurrentHaul
{
get
{
if ((Object)(object)RoundDirector.instance == (Object)null)
{
return 0;
}
return Mathf.Max(0, Traverse.Create((object)RoundDirector.instance).Field("currentHaul").GetValue<int>());
}
}
public static string ExtractionString => $"[{ExtractionPointsCompleted}/{ExtractionPointsTotal}]";
public static string HaulString => "$" + SemiFunc.DollarGetString(CurrentHaul) + " / $" + SemiFunc.DollarGetString(CurrentHaulGoal);
private void Start()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Expected O, but got Unknown
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Expected O, but got Unknown
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Expected O, but got Unknown
discord = new Client();
discord.SetApplicationId(1344368447928401961uL);
discord.RegisterLaunchSteamApplication(1344368447928401961uL, 3241660u);
activity = new Activity();
activity.SetType((ActivityTypes)0);
activity.SetSupportedPlatforms((ActivityGamePlatforms)1);
party = new ActivityParty();
party.SetPrivacy((ActivityPartyPrivacy)0);
ActivityTimestamps val = new ActivityTimestamps();
val.SetStart((ulong)startupTime);
activity.SetTimestamps(val);
}
private void SetPartySizes()
{
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
partyValid = !SemiFunc.IsMainMenu() && !SemiFunc.RunIsTutorial();
if (!SemiFunc.IsMultiplayer() || !CurrentLobby.HasValue)
{
party.SetCurrentSize(1);
party.SetMaxSize(1);
party.SetId((startupTime * 8626).ToString());
return;
}
ActivityParty obj = party;
Lobby value = CurrentLobby.Value;
obj.SetCurrentSize(Mathf.Max(1, ((Lobby)(ref value)).MemberCount));
ActivityParty obj2 = party;
int[] array = new int[1];
value = CurrentLobby.Value;
array[0] = ((Lobby)(ref value)).MaxMembers;
obj2.SetMaxSize(Mathf.Max(array));
ActivityParty obj3 = party;
value = CurrentLobby.Value;
Friend owner = ((Lobby)(ref value)).Owner;
obj3.SetId(((object)(SteamId)(ref owner.Id)).ToString());
}
private void SetPresence(string details, string state = null, string largeImage = null, string largeImageText = null)
{
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Expected O, but got Unknown
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Expected O, but got Unknown
activity.SetDetails(details);
activity.SetState(state);
ActivitySecrets val = null;
if (partyValid)
{
activity.SetParty(party);
if (SemiFunc.RunIsLobbyMenu() && ingameRichPresenceSetToFull && CurrentLobby.HasValue)
{
val = new ActivitySecrets();
ActivitySecrets obj = val;
Lobby value = CurrentLobby.Value;
SteamId id = ((Lobby)(ref value)).Id;
obj.SetJoin(((object)(SteamId)(ref id)).ToString());
}
}
else
{
activity.SetParty((ActivityParty)null);
}
activity.SetSecrets(val);
ActivityAssets val2 = null;
if (largeImage != null && largeImageText != "Main Menu")
{
if (Debug.isDebugBuild && largeImage != GetArtAsset("Truck") && largeImage != GetArtAsset("Disposal Arena") && largeImage != GetArtAsset("Service Station"))
{
largeImage = GetArtAsset("unknown");
largeImageText = "<hidden by debug build>";
}
val2 = new ActivityAssets();
val2.SetLargeImage(largeImage);
val2.SetLargeText(largeImageText);
}
activity.SetAssets(val2);
Client obj2 = discord;
Activity obj3 = activity;
object obj4 = <>c.<>9__41_0;
if (obj4 == null)
{
UpdateRichPresenceCallback val3 = delegate
{
};
<>c.<>9__41_0 = val3;
obj4 = (object)val3;
}
obj2.UpdateRichPresence(obj3, (UpdateRichPresenceCallback)obj4);
}
private void FixedUpdate()
{
if (activity == null)
{
return;
}
if (Time.unscaledTime - lastPartySet > 2.5f)
{
SetPartySizes();
lastPartySet = Time.unscaledTime;
}
if (!((Object)(object)LevelGenerator.Instance == (Object)null) && !((Object)(object)LevelGenerator.Instance.Level == (Object)null))
{
if (SemiFunc.RunIsLobby())
{
SetLobby();
}
else if (SemiFunc.RunIsShop())
{
SetServiceStation();
}
else if (SemiFunc.RunIsArena())
{
SetDisposalArena();
}
else if (SemiFunc.RunIsTutorial())
{
SetTutorial();
}
else if (SemiFunc.RunIsLobbyMenu() && Object.op_Implicit((Object)(object)MenuPageLobby.instance))
{
SetMultiplayerLobby();
}
else if (SemiFunc.IsMainMenu())
{
SetMainMenu();
}
else if (SemiFunc.RunIsLevel())
{
SetLevel();
}
}
}
private bool CheckSwitchState(GameState newState)
{
if (lastState == newState)
{
return true;
}
lastState = newState;
if (newState != GameState.LevelActive)
{
lastHaul = -1;
}
if (newState != GameState.Shop)
{
lastMoney = -1;
}
if (newState != GameState.MenuMultiplayerLobby)
{
lastPlayerCount = -1;
}
if (newState != GameState.GameOver)
{
lastPlayersAlive = -1;
}
ingameRichPresenceSetToFull = DataDirector.instance.SettingValueFetch((Setting)59) >= 2;
return false;
}
private void SetMultiplayerLobby()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
int num;
if (!CurrentLobby.HasValue)
{
num = 1;
}
else
{
Lobby value = CurrentLobby.Value;
num = ((Lobby)(ref value)).MemberCount;
}
int num2 = num;
if (!CheckSwitchState(GameState.MenuMultiplayerLobby) || lastPlayerCount != num2)
{
lastPlayerCount = num2;
SetPartySizes();
SetPresence("In multiplayer lobby", "Waiting for host to start");
Plugin.loggy.LogDebug((object)$"Switching to Multiplayer Lobby ({lastPlayerCount})");
}
}
private void SetMainMenu()
{
if (!CheckSwitchState(GameState.MainMenu))
{
SetPartySizes();
SetPresence("Main menu", CurrentVersion);
Plugin.loggy.LogDebug((object)"Switching to Main Menu");
}
}
private void SetServiceStation()
{
int num = SemiFunc.StatGetRunCurrency();
if (!CheckSwitchState(GameState.Shop) || lastMoney != num)
{
lastMoney = num;
SetPartySizes();
SetPresence($"Level {CurrentLevel} - Service Station", $"${num}K", GetArtAsset("Service Station"), "Service Station");
Plugin.loggy.LogDebug((object)$"Switching to Service Station ({num}K)");
}
}
private void SetDisposalArena()
{
if (!CheckSwitchState(GameState.GameOver) || lastPlayersAlive != ArenaPlayersRemaining)
{
lastPlayersAlive = ArenaPlayersRemaining;
string artAsset = GetArtAsset("Disposal Arena");
SetPartySizes();
Plugin.loggy.LogDebug((object)$"Switching to Disposal Arena ({lastPlayersAlive})");
if (ArenaPlayersRemaining >= 0)
{
SetPresence("Game Over - Disposal Arena", $"{ArenaPlayersRemaining} Remaining...", artAsset, "Disposal Arena");
}
else
{
SetPresence("Game Over - Disposal Arena", null, artAsset, "Disposal Arena");
}
}
}
private void SetTutorial()
{
if (!CheckSwitchState(GameState.Tutorial))
{
SetPartySizes();
SetPresence("Tutorial");
Plugin.loggy.LogDebug((object)"Switching to Tutorial");
}
}
private string GetArtAsset(string name)
{
return "https://lh3.googleusercontent.com/d/" + name switch
{
"Truck" => "1XyycWAqn29Kms0QgDAbXS42O-QXj8cYA",
"McJannek Station" => "1Nl4gtFE-syWUFV-5SbGb_3rTLlMlEP7Q",
"Disposal Arena" => "1DUpdbd2jNO0vCYirjRzea6t811j6q-w-",
"Headman Manor" => "1bI0PePH0Zl25b-oiVjodm6sRcWZi03AQ",
"Service Station" => "10l_dhKcnmvmtr5bfSunapMZldWeX3JVB",
"Swiftbroom Academy" => "1LTfIkGv0Q7ZejFclL7ZZ2f57goBTOk9f",
"Museum of Human Art" => "122_zKhXSTeHU7Y_AKlioLN8-BB3VuLwF",
_ => "1KvzedfoqHF-UXNRiepqkRMuaBIzdfRCg",
};
}
private void SetLevel()
{
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Invalid comparison between Unknown and I4
string artAsset = GetArtAsset(CurrentLevelName);
if (ExtractionPointsTotal == 0)
{
SetLevelLoad(artAsset);
}
else if (ExtractionPointsCompleted >= ExtractionPointsTotal)
{
SetLevelFinalExtraction(artAsset);
}
else if (!ExtractionPointActive)
{
SetLevelSearchingForExtraction(artAsset);
}
else if ((Object)(object)ExtractionPointCurrent != (Object)null && (int)CurrentExtractionPointState == 6 && ExtractionPointTubeHit)
{
SetLevelCurrentlyExtracting(artAsset);
}
else if (CurrentHaulGoal == 0)
{
SetLevelStart(artAsset);
}
else if (!CheckSwitchState(GameState.LevelActive) || lastHaul != CurrentHaul)
{
if (lastHaulQuickUpdate != CurrentHaul)
{
lastHaulUpdateTimer = 0f;
}
lastHaulQuickUpdate = CurrentHaul;
if (lastHaulUpdateTimer < 3f)
{
lastHaulUpdateTimer += Time.fixedDeltaTime;
return;
}
lastHaul = CurrentHaul;
SetPartySizes();
SetPresence($"Level {CurrentLevel} - {CurrentLevelName}", ExtractionString + " - " + HaulString, artAsset, CurrentLevelName);
Plugin.loggy.LogDebug((object)$"Switching to Level Scavenging ({CurrentHaul} / {CurrentHaulGoal})");
}
}
private void SetLevelLoad(string artAsset)
{
if (!CheckSwitchState(GameState.LevelLoading))
{
SetPartySizes();
SetPresence($"Level {CurrentLevel} - {CurrentLevelName}", null, artAsset, CurrentLevelName);
Plugin.loggy.LogDebug((object)"Switching to Level Loading");
}
}
private void SetLevelStart(string artAsset)
{
if (!CheckSwitchState(GameState.LevelStart))
{
SetPartySizes();
SetPresence($"Level {CurrentLevel} - {CurrentLevelName}", ExtractionString ?? "", artAsset, CurrentLevelName);
Plugin.loggy.LogDebug((object)"Switching to Level Begin");
}
}
private void SetLevelFinalExtraction(string artAsset)
{
if (!CheckSwitchState(GameState.LevelFinalExtract))
{
SetPartySizes();
SetPresence($"Level {CurrentLevel} - {CurrentLevelName}", ExtractionString + " - Returning to the truck", artAsset, CurrentLevelName);
Plugin.loggy.LogDebug((object)"Switching to Final Extraction");
}
}
private void SetLevelSearchingForExtraction(string artAsset)
{
if (!CheckSwitchState(GameState.LevelSearchingForExtract))
{
SetPartySizes();
if (ExtractionPointsTotal == 0 || !LevelGenerator.Instance.Generated)
{
SetPresence($"Level {CurrentLevel} - {CurrentLevelName}", null, artAsset, CurrentLevelName);
return;
}
if (ExtractionPointsCompleted == 0)
{
SetPresence($"Level {CurrentLevel} - {CurrentLevelName}", ExtractionString ?? "", artAsset, CurrentLevelName);
return;
}
SetPresence($"Level {CurrentLevel} - {CurrentLevelName}", ExtractionString + " - Searching for next extraction", artAsset, CurrentLevelName);
Plugin.loggy.LogDebug((object)"Switching to Searching For Extraction");
}
}
private void SetLevelCurrentlyExtracting(string artAsset)
{
if (!CheckSwitchState(GameState.LevelExtracting))
{
SetPartySizes();
SetPresence($"Level {CurrentLevel} - {CurrentLevelName}", ExtractionString + " - Extracting...", artAsset, CurrentLevelName);
Plugin.loggy.LogDebug((object)"Switching to Currently Extracting");
}
}
private void SetLobby()
{
if (!CheckSwitchState(GameState.TruckLobby))
{
SetPartySizes();
SetPresence($"Level {CurrentLevel} - Truck Lobby", null, GetArtAsset("Truck"), "Truck Lobby");
Plugin.loggy.LogDebug((object)"Switching to Truck Lobby");
}
}
}
[BepInPlugin("Swaggies.RepoDRP", "RepoDRP", "1.2.0")]
public class Plugin : BaseUnityPlugin
{
private const string _guid = "Swaggies.RepoDRP";
private const string _name = "RepoDRP";
public const string _ver = "1.2.0";
private readonly Harmony harmony = new Harmony("Swaggies.RepoDRP");
public static ManualLogSource loggy;
private void Awake()
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
loggy = Logger.CreateLogSource("Swaggies.RepoDRP");
loggy.LogMessage((object)"RepoDRP's up and runnin' on 1.2.0");
harmony.PatchAll(typeof(Plugin));
loggy.LogInfo((object)"adding discord...");
GameObject val = new GameObject("Swaggies-RepoDRP Discord Manager");
val.AddComponent<DiscordManager>();
((Object)val).hideFlags = (HideFlags)61;
Object.DontDestroyOnLoad((Object)(object)val);
DiscordManager.startupTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
}
}
}