Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
using Content.Server.Antag;
|
2023-07-25 17:31:35 -04:00
|
|
|
using Content.Server.Chat.Systems;
|
2023-04-25 20:23:14 -04:00
|
|
|
using Content.Server.GameTicking.Rules.Components;
|
2022-07-05 23:42:51 -04:00
|
|
|
using Content.Server.Popups;
|
2024-06-21 07:42:17 +02:00
|
|
|
using Content.Server.Roles;
|
2022-07-05 23:42:51 -04:00
|
|
|
using Content.Server.RoundEnd;
|
2023-07-25 17:31:35 -04:00
|
|
|
using Content.Server.Station.Components;
|
|
|
|
|
using Content.Server.Station.Systems;
|
2022-07-05 23:42:51 -04:00
|
|
|
using Content.Server.Zombies;
|
2024-06-04 11:53:24 +00:00
|
|
|
using Content.Shared.GameTicking.Components;
|
2022-12-24 23:28:21 -05:00
|
|
|
using Content.Shared.Humanoid;
|
2023-08-30 21:46:11 -07:00
|
|
|
using Content.Shared.Mind;
|
2023-01-13 16:57:10 -08:00
|
|
|
using Content.Shared.Mobs;
|
|
|
|
|
using Content.Shared.Mobs.Components;
|
|
|
|
|
using Content.Shared.Mobs.Systems;
|
2024-10-10 10:48:56 +02:00
|
|
|
using Content.Shared.Roles;
|
2022-07-05 23:42:51 -04:00
|
|
|
using Content.Shared.Zombies;
|
2023-10-28 09:59:53 +11:00
|
|
|
using Robust.Shared.Player;
|
2023-07-25 17:31:35 -04:00
|
|
|
using Robust.Shared.Timing;
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
using System.Globalization;
|
2022-07-05 23:42:51 -04:00
|
|
|
|
|
|
|
|
namespace Content.Server.GameTicking.Rules;
|
|
|
|
|
|
2023-04-25 20:23:14 -04:00
|
|
|
public sealed class ZombieRuleSystem : GameRuleSystem<ZombieRuleComponent>
|
2022-07-05 23:42:51 -04:00
|
|
|
{
|
2024-10-10 10:48:56 +02:00
|
|
|
[Dependency] private readonly AntagSelectionSystem _antag = default!;
|
2023-07-25 17:31:35 -04:00
|
|
|
[Dependency] private readonly ChatSystem _chat = default!;
|
2023-08-30 21:46:11 -07:00
|
|
|
[Dependency] private readonly SharedMindSystem _mindSystem = default!;
|
2024-10-10 10:48:56 +02:00
|
|
|
[Dependency] private readonly MobStateSystem _mobState = default!;
|
|
|
|
|
[Dependency] private readonly PopupSystem _popup = default!;
|
|
|
|
|
[Dependency] private readonly SharedRoleSystem _roles = default!;
|
|
|
|
|
[Dependency] private readonly RoundEndSystem _roundEnd = default!;
|
2023-07-25 17:31:35 -04:00
|
|
|
[Dependency] private readonly StationSystem _station = default!;
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
[Dependency] private readonly IGameTiming _timing = default!;
|
2024-10-10 10:48:56 +02:00
|
|
|
[Dependency] private readonly ZombieSystem _zombie = default!;
|
2022-07-05 23:42:51 -04:00
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
2024-06-21 07:42:17 +02:00
|
|
|
SubscribeLocalEvent<InitialInfectedRoleComponent, GetBriefingEvent>(OnGetBriefing);
|
|
|
|
|
SubscribeLocalEvent<ZombieRoleComponent, GetBriefingEvent>(OnGetBriefing);
|
2024-05-09 17:45:23 -04:00
|
|
|
SubscribeLocalEvent<IncurableZombieComponent, ZombifySelfActionEvent>(OnZombifySelf);
|
2022-07-05 23:42:51 -04:00
|
|
|
}
|
|
|
|
|
|
2024-10-10 10:48:56 +02:00
|
|
|
private void OnGetBriefing(Entity<InitialInfectedRoleComponent> role, ref GetBriefingEvent args)
|
2024-06-21 07:42:17 +02:00
|
|
|
{
|
2024-10-10 10:48:56 +02:00
|
|
|
if (!_roles.MindHasRole<ZombieRoleComponent>(args.Mind.Owner))
|
|
|
|
|
args.Append(Loc.GetString("zombie-patientzero-role-greeting"));
|
2024-06-21 07:42:17 +02:00
|
|
|
}
|
|
|
|
|
|
2024-10-10 10:48:56 +02:00
|
|
|
private void OnGetBriefing(Entity<ZombieRoleComponent> role, ref GetBriefingEvent args)
|
2024-06-21 07:42:17 +02:00
|
|
|
{
|
|
|
|
|
args.Append(Loc.GetString("zombie-infection-greeting"));
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-10 10:48:56 +02:00
|
|
|
protected override void AppendRoundEndText(EntityUid uid,
|
|
|
|
|
ZombieRuleComponent component,
|
|
|
|
|
GameRuleComponent gameRule,
|
2024-04-24 21:31:45 -04:00
|
|
|
ref RoundEndTextAppendEvent args)
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
{
|
2024-04-24 21:31:45 -04:00
|
|
|
base.AppendRoundEndText(uid, component, gameRule, ref args);
|
|
|
|
|
|
|
|
|
|
// This is just the general condition thing used for determining the win/lose text
|
|
|
|
|
var fraction = GetInfectedFraction(true, true);
|
|
|
|
|
|
|
|
|
|
if (fraction <= 0)
|
|
|
|
|
args.AddLine(Loc.GetString("zombie-round-end-amount-none"));
|
|
|
|
|
else if (fraction <= 0.25)
|
|
|
|
|
args.AddLine(Loc.GetString("zombie-round-end-amount-low"));
|
|
|
|
|
else if (fraction <= 0.5)
|
|
|
|
|
args.AddLine(Loc.GetString("zombie-round-end-amount-medium", ("percent", Math.Round((fraction * 100), 2).ToString(CultureInfo.InvariantCulture))));
|
|
|
|
|
else if (fraction < 1)
|
|
|
|
|
args.AddLine(Loc.GetString("zombie-round-end-amount-high", ("percent", Math.Round((fraction * 100), 2).ToString(CultureInfo.InvariantCulture))));
|
|
|
|
|
else
|
|
|
|
|
args.AddLine(Loc.GetString("zombie-round-end-amount-all"));
|
|
|
|
|
|
|
|
|
|
var antags = _antag.GetAntagIdentifiers(uid);
|
|
|
|
|
args.AddLine(Loc.GetString("zombie-round-end-initial-count", ("initialCount", antags.Count)));
|
|
|
|
|
foreach (var (_, data, entName) in antags)
|
2023-04-24 16:21:05 +10:00
|
|
|
{
|
2024-04-24 21:31:45 -04:00
|
|
|
args.AddLine(Loc.GetString("zombie-round-end-user-was-initial",
|
|
|
|
|
("name", entName),
|
|
|
|
|
("username", data.UserName)));
|
|
|
|
|
}
|
2023-04-24 01:20:51 -04:00
|
|
|
|
2024-04-24 21:31:45 -04:00
|
|
|
var healthy = GetHealthyHumans();
|
|
|
|
|
// Gets a bunch of the living players and displays them if they're under a threshold.
|
|
|
|
|
// InitialInfected is used for the threshold because it scales with the player count well.
|
|
|
|
|
if (healthy.Count <= 0 || healthy.Count > 2 * antags.Count)
|
|
|
|
|
return;
|
|
|
|
|
args.AddLine("");
|
|
|
|
|
args.AddLine(Loc.GetString("zombie-round-end-survivor-count", ("count", healthy.Count)));
|
|
|
|
|
foreach (var survivor in healthy)
|
|
|
|
|
{
|
|
|
|
|
var meta = MetaData(survivor);
|
|
|
|
|
var username = string.Empty;
|
|
|
|
|
if (_mindSystem.TryGetMind(survivor, out _, out var mind) && mind.Session != null)
|
2023-04-25 20:23:14 -04:00
|
|
|
{
|
2024-04-24 21:31:45 -04:00
|
|
|
username = mind.Session.Name;
|
2023-04-25 20:23:14 -04:00
|
|
|
}
|
|
|
|
|
|
2024-04-24 21:31:45 -04:00
|
|
|
args.AddLine(Loc.GetString("zombie-round-end-user-was-survivor",
|
|
|
|
|
("name", meta.EntityName),
|
|
|
|
|
("username", username)));
|
2023-04-25 20:23:14 -04:00
|
|
|
}
|
2022-07-05 23:42:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The big kahoona function for checking if the round is gonna end
|
|
|
|
|
/// </summary>
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
private void CheckRoundEnd(ZombieRuleComponent zombieRuleComponent)
|
2022-07-05 23:42:51 -04:00
|
|
|
{
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
var healthy = GetHealthyHumans();
|
|
|
|
|
if (healthy.Count == 1) // Only one human left. spooky
|
|
|
|
|
_popup.PopupEntity(Loc.GetString("zombie-alone"), healthy[0], healthy[0]);
|
2023-07-25 17:31:35 -04:00
|
|
|
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
if (GetInfectedFraction(false) > zombieRuleComponent.ZombieShuttleCallPercentage && !_roundEnd.IsRoundEndRequested())
|
|
|
|
|
{
|
|
|
|
|
foreach (var station in _station.GetStations())
|
2023-07-25 17:31:35 -04:00
|
|
|
{
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
_chat.DispatchStationAnnouncement(station, Loc.GetString("zombie-shuttle-call"), colorOverride: Color.Crimson);
|
2023-07-25 17:31:35 -04:00
|
|
|
}
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
_roundEnd.RequestRoundEnd(null, false);
|
2023-04-25 20:23:14 -04:00
|
|
|
}
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
|
|
|
|
|
// we include dead for this count because we don't want to end the round
|
|
|
|
|
// when everyone gets on the shuttle.
|
|
|
|
|
if (GetInfectedFraction() >= 1) // Oops, all zombies
|
|
|
|
|
_roundEnd.EndRound();
|
2022-07-05 23:42:51 -04:00
|
|
|
}
|
|
|
|
|
|
2023-04-25 20:23:14 -04:00
|
|
|
protected override void Started(EntityUid uid, ZombieRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
|
2022-07-05 23:42:51 -04:00
|
|
|
{
|
2023-04-25 20:23:14 -04:00
|
|
|
base.Started(uid, component, gameRule, args);
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
|
2024-04-24 21:31:45 -04:00
|
|
|
component.NextRoundEndCheck = _timing.CurTime + component.EndCheckDelay;
|
2023-07-25 17:31:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void ActiveTick(EntityUid uid, ZombieRuleComponent component, GameRuleComponent gameRule, float frameTime)
|
|
|
|
|
{
|
|
|
|
|
base.ActiveTick(uid, component, gameRule, frameTime);
|
2024-04-24 21:31:45 -04:00
|
|
|
if (!component.NextRoundEndCheck.HasValue || component.NextRoundEndCheck > _timing.CurTime)
|
|
|
|
|
return;
|
|
|
|
|
CheckRoundEnd(component);
|
|
|
|
|
component.NextRoundEndCheck = _timing.CurTime + component.EndCheckDelay;
|
2022-07-05 23:42:51 -04:00
|
|
|
}
|
|
|
|
|
|
2024-05-09 17:45:23 -04:00
|
|
|
private void OnZombifySelf(EntityUid uid, IncurableZombieComponent component, ZombifySelfActionEvent args)
|
2022-07-05 23:42:51 -04:00
|
|
|
{
|
2023-07-25 17:31:35 -04:00
|
|
|
_zombie.ZombifyEntity(uid);
|
2023-09-23 04:49:39 -04:00
|
|
|
if (component.Action != null)
|
|
|
|
|
Del(component.Action.Value);
|
2022-07-05 23:42:51 -04:00
|
|
|
}
|
|
|
|
|
|
Refactor antag rule code (#23445)
* Initial Pass, Rev, Thief
* Zombie initial pass
* Rebase, Traitor
* Nukeops, More overloads
* Revert RevolutionaryRuleComponent
* Use TryRoundStartAttempt, Rewrite nukie spawning
* Comments, Add task scheduler to GameRuleSystem
* Zombie initial testing done
* Sort methods, rework GameRuleTask
* Add CCVar, Initial testing continues
* Might as well get rid of the obsolete logging
* Oops, i dont know how to log apparently
* Suggested formatting fixes
* Suggested changes
* Fix merge issues
* Minor optimisation
* Allowed thief to choose other antags
* Review changes
* Spawn items on floor first, then inserting
* minor tweaks
* Shift as much as possible to ProtoId<>
* Remove unneeded
* Add exclusive antag attribute
* Fix merge issues
* Minor formatting fix
* Convert to struct
* Cleanup
* Review cleanup (need to test a lot)
* Some fixes, (mostly) tested
* oop
* Pass tests (for real)
---------
Co-authored-by: Rainfall <rainfey0+git@gmail.com>
Co-authored-by: AJCM <AJCM@tutanota.com>
2024-02-29 06:25:10 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// Get the fraction of players that are infected, between 0 and 1
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="includeOffStation">Include healthy players that are not on the station grid</param>
|
|
|
|
|
/// <param name="includeDead">Should dead zombies be included in the count</param>
|
|
|
|
|
/// <returns></returns>
|
2023-07-25 17:31:35 -04:00
|
|
|
private float GetInfectedFraction(bool includeOffStation = true, bool includeDead = false)
|
2022-07-05 23:42:51 -04:00
|
|
|
{
|
2023-07-25 17:31:35 -04:00
|
|
|
var players = GetHealthyHumans(includeOffStation);
|
|
|
|
|
var zombieCount = 0;
|
|
|
|
|
var query = EntityQueryEnumerator<HumanoidAppearanceComponent, ZombieComponent, MobStateComponent>();
|
|
|
|
|
while (query.MoveNext(out _, out _, out _, out var mob))
|
|
|
|
|
{
|
|
|
|
|
if (!includeDead && mob.CurrentState == MobState.Dead)
|
|
|
|
|
continue;
|
|
|
|
|
zombieCount++;
|
|
|
|
|
}
|
2022-07-05 23:42:51 -04:00
|
|
|
|
2023-07-25 17:31:35 -04:00
|
|
|
return zombieCount / (float) (players.Count + zombieCount);
|
2023-05-02 17:31:14 +03:00
|
|
|
}
|
2022-07-05 23:42:51 -04:00
|
|
|
|
2023-07-25 17:31:35 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the list of humans who are alive, not zombies, and are on a station.
|
|
|
|
|
/// Flying off via a shuttle disqualifies you.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private List<EntityUid> GetHealthyHumans(bool includeOffStation = true)
|
2023-05-02 17:31:14 +03:00
|
|
|
{
|
|
|
|
|
var healthy = new List<EntityUid>();
|
2023-07-25 17:31:35 -04:00
|
|
|
|
|
|
|
|
var stationGrids = new HashSet<EntityUid>();
|
|
|
|
|
if (!includeOffStation)
|
2022-07-05 23:42:51 -04:00
|
|
|
{
|
2023-07-25 17:31:35 -04:00
|
|
|
foreach (var station in _station.GetStationsSet())
|
2022-07-05 23:42:51 -04:00
|
|
|
{
|
2023-07-25 17:31:35 -04:00
|
|
|
if (TryComp<StationDataComponent>(station, out var data) && _station.GetLargestGrid(data) is { } grid)
|
|
|
|
|
stationGrids.Add(grid);
|
2022-07-05 23:42:51 -04:00
|
|
|
}
|
|
|
|
|
}
|
2023-07-25 17:31:35 -04:00
|
|
|
|
|
|
|
|
var players = AllEntityQuery<HumanoidAppearanceComponent, ActorComponent, MobStateComponent, TransformComponent>();
|
|
|
|
|
var zombers = GetEntityQuery<ZombieComponent>();
|
|
|
|
|
while (players.MoveNext(out var uid, out _, out _, out var mob, out var xform))
|
|
|
|
|
{
|
|
|
|
|
if (!_mobState.IsAlive(uid, mob))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (zombers.HasComponent(uid))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (!includeOffStation && !stationGrids.Contains(xform.GridUid ?? EntityUid.Invalid))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
healthy.Add(uid);
|
|
|
|
|
}
|
2023-05-02 17:31:14 +03:00
|
|
|
return healthy;
|
2022-07-05 23:42:51 -04:00
|
|
|
}
|
|
|
|
|
}
|