21 Commits
Author SHA1 Message Date
Daemon 5cdf781cfa Removed modded handshake unpatch 2021-06-06 17:21:18 +01:00
Daemon 3c5dc2566a Updated for v2021.5.10s
Stopped objects appearing when opening language selection menu

Removed unused code

Improved custom button class
2021-05-11 21:22:49 +01:00
Daemon 3feb94b45d Updated for v2021.5.10s
Stopped objects appearing when opening language
2021-05-11 21:18:14 +01:00
Daemon 7b4a916d84 Added region menu editor
Added Przebot region

Added ability to hide certain regions
2021-05-01 22:05:34 +01:00
Daemon 9c70216a9f Tidied code and fixed bugs
Tidied code and removed redundant code

Fixed region file getting spam reloaded

Fixed multiple direct connect buttons existing at once

Added IP and port under names of custom regions in regions menu
2021-04-21 22:26:53 +01:00
Daemon a16eb79973 Updated version and README 2021-04-14 12:37:47 +01:00
Daemon f0010bf13e Built project 2021-04-14 12:25:01 +01:00
Daemon 1e7bc25ba8 Revert "Change regions after ServerManager.LoadServers instead of on game load"
This reverts commit d5de86c1e8, reversing
changes made to 7c1e2533b2.
2021-04-14 12:19:58 +01:00
Daemon d5de86c1e8 Change regions after ServerManager.LoadServers instead of on game load 2021-04-14 12:14:51 +01:00
Daemon 7c1e2533b2 Change regions after ServerManager.LoadServers instead of on game load 2021-04-14 12:11:16 +01:00
Daemon 1da6af54a9 Merge branch 'master' into 2021 2021-04-13 19:08:56 +01:00
Daemon e26fbccdb9 Updated code for Reactor 0.4.0-ci.53 2021-04-13 18:59:19 +01:00
Daemon 6f8a657fd0 Merge pull request #21 from MoltenMods/2021-pre
Updated code to work with 2021.4.12s
2021-04-13 14:02:27 +01:00
Daemon 5a4d501b9e Updated code to work with 2021.4.12s 2021-04-13 14:01:13 +01:00
Daemon ea4be527b7 Merge pull request #20 from MoltenMods/2021
Merge features from 2021 branch into 2021-pre branch
2021-04-13 13:47:17 +01:00
Daemon 6f266f7f93 Merge pull request #19 from MoltenMods/2021
Fixed bug caused by reckless code, tidied code and changed way regions menu is displayed
2021-04-11 14:19:39 +01:00
Daemon 1f5736c7f8 Updated version 2021-04-11 14:18:43 +01:00
Daemon 6df20f83c8 Updated README 2021-04-11 14:17:23 +01:00
Daemon 4c8866a33e Reduced custom regions length from 10 to 9 2021-04-11 14:15:53 +01:00
Daemon fd5a11394a Fixed bug caused by reckless code
Changed how regions menu is displayed
2021-04-11 14:15:05 +01:00
Daemon 5b63d7cd0c Tidied code
Removed `MergeRegions` function in favour of `AddRangeToArray` array method

Removed old 'disable modded handshake' code

