Skip to content

Commit

Permalink
Update v1.0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mxyx0412 committed Nov 4, 2024
1 parent 415692d commit 1c6159c
Show file tree
Hide file tree
Showing 35 changed files with 485 additions and 239 deletions.
Binary file modified Strings.xlsx
Binary file not shown.
3 changes: 0 additions & 3 deletions TheOtherRoles.sln
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Global
Debug|Any CPU = Debug|Any CPU
mxyx-club|Any CPU = mxyx-club|Any CPU
Release|Any CPU = Release|Any CPU
Sunday|Any CPU = Sunday|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{11FBC798-BAF5-4EE5-9511-BE6DB0592F99}.Beta|Any CPU.ActiveCfg = Beta|Any CPU
Expand All @@ -31,8 +30,6 @@ Global
{11FBC798-BAF5-4EE5-9511-BE6DB0592F99}.mxyx-club|Any CPU.Build.0 = mxyx-club|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
{11FBC798-BAF5-4EE5-9511-BE6DB0592F99}.Sunday|Any CPU.ActiveCfg = Sunday|Any CPU
{11FBC798-BAF5-4EE5-9511-BE6DB0592F99}.Sunday|Any CPU.Build.0 = Sunday|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
91 changes: 43 additions & 48 deletions TheOtherRoles/Buttons/Buttons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,22 @@ private static void setButtonTargetDisplay(PlayerControl target, CustomButton bu
targetDisplay.gameObject.SetActive(true);
}

public static void createRoleSummaryButton(HudManager __instance)
public static void Postfix(HudManager __instance)
{
initialized = false;

try
{
createButtonsPostfix(__instance);
}
catch { }
}

public static void createButtonsPostfix(HudManager __instance)
{
// get map id, or raise error to wait...
var mapId = GameOptionsManager.Instance.currentNormalGameOptions.MapId;

roleSummaryButton = new CustomButton(
() =>
{
Expand All @@ -445,29 +459,32 @@ public static void createRoleSummaryButton(HudManager __instance)
return true;
},
() => { },
UnityHelper.loadSpriteFromResources("TheOtherRoles.Resources.HelpButton.png", 150f),
new ResourceSprite("TheOtherRoles.Resources.HelpButton.png", 85f),
new Vector3(0.4f, 3f, 0),
__instance,
null
);
}

public static void Postfix(HudManager __instance)
{
initialized = false;

try
zoomOutButton = new CustomButton(
() => { toggleZoom(); },
() =>
{
if (!PlayerControl.LocalPlayer.IsDead() || CachedPlayer.LocalPlayer.Data.Role.IsImpostor && !CustomOptionHolder.deadImpsBlockSabotage.getBool()) return false;
var (playerCompleted, playerTotal) = TasksHandler.taskInfo(CachedPlayer.LocalPlayer.Data);
var numberOfLeftTasks = playerTotal - playerCompleted;
return numberOfLeftTasks <= 0 || !CustomOptionHolder.finishTasksBeforeHauntingOrZoomingOut.getBool();
},
() => { return true; },
() => { },
UnityHelper.loadSpriteFromResources("TheOtherRoles.Resources.ZoomOut.png", 85f), // Invisible button!
new Vector3(0.4f, 2.35f, 0f),
__instance,
KeyCode.KeypadPlus
)
{
createButtonsPostfix(__instance);
}
catch { }
}
Timer = 0f
};

public static void createButtonsPostfix(HudManager __instance)
{
// get map id, or raise error to wait...
var mapId = GameOptionsManager.Instance.currentNormalGameOptions.MapId;
createRoleSummaryButton(__instance);
// Engineer Repair
engineerRepairButton = new CustomButton(
() =>
Expand Down Expand Up @@ -1595,7 +1612,8 @@ public static void createButtonsPostfix(HudManager __instance)
modKillInput.keyCode,
false,
0f,
() => { vampireKillButton.Timer = vampireKillButton.MaxTimer; }
() => { vampireKillButton.Timer = vampireKillButton.MaxTimer; },
buttonText: "VampireText".Translate()
);

garlicButton = new CustomButton(
Expand Down Expand Up @@ -1770,7 +1788,7 @@ public static void createButtonsPostfix(HudManager __instance)
Portalmaker.usePortalButtonSprite,
new Vector3(1f, 0f, 0),
__instance,
KeyCode.H,
null,
true,
buttonText: getString("usePortalText")
);
Expand Down Expand Up @@ -1825,7 +1843,7 @@ public static void createButtonsPostfix(HudManager __instance)
Portalmaker.usePortalButtonSprite,
new Vector3(1f, 1f, 0),
__instance,
KeyCode.J,
null,
true
);

