Skip to content

Commit

Permalink
Merge pull request #333 from Eisbison/v-3-4-5
Browse files Browse the repository at this point in the history
Version 3.4.5
  • Loading branch information
dwd0tcom authored Apr 9, 2022
2 parents 481b05e + 7d30ebd commit 70139e3
Show file tree
Hide file tree
Showing 26 changed files with 326 additions and 139 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ The [Role Assignment](#role-assignment) sections explains how the roles are bein
# Releases
| Among Us - Version| Mod Version | Link |
|----------|-------------|-----------------|
| 2022.3.29s| v3.4.5| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v3.4.5/TheOtherRoles.zip)
| 2022.2.23s| v3.4.4| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v3.4.4/TheOtherRoles.zip)
| 2021.12.15s| v3.4.3| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v3.4.3/TheOtherRoles.zip)
| 2021.12.15s| v3.4.2| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v3.4.2/TheOtherRoles.zip)
Expand Down Expand Up @@ -100,8 +101,18 @@ The [Role Assignment](#role-assignment) sections explains how the roles are bein
<details>
<summary>Click to show the Changelog</summary>

**Version 3.4.5**
- Update to Among Us version 2022.3.29s
- Added horse-mode button in the main menu (bottom right)
- Added TheOtherRoles-discord button in the main menu (bottom left, report your bugs and feature suggestions here)
- Fixed a bug where the deputy was not assigned properly
- Fixed a bug where a promoted deputy had wrong cooldown
- Fixed a bug where the killer doesn't teleport to the body
- Changed the light source to prevent vanilla bugs
- Removed dlekS (for now) :c

**Version 3.4.4**
- Fixed a bug where games were not finished properly on official servers (special thanks to miniduikboot & 6pak)
- Fixed a bug where games were not finished properly on offical servers (special thanks to miniduikboot & 6pak)

**Version 3.4.3**
- Fixed a bug where "Guesser Is Impostor Chance" crashed the role system
Expand Down
2 changes: 0 additions & 2 deletions TheOtherRoles/CustomOptionHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ public class CustomOptionHolder {
public static CustomOption dynamicMapEnableSkeld;
public static CustomOption dynamicMapEnableMira;
public static CustomOption dynamicMapEnablePolus;
public static CustomOption dynamicMapEnableDleks;
public static CustomOption dynamicMapEnableAirShip;


Expand Down Expand Up @@ -477,7 +476,6 @@ public static void Load() {
dynamicMapEnableMira = CustomOption.Create(502, "Enable Mira Rotation", true, dynamicMap, false);
dynamicMapEnablePolus = CustomOption.Create(503, "Enable Polus Rotation", true, dynamicMap, false);
dynamicMapEnableAirShip = CustomOption.Create(504, "Enable Airship Rotation", true, dynamicMap, false);
dynamicMapEnableDleks = CustomOption.Create(505, "Enable dlekS Rotation", false, dynamicMap, false);

blockedRolePairings.Add((byte)RoleId.Vampire, new [] { (byte)RoleId.Warlock});
blockedRolePairings.Add((byte)RoleId.Warlock, new [] { (byte)RoleId.Vampire});
Expand Down
32 changes: 25 additions & 7 deletions TheOtherRoles/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,16 @@ public static void setLook(this PlayerControl target, String playerName, int col
target.RawSetHat(hatId, colorId);
target.RawSetName(hidePlayerName(PlayerControl.LocalPlayer, target) ? "" : playerName);

SkinData nextSkin = DestroyableSingleton<HatManager>.Instance.GetSkinById(skinId);
SkinViewData nextSkin = DestroyableSingleton<HatManager>.Instance.GetSkinById(skinId).viewData.viewData;
PlayerPhysics playerPhysics = target.MyPhysics;
AnimationClip clip = null;
var spriteAnim = playerPhysics.Skin.animator;
var currentPhysicsAnim = playerPhysics.Animator.GetCurrentAnimation();
if (currentPhysicsAnim == playerPhysics.RunAnim) clip = nextSkin.RunAnim;
else if (currentPhysicsAnim == playerPhysics.SpawnAnim) clip = nextSkin.SpawnAnim;
else if (currentPhysicsAnim == playerPhysics.EnterVentAnim) clip = nextSkin.EnterVentAnim;
else if (currentPhysicsAnim == playerPhysics.ExitVentAnim) clip = nextSkin.ExitVentAnim;
else if (currentPhysicsAnim == playerPhysics.IdleAnim) clip = nextSkin.IdleAnim;
if (currentPhysicsAnim == playerPhysics.CurrentAnimationGroup.RunAnim) clip = nextSkin.RunAnim;
else if (currentPhysicsAnim == playerPhysics.CurrentAnimationGroup.SpawnAnim) clip = nextSkin.SpawnAnim;
else if (currentPhysicsAnim == playerPhysics.CurrentAnimationGroup.EnterVentAnim) clip = nextSkin.EnterVentAnim;
else if (currentPhysicsAnim == playerPhysics.CurrentAnimationGroup.ExitVentAnim) clip = nextSkin.ExitVentAnim;
else if (currentPhysicsAnim == playerPhysics.CurrentAnimationGroup.IdleAnim) clip = nextSkin.IdleAnim;
else clip = nextSkin.IdleAnim;
float progress = playerPhysics.Animator.m_animator.GetCurrentAnimatorStateInfo(0).normalizedTime;
playerPhysics.Skin.skin = nextSkin;
Expand All @@ -242,13 +242,31 @@ public static void setLook(this PlayerControl target, String playerName, int col
spriteAnim.m_animator.Update(0f);

if (target.CurrentPet) UnityEngine.Object.Destroy(target.CurrentPet.gameObject);
target.CurrentPet = UnityEngine.Object.Instantiate<PetBehaviour>(DestroyableSingleton<HatManager>.Instance.GetPetById(petId).PetPrefab);
target.CurrentPet = UnityEngine.Object.Instantiate<PetBehaviour>(DestroyableSingleton<HatManager>.Instance.GetPetById(petId).viewData.viewData);
target.CurrentPet.transform.position = target.transform.position;
target.CurrentPet.Source = target;
target.CurrentPet.Visible = target.Visible;
PlayerControl.SetPlayerMaterialColors(colorId, target.CurrentPet.rend);
}

public static void showFlash(Color color, float duration=1f) {
if (HudManager.Instance == null || HudManager.Instance.FullScreen == null) return;
HudManager.Instance.FullScreen.gameObject.SetActive(true);
HudManager.Instance.FullScreen.enabled = true;
HudManager.Instance.StartCoroutine(Effects.Lerp(duration, new Action<float>((p) => {
var renderer = HudManager.Instance.FullScreen;

if (p < 0.5) {
if (renderer != null)
renderer.color = new Color(color.r, color.g, color.b, Mathf.Clamp01(p * 2 * 0.75f));
} else {
if (renderer != null)
renderer.color = new Color(color.r, color.g, color.b, Mathf.Clamp01((1 - p) * 2 * 0.75f));
}
if (p == 1f && renderer != null) renderer.enabled = false;
})));
}

public static bool roleCanUseVents(this PlayerControl player) {
bool roleCouldUse = false;
if (Engineer.engineer != null && Engineer.engineer == player)
Expand Down
4 changes: 3 additions & 1 deletion TheOtherRoles/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace TheOtherRoles
public class TheOtherRolesPlugin : BasePlugin
{
public const string Id = "me.eisbison.theotherroles";
public const string VersionString = "3.4.4";
public const string VersionString = "3.4.5";

public static System.Version Version = System.Version.Parse(VersionString);
internal static BepInEx.Logging.ManualLogSource Logger;
Expand All @@ -38,6 +38,7 @@ public class TheOtherRolesPlugin : 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<string> StreamerModeReplacementText { get; set; }
public static ConfigEntry<string> StreamerModeReplacementColor { get; set; }
public static ConfigEntry<string> Ip { get; set; }
Expand Down Expand Up @@ -66,6 +67,7 @@ public override void Load() {
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);
ShowPopUpVersion = Config.Bind("Custom", "Show PopUp", "0");
StreamerModeReplacementText = Config.Bind("Custom", "Streamer Mode Replacement Text", "\n\nThe Other Roles");
StreamerModeReplacementColor = Config.Bind("Custom", "Streamer Mode Replacement Text Hex Color", "#87AAF5FF");
Expand Down
8 changes: 7 additions & 1 deletion TheOtherRoles/MapOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ static class MapOptions {
public static bool showRoleSummary = true;
public static bool allowParallelMedBayScans = false;
public static bool showLighterDarker = true;
public static bool enableHorseMode = 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 @@ -35,11 +36,16 @@ public static void clearAndReloadMapOptions() {
noVoteIsSelfVote = CustomOptionHolder.noVoteIsSelfVote.getBool();
hidePlayerNames = CustomOptionHolder.hidePlayerNames.getBool();
allowParallelMedBayScans = CustomOptionHolder.allowParallelMedBayScans.getBool();
}

public static void reloadPluginOptions() {
ghostsSeeRoles = TheOtherRolesPlugin.GhostsSeeRoles.Value;
ghostsSeeTasks = TheOtherRolesPlugin.GhostsSeeTasks.Value;
ghostsSeeVotes = TheOtherRolesPlugin.GhostsSeeVotes.Value;
showRoleSummary = TheOtherRolesPlugin.ShowRoleSummary.Value;
showLighterDarker = TheOtherRolesPlugin.ShowLighterDarker.Value;
enableHorseMode = TheOtherRolesPlugin.EnableHorseMode.Value;
Patches.ShouldAlwaysHorseAround.isHorseMode = TheOtherRolesPlugin.EnableHorseMode.Value;
}
}
}
58 changes: 28 additions & 30 deletions TheOtherRoles/Modules/CustomHats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,34 +126,32 @@ private static Sprite CreateHatSprite(string path, bool fromDisk = false) {
return sprite;
}

private static HatBehaviour CreateHatBehaviour(CustomHat ch, bool fromDisk = false, bool testOnly = false) {
if (hatShader == null && DestroyableSingleton<HatManager>.InstanceExists) {
foreach (HatBehaviour h in DestroyableSingleton<HatManager>.Instance.AllHats) {
if (h.AltShader != null) {
hatShader = h.AltShader;
break;
}
}
private static HatData CreateHatBehaviour(CustomHat ch, bool fromDisk = false, bool testOnly = false) {
if (hatShader == null) {
Material tmpShader = new Material("PlayerMaterial");
tmpShader.shader = Shader.Find("Unlit/PlayerShader");
hatShader = tmpShader;
}

HatBehaviour hat = ScriptableObject.CreateInstance<HatBehaviour>();
hat.MainImage = CreateHatSprite(ch.resource, fromDisk);
HatData hat = ScriptableObject.CreateInstance<HatData>();
hat.hatViewData.viewData = ScriptableObject.CreateInstance<HatViewData>();
hat.hatViewData.viewData.MainImage = CreateHatSprite(ch.resource, fromDisk);
if (ch.backresource != null) {
hat.BackImage = CreateHatSprite(ch.backresource, fromDisk);
hat.hatViewData.viewData.BackImage = CreateHatSprite(ch.backresource, fromDisk);
ch.behind = true; // Required to view backresource
}
if (ch.climbresource != null)
hat.ClimbImage = CreateHatSprite(ch.climbresource, fromDisk);
hat.hatViewData.viewData.ClimbImage = CreateHatSprite(ch.climbresource, fromDisk);
hat.name = ch.name;
hat.Order = 99;
hat.displayOrder = 99;
hat.ProductId = "hat_" + ch.name.Replace(' ', '_');
hat.InFront = !ch.behind;
hat.NoBounce = !ch.bounce;
hat.ChipOffset = new Vector2(0f, 0.2f);
hat.Free = true;

if (ch.adaptive && hatShader != null)
hat.AltShader = hatShader;
hat.hatViewData.viewData.AltShader = hatShader;

HatExtension extend = new HatExtension();
extend.author = ch.author != null ? ch.author : "Unknown";
Expand All @@ -175,7 +173,7 @@ private static HatBehaviour CreateHatBehaviour(CustomHat ch, bool fromDisk = fal
return hat;
}

private static HatBehaviour CreateHatBehaviour(CustomHatLoader.CustomHatOnline chd) {
private static HatData CreateHatBehaviour(CustomHatLoader.CustomHatOnline chd) {
string filePath = Path.GetDirectoryName(Application.dataPath) + @"\TheOtherHats\";
chd.resource = filePath + chd.resource;
if (chd.backresource != null)
Expand All @@ -196,7 +194,7 @@ static void Prefix(HatManager __instance) {
RUNNING = true; // prevent simultanious execution
try {
while (CustomHatLoader.hatdetails.Count > 0) {
__instance.AllHats.Add(CreateHatBehaviour(CustomHatLoader.hatdetails[0]));
__instance.allHats.Add(CreateHatBehaviour(CustomHatLoader.hatdetails[0]));
CustomHatLoader.hatdetails.RemoveAt(0);
}
} catch (System.Exception e) {
Expand All @@ -214,7 +212,7 @@ static void Postfix(HatManager __instance) {
private static class PlayerPhysicsHandleAnimationPatch {
private static void Postfix(PlayerPhysics __instance) {
AnimationClip currentAnimation = __instance.Animator.GetCurrentAnimation();
if (currentAnimation == __instance.ClimbAnim || currentAnimation == __instance.ClimbDownAnim) return;
if (currentAnimation == __instance.CurrentAnimationGroup.ClimbAnim || currentAnimation == __instance.CurrentAnimationGroup.ClimbDownAnim) return;
HatParent hp = __instance.myPlayer.HatRenderer;
if (hp.Hat == null) return;
HatExtension extend = hp.Hat.getHatExtension();
Expand All @@ -223,14 +221,14 @@ private static void Postfix(PlayerPhysics __instance) {
if (__instance.rend.flipX) {
hp.FrontLayer.sprite = extend.FlipImage;
} else {
hp.FrontLayer.sprite = hp.Hat.MainImage;
hp.FrontLayer.sprite = hp.hatView.MainImage;
}
}
if (extend.BackFlipImage != null) {
if (__instance.rend.flipX) {
hp.BackLayer.sprite = extend.BackFlipImage;
} else {
hp.BackLayer.sprite = hp.Hat.BackImage;
hp.BackLayer.sprite = hp.hatView.BackImage;
}
}
}
Expand Down Expand Up @@ -261,7 +259,7 @@ public class HatsTabOnEnablePatch {
public static string innerslothPackageName = "Innersloth Hats";
private static TMPro.TMP_Text textTemplate;

public static float createHatPackage(List<System.Tuple<HatBehaviour, HatExtension>> hats, string packageName, float YStart, HatsTab __instance) {
public static float createHatPackage(List<System.Tuple<HatData, HatExtension>> hats, string packageName, float YStart, HatsTab __instance) {
bool isDefaultPackage = innerslothPackageName == packageName;
if (!isDefaultPackage)
hats = hats.OrderBy(x => x.Item1.name).ToList();
Expand All @@ -277,7 +275,7 @@ public static float createHatPackage(List<System.Tuple<HatBehaviour, HatExtensio
offset -= 0.8f * __instance.YOffset;
}
for (int i = 0; i < hats.Count; i++) {
HatBehaviour hat = hats[i].Item1;
HatData hat = hats[i].Item1;
HatExtension ext = hats[i].Item2;

float xpos = __instance.XRange.Lerp((i % __instance.NumPerRow) / (__instance.NumPerRow - 1f));
Expand Down Expand Up @@ -327,20 +325,20 @@ public static void Postfix(HatsTab __instance) {
UnityEngine.Object.Destroy(__instance.scroller.Inner.GetChild(i).gameObject);
__instance.ColorChips = new Il2CppSystem.Collections.Generic.List<ColorChip>();

HatBehaviour[] unlockedHats = DestroyableSingleton<HatManager>.Instance.GetUnlockedHats();
Dictionary<string, List<System.Tuple<HatBehaviour, HatExtension>>> packages = new Dictionary<string, List<System.Tuple<HatBehaviour, HatExtension>>>();
HatData[] unlockedHats = DestroyableSingleton<HatManager>.Instance.GetUnlockedHats();
Dictionary<string, List<System.Tuple<HatData, HatExtension>>> packages = new Dictionary<string, List<System.Tuple<HatData, HatExtension>>>();

foreach (HatBehaviour hatBehaviour in unlockedHats) {
foreach (HatData hatBehaviour in unlockedHats) {
HatExtension ext = hatBehaviour.getHatExtension();

if (ext != null) {
if (!packages.ContainsKey(ext.package))
packages[ext.package] = new List<System.Tuple<HatBehaviour, HatExtension>>();
packages[ext.package].Add(new System.Tuple<HatBehaviour, HatExtension>(hatBehaviour, ext));
packages[ext.package] = new List<System.Tuple<HatData, HatExtension>>();
packages[ext.package].Add(new System.Tuple<HatData, HatExtension>(hatBehaviour, ext));
} else {
if (!packages.ContainsKey(innerslothPackageName))
packages[innerslothPackageName] = new List<System.Tuple<HatBehaviour, HatExtension>>();
packages[innerslothPackageName].Add(new System.Tuple<HatBehaviour, HatExtension>(hatBehaviour, null));
packages[innerslothPackageName] = new List<System.Tuple<HatData, HatExtension>>();
packages[innerslothPackageName].Add(new System.Tuple<HatData, HatExtension>(hatBehaviour, null));
}
}

Expand All @@ -353,7 +351,7 @@ public static void Postfix(HatsTab __instance) {
return 500;
});
foreach (string key in orderedKeys) {
List<System.Tuple<HatBehaviour, HatExtension>> value = packages[key];
List<System.Tuple<HatData, HatExtension>> value = packages[key];
YOffset = createHatPackage(value, key, YOffset, __instance);
}

Expand Down Expand Up @@ -497,7 +495,7 @@ public class CustomHatOnline : CustomHats.CustomHat {
}
}
public static class CustomHatExtensions {
public static CustomHats.HatExtension getHatExtension(this HatBehaviour hat) {
public static CustomHats.HatExtension getHatExtension(this HatData hat) {
CustomHats.HatExtension ret = null;
if (CustomHats.TestExt != null && CustomHats.TestExt.condition.Equals(hat.name)) {
return CustomHats.TestExt;
Expand Down
Loading

0 comments on commit 70139e3

Please sign in to comment.