Renamed `directConnect` field to `DirectConnect`
2021-04-11 12:27:31 +01:00
13 changed files with 402 additions and 113 deletions

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ContentModelUserStore">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
+10 -10
View File
@@ -1,14 +1,9 @@
> **⚠ WARNING**
>
> To play on a custom server on 2021.3.31.3s, you must compile the
> *airship* branch of Impostor located here:
> https://github.com/Impostor/Impostor/tree/airship.
# Unify
An Among Us mod to add extra regions to the regions menu.
An Among Us mod to add extra regions to the region menu.
![Regions menu](images/RegionsMenu.png)
![Region menu](images/RegionsMenu.png)
![Region menu editor](images/RegionsMenuEditor.png)
# Table of Contents
- [Features](#features)
@@ -21,12 +16,16 @@ The following regions have been added:
- [skeld.net](https://skeld.net/)
- localhost *(for playing on a server running on your computer)*
- matux.fr
- Przebot (may be unreliable or outdated)
Regions can be connected to directly using an IP address.
Custom regions can be added as detailed below in the
[configuration](#configuration) section.
Other mods can add regions via the
`AddRegion(string name, string ip, ushort port)` API method.
## Installation
> **⚠ WARNING**
@@ -39,7 +38,8 @@ Custom regions can be added as detailed below in the
> If you are still using 2021.3.5s and Reactor fails to load, try using the Reactor version located
> here: https://github.com/NuclearPowered/Reactor/actions/runs/636023321.
1. Ensure that BepInEx and Reactor are installed ([installation guide](INSTALLATION.md)).
1. Ensure that BepInEx and Reactor (Reactor is not required for pre releases) are installed
([installation guide](INSTALLATION.md)).
2. Download the latest mod on the [releases](https://github.com/DaemonBeast/Unify/releases) page
for the version of Among Us you are using.
3. Move the mod to the `(Among Us game files)/BepInEx/plugins` folder.
@@ -60,7 +60,7 @@ The configuration file is located at
### Custom regions
Custom regions can be added by modifying the `[Region 1]`,
`[Region 2]` ... `[Region 10]` sections of the configuration file.
`[Region 2]` ... `[Region 9]` sections of the configuration file.
You can modify the display name of the region,
the IP address of the region and the port of the region.
+125
View File
@@ -0,0 +1,125 @@
using System;
using System.Threading.Tasks;
using Reactor.Extensions;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using Object = UnityEngine.Object;
namespace Unify.Controls
{
public class Button
{
private static readonly TaskCompletionSource<bool> Initialized = new TaskCompletionSource<bool>();
private static GameObject _instance;
private readonly SpriteRenderer _spriteRenderer;
private readonly BoxCollider2D _boxCollider2D;
public GameObject GameObject { get; }
public TextMeshPro Text { get; }
public Vector2 Size
{
get => _spriteRenderer.size;
set
{
Text.rectTransform.sizeDelta = value;
_spriteRenderer.size = value;
_boxCollider2D.size = value;
}
}
public AspectPosition Position { get; }
public UnityEngine.UI.Button.ButtonClickedEvent OnClick { get; }
private Button(string text)
{
GameObject = Object.Instantiate(_instance).DontDestroy();
Text = GameObject.GetComponentInChildren<TextMeshPro>();
Position = GameObject.GetComponent<AspectPosition>();
OnClick = GameObject.GetComponent<PassiveButton>().OnClick;
_spriteRenderer = GameObject.GetComponent<SpriteRenderer>();
_boxCollider2D = GameObject.GetComponent<BoxCollider2D>();
var size = new Vector2(Text.preferredWidth, Text.preferredHeight);
Text.text = text;
Text.rectTransform.sizeDelta = size;
Position.DistanceFromEdge =
new Vector3(Text.preferredWidth / 2f + 0.1f, Text.preferredHeight / 2f + 0.1f, -100f);
_spriteRenderer.size = size;
_boxCollider2D.size = size;
}
public static async Task<Button> Create(string text)
{
await Initialized.Task;
return new Button(text);
}
public Button SetText(string newText)
{
Text.text = newText;
return this;
}
public Button SetSize(Vector2 newSize)
{
Size = newSize;
return this;
}
public Button SetDistanceFromEdge(Vector2 newPosition)
{
Position.DistanceFromEdge = new Vector3(newPosition.x, newPosition.y, -100f);
return this;
}
public Button SetAlignment(AspectPosition.EdgeAlignments newAlignment)
{
Position.Alignment = newAlignment;
return this;
}
public static void InitializeBaseButton()
{
BaseButton.Initialize();
}
private static class BaseButton
{
public static void Initialize()
{
SceneManager.add_sceneLoaded((Action<Scene, LoadSceneMode>) OnSceneLoaded);
}
private static void OnSceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
{
Instantiate();
SceneManager.remove_sceneLoaded((Action<Scene, LoadSceneMode>) OnSceneLoaded);
}
private static void Instantiate()
{
if (Initialized.Task.IsCompleted) return;
var exitButton = GameObject.Find("ExitGameButton");
if (!exitButton) return;
_instance = Object.Instantiate(exitButton).DontDestroy();
_instance.SetActive(false);
_instance.name = "Button";
_instance.GetComponent<PassiveButton>().OnClick = new UnityEngine.UI.Button.ButtonClickedEvent();
_instance.GetComponent<SceneChanger>().Destroy();
_instance.GetComponent<ConditionalHide>().Destroy();
_instance.GetComponentInChildren<TextTranslatorTMP>().Destroy();
_instance.GetComponentInChildren<TextMeshPro>().text = "Button";
Initialized.SetResult(true);
}
}
}
}
+233 -67
View File
@@ -1,9 +1,11 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using BepInEx.Configuration;
using HarmonyLib;
using Reactor.Extensions;
using UnityEngine;
using UnityEngine.UI;
using Button = UnityEngine.UI.Button;
using Object = UnityEngine.Object;
using String = System.String;
@@ -11,43 +13,45 @@ namespace Unify.Patches
{
public static class RegionsPatch
{
private static IRegionInfo[] _oldRegions { get; } = ServerManager.DefaultRegions;
private static IRegionInfo[] _newRegions { get; } = new IRegionInfo[]
internal static IRegionInfo[] OldRegions { get; } = ServerManager.DefaultRegions;
internal static IRegionInfo[] NewRegions { get; } = new IRegionInfo[]
{
new DnsRegionInfo("192.241.154.115", "skeld.net", StringNames.NoTranslation, "192.241.154.115", 22023)
.Cast<IRegionInfo>(),
new DnsRegionInfo("localhost", "localhost", StringNames.NoTranslation, "127.0.0.1", 22023)
.Cast<IRegionInfo>(),
new DnsRegionInfo("152.228.160.91", "matux.fr", StringNames.NoTranslation, "152.228.160.91", 22023)
.Cast<IRegionInfo>(),
new DnsRegionInfo("77.55.217.159", "Przebot", StringNames.NoTranslation, "77.55.217.159", 22023)
.Cast<IRegionInfo>()
};
public static List<IRegionInfo> ModRegions { get; } = new List<IRegionInfo>();
internal static List<IRegionInfo> ModRegions { get; } = new List<IRegionInfo>();
public static IRegionInfo DirectRegion { get; set; }
private static TextBox directConnect { get; set; }
internal static TextBoxTMP DirectConnect { get; set; }
public static void Patch()
{
ServerManager serverManager = ServerManager.Instance;
IRegionInfo[] customRegions = UnifyPlugin.MergeRegions(_newRegions, ModRegions.ToArray());
customRegions = UnifyPlugin.MergeRegions(customRegions, LoadCustomUserRegions());
if (DirectRegion != null) customRegions = customRegions.AddToArray(DirectRegion);
IRegionInfo[] patchedRegions = UnifyPlugin.MergeRegions(_oldRegions, customRegions);
IRegionInfo[] patchedRegions = OldRegions
.AddRangeToArray(NewRegions)
.AddRangeToArray(ModRegions.ToArray())
.AddRangeToArray(LoadCustomUserRegions());
if (DirectRegion != null) patchedRegions = patchedRegions.AddToArray(DirectRegion);
ServerManager.DefaultRegions = patchedRegions;
serverManager.AvailableRegions = patchedRegions;
serverManager.SaveServers();
}
private static IRegionInfo[] LoadCustomUserRegions()
{
List<IRegionInfo> customRegions = new List<IRegionInfo>();
for (int x = 0; x < 10; x++)
for (int x = 0; x < 9; x++)
{
ConfigEntry<string> regionName = UnifyPlugin.ConfigFile.Bind(
$"Region {x + 1}", $"Name", "custom region");
@@ -59,75 +63,43 @@ namespace Unify.Patches
if (String.IsNullOrWhiteSpace(regionIp.Value)) continue;
IRegionInfo regionInfo = new DnsRegionInfo(
regionIp.Value, regionName.Value, StringNames.NoTranslation, regionIp.Value, regionPort.Value)
regionIp.Value, regionName.Value,
StringNames.NoTranslation, regionIp.Value, regionPort.Value)
.Cast<IRegionInfo>();
customRegions.Add(regionInfo);
}
return customRegions.ToArray();
}
private static void UpdateRegion()
{
RegionMenu regionMenu = GameObject.Find("RegionMenu").GetComponent<RegionMenu>();
bool success = UnifyPlugin.SetDirectRegion(directConnect.text, out IRegionInfo newRegion);
RegionMenu regionMenu = DestroyableSingleton<RegionMenu>.Instance;
bool success = UnifyPlugin.SetDirectRegion(DirectConnect.text, out IRegionInfo newRegion);
if (!success)
{
directConnect.StartCoroutine(Effects.FIJHCJMBGFP(directConnect.transform, 0.75f, 0.25f));
DirectConnect.StartCoroutine(Effects.SwayX(DirectConnect.transform, 0.75f, 0.25f));
return;
}
regionMenu.ChooseOption(newRegion);
regionMenu.Close();
}
[HarmonyPatch(typeof(RegionMenu), nameof(RegionMenu.Open))]
public static class DirectConnectButtonPatch
[HarmonyPatch(typeof(ServerManager), nameof(ServerManager.LoadServers))]
public static class LoadNewRegionsPatch
{
public static void Postfix()
{
JoinGameButton joinGameButton = DestroyableSingleton<JoinGameButton>.Instance;
RegionMenu regionMenu = DestroyableSingleton<RegionMenu>.Instance;
directConnect = Object.Instantiate(joinGameButton.GameIdText, regionMenu.transform);
directConnect.gameObject.SetActive(false);
directConnect.IpMode = true;
directConnect.characterLimit = 15;
directConnect.ClearOnFocus = false;
directConnect.OnEnter = new Button.ButtonClickedEvent();
directConnect.OnEnter.AddListener((Action) UpdateRegion);
int offset = ((ServerManager.DefaultRegions.Length + 1) / 2) + 1;
directConnect.transform.localPosition = new Vector3(0, 2f - (offset / 2f), -100f);
}
}
[HarmonyPatch(typeof(RegionMenu), nameof(RegionMenu.Open))]
public static class RegionMenuLayoutPatch
{
public static void Postfix(RegionMenu __instance)
{
directConnect.gameObject.SetActive(true);
var regionButtons = __instance.ButtonPool.activeChildren.ToArray();
int half = (regionButtons.Length + 1) / 2;
for (int x = 0; x < regionButtons.Length; x++)
{
ServerListButton regionButton = regionButtons[x].Cast<ServerListButton>();
regionButton.transform.localPosition = new Vector3(1.25f * ((x < half)? -1: 1), 2f - 0.5f * (x - ((x < half)? 0 : half)), 0f);
}
Patch();
}
}
[HarmonyPatch(typeof(JoinGameButton), nameof(JoinGameButton.OnClick))]
public static class DirectConnectEnterButtonPatch
{
public static class DirectConnectEnterButtonPatch {
public static bool Prefix(JoinGameButton __instance)
{
GameObject regionMenuGameObject = GameObject.Find("RegionMenu");
@@ -139,21 +111,215 @@ namespace Unify.Patches
}
}
[HarmonyPatch(typeof(RegionMenu), nameof(RegionMenu.Close))]
public static class HideDirectConnectPatch
[HarmonyPatch(typeof(RegionMenu))]
public static class RegionMenuPatches
{
public static void Postfix()
[HarmonyPatch(nameof(RegionMenu.Open))]
[HarmonyPostfix]
public static void DirectConnectButtonPatch()
{
directConnect.gameObject.SetActive(false);
RefreshDirectConnectButton();
}
[HarmonyPatch(nameof(RegionMenu.Open))]
[HarmonyPostfix]
public static void RegionMenuLayoutPatch()
{
RefreshRegionMenu();
}
internal static void RefreshRegionMenu()
{
if (!GameObject.Find("RegionMenu")) return;
var regionButtons = DestroyableSingleton<RegionMenu>.Instance.ButtonPool.activeChildren.ToArray();
var defaultRegions = ServerManager.DefaultRegions;
var showOfficials = UnifyPlugin.ShowOfficialRegions.Value;
var showExtras = UnifyPlugin.ShowExtraRegions.Value;
for (int i = 0; i < regionButtons.Length; i++)
{
ServerListButton regionButton = regionButtons[i].Cast<ServerListButton>();
IRegionInfo region = defaultRegions[i];
var textTranslatorTemp = regionButton.GetComponentInChildren<TextTranslatorTMP>();
if (textTranslatorTemp) textTranslatorTemp.Destroy();
int extraRegionCount = OldRegions.Length + NewRegions.Length + ModRegions.Count;
bool isCustomRegion = i >= OldRegions.Length;
bool isCustomUserRegion = i >= extraRegionCount;
float x = (!isCustomRegion && !showExtras ? 3f : 0) + (isCustomRegion ? 3f : 0) +
(isCustomUserRegion ? 3f : 0) - 4.25f - (!showOfficials || OldRegions.Length == 0 ? 1.5f : 0) -
(!showExtras || extraRegionCount == 0 ? 1.5f : 0);
float y = i - (isCustomRegion ? OldRegions.Length : 0) -
(isCustomUserRegion ? NewRegions.Length + ModRegions.Count : 0);
var regionButtonPosition = new Vector3(1.25f + x, 2f - 0.5f * y, 0);
regionButton.transform.localPosition = regionButtonPosition;
regionButton.gameObject.SetActive(
(showOfficials || i >= OldRegions.Length) &&
(showExtras || !isCustomRegion || isCustomUserRegion));
var buttonRolloverHandler = regionButton.GetComponent<ButtonRolloverHandler>();
if (RegionsEditor.IsActive)
{
buttonRolloverHandler.OverColor =
ServerManager.Instance.CurrentRegion.Name == region.Name ? Color.white : Color.black;
regionButton.Text.color = Color.gray;
}
else
{
buttonRolloverHandler.OverColor = Color.green;
regionButton.Text.color = Color.white;
}
if (isCustomUserRegion)
{
regionButton.Text.text =
RegionsEditor.IsActive ? $"{region.Name}\n{region.PingServer} {region.Servers[0].Port}" :
region.Name;
}
}
}
internal static void RefreshDirectConnectButton()
{
if (!GameObject.Find("RegionMenu")) return;
if (DirectConnect) DirectConnect.gameObject.Destroy();
RegionMenu regionMenu = DestroyableSingleton<RegionMenu>.Instance;
JoinGameButton joinGameButton = DestroyableSingleton<JoinGameButton>.Instance;
DirectConnect = Object.Instantiate(joinGameButton.GameIdText, regionMenu.transform);
DirectConnect.GetComponentInChildren<TextTranslatorTMP>().Destroy();
DirectConnect.GetComponent<JoinGameButton>().Destroy();
DirectConnect.outputText.text = "Enter IP";
DirectConnect.IpMode = true;
DirectConnect.characterLimit = 15;
DirectConnect.ClearOnFocus = false;
DirectConnect.OnEnter = new Button.ButtonClickedEvent();
DirectConnect.OnEnter.AddListener((Action) UpdateRegion);
int offset = NewRegions.Length + ModRegions.Count;
DirectConnect.transform.localPosition = new Vector3(0, 1f - (offset / 2f), -100f);
}
}
}
internal static class RegionsEditor
{
private static Controls.Button _switchButton;
private static Controls.Button _toggleOfficialsButton;
private static Controls.Button _toggleExtrasButton;
internal static bool IsActive;
internal static async void SetUp()
{
await SetUpSwitchButton();
await SetUpToggleOfficialsButton();
await SetUpToggleExtrasButton();
}
private static void SetRegionsEditorVisibility(bool visible)
{
IsActive = visible;
_toggleOfficialsButton.GameObject.SetActive(visible);
_toggleExtrasButton.GameObject.SetActive(visible);
RegionsPatch.RegionMenuPatches.RefreshRegionMenu();
if (visible)
{
_switchButton.Text.text = "Back";
RegionsPatch.DirectConnect.gameObject.SetActive(false);
}
else
{
_switchButton.Text.text = "Edit";
RegionsPatch.RegionMenuPatches.RefreshDirectConnectButton();
}
}
[HarmonyPatch(typeof(RegionMenu), nameof(RegionMenu.ChooseOption))]
public static class HideDirectConnectOnSelectPatch
private static async Task SetUpSwitchButton()
{
_switchButton = await Controls.Button.Create("Edit");
_switchButton.SetSize(new Vector2(0.8f, 0.4f)).SetDistanceFromEdge(new Vector2(0.5f, 0.3f));
_switchButton.OnClick.AddListener((Action) (() =>
{
SetRegionsEditorVisibility(!IsActive);
}));
}
private static async Task SetUpToggleOfficialsButton()
{
_toggleOfficialsButton = await Controls.Button.Create("Toggle Official Regions");
_toggleOfficialsButton.SetSize(new Vector2(2f, 0.4f)).SetDistanceFromEdge(new Vector2(1.1f, 1.3f));
_toggleOfficialsButton.OnClick.AddListener((Action) (() =>
{
UnifyPlugin.ShowOfficialRegions.Value = !UnifyPlugin.ShowOfficialRegions.Value;
RegionsPatch.RegionMenuPatches.RefreshRegionMenu();
}));
}
private static async Task SetUpToggleExtrasButton()
{
_toggleExtrasButton = await Controls.Button.Create("Toggle Extra Regions");
_toggleExtrasButton.SetSize(new Vector2(2f, 0.4f)).SetDistanceFromEdge(new Vector2(1.1f, 1.8f));
_toggleExtrasButton.OnClick.AddListener((Action) (() =>
{
UnifyPlugin.ShowExtraRegions.Value = !UnifyPlugin.ShowExtraRegions.Value;
RegionsPatch.RegionMenuPatches.RefreshRegionMenu();
}));
}
[HarmonyPatch(typeof(RegionMenu), nameof(RegionMenu.Open))]
public static class OpenRegionsEditorPatch
{
public static void Postfix()
{
directConnect.gameObject.SetActive(false);
if (!GameObject.Find("RegionMenu")) return;
_switchButton.GameObject.SetActive(true);
}
}
[HarmonyPatch(typeof(RegionMenu))]
public static class HideRegionsEditorPatch
{
[HarmonyPatch(nameof(RegionMenu.Close))]
[HarmonyPostfix]
public static void HideOnClosePatch()
{
Hide();
}
[HarmonyPatch(nameof(RegionMenu.ChooseOption))]
[HarmonyPrefix]
public static bool DisableRegionButtonsPatch()
{
if (IsActive) return false;
Hide();
return true;
}
private static void Hide()
{
if (!RegionsPatch.DirectConnect) return;
SetRegionsEditorVisibility(false);
_switchButton.GameObject.SetActive(false);
RegionsPatch.DirectConnect.gameObject.SetActive(false);
}
}
}
+29 -31
View File
@@ -6,7 +6,9 @@ using BepInEx;
using BepInEx.Configuration;
using BepInEx.IL2CPP;
using HarmonyLib;
using Hazel.Udp;
using Reactor;
using Unify.Controls;
using Unify.Patches;
namespace Unify
@@ -19,49 +21,31 @@ namespace Unify
{
public const string Id = "daemon.unify";
private const string Name = "Unify";
private const string Version = "3.0.0";
private const string Version = "5.0.0";
public static ConfigFile ConfigFile { get; private set; }
// public static readonly bool HandshakeDisabled = !PluginSingleton<ReactorPlugin>.Instance.ModdedHandshake.Value;
/*public static readonly string[] NormalHandshake =
new string[] {"North America", "Europe", "Asia", "skeld.net"};*/
internal static ConfigEntry<bool> ShowOfficialRegions;
internal static ConfigEntry<bool> ShowExtraRegions;
public Harmony Harmony { get; } = new Harmony(Id);
public override void Load()
{
// ===== For compatibility reasons =====
string oldConfigPath = Path.Combine(Paths.ConfigPath, "daemon.unify.reactor.cfg");
string newConfigPath = Path.Combine(Paths.ConfigPath, $"{UnifyPlugin.Id}.cfg");
bool oldConfigExists = File.Exists(oldConfigPath);
if (oldConfigExists)
{
File.Copy(oldConfigPath, newConfigPath, true);
File.Delete(oldConfigPath);
}
ConfigFile = new ConfigFile(Path.Combine(Paths.ConfigPath, $"{UnifyPlugin.Id}.cfg"), true);
// =====================================
FixCompatibility();
RegionsPatch.Patch();
Harmony.UnpatchAll(ReactorPlugin.Id);
ShowOfficialRegions = ConfigFile.Bind("Preferences", "Show Official Regions", true,
"If the official regions should be shown when displaying the regions menu");
ShowExtraRegions = ConfigFile.Bind("Preferences", "Show Extra Regions", true,
"If the extra regions added by default in Unify should be shown when displaying the regions menu");
Harmony.PatchAll();
Button.InitializeBaseButton();
RegionsEditor.SetUp();
}
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 IRegionInfo AddRegion(string name, string ip)
public static IRegionInfo AddRegion(string name, string ip, ushort port)
{
if (Uri.CheckHostName(ip) != UriHostNameType.IPv4) return ServerManager.Instance.CurrentRegion;
@@ -69,7 +53,7 @@ namespace Unify
ServerManager.DefaultRegions.ToArray().FirstOrDefault(region => region.PingServer == ip);
if (existingRegion != null) return existingRegion;
IRegionInfo newRegion = new DnsRegionInfo(ip, name, StringNames.NoTranslation, ip, 22023)
IRegionInfo newRegion = new DnsRegionInfo(ip, name, StringNames.NoTranslation, ip, port)
.Cast<IRegionInfo>();
RegionsPatch.ModRegions.Add(newRegion);
@@ -92,5 +76,19 @@ namespace Unify
return true;
}
private static void FixCompatibility()
{
string oldConfigPath = Path.Combine(Paths.ConfigPath, "daemon.unify.reactor.cfg");
string newConfigPath = Path.Combine(Paths.ConfigPath, $"{UnifyPlugin.Id}.cfg");
bool oldConfigExists = File.Exists(oldConfigPath);
if (oldConfigExists)
{
File.Copy(oldConfigPath, newConfigPath, true);
File.Delete(oldConfigPath);
}
ConfigFile = new ConfigFile(Path.Combine(Paths.ConfigPath, $"{UnifyPlugin.Id}.cfg"), true);
}
}
}
+4 -4
View File
@@ -1,20 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Version>3.0.0</Version>
<Mappings>NuclearPowered/Mappings:0.3.0</Mappings>
<Version>5.0.1</Version>
<Mappings>DaemonBeast/Mappings:0.6.0</Mappings>
<Description>Region mod</Description>
<Authors>Daemon</Authors>
</PropertyGroup>
<PropertyGroup Condition="'$(GamePlatform)' == 'Steam'">
<GameVersion>2021.3.31.3s</GameVersion>
<GameVersion>2021.5.25s</GameVersion>
<DefineConstants>$(DefineConstants);STEAM</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(GamePlatform)' == 'Itch'">
<GameVersion>2021.3.31.3i</GameVersion>
<GameVersion>2021.5.25i</GameVersion>
<DefineConstants>$(DefineConstants);ITCH</DefineConstants>
</PropertyGroup>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 KiB

After

Width:  |  Height:  |  Size: 268 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 KiB