Skip to content

Commit

Permalink
Preparation for updating v1.2.9
Browse files Browse the repository at this point in the history
  • Loading branch information
dabao40 committed Oct 5, 2024
1 parent 8f32543 commit e8e5383
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 38 deletions.
Binary file modified Strings.xlsx
Binary file not shown.
15 changes: 9 additions & 6 deletions TheOtherRoles/Buttons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,11 @@ public static void setCustomButtonCooldowns() {
foxImmoralistButton.MaxTimer = 20f;
immoralistButton.MaxTimer = 20f;
buskerButton.MaxTimer = Busker.cooldown;
operateButton.MaxTimer = 0f;
operateButton.Timer = 0f;
freePlayReviveButton.MaxTimer = 0f;
freePlayReviveButton.Timer = 0f;
freePlaySuicideButton.MaxTimer = 0f;
freePlaySuicideButton.Timer = 0f;
//trapperButton.MaxTimer = Trapper.cooldown;
//bomberButton.MaxTimer = Bomber.bombCooldown;
Expand Down Expand Up @@ -4118,8 +4121,8 @@ Func<bool> fortuneTellerCouldUse(byte index)
operateButton = new CustomButton(
() => { FreePlayGM.OpenRoleWindow(); },
() => { return FreePlayGM.isFreePlayGM; },
() => { return true; },
() => { },
() => { return FreePlayGM.roleScreen == null; },
() => { operateButton.Timer = operateButton.MaxTimer = 0f; },
FreePlayGM.getOperateButtonSprite(),
new Vector3(0f, 1f, 0f),
__instance,
Expand Down Expand Up @@ -4147,11 +4150,11 @@ Func<bool> fortuneTellerCouldUse(byte index)
{
return true;
},
() => { },
() => { freePlayReviveButton.Timer = freePlayReviveButton.MaxTimer = 0f; },
FreePlayGM.getReviveButtonSprite(),
new Vector3(1f, 1f, 0f),
__instance,
KeyCode.X,
KeyCode.Y,
true,
buttonText: ModTranslation.getString("FreePlayReviveText"),
abilityTexture: true
Expand All @@ -4176,7 +4179,7 @@ Func<bool> fortuneTellerCouldUse(byte index)
{
return true;
},
() => { },
() => { freePlaySuicideButton.Timer = freePlaySuicideButton.MaxTimer = 0f; },
__instance.KillButton.graphic.sprite,
new Vector3(1f, 1f, 0f),
__instance,
Expand Down Expand Up @@ -4204,7 +4207,7 @@ Func<bool> fortuneTellerCouldUse(byte index)
writer2.Write(0);
RPCProcedure.uncheckedMurderPlayer(thief.PlayerId, thief.PlayerId, 0);
AmongUsClient.Instance.FinishRpcImmediately(writer2);
Thief.thief.clearAllTasks();
if (!FreePlayGM.isFreePlayGM) Thief.thief.clearAllTasks();
}

// Steal role if survived.
Expand Down
15 changes: 9 additions & 6 deletions TheOtherRoles/CustomGameModes/FreePlayGM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public static class FreePlayGM
public static bool isFreePlayGM = false;
public static Sprite operateButtonSprite;
public static Sprite reviveSprite;
public static MetaScreen roleScreen;

public static Sprite getOperateButtonSprite()
{
Expand All @@ -36,7 +37,7 @@ public static Sprite getReviveButtonSprite()

public static void OpenRoleWindow()
{
var window = MetaScreen.GenerateWindow(new Vector2(7.5f, 4.5f), HudManager.Instance.transform, new Vector3(0, 0, -400f), true, false);
roleScreen = MetaScreen.GenerateWindow(new Vector2(7.5f, 4.5f), HudManager.Instance.transform, new Vector3(0, 0, -400f), true, false);

var gui = TORGUIContextEngine.Instance;
var roleMaskedTittleAttr = gui.GetAttribute(AttributeAsset.MetaRoleButton);
Expand All @@ -58,19 +59,20 @@ void SetWidget(int tab)
inner = gui.Arrange(GUIAlignment.Center, RoleInfo.allRoleInfos.Where(x => x != RoleInfo.bomberB && x != RoleInfo.bomberA && x != RoleInfo.jackal
&& x != RoleInfo.sidekick && x != RoleInfo.mimicA && x != RoleInfo.mimicK && x != RoleInfo.arsonist && x != RoleInfo.bountyHunter && !x.isModifier).Select(r => gui.RawButton(GUIAlignment.Center, roleMaskedTittleAttr, Helpers.cs(r.color, r.name), () =>
{
bool isImpostorFormer = PlayerControl.LocalPlayer.Data.Role.IsImpostor;
var formerRole = RoleInfo.getRoleInfoForPlayer(PlayerControl.LocalPlayer, false).FirstOrDefault();
if (formerRole == r) return; // Do nothing if the same role was given
RPCProcedure.erasePlayerRoles(PlayerControl.LocalPlayer.PlayerId);
if (r.isImpostor() && !formerRole.isImpostor()) PlayerControl.LocalPlayer.FastSetRole(RoleTypes.Impostor);
else if (!r.isImpostor() && formerRole.isImpostor()) PlayerControl.LocalPlayer.FastSetRole(RoleTypes.Crewmate);
if (r.isImpostor() && !isImpostorFormer) PlayerControl.LocalPlayer.FastSetRole(RoleTypes.Impostor);
else if (!r.isImpostor() && isImpostorFormer) PlayerControl.LocalPlayer.FastSetRole(RoleTypes.Crewmate);

if (r == RoleInfo.chainshifter) Shifter.isNeutral = true;
else if (r == RoleInfo.niceshifter) Shifter.isNeutral = false;
RPCProcedure.setRole((byte)r.roleId, PlayerControl.LocalPlayer.PlayerId);

if (r.roleId == RoleId.Fox) {
if (Shrine.allShrine?.FirstOrDefault() == null){
Shrine.activateShrines(GameOptionsManager.Instance.currentNormalGameOptions.MapId);System.Console.WriteLine("1");
Shrine.activateShrines(GameOptionsManager.Instance.currentNormalGameOptions.MapId);
}
List<Byte> taskIdList = new();
Shrine.allShrine.ForEach(shrine => taskIdList.Add((byte)shrine.console.ConsoleId));
Expand All @@ -84,7 +86,7 @@ void SetWidget(int tab)
PlayerControl.LocalPlayer.generateAndAssignTasks(options.NumCommonTasks, options.NumShortTasks, options.NumLongTasks);
}
RPCProcedure.resetAchievement();
window.CloseScreen();
roleScreen.CloseScreen();
})), 4);
}
else if (tab == 1)
Expand All @@ -104,7 +106,7 @@ void SetWidget(int tab)
})), 4)}
);
}
window.SetContext(gui.VerticalHolder(GUIAlignment.Center, new List<GUIContext>() { holder, gui.ScrollView(GUIAlignment.Center, new(7.4f, 3.5f), null, inner, out _) }), out _);
roleScreen.SetContext(gui.VerticalHolder(GUIAlignment.Center, new List<GUIContext>() { holder, gui.ScrollView(GUIAlignment.Center, new(7.4f, 3.5f), null, inner, out _) }), out _);
}

