mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
Try fixing lag
This commit is contained in:
1 parent
ab8bd822f3
commit
b4ba5c0f4b
5 files changed
+64
-41
No files matched your search
@@ -108,6 +108,7 @@ public static class DevManager
|
||||
new(code: "pocketdoor#9080", color: "null", tag: "null", isUp: true, deBug: false), // Imnot
|
||||
new(code: "motorstack#2287", color: "#E34234", tag: "Foxfire", isUp: true, deBug: false), // Esrazraft
|
||||
new(code: "motorlace#4741", color: "#DFB722", tag: "\u2756 Assistant Tester \u2756", isUp: true, deBug: false), // PEPPERcula
|
||||
new(code: "keyrunning#8720", color: "#00ffff", tag: "Miku", isUp: true, deBug: false), // EverMortal_1455
|
||||
|
||||
// Sponsor
|
||||
new(code: "recentduct#6068", color: "#FF00FF", tag: "高冷男模法师", isUp: false, deBug: true),
|
||||
|
||||
+8
-37
@@ -55,6 +55,8 @@ public static class Utils
|
||||
private static long LastNotifyRolesErrorTS = TimeStamp;
|
||||
|
||||
public static long GameStartTimeStamp;
|
||||
|
||||
public static readonly Dictionary<byte, (string Text, int Duration, bool Long)> LongRoleDescriptions = [];
|
||||
public static long TimeStamp => (long)(DateTime.Now.ToUniversalTime() - TimeStampStartTime).TotalSeconds;
|
||||
public static bool DoRPC => AmongUsClient.Instance.AmHost && Main.AllPlayerControls.Any(x => x.IsModClient() && !x.IsHost());
|
||||
public static int TotalTaskCount => Main.RealOptionsData.GetInt(Int32OptionNames.NumCommonTasks) + Main.RealOptionsData.GetInt(Int32OptionNames.NumLongTasks) + Main.RealOptionsData.GetInt(Int32OptionNames.NumShortTasks);
|
||||
@@ -2064,48 +2066,17 @@ public static class Utils
|
||||
}
|
||||
else
|
||||
{
|
||||
var longInfo = seer.GetRoleInfo(InfoLong: true).Split("\n\n")[0];
|
||||
if (longInfo.Contains("):\n")) longInfo = longInfo.Split("):\n")[1];
|
||||
bool tooLong = false;
|
||||
bool showLongInfo = Options.ShowLongInfo.GetBool();
|
||||
if (showLongInfo)
|
||||
{
|
||||
if (longInfo.Length > 296)
|
||||
{
|
||||
longInfo = longInfo[..296];
|
||||
longInfo += "...";
|
||||
tooLong = true;
|
||||
}
|
||||
|
||||
for (int i = 50; i < longInfo.Length; i += 50)
|
||||
{
|
||||
if (tooLong && i > 296) break;
|
||||
int index = longInfo.LastIndexOf(' ', i);
|
||||
if (index != -1) longInfo = longInfo.Insert(index + 1, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
longInfo = $"<#ffffff>{longInfo}</color>";
|
||||
|
||||
if (showLongInfo)
|
||||
{
|
||||
var lines = longInfo.Count(x => x == '\n');
|
||||
var readTime = 30 + (lines * 5);
|
||||
|
||||
if (GameStartTimeStamp + readTime <= now)
|
||||
showLongInfo = false;
|
||||
}
|
||||
|
||||
var mHelp = (!showLongInfo || tooLong) && Options.CurrentGameMode == CustomGameMode.Standard ? "\n" + GetString("MyRoleCommandHelp") : string.Empty;
|
||||
var showLongInfo = LongRoleDescriptions.TryGetValue(seer.PlayerId, out var description) && GameStartTimeStamp + description.Duration > now;
|
||||
var mHelp = (!showLongInfo || description.Long) && Options.CurrentGameMode == CustomGameMode.Standard ? "\n" + GetString("MyRoleCommandHelp") : string.Empty;
|
||||
|
||||
SeerRealName = !Options.ChangeNameToRoleInfo.GetBool()
|
||||
? SeerRealName
|
||||
: seerTeam switch
|
||||
{
|
||||
Team.Impostor when seer.IsMadmate() => $"<size=150%><color=#ff1919>{GetString("YouAreMadmate")}</size></color>\n<size=90%>{(showLongInfo ? longInfo : seer.GetRoleInfo()) + mHelp}</size>",
|
||||
Team.Impostor => $"\n<size=90%>{(showLongInfo ? longInfo : seer.GetRoleInfo()) + mHelp}</size>",
|
||||
Team.Crewmate => $"<size=150%><color=#8cffff>{GetString("YouAreCrewmate")}</size></color>\n<size=90%>{(showLongInfo ? longInfo : seer.GetRoleInfo()) + mHelp}</size>",
|
||||
Team.Neutral => $"<size=150%><color=#ffab1b>{GetString("YouAreNeutral")}</size></color>\n<size=90%>{(showLongInfo ? longInfo : seer.GetRoleInfo()) + mHelp}</size>",
|
||||
Team.Impostor when seer.IsMadmate() => $"<size=150%><color=#ff1919>{GetString("YouAreMadmate")}</size></color>\n<size=90%>{(showLongInfo ? description.Text : seer.GetRoleInfo()) + mHelp}</size>",
|
||||
Team.Impostor => $"\n<size=90%>{(showLongInfo ? description.Text : seer.GetRoleInfo()) + mHelp}</size>",
|
||||
Team.Crewmate => $"<size=150%><color=#8cffff>{GetString("YouAreCrewmate")}</size></color>\n<size=90%>{(showLongInfo ? description.Text : seer.GetRoleInfo()) + mHelp}</size>",
|
||||
Team.Neutral => $"<size=150%><color=#ffab1b>{GetString("YouAreNeutral")}</size></color>\n<size=90%>{(showLongInfo ? description.Text : seer.GetRoleInfo()) + mHelp}</size>",
|
||||
_ => SeerRealName
|
||||
};
|
||||
}
|
||||
|
||||
@@ -358,6 +358,46 @@ internal class ChangeRoleSettings
|
||||
MeetingStates.MeetingCalled = false;
|
||||
MeetingStates.FirstMeeting = true;
|
||||
GameStates.AlreadyDied = false;
|
||||
|
||||
try
|
||||
{
|
||||
Utils.LongRoleDescriptions.Clear();
|
||||
|
||||
foreach (var seer in Main.AllPlayerControls)
|
||||
{
|
||||
var longInfo = seer.GetRoleInfo(InfoLong: true).Split("\n\n")[0];
|
||||
if (longInfo.Contains("):\n")) longInfo = longInfo.Split("):\n")[1];
|
||||
bool tooLong = false;
|
||||
bool showLongInfo = Options.ShowLongInfo.GetBool();
|
||||
if (showLongInfo)
|
||||
{
|
||||
if (longInfo.Length > 296)
|
||||
{
|
||||
longInfo = longInfo[..296];
|
||||
longInfo += "...";
|
||||
tooLong = true;
|
||||
}
|
||||
|
||||
for (int i = 50; i < longInfo.Length; i += 50)
|
||||
{
|
||||
if (tooLong && i > 296) break;
|
||||
int index = longInfo.LastIndexOf(' ', i);
|
||||
if (index != -1) longInfo = longInfo.Insert(index + 1, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
longInfo = $"<#ffffff>{longInfo}</color>";
|
||||
|
||||
var lines = longInfo.Count(x => x == '\n');
|
||||
var readTime = 30 + (lines * 5);
|
||||
|
||||
Utils.LongRoleDescriptions[seer.PlayerId] = (longInfo, readTime, tooLong);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.ThrowException(e);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -1170,8 +1170,8 @@ static class FixedUpdatePatch
|
||||
public static void Postfix(PlayerControl __instance)
|
||||
{
|
||||
if (__instance == null || __instance.PlayerId == 255) return;
|
||||
|
||||
if (__instance.PlayerId == PlayerControl.LocalPlayer.PlayerId)
|
||||
|
||||
if (__instance.PlayerId == PlayerControl.LocalPlayer.PlayerId && CustomNetObject.AllObjects.Count > 0)
|
||||
CustomNetObject.FixedUpdate();
|
||||
|
||||
if (__instance.IsAlive())
|
||||
@@ -1275,11 +1275,11 @@ static class FixedUpdatePatch
|
||||
NameNotifyManager.OnFixedUpdate(player);
|
||||
TargetArrow.OnFixedUpdate(player);
|
||||
LocateArrow.OnFixedUpdate(player);
|
||||
AFKDetector.OnFixedUpdate(player);
|
||||
|
||||
if (AmongUsClient.Instance.AmHost)
|
||||
{
|
||||
Camouflage.OnFixedUpdate(player);
|
||||
AFKDetector.OnFixedUpdate(player);
|
||||
}
|
||||
|
||||
if (RPCHandlerPatch.ReportDeadBodyRPCs.Remove(playerId))
|
||||
@@ -1472,7 +1472,7 @@ static class FixedUpdatePatch
|
||||
RoleText.enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bool shouldSeeTargetAddons = playerId == lpId || new[] { PlayerControl.LocalPlayer, player }.All(x => x.Is(Team.Impostor));
|
||||
|
||||
var RoleTextData = GetRoleText(lpId, playerId, seeTargetBetrayalAddons: shouldSeeTargetAddons);
|
||||
|
||||
@@ -462,6 +462,7 @@ static class VentilationSystemDeterioratePatch
|
||||
public static Dictionary<byte, int> LastClosestVent = [];
|
||||
private static readonly Dictionary<byte, bool> LastCanUseVent = [];
|
||||
private static readonly Dictionary<byte, int> LastClosestVentForUpdate = [];
|
||||
private static readonly Dictionary<byte, long> LastVentInteractionCheck = [];
|
||||
|
||||
public static void Postfix(VentilationSystem __instance)
|
||||
{
|
||||
@@ -607,6 +608,16 @@ static class VentilationSystemDeterioratePatch
|
||||
{
|
||||
if (!GameStates.IsInTask || ExileController.Instance) return;
|
||||
|
||||
if (!LastVentInteractionCheck.TryGetValue(pc.PlayerId, out long lastCheck))
|
||||
{
|
||||
LastVentInteractionCheck[pc.PlayerId] = Utils.TimeStamp;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Utils.TimeStamp == lastCheck) return;
|
||||
LastVentInteractionCheck[pc.PlayerId] = Utils.TimeStamp;
|
||||
|
||||
|
||||
int closestVent = pc.GetClosestVent().Id;
|
||||
if (!LastClosestVentForUpdate.TryGetValue(pc.PlayerId, out int lastClosestVent))
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user