mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
optimize code & EAC addition
This commit is contained in:
1 parent
b53f86e8cf
commit
29e75d85b8
3 files changed
+91
-88
No files matched your search
+83
-63
@@ -3495,79 +3495,95 @@ public static class Utils
|
||||
public static void AfterMeetingTasks()
|
||||
{
|
||||
LateTask.New(() => GameEndChecker.ShouldNotCheck = false, 0.1f, "Enable GameEndChecker");
|
||||
|
||||
if (Lovers.PrivateChat.GetBool() && Main.LoversPlayers.TrueForAll(x => x.IsAlive()))
|
||||
Main.LoversPlayers.ForEach(x => x.SetChatVisible(true));
|
||||
|
||||
AFKDetector.NumAFK = 0;
|
||||
AFKDetector.PlayerData.Clear();
|
||||
try
|
||||
{
|
||||
if (Lovers.PrivateChat.GetBool() && Main.LoversPlayers.TrueForAll(x => x.IsAlive()))
|
||||
Main.LoversPlayers.ForEach(x => x.SetChatVisible(true));
|
||||
}
|
||||
catch (System.Exception e) { ThrowException(e); }
|
||||
|
||||
Camouflage.CheckCamouflage();
|
||||
try
|
||||
{
|
||||
AFKDetector.NumAFK = 0;
|
||||
AFKDetector.PlayerData.Clear();
|
||||
|
||||
CopyCat.ResetRoles();
|
||||
Imitator.SetRoles();
|
||||
Camouflage.CheckCamouflage();
|
||||
|
||||
CopyCat.ResetRoles();
|
||||
Imitator.SetRoles();
|
||||
}
|
||||
catch (System.Exception e) { ThrowException(e); }
|
||||
|
||||
foreach (PlayerControl pc in Main.AllPlayerControls)
|
||||
{
|
||||
if (pc.IsAlive())
|
||||
try
|
||||
{
|
||||
if (pc.Is(CustomRoles.Bloodlust))
|
||||
if (pc.IsAlive())
|
||||
{
|
||||
pc.RpcSetRoleDesync(RoleTypes.Impostor, pc.OwnerId);
|
||||
LateTask.New(() => pc.SetKillCooldown(), 0.2f, log: false);
|
||||
}
|
||||
|
||||
if (pc.Is(CustomRoles.Truant))
|
||||
{
|
||||
float beforeSpeed = Main.AllPlayerSpeed[pc.PlayerId];
|
||||
Main.AllPlayerSpeed[pc.PlayerId] = Main.MinSpeed;
|
||||
pc.MarkDirtySettings();
|
||||
|
||||
LateTask.New(() =>
|
||||
try
|
||||
{
|
||||
Main.AllPlayerSpeed[pc.PlayerId] = beforeSpeed;
|
||||
pc.MarkDirtySettings();
|
||||
}, Options.TruantWaitingTime.GetFloat(), $"Truant Waiting: {pc.GetNameWithRole()}");
|
||||
}
|
||||
if (pc.Is(CustomRoles.Bloodlust))
|
||||
{
|
||||
pc.RpcSetRoleDesync(RoleTypes.Impostor, pc.OwnerId);
|
||||
LateTask.New(() => pc.SetKillCooldown(), 0.2f, log: false);
|
||||
}
|
||||
|
||||
if (Options.UsePets.GetBool())
|
||||
{
|
||||
pc.AddAbilityCD(false);
|
||||
if (pc.Is(CustomRoles.Truant))
|
||||
{
|
||||
float beforeSpeed = Main.AllPlayerSpeed[pc.PlayerId];
|
||||
Main.AllPlayerSpeed[pc.PlayerId] = Main.MinSpeed;
|
||||
pc.MarkDirtySettings();
|
||||
|
||||
LateTask.New(() =>
|
||||
LateTask.New(() =>
|
||||
{
|
||||
Main.AllPlayerSpeed[pc.PlayerId] = beforeSpeed;
|
||||
pc.MarkDirtySettings();
|
||||
}, Options.TruantWaitingTime.GetFloat(), $"Truant Waiting: {pc.GetNameWithRole()}");
|
||||
}
|
||||
}
|
||||
catch (Exception e) { ThrowException(e); }
|
||||
|
||||
if (Options.UsePets.GetBool())
|
||||
{
|
||||
if (GameStates.IsEnded) return;
|
||||
string petId = PetsHelper.GetPetId();
|
||||
PetsHelper.SetPet(pc, petId);
|
||||
pc.Data.DefaultOutfit.PetSequenceId += 10;
|
||||
pc.RpcSetPet(petId);
|
||||
}, 3f, "No Pet Reassign");
|
||||
pc.AddAbilityCD(false);
|
||||
|
||||
LateTask.New(() =>
|
||||
{
|
||||
if (GameStates.IsEnded) return;
|
||||
string petId = PetsHelper.GetPetId();
|
||||
PetsHelper.SetPet(pc, petId);
|
||||
pc.Data.DefaultOutfit.PetSequenceId += 10;
|
||||
pc.RpcSetPet(petId);
|
||||
}, 3f, "No Pet Reassign");
|
||||
}
|
||||
|
||||
AFKDetector.RecordPosition(pc);
|
||||
|
||||
if (Camouflage.IsCamouflage)
|
||||
Camouflage.RpcSetSkin(pc);
|
||||
}
|
||||
else
|
||||
{
|
||||
TaskState taskState = pc.GetTaskState();
|
||||
|
||||
if (pc.IsCrewmate() && !taskState.IsTaskFinished && taskState.HasTasks)
|
||||
pc.Notify(GetString("DoYourTasksPlease"), 8f);
|
||||
|
||||
GhostRolesManager.NotifyAboutGhostRole(pc);
|
||||
}
|
||||
|
||||
AFKDetector.RecordPosition(pc);
|
||||
Main.PlayerStates[pc.PlayerId].Role.AfterMeetingTasks();
|
||||
|
||||
if (Camouflage.IsCamouflage)
|
||||
Camouflage.RpcSetSkin(pc);
|
||||
}
|
||||
else
|
||||
{
|
||||
TaskState taskState = pc.GetTaskState();
|
||||
|
||||
if (pc.IsCrewmate() && !taskState.IsTaskFinished && taskState.HasTasks)
|
||||
pc.Notify(GetString("DoYourTasksPlease"), 8f);
|
||||
|
||||
GhostRolesManager.NotifyAboutGhostRole(pc);
|
||||
}
|
||||
|
||||
Main.PlayerStates[pc.PlayerId].Role.AfterMeetingTasks();
|
||||
|
||||
if (pc.Is(CustomRoles.Phantasm) || pc.Is(CustomRoles.Haunter))
|
||||
pc.RpcResetAbilityCooldown();
|
||||
if (pc.Is(CustomRoles.Phantasm) || pc.Is(CustomRoles.Haunter))
|
||||
pc.RpcResetAbilityCooldown();
|
||||
|
||||
if (pc.Is(CustomRoles.TaskMaster))
|
||||
TaskMaster.AfterMeetingTasks(pc);
|
||||
if (pc.Is(CustomRoles.TaskMaster))
|
||||
TaskMaster.AfterMeetingTasks(pc);
|
||||
|
||||
Main.CheckShapeshift[pc.PlayerId] = false;
|
||||
Main.CheckShapeshift[pc.PlayerId] = false;
|
||||
}
|
||||
catch (System.Exception e) { ThrowException(e); }
|
||||
}
|
||||
|
||||
LateTask.New(() => Main.ProcessShapeshifts = true, 1f, log: false);
|
||||
@@ -3575,22 +3591,26 @@ public static class Utils
|
||||
if (Options.DiseasedCDReset.GetBool())
|
||||
{
|
||||
Main.KilledDiseased.SetAllValues(0);
|
||||
Main.KilledDiseased.Keys.ToValidPlayers().Do(x => x?.ResetKillCooldown());
|
||||
Main.KilledDiseased.Keys.ToValidPlayers().Do(x => x.ResetKillCooldown());
|
||||
Main.KilledDiseased.Clear();
|
||||
}
|
||||
|
||||
if (Options.AntidoteCDReset.GetBool())
|
||||
{
|
||||
Main.KilledAntidote.SetAllValues(0);
|
||||
Main.KilledAntidote.Keys.ToValidPlayers().Do(x => x?.ResetKillCooldown());
|
||||
Main.KilledAntidote.Keys.ToValidPlayers().Do(x => x.ResetKillCooldown());
|
||||
Main.KilledAntidote.Clear();
|
||||
}
|
||||
|
||||
Damocles.AfterMeetingTasks();
|
||||
Stressed.AfterMeetingTasks();
|
||||
Circumvent.AfterMeetingTasks();
|
||||
Deadlined.AfterMeetingTasks();
|
||||
Tired.Reset();
|
||||
try
|
||||
{
|
||||
Damocles.AfterMeetingTasks();
|
||||
Stressed.AfterMeetingTasks();
|
||||
Circumvent.AfterMeetingTasks();
|
||||
Deadlined.AfterMeetingTasks();
|
||||
Tired.Reset();
|
||||
}
|
||||
catch (System.Exception e) { ThrowException(e); }
|
||||
|
||||
if (Options.AirshipVariableElectrical.GetBool())
|
||||
AirshipElectricalDoors.Initialize();
|
||||
|
||||
@@ -5,28 +5,26 @@ namespace EHR;
|
||||
|
||||
public static class AirshipElectricalDoors
|
||||
{
|
||||
private static ElectricalDoors Instance
|
||||
=> ShipStatus.Instance.Systems[SystemTypes.Decontamination].CastFast<ElectricalDoors>();
|
||||
private static ElectricalDoors Instance => ShipStatus.Instance.Systems[SystemTypes.Decontamination].CastFast<ElectricalDoors>();
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
if (Main.NormalOptions.MapId != 4) return;
|
||||
|
||||
Instance.Initialize();
|
||||
}
|
||||
|
||||
public static byte[] GetClosedDoors()
|
||||
public static IEnumerable<byte> GetClosedDoors()
|
||||
{
|
||||
List<byte> DoorsArray = [];
|
||||
if (Instance.Doors == null || Instance.Doors.Length == 0) return [.. DoorsArray];
|
||||
List<byte> doorsArray = [];
|
||||
if (Instance.Doors == null || Instance.Doors.Length == 0) return doorsArray;
|
||||
|
||||
for (byte i = 0; i < Instance.Doors.Count; i++)
|
||||
{
|
||||
StaticDoor door = Instance.Doors[i];
|
||||
if (door != null && !door.IsOpen) DoorsArray.Add(i);
|
||||
if (door != null && !door.IsOpen) doorsArray.Add(i);
|
||||
}
|
||||
|
||||
return DoorsArray?.ToArray();
|
||||
return doorsArray;
|
||||
}
|
||||
// 0: BottomRightHort
|
||||
// 1: BottomHort
|
||||
@@ -48,22 +46,6 @@ internal static class ElectricalDoorsInitializePatch
|
||||
public static void Postfix( /*ElectricalDoors __instance*/)
|
||||
{
|
||||
if (!GameStates.IsInGame) return;
|
||||
|
||||
var closedoors = string.Empty;
|
||||
var isFirst = true;
|
||||
byte[] array = AirshipElectricalDoors.GetClosedDoors();
|
||||
|
||||
foreach (byte num in array)
|
||||
{
|
||||
if (isFirst)
|
||||
{
|
||||
isFirst = false;
|
||||
closedoors += num.ToString();
|
||||
}
|
||||
else
|
||||
closedoors += $", {num}";
|
||||
}
|
||||
|
||||
Logger.Info($"Closed Doors: {closedoors}", "ElectricalDoors Initialize");
|
||||
Logger.Info($"Closed Doors: {string.Join(", ", AirshipElectricalDoors.GetClosedDoors())}", "ElectricalDoors Initialize");
|
||||
}
|
||||
}
|
||||
@@ -93,6 +93,7 @@ woveelixir#4088,42044d211,DMD 3CD //hacker and probably BoomplayYT's alt
|
||||
tenpalace#1924,6a259fcd9,Goaty
|
||||
cat#2761,f70d4ddb1,ULC
|
||||
pinbrittle#1538,4955c179f,Moralmaser // Cheating and disrupting lobbies
|
||||
dollfly#4791,5ba449454,Mari // Spamming RPCs to crash lobbies
|
||||
|
||||
## Griefers, toxic, harrasing, morons
|
||||
setmolar#4374,藏族顶针
|
||||
|
||||
Reference in new issue
Block a user