mirror of
https://github.com/MoltenMods/Unify.git
synced 2026-10-21 15:34:48 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7b0774f9d | ||
|
|
ab57814ee3 | ||
|
|
c861abbb4f | ||
|
|
d2a59980b0 | ||
|
|
be49899a27 | ||
|
|
071b49f85d | ||
|
|
fbc1751172 | ||
|
|
25ccc7124c | ||
|
|
cd5093407a | ||
|
|
489d1c85a7 | ||
|
|
c0d8638a27 | ||
|
|
50c678901f | ||
|
|
3dbf2befc1 | ||
|
|
3b9db051c9 | ||
|
|
6d18d01eb9 | ||
|
|
e91ea01777 | ||
|
|
bb69bbddfd | ||
|
|
8560fb6a55 | ||
|
|
5668255792 | ||
|
|
af6e7f4b4c | ||
|
|
f35196d68c | ||
|
|
7fc26d8b92 |
No files matched your search
@@ -1,6 +1,3 @@
|
||||
> The 2021.3.5s release of this mod requires you to compile an in-development version of Impostor
|
||||
> [here](https://github.com/Impostor/Impostor/tree/2021.3.5) if you want to host a local server.
|
||||
|
||||
# Unify
|
||||
|
||||
An Among Us mod to add extra regions to the regions menu.
|
||||
|
||||
+36
-15
@@ -1,5 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
using Hazel.Udp;
|
||||
using Reactor;
|
||||
using Array = System.Array;
|
||||
using String = System.String;
|
||||
|
||||
@@ -7,33 +11,30 @@ namespace Unify.Patches
|
||||
{
|
||||
public static class RegionsPatch
|
||||
{
|
||||
private static IRegionInfo[] _oldRegions = ServerManager.DefaultRegions;
|
||||
private static IRegionInfo[] _newRegions = new IRegionInfo[]
|
||||
{
|
||||
new DnsRegionInfo("192.241.154.115", "skeld.net", StringNames.NoTranslation, "192.241.154.115")
|
||||
.Duplicate(),
|
||||
.Cast<IRegionInfo>(),
|
||||
new DnsRegionInfo("localhost", "localhost", StringNames.NoTranslation, "127.0.0.1")
|
||||
.Duplicate()
|
||||
.Cast<IRegionInfo>(),
|
||||
new DnsRegionInfo("152.228.160.91", "matux.fr", StringNames.NoTranslation, "152.228.160.91")
|
||||
.Cast<IRegionInfo>()
|
||||
};
|
||||
private static IRegionInfo[] _customRegions = MergeRegions(_newRegions, LoadCustomUserRegions());
|
||||
|
||||
|
||||
public static List<IRegionInfo> ModRegions = new List<IRegionInfo>();
|
||||
|
||||
public static void Patch()
|
||||
{
|
||||
IRegionInfo[] patchedRegions = MergeRegions(ServerManager.DefaultRegions, _customRegions);
|
||||
IRegionInfo[] customRegions = UnifyPlugin.MergeRegions(_newRegions, ModRegions.ToArray());
|
||||
customRegions = UnifyPlugin.MergeRegions(customRegions, LoadCustomUserRegions());
|
||||
IRegionInfo[] patchedRegions = UnifyPlugin.MergeRegions(_oldRegions, customRegions);
|
||||
|
||||
ServerManager.DefaultRegions = patchedRegions;
|
||||
ServerManager.Instance.AvailableRegions = patchedRegions;
|
||||
ServerManager.Instance.SaveServers();
|
||||
}
|
||||
|
||||
private static IRegionInfo[] MergeRegions(IRegionInfo[] oldRegions, IRegionInfo[] newRegions)
|
||||
{
|
||||
IRegionInfo[] patchedRegions = new IRegionInfo[oldRegions.Length + newRegions.Length];
|
||||
Array.Copy(oldRegions, patchedRegions, oldRegions.Length);
|
||||
Array.Copy(newRegions, 0, patchedRegions, oldRegions.Length, newRegions.Length);
|
||||
|
||||
return patchedRegions;
|
||||
}
|
||||
|
||||
private static IRegionInfo[] LoadCustomUserRegions()
|
||||
{
|
||||
List<IRegionInfo> customRegions = new List<IRegionInfo>();
|
||||
@@ -49,7 +50,7 @@ namespace Unify.Patches
|
||||
|
||||
IRegionInfo regionInfo = new DnsRegionInfo(
|
||||
regionIp.Value, regionName.Value, StringNames.NoTranslation, regionIp.Value)
|
||||
.Duplicate();
|
||||
.Cast<IRegionInfo>();
|
||||
|
||||
customRegions.Add(regionInfo);
|
||||
}
|
||||
@@ -57,4 +58,24 @@ namespace Unify.Patches
|
||||
return customRegions.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(UdpConnection), nameof(UdpConnection.HandleSend))]
|
||||
public static class DisableModdedHandshakePatch
|
||||
{
|
||||
[HarmonyBefore(new string[] { "gg.reactor.api" })]
|
||||
public static void Prefix()
|
||||
{
|
||||
if (UnifyPlugin.HandshakeDisabled) return;
|
||||
if (!UnifyPlugin.NormalHandshake.Contains(ServerManager.Instance.CurrentRegion.Name)) return;
|
||||
|
||||
PluginSingleton<ReactorPlugin>.Instance.ModdedHandshake.Value = false;
|
||||
}
|
||||
|
||||
public static void Postfix()
|
||||
{
|
||||
if (UnifyPlugin.HandshakeDisabled) return;
|
||||
|
||||
PluginSingleton<ReactorPlugin>.Instance.ModdedHandshake.Value = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+28
-3
@@ -1,4 +1,5 @@
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.IO;
|
||||
using BepInEx;
|
||||
using BepInEx.Configuration;
|
||||
using BepInEx.IL2CPP;
|
||||
@@ -11,22 +12,46 @@ namespace Unify
|
||||
[BepInPlugin(Id, Name, Version)]
|
||||
[BepInProcess("Among Us.exe")]
|
||||
[BepInDependency(ReactorPlugin.Id)]
|
||||
[ReactorPluginSide(PluginSide.ClientOnly)]
|
||||
public class UnifyPlugin : BasePlugin
|
||||
{
|
||||
public const string Id = "daemon.unify.reactor";
|
||||
private const string Name = "Unify";
|
||||
private const string Version = "2.0.1";
|
||||
private const string Version = "2.0.3";
|
||||
|
||||
public static readonly ConfigFile ConfigFile =
|
||||
new ConfigFile(Path.Combine(Paths.ConfigPath, $"{UnifyPlugin.Id}.cfg"), true);
|
||||
|
||||
public static readonly bool HandshakeDisabled = !PluginSingleton<ReactorPlugin>.Instance.ModdedHandshake.Value;
|
||||
|
||||
public static readonly string[] NormalHandshake =
|
||||
new string[] {"North America", "Europe", "Asia", "skeld.net"};
|
||||
|
||||
public Harmony Harmony { get; } = new Harmony(Id);
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
RegionsPatch.Patch();
|
||||
|
||||
|
||||
Harmony.PatchAll();
|
||||
}
|
||||
|
||||
public static IRegionInfo[] MergeRegions(IRegionInfo[] oldRegions, IRegionInfo[] newRegions)
|
||||
{
|
||||
IRegionInfo[] patchedRegions = new IRegionInfo[oldRegions.Length + newRegions.Length];
|
||||
Array.Copy(oldRegions, patchedRegions, oldRegions.Length);
|
||||
Array.Copy(newRegions, 0, patchedRegions, oldRegions.Length, newRegions.Length);
|
||||
|
||||
return patchedRegions;
|
||||
}
|
||||
|
||||
public static void AddRegion(string name, string ip)
|
||||
{
|
||||
IRegionInfo newRegion = new DnsRegionInfo(ip, name, StringNames.NoTranslation, ip)
|
||||
.Cast<IRegionInfo>();
|
||||
|
||||
RegionsPatch.ModRegions.Add(newRegion);
|
||||
RegionsPatch.Patch();
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<Version>2.0.1</Version>
|
||||
<Version>2.0.3</Version>
|
||||
<Mappings>NuclearPowered/Mappings:0.2.0</Mappings>
|
||||
|
||||
<Description>Region mod for Reactor</Description>
|
||||
|
||||
Binary file not shown.
Reference in new issue
Block a user