14 Commits
Author SHA1 Message Date
Daemon a7b0774f9d Restructured code and added AddRegion() method 2021-03-19 21:49:09 +00:00
Daemon ab57814ee3 Added new AddRegion() method for external mods
`AddRegion()` method allows mods to add new regions
2021-03-19 21:43:43 +00:00
Daemon c861abbb4f Modified modded handshake disable patch
Stopped reactor handshake option getting set true automatically
2021-03-19 19:26:51 +00:00
Daemon d2a59980b0 Changed use of .Duplicate() method to .Cast<IRegionInfo>() 2021-03-19 19:10:44 +00:00
Daemon be49899a27 Added matux.fr to regions menu 2021-03-18 21:49:51 +00:00
Daemon 071b49f85d Added matux.fr to regions menu 2021-03-18 21:45:39 +00:00
Daemon fbc1751172 Removed outdated notice 2021-03-18 09:29:37 +00:00
Daemon cd5093407a Merge branch '2021' of https://github.com/DaemonBeast/Unify into 2021 2021-03-14 15:46:45 +00:00
Daemon 489d1c85a7 Merge branch 'dev' into 2021 2021-03-14 15:45:08 +00:00
DaemonBeast c0d8638a27 Merge branch 'dev' into 2021 2021-03-14 15:25:55 +00:00
Daemon 3b9db051c9 Revert "Modified mod to remove Reactor as a dependency" 2021-03-14 12:29:00 +00:00
Daemon 6d18d01eb9 Revert "Modified mod to remove Reactor as a dependency" 2021-03-14 12:28:46 +00:00
Daemon 5668255792 Modified mod to remove Reactor as a dependency 2021-03-14 12:10:51 +00:00
Daemon 7fc26d8b92 Fixed custom regions
Merged stable dev branch with 2021 branch
2021-03-13 15:22:53 +00:00
4 changed files with 37 additions and 19 deletions

No files matched your search

-3
View File
@@ -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.
+15 -15
View File
@@ -11,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>();
@@ -53,7 +50,7 @@ namespace Unify.Patches
IRegionInfo regionInfo = new DnsRegionInfo(
regionIp.Value, regionName.Value, StringNames.NoTranslation, regionIp.Value)
.Duplicate();
.Cast<IRegionInfo>();
customRegions.Add(regionInfo);
}
@@ -68,6 +65,7 @@ namespace Unify.Patches
[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;
@@ -75,6 +73,8 @@ namespace Unify.Patches
public static void Postfix()
{
if (UnifyPlugin.HandshakeDisabled) return;
PluginSingleton<ReactorPlugin>.Instance.ModdedHandshake.Value = true;
}
}
+22 -1
View File
@@ -1,4 +1,5 @@
using System.IO;
using System;
using System.IO;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.IL2CPP;
@@ -20,6 +21,8 @@ namespace Unify
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"};
@@ -32,5 +35,23 @@ namespace Unify
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();
}
}
}
Binary file not shown.