mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
4e73fb4dc2
9 files changed
+40
-17
No files matched your search
@@ -606,7 +606,7 @@ public static class BedWars
|
||||
|
||||
public static bool IsNotInLocalPlayersTeam(PlayerControl pc)
|
||||
{
|
||||
return !Data.TryGetValue(pc.PlayerId, out PlayerData data) || !Data.TryGetValue(PlayerControl.LocalPlayer.PlayerId, out PlayerData lpData) || data.Team != lpData.Team;
|
||||
return ExtendedPlayerControl.IsValidTargetForKillButton(pc) && (!Data.TryGetValue(pc.PlayerId, out PlayerData data) || !Data.TryGetValue(PlayerControl.LocalPlayer.PlayerId, out PlayerData lpData) || data.Team != lpData.Team);
|
||||
}
|
||||
|
||||
//[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.FixedUpdate))]
|
||||
|
||||
@@ -496,7 +496,7 @@ public static class CaptureTheFlag
|
||||
|
||||
public static bool IsNotInLocalPlayersTeam(PlayerControl pc)
|
||||
{
|
||||
return !PlayerTeams.TryGetValue(pc.PlayerId, out CTFTeam team) || !PlayerTeams.TryGetValue(PlayerControl.LocalPlayer.PlayerId, out CTFTeam lpTeam) || team != lpTeam;
|
||||
return ExtendedPlayerControl.IsValidTargetForKillButton(pc) && (!PlayerTeams.TryGetValue(pc.PlayerId, out CTFTeam team) || !PlayerTeams.TryGetValue(PlayerControl.LocalPlayer.PlayerId, out CTFTeam lpTeam) || team != lpTeam);
|
||||
}
|
||||
|
||||
private static void SendRPC()
|
||||
|
||||
@@ -649,7 +649,7 @@ public static class KingOfTheZones
|
||||
|
||||
public static bool IsNotInLocalPlayersTeam(PlayerControl pc)
|
||||
{
|
||||
return !PlayerTeams.TryGetValue(pc.PlayerId, out KOTZTeam team) || !PlayerTeams.TryGetValue(PlayerControl.LocalPlayer.PlayerId, out KOTZTeam lpTeam) || team != lpTeam;
|
||||
return ExtendedPlayerControl.IsValidTargetForKillButton(pc) && (!PlayerTeams.TryGetValue(pc.PlayerId, out KOTZTeam team) || !PlayerTeams.TryGetValue(PlayerControl.LocalPlayer.PlayerId, out KOTZTeam lpTeam) || team != lpTeam);
|
||||
}
|
||||
|
||||
private static void SendRPC()
|
||||
|
||||
@@ -1122,9 +1122,10 @@ internal static class ExtendedPlayerControl
|
||||
return pc.IsModdedClient() && !pc.IsHost();
|
||||
}
|
||||
|
||||
public static string GetDisplayRoleName(this PlayerControl player, bool pure = false, bool seeTargetBetrayalAddons = false)
|
||||
public static string GetDisplayRoleName(this PlayerControl player, PlayerControl target = null, bool pure = false, bool seeTargetBetrayalAddons = false)
|
||||
{
|
||||
return Utils.GetDisplayRoleName(player.PlayerId, pure, seeTargetBetrayalAddons);
|
||||
if (!target) target = player;
|
||||
return Utils.GetDisplayRoleName(player.PlayerId, targetId: target.PlayerId, pure: pure, seeTargetBetrayalAddons: seeTargetBetrayalAddons);
|
||||
}
|
||||
|
||||
public static string GetSubRoleNames(this PlayerControl player, bool forUser = false)
|
||||
@@ -2135,6 +2136,22 @@ internal static class ExtendedPlayerControl
|
||||
return player.AmOwner || player.IsHost() || Main.PlayerVersion.ContainsKey(player.PlayerId);
|
||||
}
|
||||
|
||||
public static bool IsValidTargetForKillButton(PlayerControl target)
|
||||
{
|
||||
// Code from AU code for kill button check target, without distance check but check colliders
|
||||
if (PlayerControl.LocalPlayer.Data.Role.IsValidTarget(target.Data) && target.Collider.enabled)
|
||||
{
|
||||
Vector2 lpPos = PlayerControl.LocalPlayer.GetTruePosition();
|
||||
Vector2 vector = target.GetTruePosition() - lpPos;
|
||||
float magnitude = vector.magnitude;
|
||||
if (!PhysicsHelpers.AnyNonTriggersBetween(lpPos, vector.normalized, magnitude, Constants.ShipAndObjectsMask))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static List<PlayerControl> GetPlayersInAbilityRangeSorted(this PlayerControl player, bool ignoreColliders = false)
|
||||
{
|
||||
return player.GetPlayersInAbilityRangeSorted(_ => true, ignoreColliders);
|
||||
|
||||
@@ -64,12 +64,17 @@ public static class FixedUpdateCaller
|
||||
Predicate<PlayerControl> predicate = amongUsClient.AmHost
|
||||
? Options.CurrentGameMode switch
|
||||
{
|
||||
CustomGameMode.Standard => ExtendedPlayerControl.IsValidTargetForKillButton,
|
||||
CustomGameMode.BedWars => BedWars.IsNotInLocalPlayersTeam,
|
||||
CustomGameMode.CaptureTheFlag => CaptureTheFlag.IsNotInLocalPlayersTeam,
|
||||
CustomGameMode.KingOfTheZones => KingOfTheZones.IsNotInLocalPlayersTeam,
|
||||
_ => _ => true
|
||||
}
|
||||
: _ => true;
|
||||
: Options.CurrentGameMode switch
|
||||
{
|
||||
CustomGameMode.Standard => ExtendedPlayerControl.IsValidTargetForKillButton,
|
||||
_ => _ => true
|
||||
};
|
||||
|
||||
PlayerControl closest = FastVector2.TryGetClosestPlayerInRangeTo(PlayerControl.LocalPlayer, GameManager.Instance.LogicOptions.GetKillDistance(), out PlayerControl closestPlayer, predicate) ? closestPlayer : null;
|
||||
|
||||
|
||||
+6
-5
@@ -428,9 +428,10 @@ public static class Utils
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetDisplayRoleName(byte playerId, bool pure = false, bool seeTargetBetrayalAddons = false)
|
||||
public static string GetDisplayRoleName(byte playerId, byte targetId = byte.MaxValue, bool pure = false, bool seeTargetBetrayalAddons = false)
|
||||
{
|
||||
(string, Color) textData = GetRoleText(playerId, playerId, pure, seeTargetBetrayalAddons);
|
||||
if (targetId == byte.MaxValue) targetId = playerId;
|
||||
(string, Color) textData = GetRoleText(playerId, targetId, pure, seeTargetBetrayalAddons);
|
||||
return ColorString(textData.Item2, textData.Item1);
|
||||
}
|
||||
|
||||
@@ -3087,7 +3088,7 @@ public static class Utils
|
||||
|
||||
string targetRoleText =
|
||||
KnowsTargetRole(seer, target)
|
||||
? $"<size={fontSize}>{GetRoleText(seer.PlayerId, target.PlayerId, seeTargetBetrayalAddons: shouldSeeTargetAddons)}{GetProgressText(target)}</size>\r\n"
|
||||
? $"<size={fontSize}>{GetDisplayRoleName(seer.PlayerId, target.PlayerId, seeTargetBetrayalAddons: shouldSeeTargetAddons)}{GetProgressText(target)}</size>\r\n"
|
||||
: string.Empty;
|
||||
|
||||
if (IsRevivingRoleAlive() && Main.DiedThisRound.Contains(seer.PlayerId))
|
||||
@@ -4170,7 +4171,7 @@ public static class Utils
|
||||
else
|
||||
taskCount = string.Empty;
|
||||
|
||||
var summary = $"{ColorString(Main.PlayerColors[id], name)} - {GetDisplayRoleName(id, true)}{taskCount}{GetKillCountText(id)} ({GetVitalText(id, true)})";
|
||||
var summary = $"{ColorString(Main.PlayerColors[id], name)} - {GetDisplayRoleName(id, pure: true)}{taskCount}{GetKillCountText(id)} ({GetVitalText(id, true)})";
|
||||
|
||||
CustomTeamManager.CustomTeam customTeam = CustomTeamManager.GetCustomTeam(id);
|
||||
if (customTeam != null) summary += $" ({ColorString(customTeam.RoleRevealScreenBackgroundColor == "*" || !ColorUtility.TryParseHtmlString(customTeam.RoleRevealScreenBackgroundColor, out Color color) ? Color.yellow : color, customTeam.RoleRevealScreenTitle == "*" ? customTeam.TeamName : customTeam.RoleRevealScreenTitle)})";
|
||||
@@ -4236,7 +4237,7 @@ public static class Utils
|
||||
break;
|
||||
}
|
||||
|
||||
return check && GetDisplayRoleName(id, true).RemoveHtmlTags().Contains("INVALID:NotAssigned")
|
||||
return check && GetDisplayRoleName(id, pure: true).RemoveHtmlTags().Contains("INVALID:NotAssigned")
|
||||
? "INVALID"
|
||||
: disableColor
|
||||
? summary.RemoveHtmlTags()
|
||||
|
||||
@@ -66,13 +66,13 @@ internal static class ControllerManagerUpdatePatch
|
||||
|
||||
if (KeysDown(KeyCode.LeftAlt, KeyCode.Return)) LateTask.New(SetResolutionManager.Postfix, 0.01f, "Fix Button Position");
|
||||
|
||||
if (GameStates.IsInGame && (GameStates.IsCanMove || GameStates.IsMeeting) && Options.CurrentGameMode == CustomGameMode.Standard)
|
||||
if (GameStates.IsInGame && (GameStates.IsCanMove || GameStates.IsMeeting))
|
||||
{
|
||||
// PS4/PS5: Touchpad
|
||||
if (Input.GetKeyDown(KeyCode.JoystickButton13))
|
||||
TaskPanelBehaviourPatch.RolePanelButton.OnClick.Invoke();
|
||||
TaskPanelBehaviourPatch.RolePanelButton?.OnClick.Invoke();
|
||||
|
||||
if (Input.GetKey(KeyCode.F1) || Input.GetKey(KeyCode.JoystickButton11)) // PS4/PS5: R3 Stick
|
||||
if (Options.CurrentGameMode == CustomGameMode.Standard && (Input.GetKey(KeyCode.F1) || Input.GetKey(KeyCode.JoystickButton11))) // PS4/PS5: R3 Stick
|
||||
{
|
||||
if (!InGameRoleInfoMenu.Showing) InGameRoleInfoMenu.SetRoleInfoRef(PlayerControl.LocalPlayer);
|
||||
|
||||
|
||||
@@ -368,7 +368,7 @@ internal static class CheckForEndVotingPatch
|
||||
|
||||
PlayerControl player = exiledPlayer.Object;
|
||||
CustomRoles crole = exiledPlayer.GetCustomRole();
|
||||
string coloredRole = Utils.GetDisplayRoleName(exileId, true, true);
|
||||
string coloredRole = Utils.GetDisplayRoleName(exileId, pure: true, seeTargetBetrayalAddons: true);
|
||||
|
||||
if (crole == CustomRoles.LovingImpostor && !Options.ConfirmLoversOnEject.GetBool())
|
||||
{
|
||||
|
||||
@@ -68,8 +68,8 @@ internal static class EndGamePatch
|
||||
byte killerId = value.GetRealKiller();
|
||||
bool gmIsFm = Options.CurrentGameMode is CustomGameMode.FFA or CustomGameMode.StopAndGo;
|
||||
bool gmIsFmhh = gmIsFm || Options.CurrentGameMode is CustomGameMode.HotPotato or CustomGameMode.HideAndSeek or CustomGameMode.Speedrun or CustomGameMode.CaptureTheFlag or CustomGameMode.NaturalDisasters or CustomGameMode.RoomRush or CustomGameMode.KingOfTheZones or CustomGameMode.Quiz or CustomGameMode.TheMindGame or CustomGameMode.BedWars or CustomGameMode.Deathrace or CustomGameMode.Mingle or CustomGameMode.Snowdown;
|
||||
sb.Append($"\n{secondsIn / 60:00}:{secondsIn % 60:00} {Main.AllPlayerNames[key]} ({(gmIsFmhh ? string.Empty : Utils.GetDisplayRoleName(key, true))}{(gmIsFm ? string.Empty : Utils.GetSubRolesText(key, summary: true))}) [{Utils.GetVitalText(key)}]");
|
||||
if (killerId != byte.MaxValue && killerId != key) sb.Append($"\n\t⇐ {Main.AllPlayerNames[killerId]} ({(gmIsFmhh ? string.Empty : Utils.GetDisplayRoleName(killerId, true))}{(gmIsFm ? string.Empty : Utils.GetSubRolesText(killerId, summary: true))})");
|
||||
sb.Append($"\n{secondsIn / 60:00}:{secondsIn % 60:00} {Main.AllPlayerNames[key]} ({(gmIsFmhh ? string.Empty : Utils.GetDisplayRoleName(key, pure: true))}{(gmIsFm ? string.Empty : Utils.GetSubRolesText(key, summary: true))}) [{Utils.GetVitalText(key)}]");
|
||||
if (killerId != byte.MaxValue && killerId != key) sb.Append($"\n\t⇐ {Main.AllPlayerNames[killerId]} ({(gmIsFmhh ? string.Empty : Utils.GetDisplayRoleName(killerId, pure: true))}{(gmIsFm ? string.Empty : Utils.GetSubRolesText(killerId, summary: true))})");
|
||||
}
|
||||
|
||||
KillLog = sb.Append("</size>").ToString();
|
||||
|
||||
Reference in new issue
Block a user