mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
maybe one of these roles caused lag?!
This commit is contained in:
1 parent
35e0dd4186
commit
b4150add1b
9 files changed
+34
-32
No files matched your search
@@ -69,6 +69,7 @@ internal static class CustomRolesHelper
|
||||
CustomRoles.Ritualist => new EvilDiviner(),
|
||||
CustomRoles.Wraith => new Swooper(),
|
||||
CustomRoles.Goose => new Penguin(),
|
||||
CustomRoles.Monitor => new AntiAdminer(),
|
||||
|
||||
// Else, the role class is the role name - if the class doesn't exist, it defaults to VanillaRole
|
||||
_ => Main.AllRoleClasses.FirstOrDefault(x => x.GetType().Name.Equals(role.ToString(), StringComparison.OrdinalIgnoreCase)) ?? new VanillaRole()
|
||||
@@ -753,6 +754,10 @@ internal static class CustomRolesHelper
|
||||
|
||||
public static bool IsImpOnlyAddon(this CustomRoles role) => Options.GroupedAddons[AddonTypes.ImpOnly].Contains(role);
|
||||
|
||||
public static bool NeedsUpdateAfterDeath(this CustomRoles role) => role is
|
||||
CustomRoles.Altruist or
|
||||
CustomRoles.Duellist;
|
||||
|
||||
public static bool IsTaskBasedCrewmate(this CustomRoles role) => role is
|
||||
CustomRoles.Snitch or
|
||||
CustomRoles.Speedrunner or
|
||||
|
||||
@@ -435,10 +435,6 @@ static class CheckMurderPatch
|
||||
if (SoulHunter.IsSoulHunterTarget(killer.PlayerId) && target.Is(CustomRoles.SoulHunter))
|
||||
{
|
||||
Notify("SoulHunterTargetNotifyNoKill");
|
||||
LateTask.New(() =>
|
||||
{
|
||||
if (SoulHunter.IsSoulHunterTarget(killer.PlayerId)) killer.Notify(string.Format(GetString("SoulHunterTargetNotify"), SoulHunter.GetSoulHunter(killer.PlayerId).SoulHunter_.GetRealName()), 300f);
|
||||
}, 4f, log: false);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -927,10 +923,6 @@ static class ReportDeadBodyPatch
|
||||
if (SoulHunter.IsSoulHunterTarget(__instance.PlayerId))
|
||||
{
|
||||
__instance.Notify(GetString("SoulHunterTargetNotifyNoMeeting"));
|
||||
LateTask.New(() =>
|
||||
{
|
||||
if (SoulHunter.IsSoulHunterTarget(__instance.PlayerId)) __instance.Notify(string.Format(GetString("SoulHunterTargetNotify"), SoulHunter.GetSoulHunter(__instance.PlayerId).SoulHunter_.GetRealName()), 300f);
|
||||
}, 4f, log: false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1218,7 +1210,7 @@ static class FixedUpdatePatch
|
||||
}
|
||||
}
|
||||
|
||||
if (Options.DontUpdateDeadPlayers.GetBool() && !__instance.IsAlive() && (!Altruist.On || Main.PlayerStates[id].Role is not Altruist at || at.ReviveStartTS == 0))
|
||||
if (Options.DontUpdateDeadPlayers.GetBool() && !__instance.IsAlive() && !__instance.GetCustomRole().NeedsUpdateAfterDeath())
|
||||
{
|
||||
var buffer = Options.DeepLowLoad.GetBool() ? 30 : 10;
|
||||
DeadBufferTime.TryAdd(id, buffer);
|
||||
@@ -2006,10 +1998,6 @@ static class CoEnterVentPatch
|
||||
{
|
||||
__instance.myPlayer?.Notify(GetString("SoulHunterTargetNotifyNoVent"));
|
||||
__instance.RpcBootFromVent(id);
|
||||
LateTask.New(() =>
|
||||
{
|
||||
if (SoulHunter.IsSoulHunterTarget(__instance.myPlayer.PlayerId)) __instance.myPlayer.Notify(string.Format(GetString("SoulHunterTargetNotify"), SoulHunter.GetSoulHunter(__instance.myPlayer.PlayerId).SoulHunter_.GetRealName()), 300f);
|
||||
}, 4f, log: false);
|
||||
}, 0.5f, "SoulHunterTargetBootFromVent");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -41,9 +41,13 @@ namespace EHR.Crewmate
|
||||
|
||||
public static bool IsAffectedPlayer(byte id) => Utils.IsActive(SystemTypes.Electrical) && AffectedPlayers.Contains(id);
|
||||
|
||||
private int Count;
|
||||
public override void OnCheckPlayerPosition(PlayerControl pc)
|
||||
{
|
||||
if (!GameStates.IsInTask || pc == null) return;
|
||||
|
||||
if (Count++ < 10) return;
|
||||
Count = 0;
|
||||
|
||||
long now = Utils.TimeStamp;
|
||||
if (LastChange.TryGetValue(pc.PlayerId, out var ts) && ts == now) return;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace EHR.Crewmate
|
||||
private static readonly Dictionary<string, string> ReplacementDict = new() { { "Tornado", ColorString(GetRoleColor(CustomRoles.Tornado), "Tornado") } };
|
||||
|
||||
private static RandomSpawn.SpawnMap Map;
|
||||
private static readonly Dictionary<(Vector2 LOCATION, string ROOM_NAME), long> Tornados = [];
|
||||
private static readonly Dictionary<(Vector2 Location, string RoomName), long> Tornados = [];
|
||||
private static long LastNotify = TimeStamp;
|
||||
private static bool CanUseMap;
|
||||
private PlayerControl TornadoPC;
|
||||
@@ -63,11 +63,11 @@ namespace EHR.Crewmate
|
||||
MapNames.Dleks => new RandomSpawn.DleksSpawnMap(),
|
||||
MapNames.Airship => new RandomSpawn.AirshipSpawnMap(),
|
||||
MapNames.Fungle => new RandomSpawn.FungleSpawnMap(),
|
||||
_ => throw new NotImplementedException()
|
||||
_ => throw new ArgumentOutOfRangeException(Main.CurrentMap.ToString(), "Unsupported Map")
|
||||
};
|
||||
CanUseMap = true;
|
||||
}
|
||||
catch (NotImplementedException)
|
||||
catch (ArgumentOutOfRangeException)
|
||||
{
|
||||
Logger.CurrentMethod();
|
||||
Logger.Error("Unsupported Map", "Torando");
|
||||
@@ -141,16 +141,10 @@ namespace EHR.Crewmate
|
||||
|
||||
foreach (var tornado in Tornados)
|
||||
{
|
||||
if (Vector2.Distance(tornado.Key.LOCATION, pc.Pos()) <= tornadoRange)
|
||||
if (Vector2.Distance(tornado.Key.Location, pc.Pos()) <= tornadoRange)
|
||||
{
|
||||
if (!CanUseMap || Random.Next(0, 100) < 50)
|
||||
{
|
||||
pc.TPtoRndVent();
|
||||
}
|
||||
else
|
||||
{
|
||||
Map.RandomTeleport(pc);
|
||||
}
|
||||
if (!CanUseMap || Random.Next(0, 100) < 50) pc.TPtoRndVent();
|
||||
else Map.RandomTeleport(pc);
|
||||
|
||||
pc.Notify(NotifyString);
|
||||
}
|
||||
@@ -158,7 +152,7 @@ namespace EHR.Crewmate
|
||||
if (tornado.Value + tornadoDuration < now)
|
||||
{
|
||||
Tornados.Remove(tornado.Key);
|
||||
SendRPCAddTornado(false, tornado.Key.LOCATION, tornado.Key.ROOM_NAME);
|
||||
SendRPCAddTornado(false, tornado.Key.Location, tornado.Key.RoomName);
|
||||
NotifyRoles(SpecifySeer: TornadoPC, SpecifyTarget: TornadoPC);
|
||||
}
|
||||
}
|
||||
@@ -174,7 +168,7 @@ namespace EHR.Crewmate
|
||||
public override string GetSuffix(PlayerControl seer, PlayerControl target, bool hud = false, bool meeting = false)
|
||||
{
|
||||
if (seer.PlayerId != target.PlayerId || !IsEnable || (seer.IsModClient() && !hud) || seer.PlayerId != TornadoPC.PlayerId) return string.Empty;
|
||||
return string.Join(hud ? "\n" : ", ", Tornados.Select(x => $"Tornado {GetFormattedRoomName(x.Key.ROOM_NAME)} {GetFormattedVectorText(x.Key.LOCATION)} ({(int)(TornadoDuration.GetInt() - (TimeStamp - x.Value) + 1)}s)"));
|
||||
return string.Join(hud ? "\n" : ", ", Tornados.Select(x => $"Tornado {GetFormattedRoomName(x.Key.RoomName)} {GetFormattedVectorText(x.Key.Location)} ({(int)(TornadoDuration.GetInt() - (TimeStamp - x.Value) + 1)}s)"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,9 +66,14 @@ namespace EHR.Impostor
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnGlobalFixedUpdate(PlayerControl pc, bool lowLoad)
|
||||
private int Count;
|
||||
|
||||
public override void OnFixedUpdate(PlayerControl pc)
|
||||
{
|
||||
if (lowLoad || DuelPair.Count == 0) return;
|
||||
if (DuelPair.Count == 0) return;
|
||||
|
||||
if (Count++ < 40) return;
|
||||
Count = 0;
|
||||
|
||||
foreach (var pair in DuelPair)
|
||||
{
|
||||
|
||||
@@ -118,6 +118,7 @@ namespace EHR.Impostor
|
||||
Bombs.Remove(bomb.Key);
|
||||
pc.Notify(GetString("MagicianBombExploded"));
|
||||
if (b)
|
||||
{
|
||||
LateTask.New(() =>
|
||||
{
|
||||
if (!GameStates.IsEnded)
|
||||
@@ -125,6 +126,7 @@ namespace EHR.Impostor
|
||||
pc.Suicide(PlayerState.DeathReason.Bombed);
|
||||
}
|
||||
}, 0.5f, "Sapper Bomb Suicide");
|
||||
}
|
||||
}
|
||||
|
||||
var sb = new StringBuilder();
|
||||
@@ -133,7 +135,7 @@ namespace EHR.Impostor
|
||||
sb.Append(string.Format(GetString("MagicianBombExlodesIn"), Delay.GetInt() - (TimeStamp - x) + 1));
|
||||
}
|
||||
|
||||
pc.Notify(sb.ToString());
|
||||
pc.Notify(sb.ToString(), overrideAll: true);
|
||||
}
|
||||
|
||||
public override void OnReportDeadBody()
|
||||
|
||||
@@ -148,9 +148,14 @@ public class Swooper : RoleBase
|
||||
SendRPC();
|
||||
}
|
||||
|
||||
private int Count;
|
||||
|
||||
public override void OnFixedUpdate(PlayerControl player)
|
||||
{
|
||||
if (!GameStates.IsInTask || !IsEnable || player == null) return;
|
||||
|
||||
if (Count++ < 10) return;
|
||||
Count = 0;
|
||||
|
||||
var now = Utils.TimeStamp;
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ public class Pelican : RoleBase
|
||||
3 => new(27f, 3.3f), // dlekS ehT
|
||||
4 => new(-16.8f, -6.2f), // Airship
|
||||
5 => new(9.6f, 23.2f), // The Fungle
|
||||
_ => throw new NotImplementedException()
|
||||
_ => throw new ArgumentOutOfRangeException(Main.NormalOptions.MapId.ToString(), "Unsupported map")
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,6 @@ namespace EHR.Neutral
|
||||
public override bool CanUseKillButton(PlayerControl pc) => pc.IsAlive();
|
||||
|
||||
public static bool IsSoulHunterTarget(byte id) => Main.PlayerStates.Any(x => x.Value.Role is SoulHunter { IsEnable: true, IsTargetBlocked: true } sh && sh.CurrentTarget.ID == id);
|
||||
public static SoulHunter GetSoulHunter(byte targetId) => Main.PlayerStates.FirstOrDefault(x => x.Value.Role is SoulHunter { IsEnable: true, IsTargetBlocked: true } sh && sh.CurrentTarget.ID == targetId).Value.Role as SoulHunter;
|
||||
|
||||
void SendRPC()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user