Decompiled source of ScarletRCON v1.2.1
ScarletRCON.dll
Decompiled 3 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using BepInEx; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppSystem.Net.Sockets; using Microsoft.CodeAnalysis; using ProjectM; using ProjectM.Gameplay.Systems; using ProjectM.Network; using ProjectM.Scripting; using ProjectM.Shared; using RCONServerLib; using ScarletCore.Data; using ScarletCore.Services; using ScarletCore.Systems; using ScarletCore.Utils; using ScarletRCON.CommandSystem; using Stunlock.Core; using Unity.Collections; using Unity.Entities; using Unity.Mathematics; using Unity.Transforms; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("markvaaz")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("V Rising RCON Command Framework")] [assembly: AssemblyFileVersion("1.2.1.0")] [assembly: AssemblyInformationalVersion("1.2.1+1fad2946cf7306ec6ecef89280960ca2ed44cf4f")] [assembly: AssemblyProduct("ScarletRCON")] [assembly: AssemblyTitle("ScarletRCON")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.1.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 ScarletRCON { public static class ActionExecutor { private static readonly Queue<(Func<object> func, TaskCompletionSource<object> tcs)> _queue = new Queue<(Func<object>, TaskCompletionSource<object>)>(); public static int Count { get { lock (_queue) { return _queue.Count; } } } public static string Enqueue(Func<object> func) { TaskCompletionSource<object> taskCompletionSource = new TaskCompletionSource<object>(); lock (_queue) { _queue.Enqueue((func, taskCompletionSource)); } return taskCompletionSource.Task.GetAwaiter().GetResult()?.ToString(); } public static void ProcessQueue() { while (true) { (Func<object>, TaskCompletionSource<object>) tuple; lock (_queue) { if (_queue.Count == 0) { break; } tuple = _queue.Dequeue(); } try { object result = tuple.Item1(); tuple.Item2.SetResult(result); } catch (Exception exception) { tuple.Item2.SetException(exception); } } } } public static class ECSExtensions { public delegate void WithRefHandler<T>(ref T item); public static EntityManager EntityManager => GameSystems.Server.EntityManager; public static void With<T>(this Entity entity, WithRefHandler<T> action) where T : struct { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0017: Unknown result type (might be due to invalid IL or missing references) T item = entity.Read<T>(); action(ref item); EntityManager entityManager = EntityManager; ((EntityManager)(ref entityManager)).SetComponentData<T>(entity, item); } public static void AddWith<T>(this Entity entity, WithRefHandler<T> action) where T : struct { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (!entity.Has<T>()) { entity.Add<T>(); } entity.With(action); } public static void HasWith<T>(this Entity entity, WithRefHandler<T> action) where T : struct { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (entity.Has<T>()) { entity.With(action); } } public static void Write<T>(this Entity entity, T componentData) where T : struct { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = EntityManager; ((EntityManager)(ref entityManager)).SetComponentData<T>(entity, componentData); } public static T Read<T>(this Entity entity) where T : struct { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = EntityManager; return ((EntityManager)(ref entityManager)).GetComponentData<T>(entity); } public static DynamicBuffer<T> ReadBuffer<T>(this Entity entity) where T : struct { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = EntityManager; return ((EntityManager)(ref entityManager)).GetBuffer<T>(entity, false); } public static DynamicBuffer<T> AddBuffer<T>(this Entity entity) where T : struct { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = EntityManager; return ((EntityManager)(ref entityManager)).AddBuffer<T>(entity); } public static bool TryGetComponent<T>(this Entity entity, out T componentData) where T : struct { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) componentData = default(T); if (entity.Has<T>()) { componentData = entity.Read<T>(); return true; } return false; } public static bool Has<T>(this Entity entity) where T : struct { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = EntityManager; return ((EntityManager)(ref entityManager)).HasComponent(entity, new ComponentType(Il2CppType.Of<T>(), (AccessMode)0)); } public static void Add<T>(this Entity entity) where T : struct { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (!entity.Has<T>()) { EntityManager entityManager = EntityManager; ((EntityManager)(ref entityManager)).AddComponent(entity, new ComponentType(Il2CppType.Of<T>(), (AccessMode)0)); } } public static void Remove<T>(this Entity entity) where T : struct { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (entity.Has<T>()) { EntityManager entityManager = EntityManager; ((EntityManager)(ref entityManager)).RemoveComponent(entity, new ComponentType(Il2CppType.Of<T>(), (AccessMode)0)); } } public static bool TryGetPlayer(this Entity entity, out Entity player) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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) //IL_0015: Unknown result type (might be due to invalid IL or missing references) player = Entity.Null; if (entity.Has<PlayerCharacter>()) { player = entity; return true; } return false; } public static bool IsPlayer(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (entity.Has<PlayerCharacter>()) { return true; } return false; } public static bool TryGetAttached(this Entity entity, out Entity attached) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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) //IL_0016: 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_0024: 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) attached = Entity.Null; if (entity.TryGetComponent<Attach>(out Attach componentData) && componentData.Parent.Exists()) { attached = componentData.Parent; return true; } return false; } public static bool TryGetTeamEntity(this Entity entity, out Entity teamEntity) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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) //IL_0016: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) teamEntity = Entity.Null; if (entity.TryGetComponent<TeamReference>(out TeamReference componentData)) { Entity value = componentData.Value._Value; if (value.Exists()) { teamEntity = value; return true; } } return false; } public static bool Exists(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (!entity.IsNull()) { EntityManager entityManager = EntityManager; return ((EntityManager)(ref entityManager)).Exists(entity); } return false; } public static bool IsNull(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) Entity @null = Entity.Null; return ((Entity)(ref @null)).Equals(entity); } public static bool IsDisabled(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return entity.Has<Disabled>(); } public static PrefabGUID GetPrefabGuid(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (entity.TryGetComponent<PrefabGUID>(out PrefabGUID componentData)) { return componentData; } return PrefabGUID.Empty; } public static int GetGuidHash(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (entity.TryGetComponent<PrefabGUID>(out PrefabGUID componentData)) { return ((PrefabGUID)(ref componentData)).GuidHash; } PrefabGUID empty = PrefabGUID.Empty; return ((PrefabGUID)(ref empty)).GuidHash; } public static Entity GetOwner(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (entity.TryGetComponent<EntityOwner>(out EntityOwner componentData) && componentData.Owner.Exists()) { return componentData.Owner; } return Entity.Null; } public static bool HasBuff(this Entity entity, PrefabGUID buffPrefabGuid) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) ServerGameManager serverGameManager = GameSystems.ServerGameManager; return ((ServerGameManager)(ref serverGameManager)).HasBuff(entity, ((PrefabGUID)(ref buffPrefabGuid)).ToIdentifier()); } public static bool TryGetBuffer<T>(this Entity entity, out DynamicBuffer<T> dynamicBuffer) where T : struct { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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) ServerGameManager serverGameManager = GameSystems.ServerGameManager; if (((ServerGameManager)(ref serverGameManager)).TryGetBuffer<T>(entity, ref dynamicBuffer)) { return true; } dynamicBuffer = default(DynamicBuffer<T>); return false; } public static float3 AimPosition(this Entity entity) { //IL_0000: 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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (entity.TryGetComponent<EntityInput>(out EntityInput componentData)) { return componentData.AimPosition; } return float3.zero; } public static float3 Position(this Entity entity) { //IL_0000: 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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (entity.TryGetComponent<Translation>(out Translation componentData)) { return componentData.Value; } return float3.zero; } public static int2 GetTileCoord(this Entity entity) { //IL_0000: 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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (entity.TryGetComponent<TilePosition>(out TilePosition componentData)) { return componentData.Tile; } return int2.zero; } public static int GetUnitLevel(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (entity.TryGetComponent<UnitLevel>(out UnitLevel componentData)) { return componentData.Level._Value; } return 0; } public static void Destroy(this Entity entity, bool immediate = false) { //IL_0000: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0014: Unknown result type (might be due to invalid IL or missing references) if (entity.Exists()) { if (immediate) { EntityManager entityManager = EntityManager; ((EntityManager)(ref entityManager)).DestroyEntity(entity); } else { DestroyUtility.Destroy(EntityManager, entity, (DestroyDebugReason)0, (string)null, 0); } } } public static void SetTeam(this Entity entity, Entity teamSource) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) if (entity.Has<Team>() && entity.Has<TeamReference>() && teamSource.TryGetComponent<Team>(out Team componentData) && teamSource.TryGetComponent<TeamReference>(out TeamReference componentData2)) { Entity teamRefEntity = componentData2.Value._Value; int teamId = componentData.Value; entity.With<TeamReference>((WithRefHandler<TeamReference>)delegate(ref TeamReference teamReference) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) teamReference.Value._Value = teamRefEntity; }); entity.With<Team>((WithRefHandler<Team>)delegate(ref Team team) { team.Value = teamId; }); } } public static void SetPosition(this Entity entity, float3 position) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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) //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (entity.Has<Translation>()) { entity.With<Translation>((WithRefHandler<Translation>)delegate(ref Translation translation) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) translation.Value = position; }); } if (entity.Has<LastTranslation>()) { entity.With<LastTranslation>((WithRefHandler<LastTranslation>)delegate(ref LastTranslation lastTranslation) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) lastTranslation.Value = position; }); } } public static void SetFaction(this Entity entity, PrefabGUID factionPrefabGuid) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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) if (entity.Has<FactionReference>()) { entity.With<FactionReference>((WithRefHandler<FactionReference>)delegate(ref FactionReference factionReference) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) factionReference.FactionGuid._Value = factionPrefabGuid; }); } } public static bool IsAllies(this Entity entity, Entity player) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) ServerGameManager serverGameManager = GameSystems.ServerGameManager; return ((ServerGameManager)(ref serverGameManager)).IsAllies(entity, player); } public static bool IsPlayerOwned(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (entity.TryGetComponent<EntityOwner>(out EntityOwner componentData)) { return componentData.Owner.IsPlayer(); } return false; } public static Entity GetBuffTarget(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) return CreateGameplayEventServerUtility.GetBuffTarget(EntityManager, entity); } } [BepInPlugin("markvaaz.ScarletRCON", "ScarletRCON", "1.2.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BasePlugin { private static Harmony _harmony; public static Harmony Harmony => _harmony; public static Plugin Instance { get; private set; } public static ManualLogSource LogInstance { get; private set; } public override void Load() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown Instance = this; ManualLogSource log = ((BasePlugin)this).Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("markvaaz.ScarletRCON"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.2.1"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!"); } log.LogInfo(val); _harmony = new Harmony("markvaaz.ScarletRCON"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); } public override bool Unload() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } return true; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "markvaaz.ScarletRCON"; public const string PLUGIN_NAME = "ScarletRCON"; public const string PLUGIN_VERSION = "1.2.1"; } } namespace ScarletRCON.Utils { public static class StringExtensions { public static string HighlightColor = "#a963ff"; public static string HighlightErrorColor = "#ff4040"; public static string HighlightWarningColor = "#ffff00"; public static string TextColor = "#ffffff"; public static string ErrorTextColor = "#ff8f8f"; public static string WarningTextColor = "#ffff9e"; public static string Bold(this string text) { return "<b>" + text + "</b>"; } public static string Italic(this string text) { return "<i>" + text + "</i>"; } public static string Underline(this string text) { return "<u>" + text + "</u>"; } public static string Red(this string text) { return "<color=red>" + text + "</color>"; } public static string Green(this string text) { return "<color=green>" + text + "</color>"; } public static string Blue(this string text) { return "<color=blue>" + text + "</color>"; } public static string Yellow(this string text) { return "<color=yellow>" + text + "</color>"; } public static string White(this string text) { return "<color=white>" + text + "</color>"; } public static string Black(this string text) { return "<color=black>" + text + "</color>"; } public static string Orange(this string text) { return "<color=orange>" + text + "</color>"; } public static string Lime(this string text) { return "<color=#00FF00>" + text + "</color>"; } public static string Gray(this string text) { return "<color=#cccccc>" + text + "</color>"; } public static string Hex(this string hex, string text) { return $"<color={hex}>{text}</color>"; } public static string Format(this string text, List<string> highlightColors = null) { if (highlightColors == null) { highlightColors = new List<string>(1) { HighlightColor }; } return ApplyFormatting(text, TextColor, highlightColors); } public static string FormatError(this string text) { return ApplyFormatting(text, ErrorTextColor, new List<string>(1) { HighlightErrorColor }); } public static string FormatWarning(this string text) { return ApplyFormatting(text, WarningTextColor, new List<string>(1) { HighlightWarningColor }); } private static string ApplyFormatting(string text, string baseColor, List<string> highlightColors) { string pattern = "\\*\\*(.*?)\\*\\*"; string pattern2 = "\\*(.*?)\\*"; string pattern3 = "__(.*?)__"; string pattern4 = "~(.*?)~"; string input = Regex.Replace(text, pattern, (Match m) => m.Groups[1].Value.Bold()); input = Regex.Replace(input, pattern2, (Match m) => m.Groups[1].Value.Italic()); input = Regex.Replace(input, pattern3, (Match m) => m.Groups[1].Value.Underline()); int highlightIndex = 0; input = Regex.Replace(input, pattern4, delegate(Match m) { string text2 = ((highlightIndex < highlightColors.Count) ? highlightColors[highlightIndex] : HighlightColor); if (text2 == null) { text2 = HighlightColor; } highlightIndex++; return text2.Hex(m.Groups[1].Value); }); return baseColor.Hex(input); } } } namespace ScarletRCON.Patches { [HarmonyPatch(typeof(RconListenerSystem), "OnCreate")] internal class RconInitializePatch { private static RemoteConServer server; private static void Postfix(RconListenerSystem __instance) { server = __instance._Server; CommandEventHandler val = DelegateSupport.ConvertDelegate<CommandEventHandler>((Delegate)new Action<string, IList<string>>(OnCommandReceived)); server.UseCustomCommandHandler = true; CommandHandler.Initialize(); server.OnCommandReceived += val; server.TimeoutSeconds = 900; server.MaxPasswordTries = 3u; server.BanMinutes = 30; server.MaxConnections = 1u; } public static Socket GetSocket() { Enumerator<TcpClient> enumerator = server._clients.GetEnumerator(); while (enumerator.MoveNext()) { TcpClient current = enumerator.Current; if (current.Connected) { return current.Client; } } return null; } private static void OnCommandReceived(string cmd, IList<string> args) { try { List<string> list = new List<string>(); int num = 0; while (true) { try { string text = args[num]; if (text == null) { break; } list.Add(text); num++; continue; } catch { } break; } Send(CommandHandler.HandleCommand(cmd.ToLower(), list)); } catch (Exception ex) { Console.WriteLine($"RCON command error: {ex}"); Log.Error((object)("Error processing command: " + ex.Message)); } } public static void Send(string message) { Socket socket = GetSocket(); if (socket != null) { SendRconPacket(socket, message); } } private static void SendRconPacket(Socket socket, string payload) { byte[] bytes = Encoding.UTF8.GetBytes(payload); int num = 8 + bytes.Length + 2; byte[] array = new byte[4 + num]; BitConverter.GetBytes(num).CopyTo(array, 0); BitConverter.GetBytes(0).CopyTo(array, 4); BitConverter.GetBytes(0).CopyTo(array, 8); Array.Copy(bytes, 0, array, 12, bytes.Length); array[12 + bytes.Length] = 0; array[13 + bytes.Length] = 0; Il2CppStructArray<byte> val = new Il2CppStructArray<byte>((long)array.Length); for (int i = 0; i < array.Length; i++) { ((Il2CppArrayBase<byte>)(object)val)[i] = array[i]; } socket.Send(val, 0, array.Length, (SocketFlags)0); } } [HarmonyPatch(typeof(RconListenerSystem), "OnUpdate")] internal class RconUpdatePatch { private static void Postfix() { if (ActionExecutor.Count != 0) { ActionExecutor.ProcessQueue(); } } } internal static class StringExtensions { public static IntPtr ToIntPtr(this string str) { return IL2CPP.ManagedStringToIl2Cpp(str); } } } namespace ScarletRCON.Commands { [RconCommandCategory("Help")] public static class HelpCommand { [RconCommand("help", "Show info about a specific command.", null, false)] public static string Help(string commandName) { if (CommandHandler.TryGetCommands(commandName, out var commands)) { string value = "\u001b[97m"; string text = "\u001b[90m"; string text2 = "\u001b[0m"; string text3 = ""; { foreach (RconCommandDefinition item in commands) { text3 += $"{value}{item.Name}{text2}: {text}{item.Description}{text2}\n"; text3 = ((!string.IsNullOrEmpty(item.Usage)) ? (text3 + $"{text}- usage: {item.Usage}{text2}\n") : (text3 + text + "- this command has no parameters" + text2 + "\n")); } return text3; } } return "Unknown command '" + commandName + "'"; } [RconCommand("help", "List all commands.", null, false)] public static string ListAll() { string text = ""; foreach (KeyValuePair<string, List<RconCommandDefinition>> orderedCategory in GetOrderedCategories()) { text = text + "\n\u001b[97m" + orderedCategory.Key + "\u001b[0m:\n"; foreach (RconCommandDefinition item in orderedCategory.Value.OrderBy<RconCommandDefinition, string>((RconCommandDefinition c) => c.Name, StringComparer.OrdinalIgnoreCase)) { text += $"\u001b[37m- {item.Name}\u001b[0m:\u001b[90m{(string.IsNullOrEmpty(item.Usage) ? "" : (" " + item.Usage))} - {item.Description}\u001b[0m\n"; } } return text + "\nTotal commands: " + CommandHandler.Commands.Count; } public static IEnumerable<KeyValuePair<string, List<RconCommandDefinition>>> GetOrderedCategories() { Dictionary<string, List<RconCommandDefinition>> dictionary = new Dictionary<string, List<RconCommandDefinition>>(StringComparer.OrdinalIgnoreCase); foreach (KeyValuePair<string, List<RconCommandDefinition>> commandCategory in CommandHandler.CommandCategories) { string key = commandCategory.Key; List<RconCommandDefinition> value = commandCategory.Value; List<RconCommandDefinition> list = new List<RconCommandDefinition>(value.Count); list.AddRange(value); dictionary[key] = list; } foreach (KeyValuePair<string, List<RconCommandDefinition>> customCommandCategory in CommandHandler.CustomCommandCategories) { if (dictionary.TryGetValue(customCommandCategory.Key, out var value2)) { value2.AddRange(customCommandCategory.Value); continue; } string key2 = customCommandCategory.Key; List<RconCommandDefinition> value = customCommandCategory.Value; List<RconCommandDefinition> list2 = new List<RconCommandDefinition>(value.Count); list2.AddRange(value); dictionary[key2] = list2; } return dictionary.OrderBy<KeyValuePair<string, List<RconCommandDefinition>>, string>((KeyValuePair<string, List<RconCommandDefinition>> x) => x.Key, StringComparer.OrdinalIgnoreCase); } } [RconCommandCategory("Inventory Management")] public static class InventoryCommands { [RconCommand("giveitem", "Give an item to a player.", null, false)] public static string Give(string playerName, string prefabGUID, int amount) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) PlayerData val = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val)) { return "Player '" + playerName + "' was not found."; } if (!val.IsOnline) { return "Player '" + playerName + "' is not currently online."; } PrefabGUID val2 = default(PrefabGUID); if (!PrefabGUID.TryParse(prefabGUID, ref val2)) { return "Invalid PrefabGUID."; } if (InventoryService.IsFull(val.CharacterEntity)) { return "Player '" + playerName + "' has a full inventory."; } InventoryService.AddItem(val.CharacterEntity, val2, amount); return $"Given {amount} {((PrefabGUID)(ref val2)).GuidHash} to {playerName}."; } [RconCommand("giveitemall", "Give an item to all online players.", null, false)] public static string GiveAll(int prefabGUID, int amount) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) PrefabGUID val = default(PrefabGUID); if (!PrefabGUID.TryParse(prefabGUID.ToString(), ref val)) { return "Invalid Prefab GUID."; } foreach (PlayerData allPlayer in PlayerService.AllPlayers) { if (allPlayer.IsOnline && !InventoryService.IsFull(allPlayer.CharacterEntity)) { InventoryService.AddItem(allPlayer.CharacterEntity, val, amount); } } return $"Given {amount} {val} to all players."; } [RconCommand("removeitem", "Remove an item from a player's inventory.", null, false)] public static string RemoveItem(string playerName, string prefabGUID, int amount) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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) PlayerData val = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val)) { return "Player '" + playerName + "' was not found."; } if (!val.IsOnline) { return "Player '" + playerName + "' is not currently online."; } PrefabGUID val2 = default(PrefabGUID); if (!PrefabGUID.TryParse(prefabGUID, ref val2)) { return "Invalid PrefabGUID."; } if (InventoryService.HasAmount(val.CharacterEntity, val2, amount)) { InventoryService.RemoveItem(val.CharacterEntity, val2, amount); return $"Removed {amount} {((PrefabGUID)(ref val2)).GuidHash} from {playerName}'s inventory."; } return $"Player '{playerName}' does not have {amount} {((PrefabGUID)(ref val2)).GuidHash} in their inventory."; } [RconCommand("removeitemall", "Remove an item from all online players' inventories.", null, false)] public static string RemoveItemAll(int prefabGUID, int amount) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) PrefabGUID val = default(PrefabGUID); if (!PrefabGUID.TryParse(prefabGUID.ToString(), ref val)) { return "Invalid Prefab GUID."; } foreach (PlayerData allPlayer in PlayerService.AllPlayers) { if (allPlayer.IsOnline && InventoryService.HasAmount(allPlayer.CharacterEntity, val, amount)) { InventoryService.RemoveItem(allPlayer.CharacterEntity, val, amount); } } return $"Removed {amount} {val} from all players' inventories."; } } [RconCommandCategory("Messaging")] public static class MessagingCommands { [RconCommand("announce", "Send a message to all online players.", "<message>", false)] public static string Announce(List<string> args) { string text = string.Join(" ", args); MessageService.SendAll(text); return "Sent announcement: " + text; } [RconCommand("announcerestart", "Announce server restart in X minutes.", "<minutes>", false)] public static string AnnounceRestart(int minutes) { string text = $"The server will restart in {minutes} minutes!"; MessageService.SendAll(text); return "Sent announcement: " + text; } [RconCommand("private", "Send a private message to a player.", "<playerName> <message>", false)] public static string PrivateMessage(string playerName, string message) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) PlayerData val = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val)) { return "Player '" + playerName + "' was not found."; } if (!val.IsOnline) { return "Player '" + playerName + "' is not currently online."; } MessageService.Send(val.UserEntity.Read<User>(), message); return "Sent private message to " + val.Name + ": " + message; } } [RconCommandCategory("Player Administration")] public static class PlayerCommand { private static PrefabGUID FreezeBuffGUID = new PrefabGUID(-1527408583); private static PrefabGUID WoundedBuffGUID = new PrefabGUID(-1992158531); [RconCommand("playerinfo", "Show info about a player.", null, false)] public static string PlayerInfo(string playerName) { PlayerData val = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val)) { return "Player '" + playerName + "' was not found."; } string text = "- Character Name: " + val.Name + "\n"; text += $"- Steam ID: {val.PlatformId}\n"; text += $"- Profile URL: https://steamcommunity.com/profiles/{val.PlatformId}\n"; if (val.IsOnline) { text += $"- Connected Since: {val.ConnectedSince}\n"; } return text + "- " + (val.IsOnline ? "Online" : "Offline") + "\n"; } [RconCommand("kick", "Kick a player.", null, false)] public static string Kick(string playerName) { PlayerData val = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val)) { return "Player '" + playerName + "' was not found."; } if (!val.IsOnline) { return "Player '" + playerName + "' is not currently online."; } MessageService.SendAll(val.Name + " got ~kicked~ by an admin."); KickBanService.Kick(val.PlatformId); return "Kicked " + playerName + "."; } [RconCommand("ban", " Ban a player by ID.", null, false)] public static string BanById(ulong playerId) { if (!KickBanService.IsBanned(playerId)) { KickBanService.Ban(playerId); return $"Banned {playerId} by ID."; } return $"Player '{playerId}' is already banned."; } [RconCommand("ban", "Ban a player by name.", null, false)] public static string BanByName(string playerName) { PlayerData val = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val)) { return "Player '" + playerName + "' was not found.\nTry using the ID instead."; } if (KickBanService.IsBanned(val.PlatformId)) { return "Player '" + playerName + "' is already banned."; } MessageService.SendAll(val.Name + " got ~banned~ by an admin."); KickBanService.Ban(val.PlatformId); return "Banned " + playerName + " by name."; } [RconCommand("unban", "Unban a player by ID.", null, false)] public static string Unban(ulong playerId) { if (KickBanService.IsBanned(playerId)) { KickBanService.Unban(playerId); return $"Unbanned {playerId}."; } return $"Player '{playerId}' is not banned."; } [RconCommand("addadmin", "Add a player as admin by ID.", null, false)] public static string AddAdmin(ulong playerId) { if (!AdminService.IsAdmin(playerId)) { AdminService.AddAdmin(playerId); return $"Added {playerId} as admin."; } return $"Player '{playerId}' is already an admin."; } [RconCommand("addadmin", "Add a player as admin.", null, false)] public static string AddAdmin(string playerName) { PlayerData val = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val)) { return "Player '" + playerName + "' was not found."; } if (val.IsAdmin) { return "Player '" + playerName + "' is already an admin."; } AdminService.AddAdmin(val.PlatformId); return "Added " + playerName + " as admin."; } [RconCommand("removeadmin", "Remove a player as admin by ID.", null, false)] public static string RemoveAdmin(ulong playerId) { if (AdminService.IsAdmin(playerId)) { AdminService.RemoveAdmin(playerId); return $"Removed {playerId} as admin."; } return $"Player '{playerId}' is not an admin."; } [RconCommand("removeadmin", "Remove a player as admin.", null, false)] public static string RemoveAdmin(string playerName) { PlayerData val = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val)) { return "Player '" + playerName + "' was not found."; } if (!val.IsAdmin) { return "Player '" + playerName + "' is not an admin."; } AdminService.RemoveAdmin(val.PlatformId); return "Removed " + playerName + " as admin."; } [RconCommand("buff", "Apply a buff to a player.", null, false)] public static string BuffPlayer(string playerName, string prefabGUID, int duration) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) PlayerData val = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val)) { return "Player '" + playerName + "' was not found."; } if (!val.IsOnline) { return "Player '" + playerName + "' is not currently online."; } PrefabGUID val2 = default(PrefabGUID); if (!PrefabGUID.TryParse(prefabGUID, ref val2)) { return "Invalid PrefabGUID."; } if (!BuffService.HasBuff(val.CharacterEntity, val2)) { if (BuffService.TryApplyBuff(val.CharacterEntity, val2, (float)duration)) { return $"Applied buff {prefabGUID} to {playerName} for {duration} seconds."; } return $"Failed to apply buff {prefabGUID} to {playerName}."; } return $"Player {playerName} already has buff {((PrefabGUID)(ref val2)).GuidHash}."; } [RconCommand("debuff", "Remove a buff from a player.", null, false)] public static string RemoveBuff(string playerName, string prefabGUID) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) PlayerData val = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val)) { return "Player '" + playerName + "' was not found."; } if (!val.IsOnline) { return "Player '" + playerName + "' is not currently online."; } PrefabGUID val2 = default(PrefabGUID); if (!PrefabGUID.TryParse(prefabGUID, ref val2)) { return "Invalid PrefabGUID."; } if (BuffService.HasBuff(val.CharacterEntity, val2)) { BuffService.TryRemoveBuff(val.CharacterEntity, val2); return $"Removed buff {prefabGUID} from {playerName}."; } return $"Player {playerName} does not have buff {((PrefabGUID)(ref val2)).GuidHash}."; } [RconCommand("freeze", "Freeze a player for x seconds.", null, false)] public static string Freeze(string playerName, int duration) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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) PlayerData val = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val)) { return "Player '" + playerName + "' was not found."; } if (!val.IsOnline) { return "Player '" + playerName + "' is not currently online."; } if (BuffService.HasBuff(val.CharacterEntity, FreezeBuffGUID)) { return "Player " + playerName + " is already frozen."; } if (!BuffService.TryApplyBuff(val.CharacterEntity, FreezeBuffGUID, (float)duration)) { return "Failed to freeze " + playerName + "."; } MessageService.Send(val.User, $"You’ve been ~frozen~ in place for ~{duration}~ seconds by an admin!"); return "Frozen " + playerName + "."; } [RconCommand("unfreeze", "Unfreeze a player.", null, false)] public static string Unfreeze(string playerName) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) PlayerData val = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val)) { return "Player '" + playerName + "' was not found."; } if (!val.IsOnline) { return "Player '" + playerName + "' is not currently online."; } if (!BuffService.HasBuff(val.CharacterEntity, FreezeBuffGUID)) { return "Player " + playerName + " is not frozen."; } BuffService.TryRemoveBuff(val.CharacterEntity, FreezeBuffGUID); MessageService.Send(val.User, "You have been ~unfrozen~ by an admin!"); return "Unfroze " + playerName + "."; } [RconCommand("heal", "Full heal a player.", "<playerName>", false)] public static string Heal(string playerName) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) PlayerData val = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val)) { return "Player '" + playerName + "' was not found."; } if (!val.IsOnline) { return "Player '" + playerName + "' is not currently online."; } Entity characterEntity = val.CharacterEntity; Health val2 = characterEntity.Read<Health>(); val2.Value = ModifiableFloat.op_Implicit(val2.MaxHealth); val2.MaxRecoveryHealth = ModifiableFloat.op_Implicit(val2.MaxHealth); characterEntity.Write<Health>(val2); MessageService.Send(val.User, "You have been ~healed~ by an admin!"); return "Healed " + val.Name + "."; } [RconCommand("healradius", "Full heal all players within a radius of specific coordinates.", "<x> <z> <radius>", false)] public static string HealRadius(float x, float z, float radius) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) if (radius <= 0f) { return "Radius must be greater than 0."; } foreach (PlayerData allPlayer in PlayerService.AllPlayers) { Entity characterEntity = allPlayer.CharacterEntity; float3 val = allPlayer.CharacterEntity.Position(); if (!(math.distance(new float3(x, 0f, z), new float3(val.x, 0f, val.z)) > radius)) { Health val2 = characterEntity.Read<Health>(); val2.Value = ModifiableFloat.op_Implicit(val2.MaxHealth); val2.MaxRecoveryHealth = ModifiableFloat.op_Implicit(val2.MaxHealth); characterEntity.Write<Health>(val2); MessageService.Send(allPlayer.User, "You have been ~healed~ by an admin!"); } } return $"Healed all players within radius {radius} around ({x}, {z})."; } [RconCommand("healradius", "Full heal all players within a player's radius.", "<playerName> <radius>", false)] public static string HealRadius(string playerName, float radius) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) PlayerData val = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val)) { return "Player '" + playerName + "' was not found."; } if (!val.IsOnline) { return "Player '" + playerName + "' is not currently online."; } if (radius <= 0f) { return "Radius must be greater than 0."; } float3 val2 = val.CharacterEntity.Position(); foreach (PlayerData allPlayer in PlayerService.AllPlayers) { Entity characterEntity = allPlayer.CharacterEntity; float3 val3 = allPlayer.CharacterEntity.Position(); if (!(math.distance(new float3(val2.x, 0f, val2.z), new float3(val3.x, 0f, val3.z)) > radius)) { Health val4 = characterEntity.Read<Health>(); val4.Value = ModifiableFloat.op_Implicit(val4.MaxHealth); val4.MaxRecoveryHealth = ModifiableFloat.op_Implicit(val4.MaxHealth); characterEntity.Write<Health>(val4); MessageService.Send(allPlayer.User, "You have been ~healed~ by an admin!"); } } return $"Healed all players within radius {radius} around {playerName}."; } [RconCommand("healall", "Full heal all players.", null, false)] public static string HealAll() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //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_0020: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) foreach (PlayerData allPlayer in PlayerService.AllPlayers) { Entity characterEntity = allPlayer.CharacterEntity; Health val = characterEntity.Read<Health>(); val.Value = ModifiableFloat.op_Implicit(val.MaxHealth); val.MaxRecoveryHealth = ModifiableFloat.op_Implicit(val.MaxHealth); characterEntity.Write<Health>(val); MessageService.Send(allPlayer.User, "You have been ~healed~ by an admin!"); } return "Healed all players."; } [RconCommand("wound", "Wound a player.", "<playerName>", false)] public static string Wound(string playerName) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) PlayerData val = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val)) { return "Player '" + playerName + "' was not found."; } if (!val.IsOnline) { return "Player '" + playerName + "' is not currently online."; } if (!BuffService.TryApplyBuff(val.CharacterEntity, WoundedBuffGUID, 0f)) { return "Failed to wound " + playerName + "."; } MessageService.Send(val.User, "You have been ~wounded~ by an admin!"); return "Wounded " + val.Name + "."; } [RconCommand("kill", "Kill a player.", "<playerName>", false)] public static string Kill(string playerName) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) PlayerData val = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val)) { return "Player '" + playerName + "' was not found."; } if (!val.IsOnline) { return "Player '" + playerName + "' is not currently online."; } StatChangeUtility.KillEntity(GameSystems.EntityManager, val.CharacterEntity, val.CharacterEntity, GameSystems.ServerGameManager.ServerTime, (StatChangeReason)1, true); MessageService.Send(val.User, "You have been ~killed~ by an admin!"); return "Killed " + val.Name + "."; } [RconCommand("revive", "Revive a player.", "<playerName>", false)] public static string Revive(string playerName) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_00e6: Unknown result type (might be due to invalid IL or missing references) PlayerData val = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val)) { return "Player '" + playerName + "' was not found."; } if (!val.IsOnline) { return "Player '" + playerName + "' is not currently online."; } Entity characterEntity = val.CharacterEntity; Health val2 = characterEntity.Read<Health>(); Entity val3 = default(Entity); if (BuffUtility.TryGetBuff<EntityManager>(GameSystems.EntityManager, characterEntity, PrefabIdentifier.op_Implicit(WoundedBuffGUID), ref val3)) { DestroyUtility.Destroy(GameSystems.EntityManager, val3, (DestroyDebugReason)13, (string)null, 0); val2.Value = ModifiableFloat.op_Implicit(val2.MaxHealth); val2.MaxRecoveryHealth = ModifiableFloat.op_Implicit(val2.MaxHealth); characterEntity.Write<Health>(val2); } if (val2.IsDead) { LocalToWorld val4 = characterEntity.Read<LocalToWorld>(); float3 position = ((LocalToWorld)(ref val4)).Position; EntityCommandBuffer val5 = GameSystems.EntityCommandBufferSystem.CreateCommandBuffer(); GameSystems.ServerBootstrapSystem.RespawnCharacter(val5, val.UserEntity, new Nullable_Unboxed<float3> { value = position }, characterEntity, default(Entity), -1); } MessageService.Send(val.User, "You've been ~revived~ by an admin"); return "Revived " + val.Name + "."; } [RconCommand("reviveall", "Revive all players.", null, false)] public static string ReviveAll() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) Entity val2 = default(Entity); foreach (PlayerData allPlayer in PlayerService.AllPlayers) { Entity characterEntity = allPlayer.CharacterEntity; Health val = characterEntity.Read<Health>(); if (BuffUtility.TryGetBuff<EntityManager>(GameSystems.EntityManager, characterEntity, PrefabIdentifier.op_Implicit(WoundedBuffGUID), ref val2)) { DestroyUtility.Destroy(GameSystems.EntityManager, val2, (DestroyDebugReason)13, (string)null, 0); val.Value = ModifiableFloat.op_Implicit(val.MaxHealth); val.MaxRecoveryHealth = ModifiableFloat.op_Implicit(val.MaxHealth); characterEntity.Write<Health>(val); } if (val.IsDead) { LocalToWorld val3 = characterEntity.Read<LocalToWorld>(); float3 position = ((LocalToWorld)(ref val3)).Position; EntityCommandBuffer val4 = GameSystems.EntityCommandBufferSystem.CreateCommandBuffer(); GameSystems.ServerBootstrapSystem.RespawnCharacter(val4, allPlayer.UserEntity, new Nullable_Unboxed<float3> { value = position }, characterEntity, default(Entity), -1); } MessageService.Send(allPlayer.User, "You've been ~revived~ by an admin"); } return "Revived all players."; } [RconCommand("reviveradius", "Revive all players within a radius.", null, false)] public static string ReviveRadius(int x, int y, int z, int radius) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) Entity val3 = default(Entity); foreach (PlayerData allPlayer in PlayerService.AllPlayers) { Entity characterEntity = allPlayer.CharacterEntity; float3 val = allPlayer.CharacterEntity.Position(); if (!(math.distance(new float3((float)x, 0f, (float)z), new float3(val.x, 0f, val.z)) > (float)radius)) { Health val2 = characterEntity.Read<Health>(); if (BuffUtility.TryGetBuff<EntityManager>(GameSystems.EntityManager, characterEntity, PrefabIdentifier.op_Implicit(WoundedBuffGUID), ref val3)) { DestroyUtility.Destroy(GameSystems.EntityManager, val3, (DestroyDebugReason)13, (string)null, 0); val2.Value = ModifiableFloat.op_Implicit(val2.MaxHealth); val2.MaxRecoveryHealth = ModifiableFloat.op_Implicit(val2.MaxHealth); characterEntity.Write<Health>(val2); } if (val2.IsDead) { LocalToWorld val4 = characterEntity.Read<LocalToWorld>(); float3 position = ((LocalToWorld)(ref val4)).Position; EntityCommandBuffer val5 = GameSystems.EntityCommandBufferSystem.CreateCommandBuffer(); GameSystems.ServerBootstrapSystem.RespawnCharacter(val5, allPlayer.UserEntity, new Nullable_Unboxed<float3> { value = position }, characterEntity, default(Entity), -1); } MessageService.Send(allPlayer.User, "You've been ~revived~ by an admin"); } } return "Revived all players."; } [RconCommand("reviveradius", "Revive all players within a player's radius.", null, false)] public static string ReviveRadius(string playerName, int radius) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) PlayerData val = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val)) { return "Player '" + playerName + "' was not found."; } if (!val.IsOnline) { return "Player '" + playerName + "' is not currently online."; } float3 val2 = val.CharacterEntity.Position(); Entity val5 = default(Entity); foreach (PlayerData allPlayer in PlayerService.AllPlayers) { Entity characterEntity = allPlayer.CharacterEntity; float3 val3 = allPlayer.CharacterEntity.Position(); if (!(math.distance(new float3(val2.x, 0f, val2.z), new float3(val3.x, 0f, val3.z)) > (float)radius)) { Health val4 = characterEntity.Read<Health>(); if (BuffUtility.TryGetBuff<EntityManager>(GameSystems.EntityManager, characterEntity, PrefabIdentifier.op_Implicit(WoundedBuffGUID), ref val5)) { DestroyUtility.Destroy(GameSystems.EntityManager, val5, (DestroyDebugReason)13, (string)null, 0); val4.Value = ModifiableFloat.op_Implicit(val4.MaxHealth); val4.MaxRecoveryHealth = ModifiableFloat.op_Implicit(val4.MaxHealth); characterEntity.Write<Health>(val4); } if (val4.IsDead) { LocalToWorld val6 = characterEntity.Read<LocalToWorld>(); float3 position = ((LocalToWorld)(ref val6)).Position; EntityCommandBuffer val7 = GameSystems.EntityCommandBufferSystem.CreateCommandBuffer(); GameSystems.ServerBootstrapSystem.RespawnCharacter(val7, allPlayer.UserEntity, new Nullable_Unboxed<float3> { value = position }, characterEntity, default(Entity), -1); } MessageService.Send(allPlayer.User, "You've been ~revived~ by an admin"); } } return "Revived all players."; } [RconCommand("revealmap", "Reveal the map for a player.", null, false)] public static string RevealMap(string playerName) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) PlayerData val = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val)) { return "Player '" + playerName + "' was not found."; } if (!val.IsOnline) { return "Player '" + playerName + "' is not currently online."; } RevealMapService.RevealFullMap(val); MessageService.Send(val.User, "Your map has been ~revealed~ by an admin!"); return "Revealed map for " + val.Name + "."; } [RconCommand("revealmapradius", "Reveal the map within a radius of specific coordinates for a player.", null, false)] public static string RevealMapRadius(string playerName, float x, float z, float radius) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) PlayerData val = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val)) { return "Player '" + playerName + "' was not found."; } if (!val.IsOnline) { return "Player '" + playerName + "' is not currently online."; } if (radius <= 0f) { return "Radius must be greater than 0."; } RevealMapService.RevealMapRadius(val, new float3(x, 0f, z), radius); MessageService.Send(val.User, "Your map has been partially ~revealed~ by an admin!"); return $"Revealed map for {val.Name} within radius {radius} around ({x}, {z})."; } [RconCommand("revealmapradius", "Reveal the map within a radius around another player.", null, false)] public static string RevealMapRadius(string playerName, string targetPlayerName, float radius) { //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_0089: Unknown result type (might be due to invalid IL or missing references) PlayerData val = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val)) { return "Player '" + playerName + "' was not found."; } if (!val.IsOnline) { return "Player '" + playerName + "' is not currently online."; } PlayerData val2 = default(PlayerData); if (!PlayerService.TryGetByName(targetPlayerName, ref val2)) { return "Center player '" + targetPlayerName + "' was not found."; } if (!val2.IsOnline) { return "Center player '" + targetPlayerName + "' is not currently online."; } if (radius <= 0f) { return "Radius must be greater than 0."; } RevealMapService.RevealMapRadius(val, val2.CharacterEntity.Position(), radius); MessageService.Send(val.User, "Your map has been partially ~revealed~ by an admin!"); return $"Revealed map for {val.Name} within radius {radius} around {val2.Name}."; } [RconCommand("revealmaprect", "Reveal the map within a rectangle for a player.", null, false)] public static string RevealMapRect(string playerName, float x, float z, float width, float height) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) PlayerData val = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val)) { return "Player '" + playerName + "' was not found."; } if (!val.IsOnline) { return "Player '" + playerName + "' is not currently online."; } if (width <= 0f || height <= 0f) { return "Width and height must be greater than 0."; } RevealMapService.RevealMapRectangle(val, new float3(x, 0f, z), width, height); MessageService.Send(val.User, "Your map has been partially ~revealed~ by an admin!"); return $"Revealed map for {val.Name} within rectangle at ({x}, {z}) with width {width} and height {height}."; } [RconCommand("revealmapall", "Reveal the map for all players.", null, false)] public static string RevealMapAll() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) foreach (PlayerData allPlayer in PlayerService.AllPlayers) { if (allPlayer.IsOnline) { RevealMapService.RevealFullMap(allPlayer); MessageService.Send(allPlayer.User, "Your map has been ~revealed~ by an admin!"); } } return "Revealed map for all online players."; } [RconCommand("hidemap", "Hide/obscure the map for a player.", null, false)] public static string HideMap(string playerName) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) PlayerData val = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val)) { return "Player '" + playerName + "' was not found."; } if (!val.IsOnline) { return "Player '" + playerName + "' is not currently online."; } RevealMapService.HideFullMap(val); MessageService.Send(val.User, "Your map has been ~hidden~ by an admin!"); return "Hidden map for " + val.Name + "."; } } [RconCommandCategory("Server Administration")] public static class ServerCommands { [RconCommand("save", "Save the game", null, false)] public static string Save() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) string text = "Save_" + DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss") + ".save"; GameSystems.TriggerPersistenceSaveSystem.TriggerSave((SaveReason)1, FixedString128Bytes.op_Implicit(text), GetServerRuntimeSettings()); return "Game saved as '" + text + "'."; } [RconCommand("serverstats", "Show server statistics.", null, false)] public static string ServerStats() { List<PlayerData> allConnected = PlayerService.GetAllConnected(); TimeSpan value = DateTime.Now - Process.GetCurrentProcess().StartTime; Process currentProcess = Process.GetCurrentProcess(); return string.Concat(string.Concat("Server Stats\n" + $"- Players Online: {allConnected.Count}\n", $"- Uptime: {value:hh\\:mm\\:ss}\n"), $"- Memory Usage: {currentProcess.WorkingSet64 / 1048576} MB\n"); } [RconCommand("settings", "Live-updates a server setting. Does not persist after restart at the moment. This is an experimental feature, use at your own risk.", null, false)] public static string Settings(string settingsPath, string settingsValue) { object obj = null; if (settingsPath.StartsWith("serverhostsettings.", StringComparison.OrdinalIgnoreCase)) { obj = SettingsManager.ServerHostSettings; string text = settingsPath; int length = "serverhostsettings.".Length; settingsPath = text.Substring(length, text.Length - length); } else { if (!settingsPath.StartsWith("servergamesettings.", StringComparison.OrdinalIgnoreCase)) { return "Invalid root setting: must start with 'serverhostsettings.' or 'servergamesettings.'"; } obj = SettingsManager.ServerGameSettings; string text = settingsPath; int length = "servergamesettings.".Length; settingsPath = text.Substring(length, text.Length - length); } string[] array = settingsPath.Split('.'); object obj2 = obj; PropertyInfo propertyInfo = null; for (int i = 0; i < array.Length; i++) { Type type = obj2.GetType(); propertyInfo = type.GetProperty(array[i], BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public); if (propertyInfo == null) { return $"Invalid property: '{array[i]}' not found in '{type.Name}'"; } if (i < array.Length - 1) { obj2 = propertyInfo.GetValue(obj2); if (obj2 == null) { return "Null reference: '" + array[i] + "' is null."; } } } try { object value = Convert.ChangeType(settingsValue, propertyInfo.PropertyType); propertyInfo.SetValue(obj2, value); return $"Setting '{settingsPath}' changed to '{settingsValue}'"; } catch (Exception ex) { return "Failed to set property: " + ex.Message; } } [RconCommand("settings", "Get the value of a server setting.", null, false)] public static string GetSettings(string settingsPath) { object obj; if (settingsPath.StartsWith("serverhostsettings.", StringComparison.OrdinalIgnoreCase)) { obj = SettingsManager.ServerHostSettings; string text = settingsPath; int length = "serverhostsettings.".Length; settingsPath = text.Substring(length, text.Length - length); } else { if (!settingsPath.StartsWith("servergamesettings.", StringComparison.OrdinalIgnoreCase)) { return "Invalid root setting: must start with 'serverhostsettings.' or 'servergamesettings.'"; } obj = SettingsManager.ServerGameSettings; string text = settingsPath; int length = "servergamesettings.".Length; settingsPath = text.Substring(length, text.Length - length); } string[] array = settingsPath.Split('.'); object obj2 = obj; for (int i = 0; i < array.Length; i++) { Type type = obj2.GetType(); PropertyInfo property = type.GetProperty(array[i], BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public); if (property == null) { return $"Invalid property: '{array[i]}' not found in '{type.Name}'"; } obj2 = property.GetValue(obj2); if (obj2 == null) { return "Null reference: '" + array[i] + "' is null."; } } return $"Setting '{settingsPath}' is '{obj2}'"; } [RconCommand("listadmins", "List all admins.", null, false)] public static string ListAdmins() { List<PlayerData> admins = PlayerService.GetAdmins(); string text = ""; int num = 0; foreach (PlayerData item in admins) { num++; string value = (item.IsOnline ? "\u001b[32m●\u001b[0m" : "\u001b[31m●\u001b[0m"); text += $"- \u001b[97m{item.Name}\u001b[0m \u001b[90m({item.PlatformId})\u001b[0m {value}\n"; } return text + $"Total admins: {num}"; } [RconCommand("listplayers", "List all players.", null, false)] public static string ListAllPlayers() { string text = ""; int num = 0; foreach (PlayerData allPlayer in PlayerService.AllPlayers) { num++; string value = (allPlayer.IsOnline ? "\u001b[32m●\u001b[0m" : "\u001b[31m●\u001b[0m"); text += $"- \u001b[97m{allPlayer.Name}\u001b[0m \u001b[90m({allPlayer.PlatformId})\u001b[0m {value}\n"; } return text + $"Total players: {num}"; } [RconCommand("listclans", "List all clans.", null, false)] public static string ListClans() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) string text = "Clans:\n"; string value = "\u001b[97m"; string value2 = "\u001b[90m"; string value3 = "\u001b[0m"; List<ClanTeam> clanTeams = ClanService.GetClanTeams(); if (clanTeams.Count == 0) { return "No clans found."; } foreach (ClanTeam item in clanTeams) { FixedString64Bytes name = item.Name; string value4 = ((object)(FixedString64Bytes)(ref name)).ToString(); text += $"-{value} Clan Name{value3}: {value2}{value4}{value3}\n"; } return text; } private static ServerRuntimeSettings GetServerRuntimeSettings() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = GameSystems.EntityManager; EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadWrite<ServerRuntimeSettings>() }); ServerRuntimeSettings result = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2))[0].Read<ServerRuntimeSettings>(); ((EntityQuery)(ref val)).Dispose(); return result; } } [RconCommandCategory("Summon")] public static class SummonCommand { [RconCommand("summon", "Summon an entity at specific coordinates.", null, false)] public static string Summon(string prefabGUID, float x, float y, float z, int quantity, int lifeTime, bool disableWhenNoPlayersInRange) { //IL_0010: 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) //IL_002a: 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) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) PrefabGUID val = default(PrefabGUID); if (!PrefabGUID.TryParse(prefabGUID, ref val)) { return "Invalid Prefab GUID."; } List<Entity> list = UnitSpawnerService.ImmediateSpawn(val, new float3(x, y, z), quantity, 1f, 8f, (float)lifeTime, default(Entity)); if (disableWhenNoPlayersInRange) { foreach (Entity item in list) { if (item.Has<DisableWhenNoPlayersInRange>()) { item.Remove<DisableWhenNoPlayersInRange>(); } if (item.Has<DisableWhenNoPlayersInRangeOfChunk>()) { item.Remove<DisableWhenNoPlayersInRangeOfChunk>(); } } } return $"Summoned {((PrefabGUID)(ref val)).GuidHash} at ({x}, {y}, {z})."; } [RconCommand("summon", "Summon an entity at a player's location.", null, false)] public static string Summon(string prefabGUID, string playerName, int quantity, int lifeTime, bool disableWhenNoPlayersInRange) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) PrefabGUID val = default(PrefabGUID); if (!PrefabGUID.TryParse(prefabGUID, ref val)) { return "Invalid Prefab GUID."; } PlayerData val2 = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val2)) { return "Player '" + playerName + "' was not found."; } if (!val2.IsOnline) { return "Player '" + playerName + "' is not currently online."; } List<Entity> list = UnitSpawnerService.ImmediateSpawn(val, val2.CharacterEntity.Position(), quantity, 1f, 8f, (float)lifeTime, default(Entity)); if (disableWhenNoPlayersInRange) { foreach (Entity item in list) { if (item.Has<DisableWhenNoPlayersInRange>()) { item.Remove<DisableWhenNoPlayersInRange>(); } if (item.Has<DisableWhenNoPlayersInRangeOfChunk>()) { item.Remove<DisableWhenNoPlayersInRangeOfChunk>(); } } } return $"Summoned {((PrefabGUID)(ref val)).GuidHash} at {playerName}'s location."; } } [RconCommandCategory("Teleport & Location")] public static class TeleportCommand { [RconCommand("whereis", "Get position of a player.", null, false)] public static string WhereIs(string playerName) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) PlayerData val = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val)) { return "Player '" + playerName + "' was not found."; } float3 val2 = val.CharacterEntity.Position(); return $"- {val.Name}: ({val2.x} {val2.y} {val2.z})\n"; } [RconCommand("teleport", "Teleport a player to coordinates.", null, false)] public static string Teleport(string playerName, float x, float y, float z) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) PlayerData val = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val)) { return "Player '" + playerName + "' was not found."; } if (!val.IsOnline) { return "Player '" + playerName + "' is not currently online."; } TeleportService.TeleportToPosition(val.CharacterEntity, new float3(x, y, z), true); return $"Teleported {val.Name} to ({x}, {y}, {z})"; } [RconCommand("teleport", "Teleport a player to another player.", null, false)] public static string Teleport(string playerName, string targetPlayerName) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) PlayerData val = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val)) { return "Player '" + playerName + "' was not found."; } if (!val.IsOnline) { return "Player '" + playerName + "' is not currently online."; } PlayerData val2 = default(PlayerData); if (!PlayerService.TryGetByName(targetPlayerName, ref val2)) { return "Target player '" + targetPlayerName + "' was not found."; } if (!val2.IsOnline) { return "Target player '" + targetPlayerName + "' is not currently online."; } TeleportService.TeleportToEntity(val.Charac