forked from Woodi-dev/Among-Us-Sheriff-Mod
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First commit of Reactor-Sheriff - The mod is now compatible with Reac…
…tor.
- Loading branch information
Showing
22 changed files
with
928 additions
and
1,020 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Common IntelliJ Platform excludes | ||
|
||
# User specific | ||
**/.idea/**/workspace.xml | ||
**/.idea/**/tasks.xml | ||
**/.idea/shelf/* | ||
**/.idea/dictionaries | ||
**/.idea/httpRequests/ | ||
|
||
# Sensitive or high-churn files | ||
**/.idea/**/dataSources/ | ||
**/.idea/**/dataSources.ids | ||
**/.idea/**/dataSources.xml | ||
**/.idea/**/dataSources.local.xml | ||
**/.idea/**/sqlDataSources.xml | ||
**/.idea/**/dynamic.xml | ||
|
||
# Rider | ||
# Rider auto-generates .iml files, and contentModel.xml | ||
**/.idea/**/*.iml | ||
**/.idea/**/contentModel.xml | ||
**/.idea/**/modules.xml | ||
|
||
*.suo | ||
*.user | ||
.vs/ | ||
[Bb]in/ | ||
[Oo]bj/ | ||
_UpgradeReport_Files/ | ||
[Pp]ackages/ | ||
|
||
Thumbs.db | ||
Desktop.ini | ||
.DS_Store | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReactorSheriff", "ReactorSheriff\ReactorSheriff.csproj", "{11FBC798-BAF5-4EE5-9511-BE6DB0592F99}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{11FBC798-BAF5-4EE5-9511-BE6DB0592F99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{11FBC798-BAF5-4EE5-9511-BE6DB0592F99}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{11FBC798-BAF5-4EE5-9511-BE6DB0592F99}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{11FBC798-BAF5-4EE5-9511-BE6DB0592F99}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace ReactorSheriff | ||
{ | ||
public static class CustomGameOptions | ||
{ | ||
public static bool ShowSheriff = false; | ||
public static float SheriffKillCD = 30f; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
using HarmonyLib; | ||
using System; | ||
using System.Linq; | ||
using UnhollowerBaseLib; | ||
using UnityEngine; | ||
|
||
namespace ReactorSheriff | ||
{ | ||
[HarmonyPatch(typeof(GameOptionsMenu))] | ||
public static class GameOptionsMenuPatch | ||
{ | ||
public static ToggleOption ShowSheriffOption; | ||
public static NumberOption SheriffCooldown; | ||
public static float LowestY; | ||
|
||
static float GetLowestConfigY(GameOptionsMenu __instance) | ||
{ | ||
return __instance.GetComponentsInChildren<OptionBehaviour>() | ||
.Min(option => option.transform.localPosition.y); | ||
} | ||
|
||
public static void PositionElement(OptionBehaviour element) | ||
{ | ||
LowestY -= 0.5f; | ||
element.transform.localPosition = new Vector3(element.transform.localPosition.x, LowestY, | ||
element.transform.localPosition.z); | ||
} | ||
|
||
public static ToggleOption PrepareToggle(GameOptionsMenu instance, string title, bool enabled) | ||
{ | ||
ToggleOption toggle = UnityEngine.Object.Instantiate(instance.GetComponentsInChildren<ToggleOption>().Last(), | ||
instance.transform); | ||
PositionElement(toggle); | ||
toggle.TitleText.Text = title; | ||
toggle.CheckMark.enabled = enabled; | ||
|
||
return toggle; | ||
} | ||
|
||
public static NumberOption PrepareNumberOption(GameOptionsMenu instance, string title, float value) | ||
{ | ||
NumberOption option = UnityEngine.Object.Instantiate(instance.GetComponentsInChildren<NumberOption>().Last(), | ||
instance.transform); | ||
|
||
PositionElement(option); | ||
option.gameObject.name = title; | ||
option.TitleText.Text = title; | ||
option.Value = value; | ||
option.ValueText.Text = value.ToString(); | ||
|
||
return option; | ||
} | ||
|
||
[HarmonyPostfix] | ||
[HarmonyPatch(nameof(GameOptionsMenu.Start))] | ||
public static void Postfix1(GameOptionsMenu __instance) | ||
{ | ||
if (GameObject.FindObjectsOfType<ToggleOption>().Count == 4) | ||
{ | ||
|
||
LowestY = GetLowestConfigY(__instance); | ||
|
||
System.Collections.Generic.List<OptionBehaviour> NewOptions = __instance.Children.ToList(); | ||
|
||
ShowSheriffOption = PrepareToggle(__instance, "Show Sheriff", CustomGameOptions.ShowSheriff); | ||
SheriffCooldown = | ||
PrepareNumberOption(__instance, "Sheriff Kill Cooldown", CustomGameOptions.SheriffKillCD); | ||
|
||
NewOptions.Add(ShowSheriffOption); | ||
NewOptions.Add(SheriffCooldown); | ||
|
||
__instance.GetComponentInParent<Scroller>().YBounds.max += | ||
0.5f * (NewOptions.Count - __instance.Children.Count); | ||
|
||
__instance.Children = new Il2CppReferenceArray<OptionBehaviour>(NewOptions.ToArray()); | ||
} | ||
} | ||
} | ||
|
||
[HarmonyPatch(typeof(ToggleOption))] | ||
public static class ToggleButtonPatch | ||
{ | ||
[HarmonyPrefix] | ||
[HarmonyPatch(nameof(ToggleOption.Toggle))] | ||
public static bool Prefix(ToggleOption __instance) | ||
{ | ||
if (__instance.TitleText.Text == GameOptionsMenuPatch.ShowSheriffOption.TitleText.Text) | ||
{ | ||
CustomGameOptions.ShowSheriff = !CustomGameOptions.ShowSheriff; | ||
PlayerControl.LocalPlayer.RpcSyncSettings(PlayerControl.GameOptions); | ||
|
||
__instance.Field_2 = CustomGameOptions.ShowSheriff; | ||
__instance.CheckMark.enabled = CustomGameOptions.ShowSheriff; | ||
|
||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
} | ||
|
||
[HarmonyPatch(typeof(NumberOption))] | ||
public static class NumberOptionPatch | ||
{ | ||
[HarmonyPrefix] | ||
[HarmonyPatch(nameof(NumberOption.Increase))] | ||
public static bool Prefix1(NumberOption __instance) | ||
{ | ||
if (__instance.TitleText.Text == GameOptionsMenuPatch.SheriffCooldown.TitleText.Text) | ||
{ | ||
CustomGameOptions.SheriffKillCD = Math.Min(CustomGameOptions.SheriffKillCD + 2.5f, 45); | ||
PlayerControl.LocalPlayer.RpcSyncSettings(PlayerControl.GameOptions); | ||
__instance.Field_3 = CustomGameOptions.SheriffKillCD; | ||
__instance.Value = CustomGameOptions.SheriffKillCD; | ||
__instance.ValueText.Text = CustomGameOptions.SheriffKillCD.ToString(); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
[HarmonyPrefix] | ||
[HarmonyPatch(nameof(NumberOption.Decrease))] | ||
public static bool Prefix2(NumberOption __instance) | ||
{ | ||
if (__instance.TitleText.Text == GameOptionsMenuPatch.SheriffCooldown.TitleText.Text) | ||
{ | ||
CustomGameOptions.SheriffKillCD = Math.Max(CustomGameOptions.SheriffKillCD - 2.5f, 10); | ||
|
||
PlayerControl.LocalPlayer.RpcSyncSettings(PlayerControl.GameOptions); | ||
__instance.Field_3 = CustomGameOptions.SheriffKillCD; | ||
__instance.Value = CustomGameOptions.SheriffKillCD; | ||
__instance.ValueText.Text = CustomGameOptions.SheriffKillCD.ToString(); | ||
|
||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.