Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #75 from LaicosVK/lvk_1.1.2
Browse files Browse the repository at this point in the history
Lvk 1.1.2
  • Loading branch information
LaicosVK authored Apr 10, 2022
2 parents abc25f1 + 06b1994 commit fbf8fde
Show file tree
Hide file tree
Showing 20 changed files with 183 additions and 73 deletions.
1 change: 1 addition & 0 deletions TheEpicRoles/Buttons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1479,6 +1479,7 @@ public static void Postfix(HudManager __instance)
jumperChargesText.transform.localScale = Vector3.one * 0.5f;
jumperChargesText.transform.localPosition += new Vector3(-0.05f, 0.7f, 0);

// ready button
readyButton = new CustomButton(
() => {
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetReadyStatus, Hazel.SendOption.Reliable, -1);
Expand Down
4 changes: 2 additions & 2 deletions TheEpicRoles/CustomOptionHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public class CustomOptionHolder {
public static CustomOption dynamicMapEnableSkeld;
public static CustomOption dynamicMapEnableMira;
public static CustomOption dynamicMapEnablePolus;
public static CustomOption dynamicMapEnableDleks;
//public static CustomOption dynamicMapEnableDleks;
public static CustomOption dynamicMapEnableAirShip;


Expand Down Expand Up @@ -530,7 +530,7 @@ public static void Load() {
dynamicMapEnableMira = CustomOption.Create(502, cs(new Color(0, 1, 217f / 255f, 1f), "Enable Mira Rotation"), "map", true, dynamicMap, false);
dynamicMapEnablePolus = CustomOption.Create(503, cs(new Color(0, 1, 217f / 255f, 1f), "Enable Polus Rotation"), "map", true, dynamicMap, false);
dynamicMapEnableAirShip = CustomOption.Create(504, cs(new Color(0, 1, 217f / 255f, 1f), "Enable Airship Rotation"), "map", true, dynamicMap, false);
dynamicMapEnableDleks = CustomOption.Create(505, cs(new Color(0, 1, 217f / 255f, 1f), "Enable dlekS Rotation"), "map", false, dynamicMap, false);
//dynamicMapEnableDleks = CustomOption.Create(505, cs(new Color(0, 1, 217f / 255f, 1f), "Enable dlekS Rotation"), "map", false, dynamicMap, false);

blockedRolePairings.Add((byte)RoleId.Vampire, new [] { (byte)RoleId.Warlock});
blockedRolePairings.Add((byte)RoleId.Warlock, new [] { (byte)RoleId.Vampire});
Expand Down
6 changes: 3 additions & 3 deletions TheEpicRoles/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public class TheEpicRolesPlugin : BasePlugin
public static ConfigEntry<bool> GhostsSeeVotes{ get; set; }
public static ConfigEntry<bool> ShowRoleSummary { get; set; }
public static ConfigEntry<bool> ShowLighterDarker { get; set; }
public static ConfigEntry<bool> EnableHorseMode { get; set; }
public static ConfigEntry<bool> ToggleCursor { get; set; }
public static ConfigEntry<bool> ToggleScreenShake { get; set; }
public static ConfigEntry<string> StreamerModeReplacementText { get; set; }
public static ConfigEntry<string> StreamerModeReplacementColor { get; set; }
public static ConfigEntry<string> Ip { get; set; }
Expand All @@ -63,14 +63,14 @@ public static void UpdateRegions() {
public override void Load() {
Logger = Log;
DebugMode = Config.Bind("Custom", "Enable Debug Mode", false);
StreamerMode = Config.Bind("Custom", "Enable Streamer Mode", false);
StreamerMode = Config.Bind("Custom", "Enable Streamer Mode", true);
GhostsSeeTasks = Config.Bind("Custom", "Ghosts See Remaining Tasks", true);
GhostsSeeRoles = Config.Bind("Custom", "Ghosts See Roles", true);
GhostsSeeVotes = Config.Bind("Custom", "Ghosts See Votes", true);
ShowRoleSummary = Config.Bind("Custom", "Show Role Summary", true);
ShowLighterDarker = Config.Bind("Custom", "Show Lighter / Darker", true);
EnableHorseMode = Config.Bind("Custom", "Enable Horse Mode", false);
ToggleCursor = Config.Bind("Custom", "Better Cursor", true);
ToggleScreenShake = Config.Bind("Custom", "Screen Shake", false);
ShowPopUpVersion = Config.Bind("Custom", "Show PopUp", "0");
StreamerModeReplacementText = Config.Bind("Custom", "Streamer Mode Replacement Text", "\n\nThe Epic Roles");
StreamerModeReplacementColor = Config.Bind("Custom", "Streamer Mode Replacement Text Hex Color", "#00FFDDFF");
Expand Down
11 changes: 8 additions & 3 deletions TheEpicRoles/MapOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ static class MapOptions {
public static bool showRoleSummary = true;
public static bool allowParallelMedBayScans = false;
public static bool showLighterDarker = true;
public static bool enableHorseMode = false;
public static bool toggleCursor = true;
public static bool toggleScreenShake = false;

// Updating values
public static int meetingsCount = 0;
public static List<SurvCamera> camerasToAdd = new List<SurvCamera>();
public static List<Vent> ventsToSeal = new List<Vent>();
public static Dictionary<byte, PoolablePlayer> playerIcons = new Dictionary<byte, PoolablePlayer>();

public static void clearAndReloadMapOptions() {
public static void clearAndReloadMapOptions() {
meetingsCount = 0;
camerasToAdd = new List<SurvCamera>();
ventsToSeal = new List<Vent>();
Expand All @@ -37,13 +37,18 @@ public static void clearAndReloadMapOptions() {
noVoteIsSelfVote = CustomOptionHolder.noVoteIsSelfVote.getBool();
hidePlayerNames = CustomOptionHolder.hidePlayerNames.getBool();
allowParallelMedBayScans = CustomOptionHolder.allowParallelMedBayScans.getBool();
}

public static void reloadPluginOptions()
{
ghostsSeeRoles = TheEpicRolesPlugin.GhostsSeeRoles.Value;
ghostsSeeTasks = TheEpicRolesPlugin.GhostsSeeTasks.Value;
ghostsSeeVotes = TheEpicRolesPlugin.GhostsSeeVotes.Value;
showRoleSummary = TheEpicRolesPlugin.ShowRoleSummary.Value;
showLighterDarker = TheEpicRolesPlugin.ShowLighterDarker.Value;
toggleCursor = TheEpicRolesPlugin.ToggleCursor.Value;
toggleScreenShake = TheEpicRolesPlugin.ToggleScreenShake.Value;
enableHorseMode = TheEpicRolesPlugin.EnableHorseMode.Value;
Patches.ShouldAlwaysHorseAround.isHorseMode = TheEpicRolesPlugin.EnableHorseMode.Value;
}
}
}
3 changes: 2 additions & 1 deletion TheEpicRoles/Modules/CustomOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,12 @@ public static void Prefix(GameSettingMenu __instance) {

public static void Postfix(GameSettingMenu __instance) {
// Setup mapNameTransform
var mapNameTransform = __instance.AllItems.FirstOrDefault(x => x.gameObject.activeSelf && x.name.Equals("MapName", StringComparison.OrdinalIgnoreCase));
var mapNameTransform = __instance.AllItems.FirstOrDefault(x => x.name.Equals("MapName", StringComparison.OrdinalIgnoreCase));
if (mapNameTransform == null) return;

var options = new Il2CppSystem.Collections.Generic.List<Il2CppSystem.Collections.Generic.KeyValuePair<string, int>>();
for (int i = 0; i < Constants.MapNames.Length; i++) {
if (i == 3) continue; // Ignore dlekS
var kvp = new Il2CppSystem.Collections.Generic.KeyValuePair<string, int>();
kvp.key = Constants.MapNames[i];
kvp.value = i;
Expand Down
3 changes: 1 addition & 2 deletions TheEpicRoles/Patches/ClientOptionsPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public static class ClientOptionsPatch
new SelectionBehaviour("Show Role Summary", () => MapOptions.showRoleSummary = TheEpicRolesPlugin.ShowRoleSummary.Value = !TheEpicRolesPlugin.ShowRoleSummary.Value, TheEpicRolesPlugin.ShowRoleSummary.Value),
new SelectionBehaviour("Show Lighter / Darker", () => MapOptions.showLighterDarker = TheEpicRolesPlugin.ShowLighterDarker.Value = !TheEpicRolesPlugin.ShowLighterDarker.Value, TheEpicRolesPlugin.ShowLighterDarker.Value),
new SelectionBehaviour("Better Cursor", () => MapOptions.toggleCursor = TheEpicRolesPlugin.ToggleCursor.Value = !TheEpicRolesPlugin.ToggleCursor.Value, TheEpicRolesPlugin.ToggleCursor.Value),
new SelectionBehaviour("Screen Shake", () => MapOptions.toggleScreenShake = TheEpicRolesPlugin.ToggleScreenShake.Value = !TheEpicRolesPlugin.ToggleScreenShake.Value, TheEpicRolesPlugin.ToggleScreenShake.Value),
};

private static GameObject popUp;
Expand Down Expand Up @@ -204,7 +203,7 @@ private static IEnumerable<GameObject> GetAllChilds(this GameObject Go)
}
}

private class SelectionBehaviour
public class SelectionBehaviour
{
public string Title;
public Func<bool> OnClick;
Expand Down
79 changes: 60 additions & 19 deletions TheEpicRoles/Patches/CredentialsPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,41 +46,82 @@ static void Prefix(PingTracker __instance) {
modStamp.transform.parent = __instance.transform.parent;
modStamp.transform.localScale *= 0.6f;
}
float offset = (AmongUsClient.Instance.GameState == InnerNet.InnerNetClient.GameStates.Started) ? 0.75f : 0f;
float offset = (AmongUsClient.Instance.GameState == InnerNet.InnerNetClient.GameStates.Started) ? 0.75f : 0.75f;
modStamp.transform.position = HudManager.Instance.MapButton.transform.position + Vector3.down * offset;

// changed position of friends list button
var objects = GameObject.FindObjectsOfType<FriendsListButton>();
if (objects == null) return;
objects[0].transform.localPosition = new Vector3(1.6f, -0.75f, objects[0].transform.localPosition.z);
}

static void Postfix(PingTracker __instance){
static void Postfix(PingTracker __instance)
{
__instance.text.alignment = TMPro.TextAlignmentOptions.TopRight;
__instance.text.SetOutlineThickness(0);
if (AmongUsClient.Instance.GameState == InnerNet.InnerNetClient.GameStates.Started) {
__instance.text.text = $"<size=130%><color={terColor}>The Epic Roles</color></size> <size=50%>v{TheEpicRolesPlugin.Version.ToString()}</size>\n" + __instance.text.text;
if (PlayerControl.LocalPlayer.Data.IsDead || (!(PlayerControl.LocalPlayer == null) && (PlayerControl.LocalPlayer == Lovers.lover1 || PlayerControl.LocalPlayer == Lovers.lover2))) {
__instance.transform.localPosition = new Vector3(3.45f, __instance.transform.localPosition.y, __instance.transform.localPosition.z);
} else {
__instance.transform.localPosition = new Vector3(4.2f, __instance.transform.localPosition.y, __instance.transform.localPosition.z);
}
} else {
__instance.text.text = $"{fullCredentials}\n{__instance.text.text}";
__instance.transform.localPosition = new Vector3(3.5f, __instance.transform.localPosition.y, __instance.transform.localPosition.z);
}
__instance.text.text = $"{fullCredentials}\n{__instance.text.text}";
if (AmongUsClient.Instance.GameState != InnerNet.InnerNetClient.GameStates.Started || PlayerControl.LocalPlayer.Data.IsDead || (!(PlayerControl.LocalPlayer == null) && (PlayerControl.LocalPlayer == Lovers.lover1 || PlayerControl.LocalPlayer == Lovers.lover2)))

__instance.transform.localPosition = new Vector3(3.45f, __instance.transform.localPosition.y, __instance.transform.localPosition.z);
else
__instance.transform.localPosition = new Vector3(4.25f, __instance.transform.localPosition.y, __instance.transform.localPosition.z);
__instance.enabled = false;
__instance.enabled = true;
}
}

[HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.Start))]
private static class LogoPatch
public static class LogoPatch
{
static void Postfix(MainMenuManager __instance) {
public static SpriteRenderer renderer;
public static Sprite bannerSprite;
public static Sprite horseBannerSprite;
private static PingTracker instance;
static void Postfix(PingTracker __instance)
{
var amongUsLogo = GameObject.Find("bannerLogo_AmongUs");
if (amongUsLogo != null) {
if (amongUsLogo != null)
{
amongUsLogo.transform.localScale *= 0.6f;
amongUsLogo.transform.position += Vector3.up * 0.25f;
}
}

var torLogo = new GameObject("bannerLogo_TOR");
var torLogo = new GameObject("bannerLogo_TER");
torLogo.transform.position = Vector3.up;
var renderer = torLogo.AddComponent<SpriteRenderer>();
renderer = torLogo.AddComponent<SpriteRenderer>();
loadSprites();
renderer.sprite = Helpers.loadSpriteFromResources("TheEpicRoles.Resources.Banner.png", 300f);

instance = __instance;
loadSprites();
renderer.sprite = MapOptions.enableHorseMode ? horseBannerSprite : bannerSprite;
}

public static void loadSprites()
{
if (bannerSprite == null) bannerSprite = Helpers.loadSpriteFromResources("TheEpicRoles.Resources.Banner.png", 300f);
if (horseBannerSprite == null) horseBannerSprite = Helpers.loadSpriteFromResources("TheEpicRoles.Resources.BannerHorse.png", 300f);
}

public static void updateSprite()
{
loadSprites();
if (renderer != null)
{
float fadeDuration = 1f;
instance.StartCoroutine(Effects.Lerp(fadeDuration, new Action<float>((p) =>
{
renderer.color = new Color(1, 1, 1, 1 - p);
if (p == 1)
{
renderer.sprite = MapOptions.enableHorseMode ? horseBannerSprite : bannerSprite;
instance.StartCoroutine(Effects.Lerp(fadeDuration, new Action<float>((p) =>
{
renderer.color = new Color(1, 1, 1, p);
})));
}
})));
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion TheEpicRoles/Patches/EndGamePatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public static void Postfix(EndGameManager __instance) {
poolablePlayer.transform.localScale = vector;
poolablePlayer.UpdateFromPlayerOutfit(winningPlayerData2, winningPlayerData2.IsDead);
if (winningPlayerData2.IsDead) {
poolablePlayer.CurrentBodySprite.GhostSprite = __instance.GhostSprite; // TODO test
poolablePlayer.CurrentBodySprite.BodySprite.sprite = poolablePlayer.CurrentBodySprite.GhostSprite;
poolablePlayer.SetDeadFlipX(i % 2 == 0);
} else {
poolablePlayer.SetFlipX(i % 2 == 0);
Expand Down
4 changes: 2 additions & 2 deletions TheEpicRoles/Patches/GameStartManagerPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ public static bool Prefix(GameStartManager __instance) {
possibleMaps.Add(1);
if (CustomOptionHolder.dynamicMapEnablePolus.getBool())
possibleMaps.Add(2);
if (CustomOptionHolder.dynamicMapEnableDleks.getBool())
possibleMaps.Add(3);
//if (CustomOptionHolder.dynamicMapEnableDleks.getBool())
// possibleMaps.Add(3);
if (CustomOptionHolder.dynamicMapEnableAirShip.getBool())
possibleMaps.Add(4);
byte chosenMapId = possibleMaps[TheEpicRoles.rnd.Next(possibleMaps.Count)];
Expand Down
16 changes: 16 additions & 0 deletions TheEpicRoles/Patches/IntroPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,5 +341,21 @@ public static void Postfix(IntroCutscene __instance, ref Il2CppSystem.Collectio
}
}
}

[HarmonyPatch(typeof(Constants), nameof(Constants.ShouldHorseAround))]
public static class ShouldAlwaysHorseAround
{
public static bool isHorseMode;
public static bool Prefix(ref bool __result)
{
if (isHorseMode != MapOptions.enableHorseMode && LobbyBehaviour.Instance != null) __result = isHorseMode;
else
{
__result = MapOptions.enableHorseMode;
isHorseMode = MapOptions.enableHorseMode;
}
return false;
}
}
}

36 changes: 36 additions & 0 deletions TheEpicRoles/Patches/LightSourcePatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using HarmonyLib;
using System;
using Hazel;
using UnityEngine;
using UnityEngine.Rendering;


namespace TheOtherRoles.Patches {

[HarmonyPatch(typeof(LightSource), nameof(LightSource.DrawOcclusion))]

class LightSourceUpdatePatch {
static bool Prefix(LightSource __instance, float effectiveRadius) {
if (__instance.cb == null) {
__instance.cb = new CommandBuffer();
__instance.cb.name = "Draw occlusion";
}
if (__instance.shadowTexture && __instance.shadowCasterMaterial) {
float num = (float)__instance.shadowTexture.width;
__instance.shadowCasterMaterial.SetFloat("_DepthCompressionValue", effectiveRadius);
__instance.cb.Clear();
__instance.cb.SetRenderTarget(__instance.shadowTexture);
__instance.cb.ClearRenderTarget(true, true, new Color(1f, 1f, 1f, 1f));
__instance.cb.SetGlobalTexture("_ShmapTexture", __instance.shadowTexture);
__instance.cb.SetGlobalFloat("_Radius", __instance.LightRadius);
__instance.cb.SetGlobalFloat("_Column", 0f);
__instance.cb.SetGlobalVector("_lightPosition", __instance.transform.position + Vector3.down * 0.095f); ;
__instance.cb.SetGlobalVector("_TexelSize", new Vector4(1f / num, 1f / num, num, num));
__instance.cb.SetGlobalFloat("_DepthCompressionValue", effectiveRadius);
__instance.cb.DrawMesh(__instance.occluderMesh, Matrix4x4.identity, __instance.shadowCasterMaterial);
Graphics.ExecuteCommandBuffer(__instance.cb);
}
return false;
}
}
}
Loading

0 comments on commit fbf8fde

Please sign in to comment.