Expand Down Expand Up @@ -3452,7 +3470,7 @@ public static void createButtonsPostfix(HudManager __instance)
},
() =>
{
showTargetNameOnButton(null, arsonistButton, getString("WitchText"));
showTargetNameOnButton(null, witchSpellButton, getString("WitchText"));
witchSpellButton.Timer = witchSpellButton.MaxTimer;
witchSpellButton.isEffectActive = false;
Witch.spellCastingTarget = null;
Expand Down Expand Up @@ -3726,10 +3744,9 @@ public static void createButtonsPostfix(HudManager __instance)
ninjaButton.Sprite = Ninja.ninjaMarked != null
? Ninja.killButtonSprite
: Ninja.markButtonSprite;
return (Ninja.currentTarget != null || Ninja.ninjaMarked != null &&
!TransportationToolPatches.isUsingTransportation(
Ninja.ninjaMarked)) && CachedPlayer.LocalPlayer
.PlayerControl.CanMove;
return (Ninja.currentTarget != null || Ninja.ninjaMarked != null
&& !Ninja.ninjaMarked.isUsingTransportation())
&& CachedPlayer.LocalPlayer.PlayerControl.CanMove;
},
() =>
{
Expand Down Expand Up @@ -4058,7 +4075,7 @@ public static void createButtonsPostfix(HudManager __instance)
Yoyo.blinkDuration,
() =>
{
if (TransportationToolPatches.isUsingTransportation(Yoyo.yoyo))
if (Yoyo.yoyo.isUsingTransportation())
{
yoyoButton.Timer = 0.5f;
yoyoButton.DeputyTimer = 0.5f;
Expand Down Expand Up @@ -4133,28 +4150,6 @@ public static void createButtonsPostfix(HudManager __instance)
"AdminMapText".Translate()
);



zoomOutButton = new CustomButton(
() => { toggleZoom(); },
() =>
{
if (CachedPlayer.LocalPlayer.PlayerControl == null || !CachedPlayer.LocalPlayer.Data.IsDead || CachedPlayer.LocalPlayer.Data.Role.IsImpostor && !CustomOptionHolder.deadImpsBlockSabotage.getBool()) return false;
var (playerCompleted, playerTotal) = TasksHandler.taskInfo(CachedPlayer.LocalPlayer.Data);
var numberOfLeftTasks = playerTotal - playerCompleted;
return numberOfLeftTasks <= 0 || !CustomOptionHolder.finishTasksBeforeHauntingOrZoomingOut.getBool();
},
() => { return true; },
() => { },
UnityHelper.loadSpriteFromResources("TheOtherRoles.Resources.MinusButton.png", 180f), // Invisible button!
new Vector3(0.4f, 2.8f, 0),
__instance,
KeyCode.KeypadPlus
)
{
Timer = 0f
};

hunterLighterButton = new CustomButton(
() =>
{
Expand Down
42 changes: 20 additions & 22 deletions TheOtherRoles/Helper/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,23 @@ public enum LogLevel

public static class Helpers
{
public static Dictionary<string, Sprite> CachedSprites = new();

public static bool zoomOutStatus;

public static bool InGame => AmongUsClient.Instance != null && AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Started;
public static bool IsCountDown => GameStartManager.InstanceExists && GameStartManager.Instance.startState == GameStartManager.StartingStates.Countdown;
public static bool IsMeeting => InGame && MeetingHud.Instance;

public static bool InMeeting => InGame && MeetingHud.Instance;
public static bool IsHideNSeek => GameOptionsManager.Instance.currentGameOptions.GameMode == GameModes.HideNSeek;
public static bool isSkeld => GameOptionsManager.Instance.CurrentGameOptions.MapId == 0;
public static bool isMira => GameOptionsManager.Instance.CurrentGameOptions.MapId == 1;
public static bool isPolus => GameOptionsManager.Instance.CurrentGameOptions.MapId == 2;
public static bool isDleks => GameOptionsManager.Instance.CurrentGameOptions.MapId == 3;
public static bool isAirship => GameOptionsManager.Instance.CurrentGameOptions.MapId == 4;
public static bool isFungle => GameOptionsManager.Instance.CurrentGameOptions.MapId == 5;

public static readonly System.Random rnd = new((int)DateTime.Now.Ticks);

public static PlayerControl GetHostPlayer => GameData.Instance.GetHost().Object;
public static bool isUsingTransportation(this PlayerControl pc) => pc.inMovingPlat || pc.onLadder;


/// <summary>
Expand Down Expand Up @@ -343,7 +344,7 @@ public static string teamString(PlayerControl player)

public static void NoCheckStartMeeting(this PlayerControl reporter, GameData.PlayerInfo target, bool force = false)
{
if (IsMeeting) return;
if (InMeeting) return;

handleVampireBiteOnBodyReport();
handleBomberExplodeOnBodyReport();
Expand Down Expand Up @@ -1358,9 +1359,9 @@ public static MurderAttemptResult checkMuderAttempt(PlayerControl killer, Player
return MurderAttemptResult.SuppressKill;
}

if (TransportationToolPatches.isUsingTransportation(target) && !blockRewind && killer == Vampire.vampire)
if (target.isUsingTransportation() && !blockRewind && killer == Vampire.vampire)
return MurderAttemptResult.DelayVampireKill;
if (TransportationToolPatches.isUsingTransportation(target))
if (target.isUsingTransportation())
return MurderAttemptResult.SuppressKill;
return MurderAttemptResult.PerformKill;
}
Expand Down Expand Up @@ -1402,11 +1403,10 @@ public static MurderAttemptResult checkMurderAttemptAndKill(PlayerControl killer
{
HudManager.Instance.StartCoroutine(Effects.Lerp(10f, new Action<float>(p =>
{
if (!TransportationToolPatches.isUsingTransportation(target) && Vampire.bitten != null)
if (!target.isUsingTransportation() && Vampire.bitten != null)
{
var writer = AmongUsClient.Instance.StartRpcImmediately(
CachedPlayer.LocalPlayer.PlayerControl.NetId, (byte)CustomRPC.VampireSetBitten,
SendOption.Reliable);
var writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId,
(byte)CustomRPC.VampireSetBitten, SendOption.Reliable);
writer.Write(byte.MaxValue);
writer.Write(byte.MaxValue);
AmongUsClient.Instance.FinishRpcImmediately(writer);
Expand All @@ -1421,7 +1421,7 @@ public static MurderAttemptResult checkMurderAttemptAndKill(PlayerControl killer
// Kill the Killer
var writer = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId,
(byte)CustomRPC.UncheckedMurderPlayer, SendOption.Reliable);
writer.Write(killer.PlayerId);
writer.Write(BodyGuard.bodyguard.PlayerId);
writer.Write(killer.PlayerId);
writer.Write(showAnimation ? byte.MaxValue : 0);
AmongUsClient.Instance.FinishRpcImmediately(writer);
Expand All @@ -1430,13 +1430,12 @@ public static MurderAttemptResult checkMurderAttemptAndKill(PlayerControl killer
// Kill the BodyGuard
var writer2 = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId,
(byte)CustomRPC.UncheckedMurderPlayer, SendOption.Reliable);
writer2.Write(BodyGuard.bodyguard.PlayerId);
writer2.Write(killer.PlayerId);
writer2.Write(BodyGuard.bodyguard.PlayerId);
writer2.Write(showAnimation ? byte.MaxValue : 0);
AmongUsClient.Instance.FinishRpcImmediately(writer2);
RPCProcedure.uncheckedMurderPlayer(BodyGuard.bodyguard.PlayerId, BodyGuard.bodyguard.PlayerId, 0);


var writer3 = AmongUsClient.Instance.StartRpcImmediately(CachedPlayer.LocalPlayer.PlayerControl.NetId,
(byte)CustomRPC.ShowBodyGuardFlash, SendOption.Reliable);
AmongUsClient.Instance.FinishRpcImmediately(writer3);
Expand Down Expand Up @@ -1482,20 +1481,19 @@ public static void toggleZoom(bool reset = false)
Camera.main.orthographicSize = orthographicSize;
foreach (var cam in Camera.allCameras)
if (cam != null && cam.gameObject.name == "UI Camera")
cam.orthographicSize =
orthographicSize; // The UI is scaled too, else we cant click the buttons. Downside: map is super small.
cam.orthographicSize = orthographicSize;
// The UI is scaled too, else we cant click the buttons. Downside: map is super small.

if (HudManagerStartPatch.zoomOutButton != null)
{
HudManagerStartPatch.zoomOutButton.Sprite = zoomOutStatus
? UnityHelper.loadSpriteFromResources("TheOtherRoles.Resources.PlusButton.png", 60f)
: UnityHelper.loadSpriteFromResources("TheOtherRoles.Resources.MinusButton.png", 150f);
HudManagerStartPatch.zoomOutButton.PositionOffset =
zoomOutStatus ? new Vector3(0f, 3f, 0) : new Vector3(0.4f, 2.8f, 0);
? new ResourceSprite("TheOtherRoles.Resources.ZoomIn.png", 21f)
: new ResourceSprite("TheOtherRoles.Resources.ZoomOut.png", 85f);
HudManagerStartPatch.zoomOutButton.PositionOffset = zoomOutStatus ? new Vector3(-0.82f, 11.5f, 0) : new(0.4f, 2.35f, 0f);
}

ResolutionManager.ResolutionChanged.Invoke((float)Screen.width / Screen.height, Screen.width, Screen.height,
Screen.fullScreen); // This will move button positions to the correct position.
// This will move button positions to the correct position.
ResolutionManager.ResolutionChanged.Invoke((float)Screen.width / Screen.height, Screen.width, Screen.height, Screen.fullScreen);
}

private static long GetBuiltInTicks()
Expand Down
1 change: 1 addition & 0 deletions TheOtherRoles/Helper/UnityHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace TheOtherRoles.Helper;

public static class UnityHelper
{
public static Dictionary<string, Sprite> CachedSprites = new();
public static IRegionInfo CurrentServer => FastDestroyableSingleton<ServerManager>.Instance.CurrentRegion;
public static bool IsCustomServer => CurrentServer.TranslateName
is StringNames.NoTranslation || CurrentServer.TranslateName != StringNames.ServerAS && CurrentServer.TranslateName != StringNames.ServerEU && CurrentServer.TranslateName != StringNames.ServerNA;
Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/Modules/ChatCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private static bool Prefix(ChatController __instance)
// 强制紧急会议或结束会议
else if (chat.StartsWith("/meeting") || chat.StartsWith("/mt"))
{
if (IsMeeting) MeetingHud.Instance.RpcClose();
if (InMeeting) MeetingHud.Instance.RpcClose();
else CachedPlayer.LocalPlayer.PlayerControl.NoCheckStartMeeting(null, true);
handled = true;
}
Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/Modules/KeyboardHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private static void Postfix(KeyboardJoystick __instance)
// 强制开始会议或结束会议
if (Input.GetKey(ModInputManager.metaControlInput.keyCode) && Input.GetKeyDown(ModInputManager.meetingInput.keyCode) && InGame)
{
if (IsMeeting) MeetingHud.Instance.RpcClose();
if (InMeeting) MeetingHud.Instance.RpcClose();
else CachedPlayer.LocalPlayer.PlayerControl.NoCheckStartMeeting(null, true);
}
// 强制结束游戏
Expand Down
2 changes: 2 additions & 0 deletions TheOtherRoles/Modules/ModInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class ModInputManager
public static ModInput modifierAbilityInput;
public static ModInput modKillInput;
public static ModInput showOptionPageInput;
public static ModInput helpInput;
public static ModInput toggleChat;
public static ModInput metaControlInput;
public static ModInput endGameInput;
Expand Down Expand Up @@ -133,6 +134,7 @@ public static void Load()
modifierAbilityInput = new ModInput("modifierAbility", KeyCode.Z);
modKillInput = new ModInput("kill", KeyCode.Q);
showOptionPageInput = new ModInput("showOptionPage", KeyCode.F1);
helpInput = new ModInput("help", KeyCode.H);
toggleChat = new ModInput("toggleChat", KeyCode.F2);
screenResolution = new ModInput("screenResolution", KeyCode.F11);
metaControlInput = new ModInput("metaControl", KeyCode.LeftControl);
Expand Down
2 changes: 1 addition & 1 deletion TheOtherRoles/Objects/Portal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public Portal(Vector2 p)
if (firstPortal == null) firstPortal = this;
else if (secondPortal == null) secondPortal = this;
var lastRoom = FastDestroyableSingleton<HudManager>.Instance?.roomTracker?.LastRoom.RoomId;
room = lastRoom != null ? DestroyableSingleton<TranslationController>.Instance.GetString((SystemTypes)lastRoom) : "Open Field";
room = lastRoom != null ? DestroyableSingleton<TranslationController>.Instance.GetString((SystemTypes)lastRoom) : "室外";
}

public static Sprite getFgAnimationSprite(int index)
Expand Down
Loading

0 comments on commit 1c6159c

Please sign in to comment.