SetWidget(0);
Expand Down Expand Up @@ -185,6 +187,7 @@ public static PlayerControl SpawnDummy()
public static void clearAndReload()
{
isFreePlayGM = TORMapOptions.gameMode == CustomGamemodes.FreePlay;
roleScreen = null;
}

[HarmonyPatch(typeof(GameStartManager), nameof(GameStartManager.BeginGame))]
Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ public static bool isChinese()
public static string getGithubUrl(this string url)
{
if (!isChinese()) return url;
return url.Replace("https://", "https://mirror.ghproxy.com/");
return url.Replace("https://", "https://ghp.ci/");
}

public static T FindAsset<T>(string name) where T : Il2CppObjectBase
Expand Down
8 changes: 5 additions & 3 deletions TheOtherRoles/MetaContext/MetaScreen.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand Down Expand Up @@ -41,8 +41,10 @@ public bool ShowBorderLine
{
if (borderLine == null && value)
{
var lineObj = new GameObject("BorderLine");
lineObj.layer = LayerMask.NameToLayer("UI");
var lineObj = new GameObject("BorderLine")
{
layer = LayerMask.NameToLayer("UI")
};
lineObj.transform.SetParent(transform);
lineObj.transform.localPosition = new Vector3(0, 0, 0);
borderLine = lineObj.AddComponent<LineRenderer>();
Expand Down
18 changes: 10 additions & 8 deletions TheOtherRoles/Modules/CustomHats/CustomHatManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand All @@ -15,7 +15,7 @@ public static class CustomHatManager
public const string InnerslothPackageName = "Innersloth Hats";
public const string DeveloperPackageName = "Developer Hats";

internal static readonly Tuple<string, string> Repository = new("TheOtherRolesAU", "TheOtherHats");
internal static readonly Tuple<string, string> Repository = new("dabao40", "TheOtherHats");
internal static string RepositoryUrl
{
get
Expand Down Expand Up @@ -304,11 +304,13 @@ public static List<CustomHat> loadHorseHats()
int i = 0;
foreach (var item in hatFilesSorted)
{
CustomHat info = new();
info.Name = $"April Hat {i++:D2}";
info.Author = "A Fool";
info.Resource = item.Value.FirstOrDefault(x => !x.Contains("back"));
info.BackResource = item.Value.FirstOrDefault(x => x.Contains("back"));
CustomHat info = new()
{
Name = $"April Hat {i++:D2}",
Author = "A Fool",
Resource = item.Value.FirstOrDefault(x => !x.Contains("back")),
BackResource = item.Value.FirstOrDefault(x => x.Contains("back"))
};
info.Adaptive = info.Resource != null && info.Resource.Contains("adaptive");
info.FlipResource = item.Value.FirstOrDefault(x => x.Contains("flip"));
info.ClimbResource = item.Value.FirstOrDefault(x => x.Contains("climb"));
Expand All @@ -319,4 +321,4 @@ public static List<CustomHat> loadHorseHats()
}
return hatdatas;
}
}
}
8 changes: 4 additions & 4 deletions TheOtherRoles/Modules/CustomOverlay.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand Down Expand Up @@ -44,7 +44,6 @@ public static bool initializeOverlays()
if (infoOverlayRoles == null)
{
infoOverlayRoles = UnityEngine.Object.Instantiate(hudManager.TaskPanel.taskText, hudManager.transform);
infoOverlayRoles.maxVisibleLines = 28;
infoOverlayRoles.fontSize = infoOverlayRoles.fontSizeMin = infoOverlayRoles.fontSizeMax = 1.15f;
infoOverlayRoles.outlineWidth += 0.02f;
infoOverlayRoles.autoSizeTextContainer = false;
Expand Down Expand Up @@ -162,7 +161,7 @@ public static void hideInfoOverlay()
var underlayTransparent = new Color(0.1f, 0.1f, 0.1f, 0.0f);
var underlayOpaque = new Color(0.1f, 0.1f, 0.1f, 0.88f);

scroller.enabled = false;
if (scroller != null) scroller.enabled = false;

FastDestroyableSingleton<HudManager>.Instance.StartCoroutine(Effects.Lerp(0.2f, new Action<float>(t =>
{
Expand Down Expand Up @@ -195,7 +194,8 @@ public static void resetOverlays()
UnityEngine.Object.Destroy(meetingUnderlay);
UnityEngine.Object.Destroy(infoUnderlay);
UnityEngine.Object.Destroy(infoOverlayRoles);
UnityEngine.Object.Destroy(roleUnderlay);
UnityEngine.Object.Destroy(roleUnderlay);
UnityEngine.Object.Destroy(scroller);

overlayShown = false;
roleUnderlay = null;
Expand Down
17 changes: 11 additions & 6 deletions TheOtherRoles/Patches/IntroPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ static public void SetRoleTexts(IntroCutscene __instance) {
// Don't override the intro of the vanilla roles
List<RoleInfo> infos = RoleInfo.getRoleInfoForPlayer(CachedPlayer.LocalPlayer.PlayerControl);
RoleInfo roleInfo = infos.Where(info => !info.isModifier).FirstOrDefault();
RoleInfo modifierInfo = infos.Where(info => info.isModifier).FirstOrDefault();
List<RoleInfo> modifierInfo = infos.Where(info => info.isModifier).ToList();

if (roleInfo == RoleInfo.fortuneTeller && FortuneTeller.numTasks > 0)
{
Expand All @@ -466,6 +466,9 @@ static public void SetRoleTexts(IntroCutscene __instance) {
}

__instance.RoleBlurbText.text = "";
__instance.RoleBlurbText.transform.localPosition = new(0.0965f, -2.12f, -36f);
__instance.RoleBlurbText.rectTransform.sizeDelta = new(12.8673f, 0.7f);
__instance.RoleBlurbText.alignment = TMPro.TextAlignmentOptions.Top;
if (roleInfo != null) {
__instance.YouAreText.color = roleInfo.color;
__instance.RoleText.text = roleInfo.name;
Expand All @@ -486,11 +489,13 @@ static public void SetRoleTexts(IntroCutscene __instance) {
}

if (modifierInfo != null) {
if (modifierInfo.roleId != RoleId.Lover)
__instance.RoleBlurbText.text += Helpers.cs(modifierInfo.color, $"\n{modifierInfo.introDescription}");
else {
PlayerControl otherLover = CachedPlayer.LocalPlayer.PlayerControl == Lovers.lover1 ? Lovers.lover2 : Lovers.lover1;
__instance.RoleBlurbText.text += "\n" + Helpers.cs(Lovers.color, String.Format(ModTranslation.getString("loversFlavor"), otherLover?.Data?.PlayerName ?? ""));
foreach (var info in modifierInfo) {
if (info.roleId != RoleId.Lover)
__instance.RoleBlurbText.text += Helpers.cs(info.color, $"\n{info.introDescription}");
else {
PlayerControl otherLover = CachedPlayer.LocalPlayer.PlayerControl == Lovers.lover1 ? Lovers.lover2 : Lovers.lover1;
__instance.RoleBlurbText.text += "\n" + Helpers.cs(Lovers.color, String.Format(ModTranslation.getString("loversFlavor"), otherLover?.Data?.PlayerName ?? ""));
}
}
}
if (Deputy.knowsSheriff && Deputy.deputy != null && Sheriff.sheriff != null) {
Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/Patches/MainMenuPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public static class MainMenuSetUpPatch
public static GameObject aboutScreen = null;
public static Dictionary<string, string> contributors = new()
{ { "Imp11", "mainMenuDeveloper" }, { "Amongus", "mainMenuDeveloper" },
{ "Fangkuai", "mainMenuArtist" }, { "Yuunozikkyou" , "mainMenuTranslator"} };
{ "Fangkuai", "mainMenuArtist" }, { "Yuunozikkyou" , "mainMenuTranslator"}, { "TAIK", "mainMenuTranslator"} };

public static void Postfix(MainMenuManager __instance)
{
Expand Down
9 changes: 6 additions & 3 deletions TheOtherRoles/Patches/PlayerControlPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2428,7 +2428,9 @@ public static void Postfix(PlayerControl __instance, [HarmonyArgument(0)]PlayerC
{
array[i].gameObject.active = false;
}
}
}
DeadPlayer deadPlayerEntry = deadPlayers.Where(x => x.player.PlayerId == target.PlayerId).FirstOrDefault();
if (deadPlayerEntry != null) deadPlayers.Remove(deadPlayerEntry);
}
else
{
Expand Down Expand Up @@ -2910,8 +2912,9 @@ public static bool Prefix(PlayerControl __instance)
DestroyableSingleton<HudManager>.Instance.SetHudActive(true);
DestroyableSingleton<HudManager>.Instance.Chat.ForceClosed();
DestroyableSingleton<HudManager>.Instance.Chat.SetVisible(false);
}

}
DeadPlayer deadPlayerEntry = deadPlayers.Where(x => x.player.PlayerId == __instance.PlayerId).FirstOrDefault();
if (deadPlayerEntry != null) deadPlayers.Remove(deadPlayerEntry);
return false;
}
}
Expand Down
Binary file added TheOtherRoles/Resources/Contributors/TAIK.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions TheOtherRoles/Resources/stringData.json
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,10 @@
"11": "\u4e00\u7dd2\u306b\u697d\u3057\u304fAmong Us\u3092\u3084\u308a\u307e\u3057\u3087\u3046!",
"13": "\u8ba9\u6211\u4eec\u4e00\u8d77\u5f00\u5fc3\u5730\u505a Among Us \u5427\uff01"
},
"mainMenuTAIKAboutSection": {
"0": "The wind and the seeds of the story bring the prologue",
"13": "\u98ce\u4e0e\u6545\u4e8b\u7684\u79cd\u5b50\u5e26\u6765\u7684\u5e8f\u5e55"
},
"mainMenuDeveloper": {
"0": "Developer",
"11": "\u958b\u767a\u8005",
Expand Down

0 comments on commit e8e5383

Please sign in to comment.