mirror of
https://github.com/NuclearPowered/Reactor.git
synced 2026-10-20 01:46:21 +00:00
Compare commits
7
Commits
1.1.0
...
1.2.0-rc.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f3b510ae2a | ||
|
|
bc9b8ea8a2 | ||
|
|
c96f12029e | ||
|
|
8e8beaf30c | ||
|
|
d9e5e7f1a9 | ||
|
|
40ae06899c | ||
|
|
73e21fc406 |
No files matched your search
@@ -23,7 +23,7 @@ jobs:
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: 5.x
|
||||
dotnet-version: 6.x
|
||||
|
||||
- name: Run the Cake script
|
||||
uses: cake-build/cake-action@v1
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<GamePlatform Condition="'$(GamePlatform)' == ''">Steam</GamePlatform>
|
||||
<GameVersion Condition="'$(GamePlatform)' == 'Steam'">2021.6.30</GameVersion>
|
||||
<GameVersion Condition="'$(GamePlatform)' == 'Itch'">2021.6.30</GameVersion>
|
||||
<GameVersion Condition="'$(GamePlatform)' == 'Steam'">2021.11.9</GameVersion>
|
||||
<GameVersion Condition="'$(GamePlatform)' == 'Itch'">2021.11.9</GameVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -5,6 +5,7 @@ using BepInEx.IL2CPP;
|
||||
using HarmonyLib;
|
||||
using InnerNet;
|
||||
using Reactor.Extensions;
|
||||
using UnhollowerBaseLib;
|
||||
using UnhollowerBaseLib.Attributes;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -63,20 +64,10 @@ namespace Reactor.Debugger
|
||||
{
|
||||
var data = PlayerControl.LocalPlayer.Data;
|
||||
|
||||
var newIsImpostor = GUILayout.Toggle(data.IsImpostor, "Is Impostor");
|
||||
if (data.IsImpostor != newIsImpostor)
|
||||
var newIsImpostor = GUILayout.Toggle(data.Role.IsImpostor, "Is Impostor");
|
||||
if (data.Role.IsImpostor != newIsImpostor)
|
||||
{
|
||||
if (newIsImpostor)
|
||||
{
|
||||
PlayerControl.LocalPlayer.RpcSetInfected(new[]
|
||||
{
|
||||
data
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerControl.LocalPlayer.RemoveInfected();
|
||||
}
|
||||
PlayerControl.LocalPlayer.RpcSetRole(newIsImpostor ? RoleTypes.Impostor : RoleTypes.Crewmate);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Spawn a dummy"))
|
||||
@@ -90,10 +81,10 @@ namespace Reactor.Debugger
|
||||
playerControl.NetTransform.enabled = false;
|
||||
playerControl.SetName($"{TranslationController.Instance.GetString(StringNames.Dummy, Array.Empty<Il2CppSystem.Object>())} {i}");
|
||||
playerControl.SetColor((byte) (i % Palette.PlayerColors.Length));
|
||||
playerControl.SetHat(i % (uint) HatManager.Instance.AllHats.Count, playerControl.Data.ColorId);
|
||||
playerControl.SetPet(i % (uint) HatManager.Instance.AllPets.Count);
|
||||
playerControl.SetSkin(i % (uint) HatManager.Instance.AllSkins.Count);
|
||||
GameData.Instance.RpcSetTasks(playerControl.PlayerId, new byte[0]);
|
||||
playerControl.SetHat(HatManager.Instance.AllHats.ToArray().ElementAt(i % HatManager.Instance.AllHats.Count).ProdId, playerControl.Data.DefaultOutfit.ColorId);
|
||||
playerControl.SetPet(HatManager.Instance.AllPets.ToArray().ElementAt(i % HatManager.Instance.AllPets.Count).ProdId);
|
||||
playerControl.SetSkin(HatManager.Instance.AllSkins.ToArray().ElementAt(i % HatManager.Instance.AllSkins.Count).ProdId);
|
||||
GameData.Instance.RpcSetTasks(playerControl.PlayerId, new Il2CppStructArray<byte>(0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Reactor.Debugger
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(GameSettingMenu), nameof(GameSettingMenu.OnEnable))]
|
||||
[HarmonyPatch(typeof(GameSettingMenu), nameof(GameSettingMenu.Start))]
|
||||
public static class GameSettingMenuPatch
|
||||
{
|
||||
public static void Prefix(GameSettingMenu __instance)
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
".NETStandard,Version=v2.1": {
|
||||
"AmongUs.GameLibs.Steam": {
|
||||
"type": "Direct",
|
||||
"requested": "[2021.6.30, )",
|
||||
"resolved": "2021.6.30",
|
||||
"contentHash": "TdlFO+S61WREk/sOV2YUmzQ6MFNXk5o+uxLv4i4ft/Z1VRkxFo66/ff3cR1ZfI8DuXni/Ao9rS4dJP+j85pEFA=="
|
||||
"requested": "[2021.11.9, )",
|
||||
"resolved": "2021.11.9",
|
||||
"contentHash": "mqaIx7oPavuwMTRZDMmBrLOAWNG6s1tCOvpysnNPZT58b3epU+WMJKBruw9fUCf53t333d71xVUov6PRcwnSZQ=="
|
||||
},
|
||||
"BepInEx.AutoPlugin": {
|
||||
"type": "Direct",
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
".NETStandard,Version=v2.1": {
|
||||
"AmongUs.GameLibs.Steam": {
|
||||
"type": "Direct",
|
||||
"requested": "[2021.6.30, )",
|
||||
"resolved": "2021.6.30",
|
||||
"contentHash": "TdlFO+S61WREk/sOV2YUmzQ6MFNXk5o+uxLv4i4ft/Z1VRkxFo66/ff3cR1ZfI8DuXni/Ao9rS4dJP+j85pEFA=="
|
||||
"requested": "[2021.11.9, )",
|
||||
"resolved": "2021.11.9",
|
||||
"contentHash": "mqaIx7oPavuwMTRZDMmBrLOAWNG6s1tCOvpysnNPZT58b3epU+WMJKBruw9fUCf53t333d71xVUov6PRcwnSZQ=="
|
||||
},
|
||||
"BepInEx.AutoPlugin": {
|
||||
"type": "Direct",
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Reactor.Extensions;
|
||||
|
||||
[RegisterInIl2Cpp]
|
||||
public class Dispatcher : MonoBehaviour
|
||||
{
|
||||
public Dispatcher(IntPtr ptr) : base(ptr)
|
||||
{
|
||||
}
|
||||
|
||||
public static Dispatcher Instance { get; private set; } = null!;
|
||||
|
||||
private static readonly Queue<Action> _queue = new();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
lock (_queue)
|
||||
{
|
||||
while (_queue.Count > 0)
|
||||
{
|
||||
_queue.Dequeue().Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Enqueue(Action action)
|
||||
{
|
||||
lock (_queue)
|
||||
{
|
||||
_queue.Enqueue(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,11 +18,12 @@ namespace Reactor.Networking.MethodRpc
|
||||
{
|
||||
public delegate object HandleDelegate(InnerNetObject innerNetObject, object[] args);
|
||||
|
||||
public MethodRpc(BasePlugin plugin, MethodInfo method, uint id, SendOption option, RpcLocalHandling localHandling) : base(plugin, id)
|
||||
public MethodRpc(BasePlugin plugin, MethodInfo method, uint id, SendOption option, RpcLocalHandling localHandling, bool sendImmediately) : base(plugin, id)
|
||||
{
|
||||
Method = method;
|
||||
LocalHandling = localHandling;
|
||||
SendOption = option;
|
||||
SendImmediately = sendImmediately;
|
||||
|
||||
if (!method.IsStatic)
|
||||
{
|
||||
@@ -56,6 +57,7 @@ namespace Reactor.Networking.MethodRpc
|
||||
public override Type InnerNetObjectType { get; }
|
||||
public override RpcLocalHandling LocalHandling { get; }
|
||||
public override SendOption SendOption { get; }
|
||||
public bool SendImmediately { get; }
|
||||
|
||||
public override void UnsafeWrite(MessageWriter writer, object? data)
|
||||
{
|
||||
@@ -82,7 +84,7 @@ namespace Reactor.Networking.MethodRpc
|
||||
|
||||
public void Send(InnerNetObject innerNetObject, object[] args)
|
||||
{
|
||||
UnsafeSend(innerNetObject, args);
|
||||
UnsafeSend(innerNetObject, args, SendImmediately);
|
||||
}
|
||||
|
||||
private static readonly MethodInfo _sendMethod = AccessTools.Method(typeof(MethodRpc), nameof(Send));
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Reactor.Networking.MethodRpc
|
||||
public uint Id { get; }
|
||||
public SendOption Option { get; set; } = SendOption.Reliable;
|
||||
public RpcLocalHandling LocalHandling { get; set; } = RpcLocalHandling.Before;
|
||||
public bool SendImmediately { get; set; }
|
||||
|
||||
public MethodRpcAttribute(uint id)
|
||||
{
|
||||
@@ -34,7 +35,7 @@ namespace Reactor.Networking.MethodRpc
|
||||
|
||||
try
|
||||
{
|
||||
var customRpc = new MethodRpc(plugin, method, attribute.Id, attribute.Option, attribute.LocalHandling);
|
||||
var customRpc = new MethodRpc(plugin, method, attribute.Id, attribute.Option, attribute.LocalHandling, attribute.SendImmediately);
|
||||
PluginSingleton<ReactorPlugin>.Instance.CustomRpcManager.Register(customRpc);
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
using HarmonyLib;
|
||||
using Il2CppSystem.Security.Cryptography.X509Certificates;
|
||||
|
||||
namespace Reactor.Networking.Patches
|
||||
{
|
||||
internal static class AuthPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(X509Certificate2Collection), nameof(X509Certificate2Collection.Contains))]
|
||||
public static class AcceptCustomCertificatesPatch
|
||||
{
|
||||
public static bool Prefix(X509Certificate2Collection __instance, ref bool __result)
|
||||
{
|
||||
if (AuthManager.Instance && AuthManager.Instance.connection != null && AuthManager.Instance.connection.serverCertificates.Equals(__instance))
|
||||
{
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,14 +151,14 @@ namespace Reactor.Networking.Patches
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(AmongUsClient), nameof(AmongUsClient.GetConnectionData))]
|
||||
[HarmonyPatch(typeof(InnerNetClient), nameof(InnerNetClient.GetConnectionData))]
|
||||
public static class HandshakePatch
|
||||
{
|
||||
public static void Postfix(ref Il2CppStructArray<byte> __result)
|
||||
{
|
||||
ModList.Update();
|
||||
|
||||
var handshake = MessageWriter.Get(SendOption.Reliable);
|
||||
var handshake = new MessageWriter(1000);
|
||||
|
||||
handshake.Write(__result);
|
||||
|
||||
@@ -167,7 +167,7 @@ namespace Reactor.Networking.Patches
|
||||
ModList.Current!.Count
|
||||
);
|
||||
|
||||
__result = handshake.ToByteArray(false);
|
||||
__result = handshake.ToByteArray(true);
|
||||
handshake.Recycle();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
using HarmonyLib;
|
||||
using Hazel.Udp;
|
||||
using Il2CppSystem.Net;
|
||||
using InnerNet;
|
||||
|
||||
namespace Reactor.Patches
|
||||
{
|
||||
internal static class CustomServersPatch
|
||||
{
|
||||
/// <summary>
|
||||
/// Send the account id only to Among Us official servers
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(InnerNetClient), nameof(InnerNetClient.GetConnectionData))]
|
||||
public static class DontSendAccountIdPatch
|
||||
{
|
||||
public static void Prefix(ref bool useDtlsLayout)
|
||||
{
|
||||
if (AmongUsClient.Instance.GameMode != GameModes.OnlineGame)
|
||||
{
|
||||
useDtlsLayout = false;
|
||||
return;
|
||||
}
|
||||
|
||||
var serverManager = ServerManager.Instance;
|
||||
if (!serverManager || serverManager.CurrentRegion?.TryCast<DnsRegionInfo>() is not { } regionInfo || !regionInfo.Fqdn.EndsWith("among.us"))
|
||||
{
|
||||
useDtlsLayout = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Encrypt connection only to Among Us official servers
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(AuthManager), nameof(AuthManager.CreateDtlsConnection))]
|
||||
public static class DontEncryptCustomServersPatch
|
||||
{
|
||||
public static bool Prefix(ref UnityUdpClientConnection __result, string targetIp, ushort targetPort)
|
||||
{
|
||||
var serverManager = ServerManager.Instance;
|
||||
if (serverManager.CurrentRegion.TryCast<DnsRegionInfo>() is not { } regionInfo || !regionInfo.Fqdn.EndsWith("among.us"))
|
||||
{
|
||||
var remoteEndPoint = new IPEndPoint(IPAddress.Parse(targetIp), targetPort - 3);
|
||||
__result = new UnityUdpClientConnection(remoteEndPoint);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,14 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Reactor.Extensions;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace Reactor.Patches
|
||||
{
|
||||
internal class RegionInfoWatcher : IDisposable
|
||||
{
|
||||
private FileSystemWatcher Watcher { get; }
|
||||
public bool Reload { get; set; }
|
||||
|
||||
internal RegionInfoWatcher()
|
||||
{
|
||||
@@ -20,7 +21,19 @@ namespace Reactor.Patches
|
||||
{
|
||||
if (new FileInfo(e.Name).Length > 0)
|
||||
{
|
||||
Reload = true;
|
||||
Dispatcher.Instance.Enqueue(() =>
|
||||
{
|
||||
ServerManager.Instance.LoadServers();
|
||||
|
||||
Object.FindObjectOfType<RegionTextMonitor>()?.Start();
|
||||
if (Object.FindObjectOfType<RegionMenu>() is { } regionMenu)
|
||||
{
|
||||
regionMenu.OnDisable();
|
||||
regionMenu.OnEnable();
|
||||
}
|
||||
|
||||
Logger<ReactorPlugin>.Info("Region file reloaded");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -29,7 +42,7 @@ namespace Reactor.Patches
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Watcher?.Dispose();
|
||||
Watcher.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,24 +7,6 @@ using InnerNet;
|
||||
|
||||
namespace Reactor.Patches
|
||||
{
|
||||
/// <summary>
|
||||
/// Fixes hardcoded ports
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(InnerNetClient), nameof(InnerNetClient.SetEndpoint))]
|
||||
public static class SetEndpointPatch
|
||||
{
|
||||
public static void Prefix(InnerNetClient __instance, ref string addr, ref ushort port)
|
||||
{
|
||||
var serverManager = ServerManager.Instance;
|
||||
if (__instance.GameMode == GameModes.OnlineGame && serverManager.CurrentServer != null && addr == serverManager.OnlineNetAddress && port != serverManager.OnlineNetPort)
|
||||
{
|
||||
Logger<ReactorPlugin>.Info($"Set endpoint to {addr}:{port}");
|
||||
Logger<ReactorPlugin>.Info($"Correcting port to {serverManager.OnlineNetPort}");
|
||||
port = serverManager.OnlineNetPort;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(InnerNetClient), nameof(InnerNetClient.Connect))]
|
||||
public static class ConnectPatch
|
||||
{
|
||||
@@ -52,7 +34,7 @@ namespace Reactor.Patches
|
||||
.ToArray();
|
||||
|
||||
__instance.cachedServers = servers;
|
||||
Logger<ReactorPlugin>.Info($"Populated {__instance.Name} ({__instance.Fqdn}:{__instance.Port}) with {servers.Length} server(s) {{{servers.Join()}}}");
|
||||
Logger<ReactorPlugin>.Info($"Populated {__instance.Name} ({__instance.Fqdn}:{__instance.Port}) with {servers.Length} server(s) {{{servers.Select(x => x.ToString()).Join()}}}");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -66,19 +48,4 @@ namespace Reactor.Patches
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// De-inlines AmongUsClient#SetEndpoint from JoinGameButton
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(JoinGameButton), nameof(JoinGameButton.OnClick))]
|
||||
public static class JoinGameButtonPatch
|
||||
{
|
||||
public static void Postfix(JoinGameButton __instance)
|
||||
{
|
||||
if (__instance.GameMode == GameModes.OnlineGame)
|
||||
{
|
||||
AmongUsClient.Instance.SetEndpoint(DestroyableSingleton<ServerManager>.Instance.OnlineNetAddress, DestroyableSingleton<ServerManager>.Instance.OnlineNetPort);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
|
||||
<VersionPrefix>1.1.0</VersionPrefix>
|
||||
<VersionPrefix>1.2.0</VersionPrefix>
|
||||
<VersionSuffix>dev</VersionSuffix>
|
||||
<Description>Core mod and API for Among Us</Description>
|
||||
<Authors>NuclearPowered</Authors>
|
||||
|
||||
+12
-13
@@ -4,6 +4,7 @@ using BepInEx;
|
||||
using BepInEx.Configuration;
|
||||
using BepInEx.IL2CPP;
|
||||
using HarmonyLib;
|
||||
using Reactor.Extensions;
|
||||
using Reactor.Networking;
|
||||
using Reactor.Networking.MethodRpc;
|
||||
using Reactor.Networking.Serialization;
|
||||
@@ -11,6 +12,7 @@ using Reactor.Patches;
|
||||
using Reactor.Unstrip;
|
||||
using UnhollowerBaseLib.Attributes;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace Reactor
|
||||
{
|
||||
@@ -44,11 +46,20 @@ namespace Reactor
|
||||
|
||||
this.AddComponent<ReactorComponent>().Plugin = this;
|
||||
this.AddComponent<Coroutines.Component>();
|
||||
this.AddComponent<Dispatcher>();
|
||||
|
||||
ReactorVersionShower.Initialize();
|
||||
FreeNamePatch.Initialize();
|
||||
SplashSkip.Initialize();
|
||||
DefaultBundle.Load();
|
||||
|
||||
SceneManager.add_sceneLoaded((Action<Scene, LoadSceneMode>) ((scene, _) =>
|
||||
{
|
||||
if (scene.name == "MainMenu")
|
||||
{
|
||||
ModManager.Instance.ShowModStamp();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public override bool Unload()
|
||||
@@ -69,23 +80,11 @@ namespace Reactor
|
||||
{
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
ModManager.Instance.ShowModStamp();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Plugin!.RegionInfoWatcher.Reload)
|
||||
{
|
||||
Plugin.RegionInfoWatcher.Reload = false;
|
||||
ServerManager.Instance.LoadServers();
|
||||
Plugin.Log.LogInfo("Region file reloaded");
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.F5))
|
||||
{
|
||||
Plugin.Log.LogInfo("Reloading all configs");
|
||||
Plugin!.Log.LogInfo("Reloading all configs");
|
||||
|
||||
foreach (var pluginInfo in IL2CPPChainloader.Instance.Plugins.Values)
|
||||
{
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
".NETStandard,Version=v2.1": {
|
||||
"AmongUs.GameLibs.Steam": {
|
||||
"type": "Direct",
|
||||
"requested": "[2021.6.30, )",
|
||||
"resolved": "2021.6.30",
|
||||
"contentHash": "TdlFO+S61WREk/sOV2YUmzQ6MFNXk5o+uxLv4i4ft/Z1VRkxFo66/ff3cR1ZfI8DuXni/Ao9rS4dJP+j85pEFA=="
|
||||
"requested": "[2021.11.9, )",
|
||||
"resolved": "2021.11.9",
|
||||
"contentHash": "mqaIx7oPavuwMTRZDMmBrLOAWNG6s1tCOvpysnNPZT58b3epU+WMJKBruw9fUCf53t333d71xVUov6PRcwnSZQ=="
|
||||
},
|
||||
"BepInEx.AutoPlugin": {
|
||||
"type": "Direct",
|
||||
|
||||
Reference in new issue
Block a user