Reformat code

This commit is contained in:
js6pak committed 2022-08-30 19:49:49 +02:00
1 parent c2047b033e
commit 5004ac8d5b
52 files changed
+258 -312

No files matched your search

+9 -10
View File
@@ -9,15 +9,15 @@ using UnhollowerBaseLib;
using UnhollowerBaseLib.Attributes;
using UnityEngine;
namespace Reactor.Debugger
namespace Reactor.Debugger;
[BepInAutoPlugin("gg.reactor.debugger")]
[BepInProcess("Among Us.exe")]
[BepInDependency(ReactorPlugin.Id)]
[ReactorPluginSide(PluginSide.ClientOnly)]
public partial class DebuggerPlugin : BasePlugin
{
[BepInAutoPlugin("gg.reactor.debugger")]
[BepInProcess("Among Us.exe")]
[BepInDependency(ReactorPlugin.Id)]
[ReactorPluginSide(PluginSide.ClientOnly)]
public partial class DebuggerPlugin : BasePlugin
{
public Harmony Harmony { get; } = new Harmony(Id);
public Harmony Harmony { get; } = new(Id);
public DebuggerComponent Component { get; private set; }
public override void Load()
@@ -97,7 +97,7 @@ namespace Reactor.Debugger
}
})
{
Enabled = false
Enabled = false,
};
}
@@ -114,5 +114,4 @@ namespace Reactor.Debugger
TestWindow.OnGUI();
}
}
}
}
+3 -4
View File
@@ -3,10 +3,10 @@ using HarmonyLib;
using UnhollowerBaseLib;
using UnityEngine;
namespace Reactor.Debugger
namespace Reactor.Debugger;
internal static class Patches
{
internal static class Patches
{
[HarmonyPatch(typeof(GameStartManager), nameof(GameStartManager.Update))]
public static class UpdatePatch
{
@@ -66,5 +66,4 @@ namespace Reactor.Debugger
.ValidRange = new FloatRange(0, byte.MaxValue);
}
}
}
}
+4 -5
View File
@@ -1,8 +1,7 @@
namespace Reactor.Example
namespace Reactor.Example;
public enum CustomRpcCalls : uint
{
public enum CustomRpcCalls : uint
{
Example,
MethodRpcExample
}
MethodRpcExample,
}
+6 -7
View File
@@ -8,13 +8,13 @@ using UnhollowerBaseLib.Attributes;
using UnityEngine;
using Random = UnityEngine.Random;
namespace Reactor.Example
namespace Reactor.Example;
[BepInAutoPlugin("gg.reactor.Example")]
[BepInProcess("Among Us.exe")]
[BepInDependency(ReactorPlugin.Id)]
public partial class ExamplePlugin : BasePlugin
{
[BepInAutoPlugin("gg.reactor.Example")]
[BepInProcess("Among Us.exe")]
[BepInDependency(ReactorPlugin.Id)]
public partial class ExamplePlugin : BasePlugin
{
public override void Load()
{
this.AddComponent<ExampleComponent>();
@@ -55,5 +55,4 @@ namespace Reactor.Example
{
Logger<ExamplePlugin>.Info($"{player.Data.PlayerName} text: {text} number: {number} testPlayer: {testPlayer.NetId}");
}
}
}
+4 -5
View File
@@ -1,11 +1,11 @@
using Hazel;
using Reactor.Networking;
namespace Reactor.Example
namespace Reactor.Example;
[RegisterCustomRpc((uint) CustomRpcCalls.Example)]
public class ExampleRpc : PlayerCustomRpc<ExamplePlugin, ExampleRpc.Data>
{
[RegisterCustomRpc((uint) CustomRpcCalls.Example)]
public class ExampleRpc : PlayerCustomRpc<ExamplePlugin, ExampleRpc.Data>
{
public ExampleRpc(ExamplePlugin plugin, uint id) : base(plugin, id)
{
}
@@ -36,5 +36,4 @@ namespace Reactor.Example
{
Plugin.Log.LogWarning($"Handle: {innerNetObject.Data.PlayerName} sent \"{data.Message}\"");
}
}
}
+3 -4
View File
@@ -2,10 +2,10 @@
using System;
namespace Reactor.Networking
namespace Reactor.Networking;
public class Mod
{
public class Mod
{
public Mod(uint netId, string id, string version, PluginSide side)
{
NetId = netId;
@@ -36,5 +36,4 @@ namespace Reactor.Networking
{
return HashCode.Combine(Id, Version);
}
}
}
@@ -1,9 +1,8 @@
namespace Reactor.Networking
namespace Reactor.Networking;
public enum ReactorMessageFlags : byte
{
public enum ReactorMessageFlags : byte
{
Handshake,
ModDeclaration,
PluginDeclaration
}
PluginDeclaration,
}
@@ -1,10 +1,10 @@
namespace Reactor.Networking
namespace Reactor.Networking;
/// <summary>
/// Version of the Reactor.Net protocol format.
/// </summary>
public enum ReactorProtocolVersion : byte
{
/// <summary>
/// Version of the Reactor.Net protocol format.
/// </summary>
public enum ReactorProtocolVersion : byte
{
/// <summary>
/// Initial version.
/// </summary>
@@ -14,5 +14,4 @@ namespace Reactor.Networking
/// Latest version.
/// </summary>
Latest = Initial,
}
}
+7 -8
View File
@@ -1,10 +1,10 @@
namespace Reactor
namespace Reactor;
/// <summary>
/// Plugin side used in modded handshake
/// </summary>
public enum PluginSide : byte
{
/// <summary>
/// Plugin side used in modded handshake
/// </summary>
public enum PluginSide : byte
{
/// <summary>
/// Required by both sides, reject connection if missing on the other side
/// </summary>
@@ -13,6 +13,5 @@ namespace Reactor
/// <summary>
/// Required only by client
/// </summary>
ClientOnly
}
ClientOnly,
}
+3 -4
View File
@@ -3,10 +3,10 @@ using System.Reflection.Emit;
using BepInEx.IL2CPP;
using HarmonyLib;
namespace Reactor
namespace Reactor;
public static class ChainloaderHooks
{
public static class ChainloaderHooks
{
public delegate void PluginLoadHandler(BasePlugin plugin);
public static event PluginLoadHandler? PluginLoad;
@@ -30,5 +30,4 @@ namespace Reactor
.InstructionEnumeration();
}
}
}
}
+3 -4
View File
@@ -5,10 +5,10 @@ using System.Runtime.CompilerServices;
using BepInEx.IL2CPP.Utils;
using UnityEngine;
namespace Reactor
namespace Reactor;
public static class Coroutines
{
public static class Coroutines
{
[RegisterInIl2Cpp]
internal class Component : MonoBehaviour
{
@@ -49,5 +49,4 @@ namespace Reactor
Component.Instance!.StopCoroutine(routine);
}
}
}
}
+4 -5
View File
@@ -3,13 +3,13 @@ using System.Linq;
using HarmonyLib;
using UnhollowerBaseLib;
namespace Reactor
namespace Reactor;
public class CustomStringName
{
public class CustomStringName
{
private static int _lastId = -1;
private static readonly List<CustomStringName> _list = new List<CustomStringName>();
private static readonly List<CustomStringName> _list = new();
public static IReadOnlyList<CustomStringName> List => _list.AsReadOnly();
@@ -50,5 +50,4 @@ namespace Reactor
return true;
}
}
}
}
+6 -7
View File
@@ -11,13 +11,13 @@ using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using Il2CppType = UnhollowerRuntimeLib.Il2CppType;
namespace Reactor.Extensions
namespace Reactor.Extensions;
/// <summary>
/// General utilities
/// </summary>
public static class Extensions
{
/// <summary>
/// General utilities
/// </summary>
public static class Extensions
{
/// <summary>
/// Adds a delegate to get one notification when a scene has loaded.
/// </summary>
@@ -119,5 +119,4 @@ namespace Reactor.Extensions
{
return assetBundle.LoadAsset(name, Il2CppType.Of<T>())?.Cast<T>();
}
}
}
+3 -4
View File
@@ -3,10 +3,10 @@ using Hazel;
using Hazel.Udp;
using UnityEngine;
namespace Reactor.Extensions
namespace Reactor.Extensions;
public static class ExtraMessageExtensions
{
public static class ExtraMessageExtensions
{
private const float MIN = -50f;
private const float MAX = 50f;
@@ -45,5 +45,4 @@ namespace Reactor.Extensions
connection.AttachReliableID(buffer, 1, ackCallback);
connection.WriteBytesToConnection(buffer, buffer.Length);
}
}
}
+12 -13
View File
@@ -4,13 +4,13 @@ using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace Reactor.Extensions
namespace Reactor.Extensions;
/// <summary>
/// GUI utilities
/// </summary>
public static class GUIExtensions
{
/// <summary>
/// GUI utilities
/// </summary>
public static class GUIExtensions
{
/// <summary>
/// Shortcut for empty texture
/// </summary>
@@ -81,10 +81,10 @@ namespace Reactor.Extensions
rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, width);
rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height);
}
}
}
public class Window
{
public class Window
{
private static int _lastWindowId;
public static int NextWindowId()
@@ -127,10 +127,10 @@ namespace Reactor.Extensions
}
}
}
}
}
public class DragWindow : Window
{
public class DragWindow : Window
{
public DragWindow(Rect rect, string title, Action<int> func) : base(rect, title, func)
{
Func = id =>
@@ -145,5 +145,4 @@ namespace Reactor.Extensions
public DragWindow(Rect rect, string title, Action func) : this(rect, title, id => func())
{
}
}
}
+8 -9
View File
@@ -5,11 +5,11 @@ using UnhollowerBaseLib;
using UnhollowerBaseLib.Attributes;
using UnhollowerRuntimeLib;
namespace Reactor.Extensions
namespace Reactor.Extensions;
[RegisterInIl2Cpp]
public class StreamWrapper : Il2CppSystem.IO.Stream
{
[RegisterInIl2Cpp]
public class StreamWrapper : Il2CppSystem.IO.Stream
{
private readonly Stream _stream;
#pragma warning disable 8618
@@ -62,7 +62,7 @@ namespace Reactor.Extensions
Il2CppSystem.IO.SeekOrigin.Begin => SeekOrigin.Begin,
Il2CppSystem.IO.SeekOrigin.Current => SeekOrigin.Current,
Il2CppSystem.IO.SeekOrigin.End => SeekOrigin.End,
_ => throw new ArgumentOutOfRangeException(nameof(origin), origin, null)
_ => throw new ArgumentOutOfRangeException(nameof(origin), origin, null),
});
}
@@ -81,13 +81,12 @@ namespace Reactor.Extensions
get => _stream.Position;
set => _stream.Position = value;
}
}
}
public static class StreamExtensions
{
public static class StreamExtensions
{
/// <summary>
/// Wraps a System Stream into an Il2Cpp Stream
/// </summary>
public static StreamWrapper AsIl2Cpp(this Stream stream) => new(stream);
}
}
+3 -4
View File
@@ -1,9 +1,9 @@
using UnityEngine;
namespace Reactor.Extensions
namespace Reactor.Extensions;
public static class UnityObjectExtensions
{
public static class UnityObjectExtensions
{
/// <summary>
/// Stops <paramref name="obj"/> from being destroyed
/// </summary>
@@ -39,5 +39,4 @@ namespace Reactor.Extensions
{
Object.DestroyImmediate(obj);
}
}
}
+3 -4
View File
@@ -1,10 +1,10 @@
using System.Collections.Generic;
using Il2CppSystem.Runtime.CompilerServices;
namespace Reactor
namespace Reactor;
public sealed class Il2CppEqualityComparer<T> : IEqualityComparer<T> where T : Il2CppSystem.Object
{
public sealed class Il2CppEqualityComparer<T> : IEqualityComparer<T> where T : Il2CppSystem.Object
{
private static Il2CppEqualityComparer<T>? _instance;
public static Il2CppEqualityComparer<T> Instance
@@ -34,5 +34,4 @@ namespace Reactor
return left.Equals(right);
}
}
}
+3 -4
View File
@@ -3,9 +3,8 @@
// ReSharper disable CheckNamespace
namespace System.Runtime.CompilerServices
namespace System.Runtime.CompilerServices;
public static class IsExternalInit
{
public static class IsExternalInit
{
}
}
+3 -4
View File
@@ -1,10 +1,10 @@
using BepInEx.IL2CPP;
using BepInEx.Logging;
namespace Reactor
namespace Reactor;
public static class Logger<T> where T : BasePlugin
{
public static class Logger<T> where T : BasePlugin
{
public static ManualLogSource Instance => PluginSingleton<T>.Instance.Log;
/// <inheritdoc cref="ManualLogSource.LogFatal"/>
@@ -24,5 +24,4 @@ namespace Reactor
/// <inheritdoc cref="ManualLogSource.LogDebug"/>
public static void Debug(object data) => Instance.LogDebug(data);
}
}
+6 -7
View File
@@ -3,10 +3,10 @@ using BepInEx.IL2CPP;
using Hazel;
using InnerNet;
namespace Reactor.Networking
namespace Reactor.Networking;
public abstract class CustomRpc<TPlugin, TInnerNetObject, TData> : UnsafeCustomRpc where TPlugin : BasePlugin where TInnerNetObject : InnerNetObject
{
public abstract class CustomRpc<TPlugin, TInnerNetObject, TData> : UnsafeCustomRpc where TPlugin : BasePlugin where TInnerNetObject : InnerNetObject
{
protected CustomRpc(TPlugin plugin, uint id) : base(plugin, id)
{
}
@@ -42,10 +42,10 @@ namespace Reactor.Networking
{
UnsafeSend(netObject, data, true, targetId);
}
}
}
public abstract class CustomRpc<TPlugin, TInnerNetObject> : UnsafeCustomRpc where TPlugin : BasePlugin where TInnerNetObject : InnerNetObject
{
public abstract class CustomRpc<TPlugin, TInnerNetObject> : UnsafeCustomRpc where TPlugin : BasePlugin where TInnerNetObject : InnerNetObject
{
protected CustomRpc(TPlugin plugin, uint id) : base(plugin, id)
{
}
@@ -78,5 +78,4 @@ namespace Reactor.Networking
{
UnsafeSend(netObject, null, true, targetId);
}
}
}
+12 -13
View File
@@ -6,21 +6,21 @@ using HarmonyLib;
using Hazel;
using InnerNet;
namespace Reactor.Networking
namespace Reactor.Networking;
public enum RpcLocalHandling
{
public enum RpcLocalHandling
{
None,
Before,
After
}
After,
}
public class CustomRpcManager
{
public class CustomRpcManager
{
public const byte CallId = byte.MaxValue;
private readonly List<UnsafeCustomRpc> _list = new List<UnsafeCustomRpc>();
private readonly Dictionary<Type, List<UnsafeCustomRpc>> _map = new Dictionary<Type, List<UnsafeCustomRpc>>();
private readonly List<UnsafeCustomRpc> _list = new();
private readonly Dictionary<Type, List<UnsafeCustomRpc>> _map = new();
public IReadOnlyList<UnsafeCustomRpc> List => _list.AsReadOnly();
@@ -86,10 +86,10 @@ namespace Reactor.Networking
return true;
}
}
}
}
public static class Rpc<T> where T : UnsafeCustomRpc
{
public static class Rpc<T> where T : UnsafeCustomRpc
{
private static T? _instance;
public static T Instance
@@ -114,5 +114,4 @@ namespace Reactor.Networking
_instance = value;
}
}
}
}
+3 -4
View File
@@ -12,10 +12,10 @@ using MonoMod.RuntimeDetour;
using MonoMod.Utils;
using Reactor.Networking.Serialization;
namespace Reactor.Networking.MethodRpc
namespace Reactor.Networking.MethodRpc;
public class MethodRpc : UnsafeCustomRpc
{
public class MethodRpc : UnsafeCustomRpc
{
public delegate object HandleDelegate(InnerNetObject innerNetObject, object[] args);
public MethodRpc(BasePlugin plugin, MethodInfo method, uint id, SendOption option, RpcLocalHandling localHandling, bool sendImmediately) : base(plugin, id)
@@ -209,5 +209,4 @@ namespace Reactor.Networking.MethodRpc
return GenerateHandler((DynamicMethod) detour.GenerateTrampoline());
}
}
}
@@ -5,11 +5,11 @@ using BepInEx.IL2CPP;
using HarmonyLib;
using Hazel;
namespace Reactor.Networking.MethodRpc
namespace Reactor.Networking.MethodRpc;
[AttributeUsage(AttributeTargets.Method)]
public class MethodRpcAttribute : Attribute
{
[AttributeUsage(AttributeTargets.Method)]
public class MethodRpcAttribute : Attribute
{
public uint Id { get; }
public SendOption Option { get; set; } = SendOption.Reliable;
public RpcLocalHandling LocalHandling { get; set; } = RpcLocalHandling.Before;
@@ -49,5 +49,4 @@ namespace Reactor.Networking.MethodRpc
{
ChainloaderHooks.PluginLoad += plugin => Register(plugin.GetType().Assembly, plugin);
}
}
}
+3 -4
View File
@@ -1,9 +1,9 @@
using Hazel;
namespace Reactor.Networking
namespace Reactor.Networking;
public static class ModDeclaration
{
public static class ModDeclaration
{
public static void Serialize(MessageWriter writer, Mod mod)
{
writer.StartMessage(byte.MaxValue);
@@ -13,5 +13,4 @@ namespace Reactor.Networking
writer.Write(mod.Version);
writer.Write((byte) mod.Side);
}
}
}
+3 -4
View File
@@ -2,10 +2,10 @@ using System.Collections.Generic;
using System.Linq;
using BepInEx.IL2CPP;
namespace Reactor.Networking
namespace Reactor.Networking;
public static class ModList
{
public static class ModList
{
private static Dictionary<string, Mod>? _mapById;
private static Dictionary<uint, Mod>? _mapByNetId;
@@ -40,5 +40,4 @@ namespace Reactor.Networking
return Current;
}
}
}
+3 -4
View File
@@ -1,13 +1,12 @@
using Hazel;
namespace Reactor.Networking
namespace Reactor.Networking;
public static class ModdedHandshakeC2S
{
public static class ModdedHandshakeC2S
{
public static void Serialize(MessageWriter writer, int modCount)
{
writer.Write((byte) ReactorProtocolVersion.Initial);
writer.WritePacked(modCount);
}
}
}
+3 -4
View File
@@ -1,9 +1,9 @@
using Hazel;
namespace Reactor.Networking
namespace Reactor.Networking;
public static class ModdedHandshakeS2C
{
public static class ModdedHandshakeS2C
{
public static void Serialize(MessageWriter writer, string serverName, string serverVersion, int pluginCount)
{
writer.StartMessage(byte.MaxValue);
@@ -20,5 +20,4 @@ namespace Reactor.Networking
serverVersion = reader.ReadString();
pluginCount = reader.ReadPackedInt32();
}
}
}
+3 -4
View File
@@ -9,10 +9,10 @@ using Reactor.Extensions;
using UnhollowerBaseLib;
using UnityEngine;
namespace Reactor.Networking.Patches
namespace Reactor.Networking.Patches;
internal static class ClientPatches
{
internal static class ClientPatches
{
[HarmonyPatch(typeof(InnerNetClient), nameof(InnerNetClient.HandleMessage))]
public static class HandleMessagePatch
{
@@ -180,5 +180,4 @@ namespace Reactor.Networking.Patches
handshake.Recycle();
}
}
}
}
+3 -4
View File
@@ -3,10 +3,10 @@ using Hazel;
using InnerNet;
using UnityEngine;
namespace Reactor.Networking.Patches
namespace Reactor.Networking.Patches;
internal static class ServerPatches
{
internal static class ServerPatches
{
[HarmonyPatch(typeof(InnerNetServer), nameof(InnerNetServer.OnServerConnect))]
public static class HandshakeResponsePatch
{
@@ -18,5 +18,4 @@ namespace Reactor.Networking.Patches
writer.Recycle();
}
}
}
}
+6 -7
View File
@@ -1,9 +1,9 @@
using BepInEx.IL2CPP;
namespace Reactor.Networking
namespace Reactor.Networking;
public abstract class PlayerCustomRpc<TPlugin, TData> : CustomRpc<TPlugin, PlayerControl, TData> where TPlugin : BasePlugin
{
public abstract class PlayerCustomRpc<TPlugin, TData> : CustomRpc<TPlugin, PlayerControl, TData> where TPlugin : BasePlugin
{
protected PlayerCustomRpc(TPlugin plugin, uint id) : base(plugin, id)
{
}
@@ -17,10 +17,10 @@ namespace Reactor.Networking
{
SendTo(PlayerControl.LocalPlayer, targetId, data);
}
}
}
public abstract class PlayerCustomRpc<TPlugin> : CustomRpc<TPlugin, PlayerControl> where TPlugin : BasePlugin
{
public abstract class PlayerCustomRpc<TPlugin> : CustomRpc<TPlugin, PlayerControl> where TPlugin : BasePlugin
{
protected PlayerCustomRpc(TPlugin plugin, uint id) : base(plugin, id)
{
}
@@ -34,5 +34,4 @@ namespace Reactor.Networking
{
SendTo(PlayerControl.LocalPlayer, targetId);
}
}
}
@@ -4,15 +4,14 @@ using System.Reflection;
using HarmonyLib;
using Hazel;
using InnerNet;
using MonoMod.Utils;
namespace Reactor.Networking.Serialization
namespace Reactor.Networking.Serialization;
[MessageConverter]
public class InnerNetObjectConverter : MessageConverter<InnerNetObject>
{
[MessageConverter]
public class InnerNetObjectConverter : MessageConverter<InnerNetObject>
{
private static readonly MethodInfo _readNetObject = AccessTools.Method(typeof(MessageExtensions), nameof(MessageExtensions.ReadNetObject));
private static readonly Dictionary<Type, Func<MessageReader, InnerNetObject>> _readNetObjectMap = new Dictionary<Type, Func<MessageReader, InnerNetObject>>();
private static readonly Dictionary<Type, Func<MessageReader, InnerNetObject>> _readNetObjectMap = new();
public static InnerNetObject ReadNetObject(MessageReader reader, Type t)
{
@@ -35,5 +34,4 @@ namespace Reactor.Networking.Serialization
{
return ReadNetObject(reader, objectType);
}
}
}
@@ -1,18 +1,18 @@
using System;
using Hazel;
namespace Reactor.Networking.Serialization
namespace Reactor.Networking.Serialization;
public abstract class UnsafeMessageConverter
{
public abstract class UnsafeMessageConverter
{
public abstract void UnsafeWrite(MessageWriter writer, object value);
public abstract object UnsafeRead(MessageReader reader, Type objectType);
public abstract bool CanConvert(Type objectType);
}
}
public abstract class MessageConverter<T> : UnsafeMessageConverter
{
public abstract class MessageConverter<T> : UnsafeMessageConverter
{
public abstract void Write(MessageWriter writer, T value);
public abstract T Read(MessageReader reader, Type objectType);
@@ -25,5 +25,4 @@ namespace Reactor.Networking.Serialization
public override void UnsafeWrite(MessageWriter writer, object value) => Write(writer, (T) value);
public override object UnsafeRead(MessageReader reader, Type objectType) => Read(reader, objectType)!;
}
}
@@ -2,11 +2,11 @@ using System;
using System.Reflection;
using HarmonyLib;
namespace Reactor.Networking.Serialization
namespace Reactor.Networking.Serialization;
[AttributeUsage(AttributeTargets.Class)]
public class MessageConverterAttribute : Attribute
{
[AttributeUsage(AttributeTargets.Class)]
public class MessageConverterAttribute : Attribute
{
public static void Register(Assembly assembly)
{
foreach (var type in assembly.GetTypes())
@@ -37,5 +37,4 @@ namespace Reactor.Networking.Serialization
{
ChainloaderHooks.PluginLoad += plugin => Register(plugin.GetType().Assembly);
}
}
}
@@ -5,13 +5,13 @@ using Hazel;
using Reactor.Extensions;
using UnityEngine;
namespace Reactor.Networking.Serialization
{
public static class MessageSerializer
{
private static List<UnsafeMessageConverter> MessageConverters { get; } = new List<UnsafeMessageConverter>();
namespace Reactor.Networking.Serialization;
private static Dictionary<Type, UnsafeMessageConverter> MessageConverterMap { get; } = new Dictionary<Type, UnsafeMessageConverter>();
public static class MessageSerializer
{
private static List<UnsafeMessageConverter> MessageConverters { get; } = new();
private static Dictionary<Type, UnsafeMessageConverter> MessageConverterMap { get; } = new();
public static void Register(UnsafeMessageConverter messageConverter)
{
@@ -152,5 +152,4 @@ namespace Reactor.Networking.Serialization
throw new NotSupportedException("Couldn't deserialize " + t);
}
}
}
+4 -5
View File
@@ -4,10 +4,10 @@ using BepInEx.IL2CPP;
using Hazel;
using InnerNet;
namespace Reactor.Networking
namespace Reactor.Networking;
public abstract class UnsafeCustomRpc
{
public abstract class UnsafeCustomRpc
{
internal CustomRpcManager? Manager { get; set; }
protected internal virtual bool IsSingleton => true;
@@ -48,7 +48,7 @@ namespace Reactor.Networking
var writer = immediately switch
{
false => AmongUsClient.Instance.StartRpc(innerNetObject.NetId, CustomRpcManager.CallId, SendOption),
true => AmongUsClient.Instance.StartRpcImmediately(innerNetObject.NetId, CustomRpcManager.CallId, SendOption, targetClientId)
true => AmongUsClient.Instance.StartRpcImmediately(innerNetObject.NetId, CustomRpcManager.CallId, SendOption, targetClientId),
};
var pluginNetId = ModList.GetById(PluginId).NetId;
@@ -73,5 +73,4 @@ namespace Reactor.Networking
UnsafeHandle(innerNetObject, data);
}
}
}
}
+3 -5
View File
@@ -1,11 +1,10 @@
using HarmonyLib;
using InnerNet;
using UnityEngine;
namespace Reactor.Patches
namespace Reactor.Patches;
internal static class BetterGuestPatch
{
internal static class BetterGuestPatch
{
[HarmonyPatch(typeof(SaveManager), nameof(SaveManager.ChatModeType), MethodType.Getter)]
public static class ChatModeTypePatch
{
@@ -15,5 +14,4 @@ namespace Reactor.Patches
return false;
}
}
}
}
+7 -8
View File
@@ -3,14 +3,14 @@ using HarmonyLib;
using TMPro;
using UnityEngine;
namespace Reactor.Patches
namespace Reactor.Patches;
/// <summary>
/// "Fixes" an issue where empty TextBoxes have wrong cursor positions
/// </summary>
[HarmonyPatch(typeof(TextMeshProExtensions), nameof(TextMeshProExtensions.CursorPos))]
internal static class CursorPosPatch
{
/// <summary>
/// "Fixes" an issue where empty TextBoxes have wrong cursor positions
/// </summary>
[HarmonyPatch(typeof(TextMeshProExtensions), nameof(TextMeshProExtensions.CursorPos))]
internal static class CursorPosPatch
{
public static bool Prefix(TextMeshPro self, ref Vector2 __result)
{
if (self.textInfo == null || self.textInfo.lineCount == 0 || self.textInfo.lineInfo[0].characterCount <= 0)
@@ -21,5 +21,4 @@ namespace Reactor.Patches
return true;
}
}
}
+4 -5
View File
@@ -1,10 +1,10 @@
using HarmonyLib;
namespace Reactor.Patches
namespace Reactor.Patches;
[HarmonyPatch]
internal static class CustomServersPatch
{
[HarmonyPatch]
internal static class CustomServersPatch
{
[HarmonyPatch(typeof(AuthManager._CoConnect_d__4), nameof(AuthManager._CoConnect_d__4.MoveNext))]
[HarmonyPatch(typeof(AuthManager._CoWaitForNonce_d__6), nameof(AuthManager._CoWaitForNonce_d__6.MoveNext))]
[HarmonyPrefix]
@@ -28,5 +28,4 @@ namespace Reactor.Patches
};
}
}
}
}
+6 -6
View File
@@ -7,10 +7,10 @@ using UnityEngine;
using UnityEngine.SceneManagement;
using Object = UnityEngine.Object;
namespace Reactor.Patches
namespace Reactor.Patches;
public static class FreeNamePatch
{
public static class FreeNamePatch
{
[HarmonyPatch(typeof(AccountManager), nameof(AccountManager.CheckAndRegenerateName))]
internal static class ValidateRandomNamePatch
{
@@ -37,7 +37,8 @@ namespace Reactor.Patches
textBox.outputText.transform.position = nameText.transform.position;
textBox.outputText.fontSize = 4f;
textBox.OnChange.AddListener((Action) (() => {
textBox.OnChange.AddListener((Action) (() =>
{
SaveManager.PlayerName = textBox.text;
}));
textBox.OnEnter = textBox.OnFocusLost = textBox.OnChange;
@@ -52,7 +53,7 @@ namespace Reactor.Patches
{
"HostGameButton",
"FindGameButton",
"JoinGameButton"
"JoinGameButton",
};
var yStart = Vector3.up;
@@ -68,5 +69,4 @@ namespace Reactor.Patches
return true;
}
}
}
+3 -4
View File
@@ -1,10 +1,10 @@
using System.Linq;
using HarmonyLib;
namespace Reactor.Patches
namespace Reactor.Patches;
internal static class PlayerIdPatch
{
internal static class PlayerIdPatch
{
[HarmonyPatch(typeof(GameData), nameof(GameData.GetAvailableId))]
public static class GetAvailableIdPatch
{
@@ -22,5 +22,4 @@ namespace Reactor.Patches
return false;
}
}
}
}
+3 -5
View File
@@ -1,5 +1,4 @@
using System;
using System.Reflection;
using BepInEx;
using BepInEx.IL2CPP;
using HarmonyLib;
@@ -8,10 +7,10 @@ using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace Reactor.Patches
namespace Reactor.Patches;
public static class ReactorVersionShower
{
public static class ReactorVersionShower
{
public static TextMeshPro? Text { get; private set; }
public static event TextUpdatedHandler? TextUpdated;
@@ -71,5 +70,4 @@ namespace Reactor.Patches
return false;
}
}
}
}
+3 -4
View File
@@ -6,10 +6,10 @@ using Reactor.Extensions;
using UnityEngine;
using Object = UnityEngine.Object;
namespace Reactor.Patches
namespace Reactor.Patches;
internal class RegionInfoWatcher : IDisposable
{
internal class RegionInfoWatcher : IDisposable
{
private FileSystemWatcher Watcher { get; }
public bool IgnoreNext { get; set; }
@@ -84,5 +84,4 @@ namespace Reactor.Patches
return true;
}
}
}
}
+11 -12
View File
@@ -5,23 +5,23 @@ using System.Net.Sockets;
using HarmonyLib;
using InnerNet;
namespace Reactor.Patches
namespace Reactor.Patches;
[HarmonyPatch(typeof(InnerNetClient), nameof(InnerNetClient.Connect))]
public static class ConnectPatch
{
[HarmonyPatch(typeof(InnerNetClient), nameof(InnerNetClient.Connect))]
public static class ConnectPatch
{
public static void Prefix(InnerNetClient __instance)
{
Logger<ReactorPlugin>.Info($"Joining {__instance.networkAddress}:{__instance.networkPort}");
}
}
}
/// <summary>
/// Fixes hardcoded port and filters out IPv6 in DnsRegionInfo
/// </summary>
[HarmonyPatch(typeof(DnsRegionInfo), nameof(DnsRegionInfo.PopulateServers))]
public static class PopulateServersPatch
{
/// <summary>
/// Fixes hardcoded port and filters out IPv6 in DnsRegionInfo
/// </summary>
[HarmonyPatch(typeof(DnsRegionInfo), nameof(DnsRegionInfo.PopulateServers))]
public static class PopulateServersPatch
{
public static bool Prefix(DnsRegionInfo __instance)
{
try
@@ -47,5 +47,4 @@ namespace Reactor.Patches
return false;
}
}
}
+8 -9
View File
@@ -1,20 +1,20 @@
using System.Reflection;
using HarmonyLib;
namespace Reactor.Patches
namespace Reactor.Patches;
[HarmonyPatch(typeof(SplashManager), nameof(SplashManager.Start))]
internal static class SplashSkip
{
[HarmonyPatch(typeof(SplashManager), nameof(SplashManager.Start))]
internal static class SplashSkip
{
private static void Prefix(SplashManager __instance)
{
__instance.minimumSecondsBeforeSceneChange = 0;
}
}
}
[HarmonyPatch(typeof(SplashManager), nameof(SplashManager.Update))]
internal static class WaitForEpicAuth
{
[HarmonyPatch(typeof(SplashManager), nameof(SplashManager.Update))]
internal static class WaitForEpicAuth
{
private static readonly PropertyInfo? _localUserIdProperty = typeof(EpicManager).GetProperty("localUserId", BindingFlags.Static | BindingFlags.Public);
private static bool _loginFinished;
@@ -39,5 +39,4 @@ namespace Reactor.Patches
if (overrideLoad) _loginFinished = true;
}
}
}
}
+3 -4
View File
@@ -3,10 +3,10 @@ using System.IO;
using System.Reflection;
using HarmonyLib;
namespace Reactor.Patches
namespace Reactor.Patches;
internal static class SteamPatch
{
internal static class SteamPatch
{
[HarmonyPatch]
public static class RestartAppIfNecessaryPatch
{
@@ -35,5 +35,4 @@ namespace Reactor.Patches
return __result = false;
}
}
}
}
+3 -4
View File
@@ -2,10 +2,10 @@ using System.Linq;
using System.Reflection;
using BepInEx.IL2CPP;
namespace Reactor
namespace Reactor;
public static class PluginSingleton<T> where T : BasePlugin
{
public static class PluginSingleton<T> where T : BasePlugin
{
private static T? _instance;
public static T Instance => _instance ??= IL2CPPChainloader.Instance.Plugins.Values.Select(x => x.Instance).OfType<T>().Single();
@@ -19,5 +19,4 @@ namespace Reactor
.SetValue(null, plugin);
};
}
}
}
+8 -9
View File
@@ -14,18 +14,18 @@ using UnhollowerBaseLib.Attributes;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace Reactor
namespace Reactor;
[BepInAutoPlugin("gg.reactor.api")]
[BepInProcess("Among Us.exe")]
public partial class ReactorPlugin : BasePlugin
{
[BepInAutoPlugin("gg.reactor.api")]
[BepInProcess("Among Us.exe")]
public partial class ReactorPlugin : BasePlugin
{
public Harmony Harmony { get; } = new Harmony(Id);
public CustomRpcManager CustomRpcManager { get; } = new CustomRpcManager();
public Harmony Harmony { get; } = new(Id);
public CustomRpcManager CustomRpcManager { get; } = new();
public ConfigEntry<bool>? AllowVanillaServers { get; private set; }
internal RegionInfoWatcher RegionInfoWatcher { get; } = new RegionInfoWatcher();
internal RegionInfoWatcher RegionInfoWatcher { get; } = new();
public ReactorPlugin()
{
@@ -105,5 +105,4 @@ namespace Reactor
}
}
}
}
}
+7 -8
View File
@@ -2,14 +2,14 @@ using System;
using System.Linq;
using System.Reflection;
namespace Reactor
namespace Reactor;
/// <summary>
/// This attribute specifies plugin's side
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
public class ReactorPluginSideAttribute : Attribute
{
/// <summary>
/// This attribute specifies plugin's side
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
public class ReactorPluginSideAttribute : Attribute
{
public PluginSide Side { get; }
public ReactorPluginSideAttribute(PluginSide side)
@@ -33,5 +33,4 @@ namespace Reactor
return PluginSide.Both;
}
}
}
+7 -8
View File
@@ -4,14 +4,14 @@ using BepInEx.IL2CPP;
using HarmonyLib;
using Reactor.Networking;
namespace Reactor
namespace Reactor;
/// <summary>
/// Utility attribute for automatically registering CustomRpc
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
public class RegisterCustomRpcAttribute : Attribute
{
/// <summary>
/// Utility attribute for automatically registering CustomRpc
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
public class RegisterCustomRpcAttribute : Attribute
{
public uint Id { get; }
public RegisterCustomRpcAttribute(uint id)
@@ -47,5 +47,4 @@ namespace Reactor
{
ChainloaderHooks.PluginLoad += plugin => Register(plugin.GetType().Assembly, plugin);
}
}
}
+7 -8
View File
@@ -3,14 +3,14 @@ using System.Reflection;
using HarmonyLib;
using UnhollowerRuntimeLib;
namespace Reactor
namespace Reactor;
/// <summary>
/// Utility attribute for automatically calling <see cref="ClassInjector.RegisterTypeInIl2Cpp{T}()"/>
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
public class RegisterInIl2CppAttribute : Attribute
{
/// <summary>
/// Utility attribute for automatically calling <see cref="ClassInjector.RegisterTypeInIl2Cpp{T}()"/>
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
public class RegisterInIl2CppAttribute : Attribute
{
public Type[] Interfaces { get; }
public RegisterInIl2CppAttribute()
@@ -67,5 +67,4 @@ namespace Reactor
{
ChainloaderHooks.PluginLoad += plugin => Register(plugin.GetType().Assembly);
}
}
}
+4 -5
View File
@@ -2,10 +2,10 @@ using Reactor.Extensions;
using UnityEngine;
using UnityEngine.UI;
namespace Reactor.Unstrip
namespace Reactor.Unstrip;
internal static class DefaultBundle
{
internal static class DefaultBundle
{
public static void Load()
{
using var stream = typeof(ReactorPlugin).Assembly.GetManifestResourceStream("Reactor.Assets.default.bundle")!;
@@ -26,10 +26,9 @@ namespace Reactor.Unstrip
knob = bundle.LoadAsset<Sprite>("Knob")!.DontUnload(),
mask = bundle.LoadAsset<Sprite>("UIMask")!.DontUnload(),
standard = bundle.LoadAsset<Sprite>("UISprite")!.DontUnload(),
inputField = bundle.LoadAsset<Sprite>("InputFieldBackground")!.DontUnload()
inputField = bundle.LoadAsset<Sprite>("InputFieldBackground")!.DontUnload(),
};
bundle.Unload(false);
}
}
}