more optimization

This commit is contained in:
Gurge44 committed 2025-11-11 16:57:57 +01:00
1 parent d61145f76c
commit 2a4d088dae
4 files changed
+10 -15

No files matched your search

-5
View File
@@ -202,11 +202,6 @@ internal static class GameEndChecker
ResetAndSetWinner(CustomWinner.Stalker);
WinnerIds.Add(pc.PlayerId);
break;
case CustomRoles.Specter when pc.GetTaskState().RemainingTasksCount <= 0 && !pc.IsAlive() && Options.PhantomSnatchesWin.GetBool():
reason = GameOverReason.ImpostorsByKill;
ResetAndSetWinner(CustomWinner.Specter);
WinnerIds.Add(pc.PlayerId);
break;
case CustomRoles.Specter when pc.GetTaskState().RemainingTasksCount <= 0 && !pc.IsAlive() && !Options.PhantomSnatchesWin.GetBool():
WinnerIds.Add(pc.PlayerId);
AdditionalWinnerTeams.Add(AdditionalWinners.Specter);
+3 -3
View File
@@ -181,9 +181,9 @@ internal class Arsonist : RoleBase
{
byte playerId = player.PlayerId;
if (GameStates.IsInTask && ArsonistTimer.ContainsKey(playerId))
if (GameStates.IsInTask && ArsonistTimer.TryGetValue(playerId, out var value))
{
PlayerControl arTarget = ArsonistTimer[playerId].Player;
PlayerControl arTarget = value.Player;
if (!player.IsAlive() || Pelican.IsEaten(playerId))
{
@@ -193,7 +193,7 @@ internal class Arsonist : RoleBase
}
else
{
float arTime = ArsonistTimer[playerId].Timer;
float arTime = value.Timer;
if (!arTarget.IsAlive())
ArsonistTimer.Remove(playerId);
+6 -6
View File
@@ -140,9 +140,9 @@ internal class Revolutionist : RoleBase
{
byte playerId = player.PlayerId;
if (GameStates.IsInTask && RevolutionistTimer.ContainsKey(playerId))
if (GameStates.IsInTask && RevolutionistTimer.TryGetValue(playerId, out var value))
{
PlayerControl rvTarget = RevolutionistTimer[playerId].Player;
PlayerControl rvTarget = value.Player;
if (!player.IsAlive() || Pelican.IsEaten(playerId))
{
@@ -152,7 +152,7 @@ internal class Revolutionist : RoleBase
}
else
{
float rvTime = RevolutionistTimer[playerId].Timer;
float rvTime = value.Timer;
if (!rvTarget.IsAlive())
RevolutionistTimer.Remove(playerId);
@@ -195,13 +195,13 @@ internal class Revolutionist : RoleBase
if (GameStates.IsInTask && player.IsDrawDone() && player.IsAlive() && !player.Data.IsDead)
{
if (RevolutionistStart.ContainsKey(playerId))
if (RevolutionistStart.TryGetValue(playerId, out var start))
{
if (RevolutionistLastTime.ContainsKey(playerId))
{
long nowtime = Utils.TimeStamp;
RevolutionistLastTime[playerId] = nowtime;
var time = (int)(RevolutionistLastTime[playerId] - RevolutionistStart[playerId]);
var time = (int)(RevolutionistLastTime[playerId] - start);
int countdown = RevolutionistVentCountDown.GetInt() - time;
RevolutionistCountdown.Clear();
@@ -225,7 +225,7 @@ internal class Revolutionist : RoleBase
}
else RevolutionistCountdown[playerId] = countdown;
}
else RevolutionistLastTime.TryAdd(playerId, RevolutionistStart[playerId]);
else RevolutionistLastTime.TryAdd(playerId, start);
}
else RevolutionistStart.TryAdd(playerId, Utils.TimeStamp);
}
+1 -1
View File
@@ -28,7 +28,7 @@ internal class Specter : RoleBase
public override void OnTaskComplete(PlayerControl pc, int completedTaskCount, int totalTaskCount)
{
if (completedTaskCount + 1 >= totalTaskCount)
if (completedTaskCount + 1 >= totalTaskCount && !pc.IsAlive() && PhantomSnatchesWin.GetBool())
{
CustomWinnerHolder.ResetAndSetWinner(CustomWinner.Specter);
CustomWinnerHolder.WinnerIds.Add(pc.PlayerId);