using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using TerminalApi;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("MaxMarx_AdminExtensions")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MaxMarx_AdminExtensions")]
[assembly: AssemblyTitle("MaxMarx_AdminExtensions")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace MaxMarx_GameMaster
{
internal enum LOG_TYPE
{
info,
warning,
error
}
public enum TEXT_CHAT_SENDER_TYPE
{
user,
admin,
system
}
[BepInPlugin("MaxMarx_AdminExtensions", "MaxMarx_AdminExtensions", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class MaxMarx_AdminExtensions : BaseUnityPlugin
{
private static ConfigEntry<float> configTerminalScaleValue;
private readonly Harmony harmony = new Harmony("MaxMarx_GameMaster");
public static bool isHost;
public static bool enableInfiniteSprint;
public static bool reviveSelf;
private static bool roundStarted;
private static bool addedCommands;
private static bool enableDeath;
private static bool updatedQuotaVariables;
private static MaxMarx_AdminExtensions Instance;
private static int patchCreditsValue;
private static int lastCreditsValue;
private static ManualLogSource logger;
private static float baseTerminalScale;
private static float patchBaseTerminalScaleValue;
private static Dictionary<string, string> textChatColors;
private static bool usingVirtualTerminal;
private static bool switchRadarView;
public static int totalAllowedPurchases;
private static QuotaSettings newQuotaSettings;
public static MaxNetCore net;
private static int currentRadarIndex;
private static PlayerControllerB thisPlayer;
private void Awake()
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
Instance = this;
logger = ((BaseUnityPlugin)this).Logger;
baseTerminalScale = 0f;
patchBaseTerminalScaleValue = 0f;
patchCreditsValue = 0;
isHost = (roundStarted = (addedCommands = false));
enableDeath = true;
enableInfiniteSprint = false;
usingVirtualTerminal = false;
totalAllowedPurchases = 0;
newQuotaSettings = new QuotaSettings();
newQuotaSettings.baseIncrease = 400f;
reviveSelf = false;
currentRadarIndex = 0;
switchRadarView = false;
updatedQuotaVariables = false;
net = null;
harmony.PatchAll(typeof(MaxMarx_AdminExtensions));
textChatColors = new Dictionary<string, string>
{
{ "red", "#ff3333" },
{ "yellow", "#ffcc00" },
{ "blue", "#003399" },
{ "orange", "#ff9900" },
{ "admin", "#66ffff" },
{ "white", "#ffffff" },
{ "pink", "#bb00ff" },
{ "green", "#c1ff80" },
{ "light-green", "#54ffc0" },
{ "light-purple", "#e4b8ff" },
{ "light-orange", "#ffcdb0" }
};
configTerminalScaleValue = ((BaseUnityPlugin)this).Config.Bind<float>("General", "TerminalScaleValue", 0f, "Value between 0.0 and 1.0 to determine scale size of terminal screen");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin MaxMarx_AdminExtensions is loaded!");
}
private void Update()
{
}
private static void addTerminalCommands()
{
if (isHost)
{
TerminalApi.AddCommand("max", "Mini Admin Extensions Loaded\n\n", "get", false);
TerminalApi.AddTerminalKeyword(TerminalApi.CreateTerminalKeyword("setcredits", "Setting Credits ....", true, "setCredits"));
TerminalApi.AddTerminalKeyword(TerminalApi.CreateTerminalKeyword("setscale", "Setting Scale ....", true, "setScale"));
TerminalApi.AddTerminalKeyword(TerminalApi.CreateTerminalKeyword("death", "Setting Death Mode ....", true, "setDeath"));
TerminalApi.AddTerminalKeyword(TerminalApi.CreateTerminalKeyword("revive", "Reviving a player ....", true, "revivePlayer"));
TerminalApi.AddTerminalKeyword(TerminalApi.CreateTerminalKeyword("fquota", "Setting Fulfilled Quota ....", true, "setFulfilledQuota"));
TerminalApi.AddTerminalKeyword(TerminalApi.CreateTerminalKeyword("pquota", "Setting Profit Quota ....", true, "setProfitQuota"));
TerminalApi.AddTerminalKeyword(TerminalApi.CreateTerminalKeyword("deadline", "Setting Deadline Days Left ....", true, "setDeadline"));
TerminalApi.AddTerminalKeyword(TerminalApi.CreateTerminalKeyword("cp", "Pulling Player Data ....", true, "checkPlayer"));
TerminalApi.AddTerminalKeyword(TerminalApi.CreateTerminalKeyword("q", "Switching Radar View ....", true, "switchRadarView"));
TerminalApi.AddTerminalKeyword(TerminalApi.CreateTerminalKeyword("istamina", "Setting Infinite Stamina....", true, "setInfiniteStamina"));
TerminalApi.AddTerminalKeyword(TerminalApi.CreateTerminalKeyword("ap", "Setting Total Allowed Purchases....", true, "chargeSpecials"));
}
TerminalApi.AddTerminalKeyword(TerminalApi.CreateTerminalKeyword("charge", "Charging All Battery Items....", true, "chargeSpecials"));
}
private static bool verifyPurchase(ref Terminal __instance)
{
if (!Object.op_Implicit((Object)(object)__instance) || !Object.op_Implicit((Object)(object)__instance.screenText) || __instance.screenText.text.Length == 0)
{
return true;
}
string text = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded);
string text2 = __instance.screenText.text.Substring(0, __instance.screenText.text.Length - __instance.textAdded);
if (text.Length == 0)
{
return true;
}
string[] array = text.Split(new char[1] { ' ' });
if (array.Length == 0 || text2.Contains("The cost to route to") || text2.Contains("Routing autopilot") || text2.Contains("The Company is buying"))
{
return true;
}
string text3 = array[0];
Terminal val = __instance;
if (array.Length == 1 && text3.ToLower() == "confirm")
{
if (totalAllowedPurchases <= 0)
{
val.screenText.text = "DENIED ORDER";
val.LoadNewNode(TerminalApi.CreateTerminalNode("To prevent griefing of credits, this purchase is not approved, please ask Host to approve\n\n", true, ""));
return false;
}
totalAllowedPurchases--;
net.Trigger_SyncAllowedPurchasesWithServerClient();
}
return true;
}
private static void parseTerminalCommand(ref Terminal __instance, ref TerminalNode __result, int ___totalCostOfItems)
{
if (!Object.op_Implicit((Object)(object)__instance) || !Object.op_Implicit((Object)(object)__instance.screenText) || __instance.screenText.text.Length == 0 || !Object.op_Implicit((Object)(object)__result))
{
return;
}
string text = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded);
if (text.Length == 0)
{
return;
}
string[] array = text.Split(new char[1] { ' ' });
if (array.Length == 0)
{
return;
}
string text2 = array[0];
Terminal val = __instance;
if (isHost)
{
if (array.Length == 2 && array[0] == "setcredits")
{
patchCreditsValue = int.Parse(array[1]);
if (patchCreditsValue < 0)
{
patchCreditsValue = 0;
}
val.groupCredits = patchCreditsValue;
__result = TerminalApi.CreateTerminalNode($"Set Credits to |{patchCreditsValue}\n\n", true, "");
}
if (array.Length == 2 && array[0] == "setscale")
{
patchBaseTerminalScaleValue = float.Parse(array[1]);
if (patchBaseTerminalScaleValue < 0f)
{
patchBaseTerminalScaleValue = 0f;
}
if (patchBaseTerminalScaleValue > 0f)
{
val.terminalUIScreen.scaleFactor = baseTerminalScale + patchBaseTerminalScaleValue;
}
else
{
val.terminalUIScreen.scaleFactor = baseTerminalScale + configTerminalScaleValue.Value;
}
__result = TerminalApi.CreateTerminalNode($"Updated Terminal Scale [{patchBaseTerminalScaleValue}]\n\n", true, "");
}
if (array.Length == 2 && array[0] == "setdeath")
{
if (array.Length > 1 && array[1] == "1")
{
enableDeath = true;
}
else
{
enableDeath = false;
}
__result = TerminalApi.CreateTerminalNode($"Can Host Die: [{enableDeath}]\n\n", true, "");
}
if (array.Length == 2 && array[0] == "revive")
{
int num = int.Parse(array[1]);
if (num < 0)
{
__result = TerminalApi.CreateTerminalNode($"No Player with Index: [{num}]\n\n", true, "");
return;
}
net.Trigger_SyncReviveSelfWithServerClient((ulong)num);
__result = TerminalApi.CreateTerminalNode($"Request Sent to revive Player Index: [{num}]\n\n", true, "");
}
if (array.Length == 2 && array[0] == "fquota")
{
int num2 = int.Parse(array[1]);
if (num2 < 0)
{
return;
}
TimeOfDay.Instance.quotaFulfilled = num2;
TimeOfDay.Instance.UpdateProfitQuotaCurrentTime();
__result = TerminalApi.CreateTerminalNode($"Set New Fulfilled Quota to: [{num2}]\n\n", true, "");
}
if (array.Length == 2 && array[0] == "pquota")
{
int num3 = int.Parse(array[1]);
if (num3 < 0)
{
return;
}
TimeOfDay.Instance.profitQuota = num3;
TimeOfDay.Instance.UpdateProfitQuotaCurrentTime();
__result = TerminalApi.CreateTerminalNode($"Set New Profit Quota to: [{num3}]\n\n", true, "");
}
if (array.Length == 2 && array[0] == "deadline")
{
int num4 = int.Parse(array[1]);
if (num4 < 0)
{
return;
}
TimeOfDay.Instance.daysUntilDeadline = num4;
((TMP_Text)StartOfRound.Instance.deadlineMonitorText).text = $"DEADLINE:\n{TimeOfDay.Instance.daysUntilDeadline} Days";
__result = TerminalApi.CreateTerminalNode($"Set New Deadline to: [{num4}] days\nTimeUntilDeadline: {TimeOfDay.Instance.timeUntilDeadline}\nTotalTime: {TimeOfDay.Instance.totalTime}\n\n", true, "");
}
if (array.Length == 1 && array[0] == "q")
{
switchRadarView = true;
__result = TerminalApi.CreateTerminalNode("Switched Radar View\n\n", true, "");
}
if (array.Length == 2 && array[0] == "cp")
{
int num5 = int.Parse(array[1]);
if (num5 < 0)
{
__result = TerminalApi.CreateTerminalNode($"Invalid Player [{num5}]\n\n", true, "");
return;
}
PlayerControllerB player = getPlayer(num5);
if (player.playerUsername == "" || !player.isPlayerControlled)
{
__result = TerminalApi.CreateTerminalNode($"Invalid Player [{num5}]\n\n", true, "");
return;
}
__result = TerminalApi.CreateTerminalNode($"[{player.playerUsername}] Health Is at: [{player.health}]\n\n", true, "");
}
if (array.Length == 2 && array[0] == "istamina")
{
if (array[1] == "1")
{
enableInfiniteSprint = true;
net.Trigger_SyncInfiniteStaminaWithServerClient();
}
else
{
enableInfiniteSprint = false;
net.Trigger_SyncInfiniteStaminaWithServerClient();
}
}
if (array.Length == 2 && array[0] == "ap")
{
int num6 = int.Parse(array[1]);
if (num6 <= 0)
{
return;
}
setTotalAllowedPurchases(num6);
}
}
if (array.Length == 1 && array[0].ToLower() == "confirm")
{
string text3 = __result.displayText;
int num7 = val.groupCredits - ___totalCostOfItems;
int num8 = text3.IndexOf("Our contractors");
if (num8 != -1)
{
text3 = text3.Substring(0, num8 - 1);
}
text3 = text3.Replace("[playerCredits]", "$" + num7);
text3 = text3.Replace("[variableAmount]", val.playerDefinedAmount + " X ");
text3 = text3 + "[!] Receipt from [" + thisPlayer.playerUsername + "] Stored on Server\n";
text3 += $"[!] {totalAllowedPurchases} more purchases can be made";
sendGeneralTextChatMessage(text3, "white", TEXT_CHAT_SENDER_TYPE.system);
}
if (array.Length == 1 && array[0].ToLower() == "charge")
{
chargeSpecialItems();
__result = TerminalApi.CreateTerminalNode("Sent command to charge your items\n\n", true, "");
}
if (array.Length == 1 && array[0].ToLower() == "other")
{
__result.displayText = __result.displayText.Substring(0, __result.displayText.Length - 1);
TerminalNode obj = __result;
obj.displayText += ">CHARGE\nCharges all battery powered items in your inventory, special slots included\n";
TerminalNode obj2 = __result;
obj2.displayText += "\n\n";
}
}
private static PlayerControllerB getPlayer(int playerID)
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
for (int i = 0; i < allPlayerScripts.Length; i++)
{
if ((int)allPlayerScripts[i].playerClientId == playerID)
{
return allPlayerScripts[i];
}
}
return new PlayerControllerB();
}
private static int LineNumber([CallerLineNumber] int lineNumber = 0)
{
return lineNumber;
}
public static void reviveThisPlayer(ref PlayerControllerB player)
{
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
StartOfRound instance = StartOfRound.Instance;
if (player.playerUsername == "" || !player.isPlayerDead)
{
HUDManager.Instance.DisplayTip("Unable to Revive", "[" + player.playerUsername + "] is either not dead or non-existent", false, false, "LC_Tip1");
return;
}
player.ResetPlayerBloodObjects(true);
if (player.isPlayerDead || player.isPlayerControlled)
{
player.isClimbingLadder = false;
player.ResetZAndXRotation();
((Collider)player.thisController).enabled = true;
player.health = 100;
player.disableLookInput = false;
if (player.isPlayerDead)
{
player.isPlayerDead = false;
player.isPlayerControlled = true;
player.isInElevator = true;
player.isInHangarShipRoom = true;
player.isInsideFactory = false;
player.wasInElevatorLastFrame = false;
player.TeleportPlayer(instance.playerSpawnPositions[0].position, false, 0f, false, true);
player.setPositionOfDeadPlayer = false;
player.DisablePlayerModel(instance.allPlayerObjects[player.playerClientId], true, true);
((Behaviour)player.helmetLight).enabled = false;
player.Crouch(false);
player.criticallyInjured = false;
if ((Object)(object)player.playerBodyAnimator != (Object)null)
{
player.playerBodyAnimator.SetBool("Limp", false);
}
player.bleedingHeavily = false;
player.activatingItem = false;
player.twoHanded = false;
player.inSpecialInteractAnimation = false;
player.disableSyncInAnimation = false;
player.inAnimationWithEnemy = null;
player.holdingWalkieTalkie = false;
player.speakingToWalkieTalkie = false;
player.isSinking = false;
player.isUnderwater = false;
player.sinkingValue = 0f;
player.statusEffectAudio.Stop();
player.DisableJetpackControlsLocally();
player.health = 100;
player.mapRadarDotAnimator.SetBool("dead", false);
if (((NetworkBehaviour)player).IsOwner)
{
HUDManager.Instance.gasHelmetAnimator.SetBool("gasEmitting", false);
player.hasBegunSpectating = false;
HUDManager.Instance.RemoveSpectateUI();
HUDManager.Instance.gameOverAnimator.SetTrigger("revive");
player.hinderedMultiplier = 1f;
player.isMovementHindered = 0;
player.sourcesCausingSinking = 0;
player.reverbPreset = instance.shipReverb;
}
}
SoundManager.Instance.earsRingingTimer = 0f;
player.voiceMuffledByEnemy = false;
SoundManager.Instance.playerVoicePitchTargets[player.playerClientId] = 1f;
SoundManager.Instance.SetPlayerPitch(1f, (int)player.playerClientId);
if ((Object)(object)player.currentVoiceChatIngameSettings == (Object)null)
{
instance.RefreshPlayerVoicePlaybackObjects();
}
if ((Object)(object)player.currentVoiceChatIngameSettings != (Object)null)
{
if ((Object)(object)player.currentVoiceChatIngameSettings.voiceAudio == (Object)null)
{
player.currentVoiceChatIngameSettings.InitializeComponents();
}
if ((Object)(object)player.currentVoiceChatIngameSettings.voiceAudio == (Object)null)
{
return;
}
((Component)player.currentVoiceChatIngameSettings.voiceAudio).GetComponent<OccludeAudio>().overridingLowPass = false;
}
}
player.bleedingHeavily = false;
player.criticallyInjured = false;
player.playerBodyAnimator.SetBool("Limp", false);
player.health = 100;
HUDManager.Instance.UpdateHealthUI(100, false);
player.spectatedPlayerScript = null;
((Behaviour)HUDManager.Instance.audioListenerLowPass).enabled = false;
instance.SetSpectateCameraToGameOverMode(false, player);
RagdollGrabbableObject[] array = Object.FindObjectsOfType<RagdollGrabbableObject>();
for (int i = 0; i < array.Length; i++)
{
if (!((GrabbableObject)array[i]).isHeld)
{
if (((NetworkBehaviour)instance).IsServer)
{
if (((NetworkBehaviour)array[i]).NetworkObject.IsSpawned)
{
((NetworkBehaviour)array[i]).NetworkObject.Despawn(true);
}
else
{
Object.Destroy((Object)(object)((Component)array[i]).gameObject);
}
}
}
else if (((GrabbableObject)array[i]).isHeld && (Object)(object)((GrabbableObject)array[i]).playerHeldBy != (Object)null && ((GrabbableObject)array[i]).playerHeldBy.playerClientId == player.playerClientId)
{
((GrabbableObject)array[i]).playerHeldBy.DropAllHeldItems(true, false);
}
}
DeadBodyInfo[] array2 = Object.FindObjectsOfType<DeadBodyInfo>();
for (int j = 0; j < array2.Length; j++)
{
Component val = (Component)(object)array2[j];
if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.gameObject))
{
PlayerControllerB component = val.gameObject.GetComponent<PlayerControllerB>();
if (component.playerClientId == player.playerClientId)
{
Object.Destroy((Object)(object)val.gameObject);
break;
}
}
}
instance.livingPlayers++;
instance.allPlayersDead = false;
instance.UpdatePlayerVoiceEffects();
instance.PlayerHasRevivedServerRpc();
HUDManager.Instance.DisplayTip("Revive Attempted", "Admin attempted to revive you", false, false, "LC_Tip1");
}
public static void sendGeneralTextChatMessage(string message, string color = "white", TEXT_CHAT_SENDER_TYPE type = TEXT_CHAT_SENDER_TYPE.user)
{
if (message != null && !(message == ""))
{
message = "<color=" + textChatColors[color] + ">" + message + "</color>";
if (type == TEXT_CHAT_SENDER_TYPE.admin)
{
message = "<color=" + textChatColors["admin"] + ">[ADMIN]: </color>" + message;
}
if (type == TEXT_CHAT_SENDER_TYPE.system)
{
message = "<color=" + textChatColors["admin"] + ">[SYSTEM]: </color>" + message;
}
HUDManager.Instance.AddTextToChatOnServer(message, -1);
}
}
public static void sendTip(string header, string content)
{
HUDManager.Instance.DisplayTip(header, content, false, false, "LC_Tip1");
}
private static void log(string content, LOG_TYPE type = LOG_TYPE.info)
{
switch (type)
{
case LOG_TYPE.error:
logger.LogError((object)content);
FileLog.Log("[ERROR] " + content);
break;
case LOG_TYPE.warning:
logger.LogWarning((object)content);
FileLog.Log("[WARNING] " + content);
break;
default:
logger.LogInfo((object)content);
FileLog.Log("[INFO] " + content);
break;
}
}
private static void openVirtualTerminal(Terminal term)
{
if (!term.terminalInUse)
{
usingVirtualTerminal = true;
term.BeginUsingTerminal();
HUDManager.Instance.ChangeControlTip(0, string.Empty, true);
GameNetworkManager.Instance.localPlayerController.inSpecialInteractAnimation = true;
HUDManager.Instance.DisplayTip("Terminal Open", "Used !t", false, false, "LC_Tip1");
}
}
private static void chargeSpecialItems()
{
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Expected O, but got Unknown
int num = 0;
if (!Object.op_Implicit((Object)(object)thisPlayer) || thisPlayer.ItemSlots.Length == 0)
{
return;
}
for (int i = 0; i < thisPlayer.ItemSlots.Length; i++)
{
GrabbableObject val = thisPlayer.ItemSlots[i];
if (!((Object)(object)val == (Object)null) && val.itemProperties.requiresBattery)
{
val.insertedBattery = new Battery(false, 1f);
num++;
}
}
if (num > 0)
{
sendTip("Charged Items", $"Charged {num} items in your inventory");
}
}
private static void setTotalAllowedPurchases(int amount)
{
totalAllowedPurchases = amount;
sendGeneralTextChatMessage($"[{amount}] purchases are approved at the terminal, buy away!", "white", TEXT_CHAT_SENDER_TYPE.system);
net.Trigger_SyncAllowedPurchasesWithServerClient();
}
[HarmonyPatch(typeof(RoundManager), "LoadNewLevel")]
[HarmonyPrefix]
private static bool patchLoadNewLevel()
{
if (TimeOfDay.Instance.daysUntilDeadline == 1 && !enableInfiniteSprint)
{
string text = "<color=" + textChatColors["light-purple"] + ">[MAD RUSH PROJECT MANAGER] </color><color=" + textChatColors["light-orange"] + ">INFINITE Stamina! Move fast and keep your job!</color>";
if (isHost)
{
HUDManager.Instance.AddTextToChatOnServer(text, -1);
}
enableInfiniteSprint = true;
net.Trigger_SyncInfiniteStaminaWithServerClient();
}
else if (TimeOfDay.Instance.daysUntilDeadline != 1 && enableInfiniteSprint)
{
enableInfiniteSprint = false;
net.Trigger_SyncInfiniteStaminaWithServerClient();
}
if (TimeOfDay.Instance.daysUntilDeadline == 0)
{
string text2 = "<color=" + textChatColors["light-purple"] + ">[MAD RUSH PROJECT MANAGER] </color><color=" + textChatColors["light-orange"] + ">Fingers crossed you don't end up in the unemployment lineup!</color>";
if (isHost)
{
HUDManager.Instance.AddTextToChatOnServer(text2, -1);
}
}
return true;
}
[HarmonyPatch(typeof(RoundManager), "Start")]
[HarmonyPrefix]
private static void patchRoundManagerStart()
{
isHost = ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost;
roundStarted = true;
if (isHost)
{
Terminal val = Object.FindObjectOfType<Terminal>();
Canvas terminalUIScreen = val.terminalUIScreen;
val.terminalUIScreen.renderMode = (RenderMode)0;
terminalUIScreen.scaleFactor = 1.65f;
}
if (isHost && roundStarted && !addedCommands)
{
addTerminalCommands();
addedCommands = true;
}
if (!updatedQuotaVariables)
{
TimeOfDay.Instance.quotaVariables.baseIncrease = newQuotaSettings.baseIncrease;
updatedQuotaVariables = true;
}
}
[HarmonyPatch(typeof(Terminal), "BeginUsingTerminal")]
[HarmonyPostfix]
private static void patchRunTerminalEvents(ref Terminal __instance)
{
}
[HarmonyPatch(typeof(Terminal), "OnSubmit")]
[HarmonyPrefix]
private static bool patchPurchases(ref Terminal __instance)
{
return verifyPurchase(ref __instance);
}
[HarmonyPatch(typeof(Terminal), "ParsePlayerSentence")]
[HarmonyPostfix]
private static void patchParseTerminalCommand(ref Terminal __instance, ref TerminalNode __result, int ___totalCostOfItems)
{
parseTerminalCommand(ref __instance, ref __result, ___totalCostOfItems);
}
[HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")]
[HarmonyPrefix]
private static void patchSubmitChat(HUDManager __instance)
{
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Expected O, but got Unknown
string text = __instance.chatTextField.text;
string text2 = "!";
if (!text.ToLower().StartsWith(text2.ToLower()) && text.IndexOf("@") == -1)
{
return;
}
string[] array = text.Split(new char[1] { '@' });
if (array.Length == 0)
{
return;
}
if (array[0] == "!t" && isHost)
{
Terminal val = Object.FindObjectOfType<Terminal>();
if ((Object)val == (Object)null)
{
return;
}
openVirtualTerminal(val);
__instance.chatTextField.text = "";
}
else if (array[0] == "!ap" && isHost && array.Length == 2)
{
int num = int.Parse(array[1]);
if (num > 0)
{
setTotalAllowedPurchases(num);
}
__instance.chatTextField.text = "";
}
if (array.Length == 2 && array[0][0] != '!')
{
string color = ((!textChatColors.ContainsKey(array[0]) || ((!(array[0] == "admin") || !isHost) && !(array[0] != "admin"))) ? "white" : array[0]);
string message = array[1];
if (isHost)
{
sendGeneralTextChatMessage(message, color, TEXT_CHAT_SENDER_TYPE.admin);
}
else
{
sendGeneralTextChatMessage(message, color);
}
__instance.chatTextField.text = "";
}
}
[HarmonyPatch(typeof(HUDManager), "AddTextToChatOnServer")]
[HarmonyPostfix]
private static void patchNewTextChatMessage(string chatMessage, int playerId)
{
string text = "";
if (playerId != -1)
{
PlayerControllerB player = getPlayer(playerId);
text = player.playerUsername;
}
if (isHost)
{
FileLog.Log("[CHAT MESSAGE][" + text + "] " + chatMessage);
}
}
[HarmonyPatch(typeof(Terminal), "QuitTerminal")]
[HarmonyPostfix]
private static void patchQuitTerminal()
{
GameNetworkManager.Instance.localPlayerController.inSpecialInteractAnimation = false;
usingVirtualTerminal = false;
}
[HarmonyPatch(typeof(Terminal), "LoadNewNodeIfAffordable")]
[HarmonyPrefix]
private static bool patchTerminalPurchases(ref Terminal __instance, ref TerminalNode node)
{
if (node.buyItemIndex < 0)
{
return true;
}
Item val = __instance.buyableItemsList[node.buyItemIndex];
sendGeneralTextChatMessage($"An Order was requested for {__instance.playerDefinedAmount} X {val.itemName}", "white", TEXT_CHAT_SENDER_TYPE.system);
return true;
}
[HarmonyPatch(typeof(PlayerControllerB), "AllowPlayerDeath")]
[HarmonyPrefix]
private static bool patchDeath()
{
if (isHost)
{
return enableDeath;
}
return true;
}
[HarmonyPatch(typeof(PlayerControllerB), "Update")]
[HarmonyPostfix]
private static void patchPlayerUpdate(ref PlayerControllerB __instance, ref float ___sprintMeter, ref bool ___isCameraDisabled)
{
if (enableInfiniteSprint)
{
Mathf.Clamp(___sprintMeter += 0.02f, 0f, 1f);
}
if (switchRadarView)
{
if (currentRadarIndex >= StartOfRound.Instance.connectedPlayersAmount)
{
currentRadarIndex = 0;
}
else
{
currentRadarIndex++;
}
StartOfRound.Instance.mapScreen.SwitchRadarTargetAndSync(currentRadarIndex);
switchRadarView = false;
}
if (Object.op_Implicit((Object)(object)__instance) && reviveSelf)
{
reviveThisPlayer(ref __instance);
___isCameraDisabled = true;
reviveSelf = false;
}
}
[HarmonyPatch(typeof(PlayerControllerB), "DamagePlayerFromOtherClientServerRpc")]
[HarmonyPostfix]
private static void patchDetectDamageSource(ref PlayerControllerB __instance, int __2)
{
PlayerControllerB player = getPlayer(__2);
string message = "<color=#E11919>" + player.playerUsername + " DAMAGED " + __instance.playerUsername + "</color>";
sendGeneralTextChatMessage(message);
}
[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
[HarmonyPostfix]
private static void patchNewMemberJoined(ref PlayerControllerB __instance)
{
if (Object.op_Implicit((Object)(object)__instance) && net == null)
{
net = new MaxNetCore((int)__instance.playerClientId);
thisPlayer = __instance;
patchPlayerSettings();
sendGeneralTextChatMessage("[" + __instance.playerUsername + "][CML] Active", "admin", TEXT_CHAT_SENDER_TYPE.system);
sendTip("New Terminal Command(s)", "New Terminal Command(s) available, type 'HELP' and 'OTHER' to view");
}
}
private static void patchPlayerSettings()
{
IngamePlayerSettings.Instance.settings.masterVolume = 1f;
IngamePlayerSettings.Instance.settings.lookSensitivity = 10;
IngamePlayerSettings.Instance.settings.micEnabled = true;
IngamePlayerSettings.Instance.UpdateGameToMatchSettings();
}
}
public class MaxNetCore
{
[Serializable]
public struct MessageDataParams : INetworkSerializable
{
public ulong specificPlayerId;
public int generalTarget;
public string data;
public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
{
//IL_000b: 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_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
((BufferSerializer<ulong>*)(&serializer))->SerializeValue<ulong>(ref specificPlayerId, default(ForPrimitives));
((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref generalTarget, default(ForPrimitives));
serializer.SerializeValue(ref data, false);
}
}
private Dictionary<string, HandleNamedMessageDelegate> registeredHandlers;
private bool initialized;
private bool IsHost;
private bool IsServer;
private bool IsClient;
public int myPlayerId;
public MaxNetCore(int id)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
registeredHandlers = new Dictionary<string, HandleNamedMessageDelegate>
{
{
"CoreExtensions-SyncAllowedPurchasesWithServerClient",
new HandleNamedMessageDelegate(Process_SyncAllowedPurchasesWithServerClient)
},
{
"CoreExtensions-SyncInfiniteStaminaWithServerClient",
new HandleNamedMessageDelegate(Process_SyncInfiniteStaminaWithServerClient)
},
{
"CoreExtensions-SyncReviveSelfWithServerClient",
new HandleNamedMessageDelegate(Process_SyncReviveSelfWithServerClient)
}
};
IsHost = (IsServer = NetworkManager.Singleton.IsHost);
IsClient = !IsHost;
myPlayerId = id;
Debug.Log((object)$"[MAXNETCORE] LOCAL Player ID: {id}");
initialized = true;
registerMessageHandlers();
}
public void registerMessageHandlers()
{
foreach (KeyValuePair<string, HandleNamedMessageDelegate> registeredHandler in registeredHandlers)
{
NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler(registeredHandler.Key, registeredHandler.Value);
Debug.Log((object)$"[MAXNETCORE] Requested Registration Network Message Handler: {registeredHandler.Key} ;;; Initialized: {initialized}");
}
}
public void Trigger_SyncAllowedPurchasesWithServerClient()
{
MessageDataParams messageDataParams = default(MessageDataParams);
messageDataParams.generalTarget = ((!IsHost) ? 1 : 0);
messageDataParams.specificPlayerId = 0uL;
messageDataParams.data = MaxMarx_AdminExtensions.totalAllowedPurchases.ToString();
MessageDataParams data = messageDataParams;
SendMessage("CoreExtensions-SyncAllowedPurchasesWithServerClient", data);
}
public void Process_SyncAllowedPurchasesWithServerClient(ulong senderId, FastBufferReader messagePayload)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
MessageDataParams messageDataParams = default(MessageDataParams);
((FastBufferReader)(ref messagePayload)).ReadValueSafe<MessageDataParams>(ref messageDataParams, default(ForNetworkSerializable));
int num = int.Parse(messageDataParams.data);
if (num >= 0)
{
MaxMarx_AdminExtensions.totalAllowedPurchases = num;
}
if (IsHost)
{
Debug.Log((object)$"[MAXNETCORE] Server received AllowedPurchases Amount: ({messageDataParams.data}) from client ({senderId})");
if (senderId != 0)
{
Debug.Log((object)$"[MAXNETCORE] Broadcasting AllowedPurchases Amount to Clients: ({messageDataParams.data}) from client ({senderId})");
Trigger_SyncAllowedPurchasesWithServerClient();
}
}
else
{
Debug.Log((object)("[MAXNETCORE] Client received AllowedPurchases Amount: (" + messageDataParams.data + ") from the server."));
}
}
public void Trigger_SyncInfiniteStaminaWithServerClient()
{
if (IsHost)
{
MessageDataParams messageDataParams = default(MessageDataParams);
messageDataParams.generalTarget = 0;
messageDataParams.specificPlayerId = 0uL;
messageDataParams.data = MaxMarx_AdminExtensions.enableInfiniteSprint.ToString();
MessageDataParams data = messageDataParams;
SendMessage("CoreExtensions-SyncInfiniteStaminaWithServerClient", data);
}
}
public void Process_SyncInfiniteStaminaWithServerClient(ulong senderId, FastBufferReader messagePayload)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
MessageDataParams messageDataParams = default(MessageDataParams);
((FastBufferReader)(ref messagePayload)).ReadValueSafe<MessageDataParams>(ref messageDataParams, default(ForNetworkSerializable));
if (!IsHost)
{
if (messageDataParams.data == "true")
{
Debug.Log((object)$"[MAXNETCORE] Infinite Stamina Enabled on This Client, from server ({senderId})");
MaxMarx_AdminExtensions.enableInfiniteSprint = true;
}
else
{
Debug.Log((object)$"[MAXNETCORE] Infinite Stamina Disabled on This Client, from server ({senderId})");
MaxMarx_AdminExtensions.enableInfiniteSprint = false;
}
}
}
public void Trigger_SyncReviveSelfWithServerClient(ulong targetId)
{
if (IsHost)
{
MessageDataParams messageDataParams = default(MessageDataParams);
messageDataParams.generalTarget = 2;
messageDataParams.specificPlayerId = targetId;
messageDataParams.data = targetId.ToString();
MessageDataParams data = messageDataParams;
SendMessage("CoreExtensions-SyncReviveSelfWithServerClient", data);
}
}
public void Process_SyncReviveSelfWithServerClient(ulong senderId, FastBufferReader messagePayload)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
MessageDataParams messageDataParams = default(MessageDataParams);
((FastBufferReader)(ref messagePayload)).ReadValueSafe<MessageDataParams>(ref messageDataParams, default(ForNetworkSerializable));
if (myPlayerId == (int)messageDataParams.specificPlayerId && senderId == 0)
{
MaxMarx_AdminExtensions.reviveSelf = true;
Debug.Log((object)$"[MAXNETCORE] Revive Self sent to this Client, from server ({senderId})");
}
}
public void SendMessage(string messageName, MessageDataParams data)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
FastBufferWriter val = default(FastBufferWriter);
((FastBufferWriter)(ref val))..ctor(1100, (Allocator)2, -1);
CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager;
FastBufferWriter val2 = val;
try
{
((FastBufferWriter)(ref val)).WriteValueSafe<MessageDataParams>(ref data, default(ForNetworkSerializable));
if (IsServer && data.generalTarget == 0)
{
customMessagingManager.SendNamedMessageToAll(messageName, val, (NetworkDelivery)3);
}
else if (!IsServer && data.generalTarget == 1)
{
customMessagingManager.SendNamedMessage(messageName, 0uL, val, (NetworkDelivery)3);
}
else if (!IsServer && data.generalTarget == 2)
{
customMessagingManager.SendNamedMessage(messageName, data.specificPlayerId, val, (NetworkDelivery)3);
}
}
finally
{
((IDisposable)(FastBufferWriter)(ref val2)).Dispose();
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "MaxMarx_AdminExtensions";
public const string PLUGIN_NAME = "MaxMarx_AdminExtensions";
public const string PLUGIN_VERSION = "1.0.0";
}
}