CatStation/Content.Shared/GameTicking/Rules/SurvivorRuleSystem.cs
Princess Cheeseballs 2c6ffecf62
Move GameTicker to Shared (#45834)
* Scope creep my ass

* why was this shit not pushed????

* gone...

* fix that

* review plus buildd

* asfsafsafsafsafas

* grug

* burber

* I'll fix this later

* shrimply die

* also this

* it's snerf or snuthin

* assaads

* round snend

* aaaa

* fix this shit for real

* actually, don't start GameRules until MapInit now that I think aboot it.

* forgot u

* don't actually need this part nullable

* Deffer comp removal

* one liner

* do that too

* chungus

* Honestly makes more sense here, plus WHY are we doing all that shit on "GameRuleAdded" rather than GameRuleStarted(?)

* deferred removal :V

* aaaaaaaaaaaaaaa

* whhop

* Whoop

* better

* landmine that I placed for myself then forgot about lmao

* cleanup

* FUCKING `!`

* gotovo

* amogus

* please don't check by metadata I beg

* waawsasfdfsasfa

* sfafsasfafsas

* fdsaasffsasfa

* code

* fix

* fasasffasfasfsad

* chungaas

* I may be stupid

* gra

* graaaaaaaaaaaaaaaaa

* comment

* gra

* clearing is not predicted and would require major refactors, so don't cache on client.

* lame shit :P

* last holes

* nukeopsfsafsasafsfafsa

* why  was that shit public bruh

* bubrbgwahrghfaka

* dynamic

* revert change that did nothing lmao
2026-09-16 19:34:19 +00:00

104 lines
3.9 KiB
C#

using Content.Shared.Antag;
using Content.Shared.GameTicking.Components;
using Content.Shared.GameTicking.Rules.Components;
using Content.Shared.Mind;
using Content.Shared.Mobs.Systems;
using Content.Shared.Objectives.Systems;
using Content.Shared.Roles;
using Content.Shared.Roles.Components;
using Content.Shared.Shuttles.Systems;
using Content.Shared.Survivor.Components;
using Content.Shared.Tag;
using Robust.Shared.Prototypes;
namespace Content.Shared.GameTicking.Rules;
public sealed partial class SurvivorRuleSystem : GameRuleSystem<SurvivorRuleComponent>
{
[Dependency] private AliveHumanoidTargetSystem _target = default!;
[Dependency] private AntagSelectionSystem _antag = default!;
[Dependency] private MobStateSystem _mobState = default!;
[Dependency] private SharedEmergencyShuttleSystem _eShuttle = default!;
[Dependency] private SharedRoleSystem _role = default!;
[Dependency] private SharedTransformSystem _xform = default!;
[Dependency] private TagSystem _tag = default!;
private static readonly ProtoId<TagPrototype> InvalidForSurvivorAntagTag = "InvalidForSurvivorAntag";
// TODO: Planned rework post wizard release when RandomGlobalSpawnSpell becomes a gamerule
protected override void Started(Entity<SurvivorRuleComponent, GameRuleComponent> rule, ref GameRuleStartedEvent args)
{
base.Started(rule, ref args);
var allAliveHumanMinds = _target.GetMinds();
foreach (var humanMind in allAliveHumanMinds)
{
if (!humanMind.Comp.OwnedEntity.HasValue)
continue;
var mind = humanMind.Owner;
var ent = humanMind.Comp.OwnedEntity.Value;
if (HasComp<SurvivorComponent>(mind) || _tag.HasTag(mind, InvalidForSurvivorAntagTag))
continue;
EnsureComp<SurvivorComponent>(mind);
_role.MindAddRole(mind, "MindRoleSurvivor");
_antag.SendBriefing(ent, Loc.GetString("survivor-role-greeting"), Color.Olive, null);
}
}
[SubscribeLocalEvent]
private void OnGetBriefing(Entity<SurvivorRoleComponent> ent, ref GetBriefingEvent args)
{
args.Append(Loc.GetString("survivor-role-greeting"));
}
protected override void AppendRoundEndText(Entity<SurvivorRuleComponent> rule,
ref RoundEndTextAppendEvent args)
{
base.AppendRoundEndText(rule, ref args);
// Using this instead of alive antagonists to make checking for shuttle & if the ent is alive easier
var existingSurvivors = AllEntityQuery<SurvivorComponent, MindComponent>();
var deadSurvivors = 0;
var aliveMarooned = 0;
var aliveOnShuttle = 0;
var eShuttle = _eShuttle.GetShuttle();
while (existingSurvivors.MoveNext(out _, out _, out var mindComp))
{
// If their brain is gone or they respawned/became a ghost role
if (mindComp.CurrentEntity is null)
{
deadSurvivors++;
continue;
}
var survivor = mindComp.CurrentEntity.Value;
if (!_mobState.IsAlive(survivor))
{
deadSurvivors++;
continue;
}
if (eShuttle != null && eShuttle.Value.IsValid() && (Transform(eShuttle.Value).MapID == _xform.GetMapCoordinates(survivor).MapId))
{
aliveOnShuttle++;
continue;
}
aliveMarooned++;
}
args.AddLine(Loc.GetString("survivor-round-end-dead-count", ("deadCount", deadSurvivors)));
args.AddLine(Loc.GetString("survivor-round-end-alive-count", ("aliveCount", aliveMarooned)));
args.AddLine(Loc.GetString("survivor-round-end-alive-on-shuttle-count", ("aliveCount", aliveOnShuttle)));
args.AddLine("");
// Player manifest at EOR shows who's a survivor so no need for extra info here.
}
}