mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
fix NotifyRoles & TP spam
This commit is contained in:
1 parent
7188fa533b
commit
70dd39f38f
20 files changed
+35
-42
No files matched your search
@@ -159,8 +159,6 @@ internal static class FreeForAll
|
||||
for (var i = 0; i < teamMembers.Count; i++)
|
||||
foreach (byte id in teamMembers[i])
|
||||
PlayerTeams.Add(id, i);
|
||||
|
||||
LateTask.New(() => Utils.NotifyRoles(NoCache: true, ForceLoop: true), 10f, log: false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ public static class Camouflage
|
||||
yield return null;
|
||||
}
|
||||
|
||||
yield return Utils.NotifyEveryoneAsync(speed: 8);
|
||||
yield return Utils.NotifyEveryoneAsync(speed: 5);
|
||||
}
|
||||
|
||||
public static void RpcSetSkin(PlayerControl target, bool ForceRevert = false, bool RevertToDefault = false, bool GameEnd = false, bool Revive = false)
|
||||
@@ -245,7 +245,7 @@ public static class Camouflage
|
||||
|
||||
if (!IsCamouflage && !pc.IsAlive()) PetsHelper.RpcRemovePet(pc);
|
||||
|
||||
Utils.NotifyRoles(SpecifySeer: pc, NoCache: true);
|
||||
Utils.NotifyRoles(SpecifyTarget: pc, NoCache: true);
|
||||
Utils.NotifyRoles(SpecifySeer: pc);
|
||||
Utils.NotifyRoles(SpecifyTarget: pc);
|
||||
}
|
||||
}
|
||||
@@ -86,6 +86,10 @@ namespace EHR
|
||||
|
||||
public void TP(Vector2 position)
|
||||
{
|
||||
if (Vector2.Distance(Position, position) >= 0.5f)
|
||||
Logger.Info($" Teleport Custom Net Object {GetType().Name} (ID {Id}) to {position} (from {Position})", "CNO.TP");
|
||||
else return;
|
||||
|
||||
playerControl.NetTransform.RpcSnapTo(position);
|
||||
Position = position;
|
||||
}
|
||||
|
||||
@@ -337,8 +337,8 @@ internal static class ExtendedPlayerControl
|
||||
|
||||
Camouflage.RpcSetSkin(player);
|
||||
|
||||
NotifyRoles(SpecifySeer: player, NoCache: true);
|
||||
NotifyRoles(SpecifyTarget: player, NoCache: true);
|
||||
NotifyRoles(SpecifySeer: player);
|
||||
NotifyRoles(SpecifyTarget: player);
|
||||
|
||||
player.SyncSettings();
|
||||
}
|
||||
|
||||
@@ -552,9 +552,7 @@ public static class GuessManager
|
||||
}
|
||||
|
||||
GuessManagerRole.OnGuess(dp, pc);
|
||||
|
||||
Utils.AfterPlayerDeathTasks(dp, true);
|
||||
Utils.NotifyRoles(GameStates.IsMeeting, NoCache: true);
|
||||
|
||||
LateTask.New(() => { Utils.SendMessage(string.Format(GetString("GuessKill"), Name), 255, Utils.ColorString(Utils.GetRoleColor(CustomRoles.NiceGuesser), GetString("GuessKillTitle"))); }, 0.6f, "Guess Msg");
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ static class ExitGamePatch
|
||||
if (SetUpRoleTextPatch.IsInIntro)
|
||||
{
|
||||
SetUpRoleTextPatch.IsInIntro = false;
|
||||
Utils.NotifyRoles(NoCache: true);
|
||||
Utils.NotifyRoles(ForceLoop: true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+16
-6
@@ -143,7 +143,12 @@ public static class Utils
|
||||
if (pc.inVent || pc.inMovingPlat || pc.onLadder || !pc.IsAlive() || pc.MyPhysics.Animations.IsPlayingAnyLadderAnimation() || pc.MyPhysics.Animations.IsPlayingEnterVentAnimation())
|
||||
{
|
||||
if (log) Logger.Warn($"Target ({pc.GetNameWithRole().RemoveHtmlTags()}) is in an un-teleportable state - Teleporting canceled", "TP");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Vector2.Distance(pc.Pos(), location) < 0.5f)
|
||||
{
|
||||
if (log) Logger.Warn($"Target ({pc.GetNameWithRole().RemoveHtmlTags()}) is too close to the destination - Teleporting canceled", "TP");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1956,7 +1961,7 @@ public static class Utils
|
||||
{
|
||||
foreach (PlayerControl target in aapc)
|
||||
{
|
||||
NotifyRoles(SpecifySeer: seer, SpecifyTarget: target);
|
||||
NotifyRoles(SpecifySeer: seer, SpecifyTarget: target, NoCache: true);
|
||||
if (count++ % speed == 0) yield return null;
|
||||
}
|
||||
}
|
||||
@@ -2063,7 +2068,8 @@ public static class Utils
|
||||
}
|
||||
|
||||
var fontSize = "1.7";
|
||||
if (isForMeeting && (seer.GetClient().PlatformData.Platform == Platforms.Playstation || seer.GetClient().PlatformData.Platform == Platforms.Switch)) fontSize = "70%";
|
||||
if (isForMeeting && (seer.GetClient().PlatformData.Platform == Platforms.Playstation || seer.GetClient().PlatformData.Platform == Platforms.Switch))
|
||||
fontSize = "70%";
|
||||
|
||||
// Text containing progress, such as tasks
|
||||
string SelfTaskText = GameStates.IsLobby ? string.Empty : GetProgressText(seer);
|
||||
@@ -2291,7 +2297,8 @@ public static class Utils
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((IsActive(SystemTypes.MushroomMixupSabotage) || MushroomMixup) && target.IsAlive() && !seer.Is(CustomRoleTypes.Impostor) && Main.ResetCamPlayerList.Contains(seer.PlayerId)) { target.RpcSetNamePrivate("<size=0%>", force: NoCache); }
|
||||
if ((IsActive(SystemTypes.MushroomMixupSabotage) || MushroomMixup) && target.IsAlive() && !seer.Is(CustomRoleTypes.Impostor) && Main.ResetCamPlayerList.Contains(seer.PlayerId))
|
||||
target.RpcSetNamePrivate("<size=0%>", force: NoCache);
|
||||
else
|
||||
{
|
||||
TargetMark.Clear();
|
||||
@@ -2411,18 +2418,21 @@ public static class Utils
|
||||
|
||||
if (!CustomGameMode.Standard.IsActiveOrIntegrated()) goto BeforeEnd;
|
||||
|
||||
if (GuesserIsForMeeting || isForMeeting || (seerRole == CustomRoles.Mafia && !seer.IsAlive() && Options.MafiaCanKillNum.GetInt() >= 1)) TargetPlayerName = $"{ColorString(GetRoleColor(seerRole), target.PlayerId.ToString())} {TargetPlayerName}";
|
||||
if (GuesserIsForMeeting || isForMeeting || (seerRole == CustomRoles.Mafia && !seer.IsAlive() && Options.MafiaCanKillNum.GetInt() >= 1))
|
||||
TargetPlayerName = $"{ColorString(GetRoleColor(seerRole), target.PlayerId.ToString())} {TargetPlayerName}";
|
||||
|
||||
switch (seerRole)
|
||||
{
|
||||
case CustomRoles.EvilTracker:
|
||||
TargetMark.Append(EvilTracker.GetTargetMark(seer, target));
|
||||
if (isForMeeting && EvilTracker.IsTrackTarget(seer, target) && EvilTracker.CanSeeLastRoomInMeeting) TargetRoleText = $"<size={fontSize}>{EvilTracker.GetArrowAndLastRoom(seer, target)}</size>\r\n";
|
||||
if (isForMeeting && EvilTracker.IsTrackTarget(seer, target) && EvilTracker.CanSeeLastRoomInMeeting)
|
||||
TargetRoleText = $"<size={fontSize}>{EvilTracker.GetArrowAndLastRoom(seer, target)}</size>\r\n";
|
||||
|
||||
break;
|
||||
case CustomRoles.Scout:
|
||||
TargetMark.Append(Scout.GetTargetMark(seer, target));
|
||||
if (isForMeeting && Scout.IsTrackTarget(seer, target) && Scout.CanSeeLastRoomInMeeting) TargetRoleText = $"<size={fontSize}>{Scout.GetArrowAndLastRoom(seer, target)}</size>\r\n";
|
||||
if (isForMeeting && Scout.IsTrackTarget(seer, target) && Scout.CanSeeLastRoomInMeeting)
|
||||
TargetRoleText = $"<size={fontSize}>{Scout.GetArrowAndLastRoom(seer, target)}</size>\r\n";
|
||||
|
||||
break;
|
||||
case CustomRoles.Psychic when seer.IsAlive() && Psychic.IsRedForPsy(target, seer) && isForMeeting:
|
||||
|
||||
@@ -1194,10 +1194,11 @@ internal static class ChatCommands
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (PlayerControl pc in Main.AllAlivePlayerControls) pc.RpcSetNameEx(pc.GetRealName(true));
|
||||
foreach (PlayerControl pc in Main.AllAlivePlayerControls)
|
||||
pc.RpcSetNameEx(pc.GetRealName(true));
|
||||
|
||||
ChatUpdatePatch.DoBlockChat = false;
|
||||
Utils.NotifyRoles(GameStates.IsMeeting, NoCache: true);
|
||||
Utils.NotifyRoles(isForMeeting: GameStates.IsMeeting, ForceLoop: true);
|
||||
Utils.SendMessage(GetString("Message.TryFixName"), player.PlayerId);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ internal static class GameEndChecker
|
||||
if (WinnerTeam != CustomWinner.Default)
|
||||
{
|
||||
NameNotifyManager.Reset();
|
||||
NotifyRoles(NoCache: true);
|
||||
NotifyRoles(ForceLoop: true);
|
||||
|
||||
Main.AllPlayerControls.Do(pc => Camouflage.RpcSetSkin(pc, true, true, true));
|
||||
|
||||
|
||||
@@ -154,8 +154,8 @@ internal static class ExileControllerWrapUpPatch
|
||||
Main.AfterMeetingDeathPlayers.Clear();
|
||||
Utils.AfterMeetingTasks();
|
||||
Utils.SyncAllSettings();
|
||||
Utils.NotifyRoles(NoCache: true);
|
||||
Utils.CheckAndSetVentInteractions();
|
||||
Main.Instance.StartCoroutine(Utils.NotifyEveryoneAsync(speed: 5));
|
||||
}
|
||||
}, 2f, "AntiBlackout Reset & AfterMeetingTasks");
|
||||
}
|
||||
|
||||
@@ -853,7 +853,6 @@ internal static class CoShowIntroPatch
|
||||
IntroStarted = true;
|
||||
|
||||
Utils.SetupLongRoleDescriptions();
|
||||
Main.Instance.StartCoroutine(Utils.NotifyEveryoneAsync(speed: 10));
|
||||
|
||||
LateTask.New(() =>
|
||||
{
|
||||
|
||||
@@ -18,9 +18,7 @@ internal static class SetUpRoleTextPatch
|
||||
|
||||
public static void Postfix(IntroCutscene __instance)
|
||||
{
|
||||
// After showing team for non-modded clients, update player names.
|
||||
IsInIntro = false;
|
||||
Utils.DoNotifyRoles(NoCache: true);
|
||||
|
||||
PlayerControl lp = PlayerControl.LocalPlayer;
|
||||
|
||||
@@ -822,8 +820,6 @@ internal static class IntroCutsceneDestroyPatch
|
||||
pc.AddAbilityCD(10);
|
||||
else
|
||||
pc.AddAbilityCD(false);
|
||||
|
||||
Utils.NotifyRoles(SpecifySeer: pc, SpecifyTarget: pc, NoCache: true);
|
||||
}
|
||||
|
||||
if (CustomGameMode.Standard.IsActiveOrIntegrated())
|
||||
|
||||
@@ -57,7 +57,6 @@ internal static class CheckForEndVotingPatch
|
||||
Main.MadmateNum++;
|
||||
pc.RpcSetCustomRole(CustomRoles.Madmate);
|
||||
ExtendedPlayerControl.RpcSetCustomRole(pc.PlayerId, CustomRoles.Madmate);
|
||||
Utils.NotifyRoles(true, pc, NoCache: true);
|
||||
Logger.Info($"Set role: {pc.Data?.PlayerName} => {pc.GetCustomRole()} + {CustomRoles.Madmate}", $"Assign {CustomRoles.Madmate}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -729,7 +729,7 @@ internal static class MurderPlayerPatch
|
||||
{
|
||||
__instance.MarkDirtySettings();
|
||||
target.MarkDirtySettings();
|
||||
Main.Instance.StartCoroutine(NotifyEveryoneAsync(speed: 12));
|
||||
Main.Instance.StartCoroutine(NotifyEveryoneAsync(speed: 4));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -834,7 +834,7 @@ internal static class ShapeshiftPatch
|
||||
|
||||
// Forced rewriting in case the name cannot be corrected due to the timing of canceling the transformation being off.
|
||||
if (!shapeshifting && !shapeshifter.Is(CustomRoles.Glitch) && isSSneeded)
|
||||
LateTask.New(() => NotifyRoles(NoCache: true), 1.2f, "ShapeShiftNotify");
|
||||
LateTask.New(() => Main.Instance.StartCoroutine(NotifyEveryoneAsync(speed: 3)), 1.2f, "ShapeShiftNotify");
|
||||
|
||||
if (!(shapeshifting && doSSwithoutAnim) && !isSSneeded && !Swapster.FirstSwapTarget.ContainsKey(shapeshifter.PlayerId))
|
||||
LateTask.New(shapeshifter.RpcResetAbilityCooldown, 0.01f, log: false);
|
||||
@@ -1174,7 +1174,7 @@ internal static class ReportDeadBodyPatch
|
||||
MeetingTimeManager.OnReportDeadBody();
|
||||
|
||||
NameNotifyManager.Reset();
|
||||
NotifyRoles(true, NoCache: true, CamouflageIsForMeeting: true, GuesserIsForMeeting: true);
|
||||
NotifyRoles(isForMeeting: true, ForceLoop: true, CamouflageIsForMeeting: true, GuesserIsForMeeting: true);
|
||||
|
||||
LateTask.New(SyncAllSettings, 3f, "SyncAllSettings on meeting start");
|
||||
|
||||
|
||||
@@ -326,7 +326,7 @@ internal static class OnPlayerLeftPatch
|
||||
catch (Exception ex) { Logger.Error(ex.ToString(), "OnPlayerLeftPatch.Postfix"); }
|
||||
finally
|
||||
{
|
||||
Utils.NotifyRoles(NoCache: true);
|
||||
Utils.NotifyRoles(ForceLoop: true);
|
||||
ChatUpdatePatch.DoBlockChat = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,8 +351,6 @@ internal static class ShipStatusBeginPatch
|
||||
|
||||
GameData.Instance.RecomputeTaskCounts();
|
||||
TaskState.InitialTotalTasks = GameData.Instance.TotalTasks;
|
||||
|
||||
Utils.DoNotifyRoles(ForceLoop: true, NoCache: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,8 +233,6 @@ public class Judge : RoleBase
|
||||
|
||||
Utils.AfterPlayerDeathTasks(dp, true);
|
||||
|
||||
Utils.NotifyRoles(NoCache: true);
|
||||
|
||||
LateTask.New(() => { Utils.SendMessage(string.Format(GetString("TrialKill"), Name), 255, Utils.ColorString(Utils.GetRoleColor(CustomRoles.NiceGuesser), GetString("TrialKillTitle"))); }, 0.6f, "Guess Msg");
|
||||
}, 0.2f, "Trial Kill");
|
||||
}
|
||||
|
||||
@@ -166,8 +166,6 @@ public class NiceSwapper : RoleBase
|
||||
pc.ShowPopUp(GetString("CantSwapSelf"));
|
||||
}
|
||||
|
||||
LateTask.New(() => Utils.NotifyRoles(true, NoCache: true), 0.2f, "NiceSwapperNotifyRoles");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,8 +224,6 @@ public class Councillor : RoleBase
|
||||
|
||||
Utils.AfterPlayerDeathTasks(dp, true);
|
||||
|
||||
Utils.NotifyRoles(NoCache: true);
|
||||
|
||||
LateTask.New(() => Utils.SendMessage(string.Format(GetString("MurderKill"), Name), 255, Utils.ColorString(Utils.GetRoleColor(CustomRoles.NiceGuesser), GetString("MurderKillTitle"))), 0.6f, "Guess Msg");
|
||||
}, 0.2f, "Murder Kill");
|
||||
}
|
||||
|
||||
@@ -162,11 +162,7 @@ internal class Mafia : RoleBase
|
||||
if (GameStates.IsMeeting)
|
||||
{
|
||||
target.RpcGuesserMurderPlayer();
|
||||
|
||||
//死者检查
|
||||
Utils.AfterPlayerDeathTasks(target, true);
|
||||
|
||||
Utils.NotifyRoles(GameStates.IsMeeting, NoCache: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user