Skip to content

Commit

Permalink
Merge pull request #344 from Eisbison/4.1.1
Browse files Browse the repository at this point in the history
4.1.1
  • Loading branch information
Mallaris authored May 2, 2022
2 parents 322de56 + 3d06deb commit c623255
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 15 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ The [Role Assignment](#role-assignment) sections explains how the roles are bein
# Releases
| Among Us - Version| Mod Version | Link |
|----------|-------------|-----------------|
| 2022.3.29| v4.1.1| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v4.1.1/TheOtherRoles.zip)
| 2022.3.29| v4.1.0| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v4.1.0/TheOtherRoles.zip)
| 2022.3.29s| v4.0.0| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v4.0.0/TheOtherRoles.zip)
| 2022.3.29s| v3.4.5| [Download](https://github.com/Eisbison/TheOtherRoles/releases/download/v3.4.5/TheOtherRoles.zip)
Expand Down Expand Up @@ -102,6 +103,14 @@ The [Role Assignment](#role-assignment) sections explains how the roles are bein
<details>
<summary>Click to show the Changelog</summary>

**Version 4.1.1**
- Fixed a bug where the download submerged button did not work
- Fixed a bug where the medium revealed a evil mini
- Fixed a bug where the teleporter teleported while meeting is called
- Fixed a bug where buttons appeared in meeting
- Fixed the Popup
- Fixed some ui bugs

**Version 4.1.0**
- Added support for the Submerged map (https://github.com/SubmergedAmongUs/Submerged), which can be downloaded ingame with the Update button. If there is also a mod update, it will be prioritized
- Added an option to give the Mayor a portable Meeting Button
Expand Down
6 changes: 3 additions & 3 deletions TheOtherRoles/Buttons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ public static void Postfix(HudManager __instance)
HudManager.Instance.StartCoroutine(Effects.Lerp(Portal.teleportDuration, new Action<float>((p) => { // Delayed action
PlayerControl.LocalPlayer.moveable = false;
PlayerControl.LocalPlayer.NetTransform.Halt();
if (p >= 0.5f && p <= 0.53f && !didTeleport) {
if (p >= 0.5f && p <= 0.53f && !didTeleport && !MeetingHud.Instance) {
if (SubmergedCompatibility.isSubmerged()) {
SubmergedCompatibility.ChangeFloor(exit.y > -7);
}
Expand Down Expand Up @@ -1242,7 +1242,7 @@ public static void Postfix(HudManager __instance)
if (Medium.target == null || Medium.target.player == null) return;
string msg = "";

int randomNumber = TheOtherRoles.rnd.Next(4);
int randomNumber = Medium.target.killerIfExisting?.PlayerId == Mini.mini?.PlayerId ? TheOtherRoles.rnd.Next(3) : TheOtherRoles.rnd.Next(4);
string typeOfColor = Helpers.isLighterColor(Medium.target.killerIfExisting.Data.DefaultOutfit.ColorId) ? "lighter" : "darker";
float timeSinceDeath = ((float)(Medium.meetingStartTime - Medium.target.timeOfDeath).TotalMilliseconds);
string name = " (" + Medium.target.player.Data.PlayerName + ")";
Expand All @@ -1251,7 +1251,7 @@ public static void Postfix(HudManager __instance)
if (randomNumber == 0) msg = "What is your role? My role is " + RoleInfo.GetRolesString(Medium.target.player, false) + name;
else if (randomNumber == 1) msg = "What is your killer`s color type? My killer is a " + typeOfColor + " color" + name;
else if (randomNumber == 2) msg = "When did you die? I have died " + Math.Round(timeSinceDeath / 1000) + "s before meeting started" + name;
else msg = "What is your killer`s role? My killer is " + RoleInfo.GetRolesString(Medium.target.killerIfExisting, false) + name;
else msg = "What is your killer`s role? My killer is " + RoleInfo.GetRolesString(Medium.target.killerIfExisting, true) + name;

DestroyableSingleton<HudManager>.Instance.Chat.AddChat(PlayerControl.LocalPlayer, $"{msg}");

Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace TheOtherRoles
public class TheOtherRolesPlugin : BasePlugin
{
public const string Id = "me.eisbison.theotherroles";
public const string VersionString = "4.1.0";
public const string VersionString = "4.1.1";

public static Version Version = Version.Parse(VersionString);
internal static BepInEx.Logging.ManualLogSource Logger;
Expand Down
1 change: 1 addition & 0 deletions TheOtherRoles/Modules/CustomOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ public static void Prefix(HudManager __instance) {
LastPosition = new Vector3(MinX, MinY);
lastAspect = aspect;
setLastPosition = true;
if (Scroller != null) Scroller.ContentXBounds = new FloatRange(MinX, MinX);
}

CreateScroller(__instance);
Expand Down
20 changes: 17 additions & 3 deletions TheOtherRoles/Modules/ModUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ public void Awake()
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
if (scene.name != "MainMenu") return;
if (RequiredUpdateData is null) return;
if (RequiredUpdateData is null) {
showPopUp = false;
return;
}

var template = GameObject.Find("ExitGameButton");
if (!template) return;
Expand Down Expand Up @@ -100,6 +103,7 @@ private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
var isSubmerged = TORUpdate == null;
var announcement = $"<size=150%>A new <color=#FC0303>{(isSubmerged ? "Submerged" : "THE OTHER ROLES")}</color> update to {(isSubmerged ? SubmergedUpdate.Tag : TORUpdate.Tag)} is available</size>\n{(isSubmerged ? SubmergedUpdate.Content : TORUpdate.Content)}";
var mgr = FindObjectOfType<MainMenuManager>(true);
if (isSubmerged && !SubmergedCompatibility.Loaded) showPopUp = false;
if (showPopUp) mgr.StartCoroutine(CoShowAnnouncement(announcement));
showPopUp = false;
}
Expand Down Expand Up @@ -140,6 +144,7 @@ public static IEnumerator CoCheckUpdates()
{
var torUpdateCheck = Task.Run(() => Instance.GetGithubUpdate("Eisbison", "TheOtherRoles"));
while (!torUpdateCheck.IsCompleted) yield return null;
Announcement.updateData = torUpdateCheck.Result;
if (torUpdateCheck.Result != null && torUpdateCheck.Result.IsNewer(Version.Parse(TheOtherRolesPlugin.VersionString)))
{
Instance.TORUpdate = torUpdateCheck.Result;
Expand Down Expand Up @@ -196,11 +201,20 @@ public async Task<bool> DownloadUpdate()
if (downloadURI.Length == 0) return false;

var res = await client.GetAsync(downloadURI, HttpCompletionOption.ResponseContentRead);
string codeBase = (isSubmerged ? SubmergedCompatibility.Assembly : Assembly.GetExecutingAssembly()).CodeBase;
string codeBase = "";
if (!isSubmerged)
codeBase = Assembly.GetExecutingAssembly().CodeBase;
else if (SubmergedCompatibility.Loaded)
codeBase = SubmergedCompatibility.Assembly.CodeBase;
else {
Uri pluginsFolder = new Uri(new Uri(Assembly.GetExecutingAssembly().CodeBase), ".");
codeBase = pluginsFolder.OriginalString + "/Submerged.dll";
}

UriBuilder uri = new UriBuilder(codeBase);
string fullname = Uri.UnescapeDataString(uri.Path);
if (File.Exists(fullname + ".old")) File.Delete(fullname + ".old");
File.Move(fullname, fullname + ".old");
if (File.Exists(fullname)) File.Move(fullname, fullname + ".old");

await using var responseStream = await res.Content.ReadAsStreamAsync();
await using var fileStream = File.Create(fullname);
Expand Down
15 changes: 15 additions & 0 deletions TheOtherRoles/Patches/MainMenuPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,19 @@ private static void Prefix(MainMenuManager __instance) {
});
}
}

[HarmonyPatch(typeof(AnnouncementPopUp), nameof(AnnouncementPopUp.UpdateAnnounceText))]
public static class Announcement
{
public static ModUpdateBehaviour.UpdateData updateData = null;
public static bool Prefix(AnnouncementPopUp __instance)
{
if (ModUpdateBehaviour.showPopUp || updateData == null) return true;

var text = __instance.AnnounceTextMeshPro;
text.text = $"<size=150%><color=#FC0303>THE OTHER ROLES </color> {(updateData.Tag)}\n{(updateData.Content)}";

return false;
}
}
}
17 changes: 16 additions & 1 deletion TheOtherRoles/Patches/UpdatePatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,11 @@ public static void miniUpdate() {
}

static void updateImpostorKillButton(HudManager __instance) {
if (!PlayerControl.LocalPlayer.Data.Role.IsImpostor || MeetingHud.Instance) return;
if (!PlayerControl.LocalPlayer.Data.Role.IsImpostor) return;
if (MeetingHud.Instance) {
__instance.KillButton.Hide();
return;
}
bool enabled = true;
if (Vampire.vampire != null && Vampire.vampire == PlayerControl.LocalPlayer)
enabled = false;
Expand All @@ -272,6 +276,14 @@ static void updateVentButton(HudManager __instance)

}

static void updateUseButton(HudManager __instance) {
if (MeetingHud.Instance) __instance.UseButton.Hide();
}

static void updateSabotageButton(HudManager __instance) {
if (MeetingHud.Instance) __instance.SabotageButton.Hide();
}

static void Postfix(HudManager __instance)
{
if (AmongUsClient.Instance.GameState != InnerNet.InnerNetClient.GameStates.Started) return;
Expand All @@ -292,6 +304,9 @@ static void Postfix(HudManager __instance)
// Deputy Sabotage, Use and Vent Button Disabling
updateReportButton(__instance);
updateVentButton(__instance);
// Meeting hide buttons if needed (used for the map usage, because closing the map would show buttons)
updateSabotageButton(__instance);
updateUseButton(__instance);

}
}
Expand Down
Binary file modified TheOtherRoles/Resources/CentralUpperBlocked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 1 addition & 7 deletions TheOtherRoles/TheOtherRoles.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Version>4.0.0</Version>
<Version>4.1.1</Version>
<Description>TheOtherRoles</Description>
<Authors>Eisbison</Authors>
<LangVersion>latest</LangVersion>
Expand All @@ -24,12 +24,6 @@
<Reference Include="$(AmongUs)/BepInEx/unhollowed/*.dll" />
</ItemGroup>

<ItemGroup>
<None Remove="Resources\Blood1.png" />
<None Remove="Resources\Blood2.png" />
<None Remove="Resources\Blood3.png" />
</ItemGroup>

<Target Name="CopyCustomContent" AfterTargets="AfterBuild">
<Message Text="Second occurrence" />
<Copy SourceFiles="$(ProjectDir)\bin\$(Configuration)\netstandard2.1\TheOtherRoles.dll" DestinationFolder="$(AmongUsLatest)/BepInEx/plugins/" />
Expand Down

0 comments on commit c623255

Please sign in to comment.