6 Commits
Author SHA1 Message Date
js6pak 081e6e2ba9 1.2.1 2022-02-18 22:40:48 +01:00
js6pak 70155fe8a6 Don't reload regionInfo.json when the game saves it 2022-02-18 22:38:35 +01:00
js6pak 89a8adadf7 2021.12.15 2021-12-21 15:53:08 +01:00
js6pak 837ee142b3 2021.12.14 2021-12-15 19:45:27 +01:00
js6pak 2453bff8df Merge branch '2021.11.9' 2021-12-14 23:17:43 +01:00
js6pak f501dc1897 RandomExtensions 2021-12-14 22:40:12 +01:00
11 changed files with 62 additions and 16 deletions

No files matched your search

+2 -2
View File
@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>
<GamePlatform Condition="'$(GamePlatform)' == ''">Steam</GamePlatform>
<GameVersion Condition="'$(GamePlatform)' == 'Steam'">2021.11.9</GameVersion>
<GameVersion Condition="'$(GamePlatform)' == 'Itch'">2021.11.9</GameVersion>
<GameVersion Condition="'$(GamePlatform)' == 'Steam'">2021.12.15</GameVersion>
<GameVersion Condition="'$(GamePlatform)' == 'Itch'">2021.12.15</GameVersion>
</PropertyGroup>
<ItemGroup>
+3 -3
View File
@@ -4,9 +4,9 @@
".NETStandard,Version=v2.1": {
"AmongUs.GameLibs.Steam": {
"type": "Direct",
"requested": "[2021.11.9, )",
"resolved": "2021.11.9",
"contentHash": "mqaIx7oPavuwMTRZDMmBrLOAWNG6s1tCOvpysnNPZT58b3epU+WMJKBruw9fUCf53t333d71xVUov6PRcwnSZQ=="
"requested": "[2021.12.15, )",
"resolved": "2021.12.15",
"contentHash": "YXKxGYWvA5+cLvJXlzcsYOS55q1g/QKzLgy1QNGnyWgTYk91z1scufLb4aMb6lSfQhTPUpEB3ajyupwqtI8uOg=="
},
"BepInEx.AutoPlugin": {
"type": "Direct",
+3 -3
View File
@@ -4,9 +4,9 @@
".NETStandard,Version=v2.1": {
"AmongUs.GameLibs.Steam": {
"type": "Direct",
"requested": "[2021.11.9, )",
"resolved": "2021.11.9",
"contentHash": "mqaIx7oPavuwMTRZDMmBrLOAWNG6s1tCOvpysnNPZT58b3epU+WMJKBruw9fUCf53t333d71xVUov6PRcwnSZQ=="
"requested": "[2021.12.15, )",
"resolved": "2021.12.15",
"contentHash": "YXKxGYWvA5+cLvJXlzcsYOS55q1g/QKzLgy1QNGnyWgTYk91z1scufLb4aMb6lSfQhTPUpEB3ajyupwqtI8uOg=="
},
"BepInEx.AutoPlugin": {
"type": "Direct",
+2
View File
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using UnhollowerBaseLib.Attributes;
using UnityEngine;
namespace Reactor.Extensions;
@@ -31,6 +32,7 @@ public class Dispatcher : MonoBehaviour
}
}
[HideFromIl2Cpp]
public void Enqueue(Action action)
{
lock (_queue)
+23
View File
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Reactor.Extensions;
public static class RandomExtensions
{
/// <summary>
/// Returns random <typeparamref name="T"/> from <paramref name="input"/> using <paramref name="random"/>
/// </summary>
public static T? Random<T>(this IEnumerable<T> input, Random random)
{
var list = input as IList<T> ?? input.ToList();
return list.Count == 0 ? default : list[random.Next(0, list.Count)];
}
/// <summary>Returns a random double that is within a specified range.</summary>
public static double NextDouble(this Random random, double minValue, double maxValue)
{
return random.NextDouble() * (maxValue - minValue) + minValue;
}
}
+1 -1
View File
@@ -41,7 +41,7 @@ namespace Reactor.Patches
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);
__result = new UnityUdpClientConnection(null, remoteEndPoint);
return false;
}
+21
View File
@@ -1,5 +1,6 @@
using System;
using System.IO;
using HarmonyLib;
using Reactor.Extensions;
using UnityEngine;
using Object = UnityEngine.Object;
@@ -10,6 +11,8 @@ namespace Reactor.Patches
{
private FileSystemWatcher Watcher { get; }
public bool IgnoreNext { get; set; }
internal RegionInfoWatcher()
{
Watcher = new FileSystemWatcher(
@@ -21,6 +24,12 @@ namespace Reactor.Patches
{
if (new FileInfo(e.Name).Length > 0)
{
if (IgnoreNext)
{
IgnoreNext = false;
return;
}
Dispatcher.Instance.Enqueue(() =>
{
ServerManager.Instance.LoadServers();
@@ -44,5 +53,17 @@ namespace Reactor.Patches
{
Watcher.Dispose();
}
[HarmonyPatch(typeof(FileIO), nameof(FileIO.WriteAllText))]
private static class WritePatch
{
public static void Prefix(string path)
{
if (ServerManager.Instance && path == ServerManager.Instance.serverInfoFileJson)
{
PluginSingleton<ReactorPlugin>.Instance.RegionInfoWatcher.IgnoreNext = true;
}
}
}
}
}
+2 -2
View File
@@ -30,7 +30,7 @@ namespace Reactor.Patches
var servers = Dns.GetHostAddresses(__instance.Fqdn)
.Distinct()
.Where(ipAddress => ipAddress.AddressFamily == AddressFamily.InterNetwork)
.Select(ipAddress => new ServerInfo($"{__instance.Name}-{i++}", ipAddress.ToString(), __instance.Port))
.Select(ipAddress => new ServerInfo($"{__instance.Name}-{i++}", ipAddress.ToString(), __instance.Port, __instance.UseDtls))
.ToArray();
__instance.cachedServers = servers;
@@ -41,7 +41,7 @@ namespace Reactor.Patches
Logger<ReactorPlugin>.Info($"Failed to populate {__instance.Name}: {e}");
__instance.cachedServers = new[]
{
new ServerInfo(__instance.Name ?? string.Empty, __instance.DefaultIp, __instance.Port),
new ServerInfo(__instance.Name ?? string.Empty, __instance.DefaultIp, __instance.Port, __instance.UseDtls),
};
}
+1 -1
View File
@@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<VersionPrefix>1.2.0</VersionPrefix>
<VersionPrefix>1.2.1</VersionPrefix>
<VersionSuffix>dev</VersionSuffix>
<Description>Core mod and API for Among Us</Description>
<Authors>NuclearPowered</Authors>
+1 -1
View File
@@ -25,7 +25,7 @@ namespace Reactor
public ConfigEntry<bool>? AllowVanillaServers { get; private set; }
private RegionInfoWatcher RegionInfoWatcher { get; } = new RegionInfoWatcher();
internal RegionInfoWatcher RegionInfoWatcher { get; } = new RegionInfoWatcher();
public ReactorPlugin()
{
+3 -3
View File
@@ -4,9 +4,9 @@
".NETStandard,Version=v2.1": {
"AmongUs.GameLibs.Steam": {
"type": "Direct",
"requested": "[2021.11.9, )",
"resolved": "2021.11.9",
"contentHash": "mqaIx7oPavuwMTRZDMmBrLOAWNG6s1tCOvpysnNPZT58b3epU+WMJKBruw9fUCf53t333d71xVUov6PRcwnSZQ=="
"requested": "[2021.12.15, )",
"resolved": "2021.12.15",
"contentHash": "YXKxGYWvA5+cLvJXlzcsYOS55q1g/QKzLgy1QNGnyWgTYk91z1scufLb4aMb6lSfQhTPUpEB3ajyupwqtI8uOg=="
},
"BepInEx.AutoPlugin": {
"type": "Direct",