* Content changes for engine delta-state PR (#28134) * Update GasTileOverlayState * Update DecalGridState * Update NavMapState * poke * poke2 * poke3 * Poke dem tests * Update engine to v223.0.0 (#28239) * Update RobustToolbox * Improve InteractionSystem range & BUI checks (#27999) * Improve InteractionSystem range & BUI checks * Ghost fixes * AAA * Fix test * fix nullable * revert to broadcast event * Fixes for eengine PR * Ah buckle code * ) * Update engine to v223.0.0 * Update engine to v223.1.0 * Update engine to v223.1.1 * Hotfix for crashes from bad item names (#28256) * Fix weapon error logs (#28264) * Update engine to v223.1.2 (#28273) * Update RobustToolbox * Update RobustToolbox * Fix dud modular grenade visuals (#28265) * Fix not networking whitelist and blacklist in storage component (#28238) * fix id card console not updating records (#28237) * fix id card console not updating records * test --------- Co-authored-by: deltanedas <@deltanedas:kde.org> * Remove the network tab (#28231) It is useless and bloat, if a user needs to change these settings they are free to modify their cvars manually via the clientconfig.toml file or via the cvar command. * antag objective issuing refactor (#28216) * add AntagObjectives from GenericAntag * add AntagRandomObjectives that traitor and thief can use * make ObjectivesSystem use initial character name which AntagSelection passes * make thief and traitor use AntagRandomObjectives * remove now unused locale * make sleeper agents rule use baseTraitorRule * restore dragon rule oop * bandaid for genericantag * real * typo --------- Co-authored-by: deltanedas <@deltanedas:kde.org> * move nukie profile loading into its own rule (#28208) * move profile loading out of nukeops rule * make BaseNukeopsRule and use AntagLoadProfileRule * untroll --------- Co-authored-by: deltanedas <@deltanedas:kde.org> * fix antagSelect * Objects ordered through cargo system shouldn't start anchored (#28115) * Order normal space heater instead of anchored variant * Make sure ordered objects don't spawn anchored * Order space heater flatpack instead of a regular space heater * Remove obsolete TODO * Remove unnecessary name --------- Co-authored-by: Eoin Mcloughlin <helloworld@eoinrul.es> * Move PendingZombieComponent to Shared (#28143) * Move PendingZombieComponent to Shared * network me boy --------- Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> * Make it possible to hide full health bars below a total damage threshold (#28127) * Make it possible to hide full health bars below a total damage threshold * Fix not setting state * Fix storage UI interactions (#28291) * Fix storage UI interactions * Add VV support * Fix stripping not marking interactions as handled (#28292) * Make NetworkConfigurator use BoundUserInterfaceCheckRangeEvent (#28293) * Fix hypodarts not injecting with people that have ANY outerclothing (#28301) Update darts.yml * fix borg ui mispredict opening (#28305) move borg ui junk to shared * Add loadout group check (#28311) Forgot to add it back in one of the rewrites. * fix mirror server crashes (#28318) * Remove bogus C# finalizers (#28315) Begging people to learn how this programming language works before throwing random syntax into a file. None of these finalizers ever worked. I also checked whether they were memory leaks and needed *proper* shutdown logic, but they're all instantiated-once UI controls that last for the entire lifetime of the program so it's probably fine. * Cleans up some entity-related spawnmenu stuff (#28234) * cleans up a lot of stuff in the spawnmenu * skibidi dode * spawners update * Revert "spawners update" This reverts commit bc27d9f556b29f6fb1f89cebbe0ac37e28319fd0. * fix antag selection being evil (#28197) * fix antag selection being evil * fix test * untroll the other tests * remove role timer troll * Allow tests to modify antag preferences * Fix antag selection * Misc test fixes * Add AntagPreferenceTest * Fix lazy mistakes * Test cleanup * Try stop players in lobbies from being assigned mid-round antags * ranting * I am going insane --------- Co-authored-by: deltanedas <@deltanedas:kde.org> Co-authored-by: ElectroJr <leonsfriedrich@gmail.com> * Revert "fix mirror server crashes (#28318)" This reverts commit bcb0e555b058a4049d0cdb32d64eaf86c35a67be. * fix * Update engine to 223.2.0 (#28329) * Update RobustToolbox * Update RobustToolbox --------- Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Co-authored-by: Tayrtahn <tayrtahn@gmail.com> Co-authored-by: DrSmugleaf <10968691+DrSmugleaf@users.noreply.github.com> Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: Vasilis <vasilis@pikachu.systems> Co-authored-by: eoineoineoin <github@eoinrul.es> Co-authored-by: Eoin Mcloughlin <helloworld@eoinrul.es> Co-authored-by: Ady4ik <141335742+Ady4ik@users.noreply.github.com> Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Co-authored-by: Mr. 27 <45323883+Dutch-VanDerLinde@users.noreply.github.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com> Co-authored-by: Flareguy <78941145+Flareguy@users.noreply.github.com> Co-authored-by: ElectroJr <leonsfriedrich@gmail.com> Co-authored-by: Kara <lunarautomaton6@gmail.com>
583 lines
22 KiB
C#
583 lines
22 KiB
C#
using Content.Server.Antag;
|
|
using Content.Server.Communications;
|
|
using Content.Server.GameTicking.Rules.Components;
|
|
using Content.Server.Nuke;
|
|
using Content.Server.NukeOps;
|
|
using Content.Server.Popups;
|
|
using Content.Server.Roles;
|
|
using Content.Server.RoundEnd;
|
|
using Content.Server.Shuttles.Events;
|
|
using Content.Server.Shuttles.Systems;
|
|
using Content.Server.Station.Components;
|
|
using Content.Server.Store.Components;
|
|
using Content.Server.Store.Systems;
|
|
using Content.Shared.Mobs;
|
|
using Content.Shared.Mobs.Components;
|
|
using Content.Shared.NPC.Components;
|
|
using Content.Shared.NPC.Systems;
|
|
using Content.Shared.Nuke;
|
|
using Content.Shared.NukeOps;
|
|
using Content.Shared.Store;
|
|
using Content.Shared.Tag;
|
|
using Content.Shared.Zombies;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Random;
|
|
using Robust.Shared.Utility;
|
|
using System.Linq;
|
|
using Content.Server.GameTicking.Components;
|
|
using Content.Server.Humanoid;
|
|
using Content.Server.Preferences.Managers;
|
|
using Content.Server.StationEvents.Components;
|
|
using Content.Shared._White.Antag;
|
|
using Content.Shared.FixedPoint;
|
|
using Content.Shared.Humanoid;
|
|
using Content.Shared.Humanoid.Prototypes;
|
|
using Content.Shared.Mind;
|
|
using Content.Shared.Preferences;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Server.GameTicking.Rules;
|
|
|
|
public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
|
|
{
|
|
[Dependency] private readonly IServerPreferencesManager _prefs = default!;
|
|
[Dependency] private readonly HumanoidAppearanceSystem _humanoid = default!;
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
[Dependency] private readonly EmergencyShuttleSystem _emergency = default!;
|
|
[Dependency] private readonly NpcFactionSystem _npcFaction = default!;
|
|
[Dependency] private readonly AntagSelectionSystem _antag = default!;
|
|
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
|
[Dependency] private readonly RoundEndSystem _roundEndSystem = default!;
|
|
[Dependency] private readonly StoreSystem _store = default!;
|
|
[Dependency] private readonly TagSystem _tag = default!;
|
|
|
|
[ValidatePrototypeId<CurrencyPrototype>]
|
|
private const string TelecrystalCurrencyPrototype = "Telecrystal";
|
|
|
|
[ValidatePrototypeId<TagPrototype>]
|
|
private const string NukeOpsUplinkTagPrototype = "NukeOpsUplink";
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<NukeExplodedEvent>(OnNukeExploded);
|
|
SubscribeLocalEvent<GameRunLevelChangedEvent>(OnRunLevelChanged);
|
|
SubscribeLocalEvent<NukeDisarmSuccessEvent>(OnNukeDisarm);
|
|
|
|
SubscribeLocalEvent<NukeOperativeComponent, ComponentRemove>(OnComponentRemove);
|
|
SubscribeLocalEvent<NukeOperativeComponent, MobStateChangedEvent>(OnMobStateChanged);
|
|
SubscribeLocalEvent<NukeOperativeComponent, EntityZombifiedEvent>(OnOperativeZombified);
|
|
|
|
SubscribeLocalEvent<NukeOpsShuttleComponent, MapInitEvent>(OnMapInit);
|
|
|
|
SubscribeLocalEvent<ConsoleFTLAttemptEvent>(OnShuttleFTLAttempt);
|
|
SubscribeLocalEvent<WarDeclaredEvent>(OnWarDeclared);
|
|
SubscribeLocalEvent<CommunicationConsoleCallShuttleAttemptEvent>(OnShuttleCallAttempt);
|
|
|
|
SubscribeLocalEvent<NukeopsRuleComponent, AfterAntagEntitySelectedEvent>(OnAfterAntagEntSelected);
|
|
}
|
|
|
|
protected override void Started(
|
|
EntityUid uid,
|
|
NukeopsRuleComponent component,
|
|
GameRuleComponent gameRule,
|
|
GameRuleStartedEvent args)
|
|
{
|
|
var eligible = new List<Entity<StationEventEligibleComponent, NpcFactionMemberComponent>>();
|
|
var eligibleQuery = EntityQueryEnumerator<StationEventEligibleComponent, NpcFactionMemberComponent>();
|
|
while (eligibleQuery.MoveNext(out var eligibleUid, out var eligibleComp, out var member))
|
|
{
|
|
if (!_npcFaction.IsFactionHostile(component.Faction, (eligibleUid, member)))
|
|
continue;
|
|
|
|
eligible.Add((eligibleUid, eligibleComp, member));
|
|
}
|
|
|
|
if (eligible.Count == 0)
|
|
return;
|
|
|
|
component.TargetStation = RobustRandom.Pick(eligible);
|
|
}
|
|
|
|
#region Event Handlers
|
|
protected override void AppendRoundEndText(EntityUid uid, NukeopsRuleComponent component, GameRuleComponent gameRule,
|
|
ref RoundEndTextAppendEvent args)
|
|
{
|
|
var winText = Loc.GetString($"nukeops-{component.WinType.ToString().ToLower()}");
|
|
args.AddLine(winText);
|
|
|
|
foreach (var cond in component.WinConditions)
|
|
{
|
|
var text = Loc.GetString($"nukeops-cond-{cond.ToString().ToLower()}");
|
|
args.AddLine(text);
|
|
}
|
|
|
|
args.AddLine(Loc.GetString("nukeops-list-start"));
|
|
|
|
var antags =_antag.GetAntagIdentifiers(uid);
|
|
|
|
foreach (var (_, sessionData, name) in antags)
|
|
{
|
|
args.AddLine(Loc.GetString("nukeops-list-name-user", ("name", name), ("user", sessionData.UserName)));
|
|
}
|
|
}
|
|
|
|
private void OnNukeExploded(NukeExplodedEvent ev)
|
|
{
|
|
var query = QueryActiveRules();
|
|
while (query.MoveNext(out var uid, out _, out var nukeops, out _))
|
|
{
|
|
if (ev.OwningStation != null)
|
|
{
|
|
if (ev.OwningStation == GetOutpost(uid))
|
|
{
|
|
nukeops.WinConditions.Add(WinCondition.NukeExplodedOnNukieOutpost);
|
|
SetWinType((uid, nukeops), WinType.CrewMajor);
|
|
continue;
|
|
}
|
|
|
|
if (TryComp(nukeops.TargetStation, out StationDataComponent? data))
|
|
{
|
|
var correctStation = false;
|
|
foreach (var grid in data.Grids)
|
|
{
|
|
if (grid != ev.OwningStation)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
nukeops.WinConditions.Add(WinCondition.NukeExplodedOnCorrectStation);
|
|
|
|
// WD EDIT START
|
|
|
|
MapId? targetStationMap = null;
|
|
if (nukeops.TargetStation != null && TryComp(nukeops.TargetStation, out StationDataComponent? stationData))
|
|
{
|
|
var stationGrid = stationData.Grids.FirstOrNull();
|
|
targetStationMap = stationGrid != null
|
|
? Transform(stationGrid.Value).MapID
|
|
: null;
|
|
}
|
|
|
|
var operatives = EntityQuery<NukeOperativeComponent, TransformComponent>(true);
|
|
var operativesAlive = operatives
|
|
.Any(ent => ent.Item2.MapID != targetStationMap && ent.Item1.Running);
|
|
|
|
if (operativesAlive)
|
|
SetWinType((uid, nukeops), WinType.OpsMajor);
|
|
else
|
|
{
|
|
nukeops.WinConditions.Add(WinCondition.AllNukiesDead);
|
|
SetWinType((uid, nukeops), WinType.OpsMinor);
|
|
}
|
|
// WD EDIT END
|
|
|
|
correctStation = true;
|
|
}
|
|
|
|
if (correctStation)
|
|
continue;
|
|
}
|
|
|
|
nukeops.WinConditions.Add(WinCondition.NukeExplodedOnIncorrectLocation);
|
|
}
|
|
else
|
|
{
|
|
nukeops.WinConditions.Add(WinCondition.NukeExplodedOnIncorrectLocation);
|
|
}
|
|
|
|
_roundEndSystem.EndRound();
|
|
}
|
|
}
|
|
|
|
private void OnRunLevelChanged(GameRunLevelChangedEvent ev)
|
|
{
|
|
if (ev.New is not GameRunLevel.PostRound)
|
|
return;
|
|
|
|
var query = QueryActiveRules();
|
|
while (query.MoveNext(out var uid, out _, out var nukeops, out _))
|
|
{
|
|
OnRoundEnd((uid, nukeops));
|
|
}
|
|
}
|
|
|
|
private void OnRoundEnd(Entity<NukeopsRuleComponent> ent)
|
|
{
|
|
// If the win condition was set to operative/crew major win, ignore.
|
|
if (ent.Comp.WinType == WinType.OpsMajor || ent.Comp.WinType == WinType.CrewMajor)
|
|
return;
|
|
|
|
var nukeQuery = AllEntityQuery<NukeComponent, TransformComponent>();
|
|
var centcomms = _emergency.GetCentcommMaps();
|
|
|
|
while (nukeQuery.MoveNext(out var nuke, out var nukeTransform))
|
|
{
|
|
if (nuke.Status != NukeStatus.ARMED)
|
|
continue;
|
|
|
|
// UH OH
|
|
if (nukeTransform.MapUid != null && centcomms.Contains(nukeTransform.MapUid.Value))
|
|
{
|
|
ent.Comp.WinConditions.Add(WinCondition.NukeActiveAtCentCom);
|
|
SetWinType((ent, ent), WinType.OpsMajor);
|
|
return;
|
|
}
|
|
|
|
if (nukeTransform.GridUid == null || ent.Comp.TargetStation == null)
|
|
continue;
|
|
|
|
if (!TryComp(ent.Comp.TargetStation.Value, out StationDataComponent? data))
|
|
continue;
|
|
|
|
foreach (var grid in data.Grids)
|
|
{
|
|
if (grid != nukeTransform.GridUid)
|
|
continue;
|
|
|
|
ent.Comp.WinConditions.Add(WinCondition.NukeActiveInStation);
|
|
SetWinType(ent, WinType.OpsMajor);
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (_antag.AllAntagsAlive(ent.Owner))
|
|
{
|
|
SetWinType(ent, WinType.OpsMinor);
|
|
ent.Comp.WinConditions.Add(WinCondition.AllNukiesAlive);
|
|
return;
|
|
}
|
|
|
|
ent.Comp.WinConditions.Add(_antag.AnyAliveAntags(ent.Owner)
|
|
? WinCondition.SomeNukiesAlive
|
|
: WinCondition.AllNukiesDead);
|
|
|
|
var diskAtCentCom = false;
|
|
var diskQuery = AllEntityQuery<NukeDiskComponent, TransformComponent>();
|
|
while (diskQuery.MoveNext(out _, out var transform))
|
|
{
|
|
diskAtCentCom = transform.MapUid != null && centcomms.Contains(transform.MapUid.Value);
|
|
|
|
// TODO: The target station should be stored, and the nuke disk should store its original station.
|
|
// This is fine for now, because we can assume a single station in base SS14.
|
|
break;
|
|
}
|
|
|
|
// If the disk is currently at Central Command, the crew wins - just slightly.
|
|
// This also implies that some nuclear operatives have died.
|
|
SetWinType(ent, diskAtCentCom
|
|
? WinType.CrewMinor
|
|
: WinType.OpsMinor);
|
|
ent.Comp.WinConditions.Add(diskAtCentCom
|
|
? WinCondition.NukeDiskOnCentCom
|
|
: WinCondition.NukeDiskNotOnCentCom);
|
|
}
|
|
|
|
private void OnNukeDisarm(NukeDisarmSuccessEvent ev)
|
|
{
|
|
CheckRoundShouldEnd();
|
|
}
|
|
|
|
private void OnComponentRemove(EntityUid uid, NukeOperativeComponent component, ComponentRemove args)
|
|
{
|
|
RemComp<GlobalAntagonistComponent>(uid); // WD
|
|
CheckRoundShouldEnd();
|
|
}
|
|
|
|
private void OnMobStateChanged(EntityUid uid, NukeOperativeComponent component, MobStateChangedEvent ev)
|
|
{
|
|
if (ev.NewMobState == MobState.Dead)
|
|
CheckRoundShouldEnd();
|
|
}
|
|
|
|
private void OnOperativeZombified(EntityUid uid, NukeOperativeComponent component, ref EntityZombifiedEvent args)
|
|
{
|
|
RemCompDeferred(uid, component);
|
|
}
|
|
|
|
private void OnMapInit(Entity<NukeOpsShuttleComponent> ent, ref MapInitEvent args)
|
|
{
|
|
var map = Transform(ent).MapID;
|
|
|
|
var rules = EntityQueryEnumerator<NukeopsRuleComponent, LoadMapRuleComponent>();
|
|
while (rules.MoveNext(out var uid, out _, out var mapRule))
|
|
{
|
|
if (map != mapRule.Map)
|
|
continue;
|
|
ent.Comp.AssociatedRule = uid;
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void OnShuttleFTLAttempt(ref ConsoleFTLAttemptEvent ev)
|
|
{
|
|
var query = QueryActiveRules();
|
|
while (query.MoveNext(out var uid, out _, out var nukeops, out _))
|
|
{
|
|
if (ev.Uid != GetShuttle((uid, nukeops)))
|
|
continue;
|
|
|
|
if (nukeops.WarDeclaredTime != null)
|
|
{
|
|
var timeAfterDeclaration = Timing.CurTime.Subtract(nukeops.WarDeclaredTime.Value);
|
|
var timeRemain = nukeops.WarNukieArriveDelay.Subtract(timeAfterDeclaration);
|
|
if (timeRemain > TimeSpan.Zero)
|
|
{
|
|
ev.Cancelled = true;
|
|
ev.Reason = Loc.GetString("war-ops-infiltrator-unavailable",
|
|
("time", timeRemain.ToString("mm\\:ss")));
|
|
|
|
continue;
|
|
}
|
|
}
|
|
|
|
nukeops.LeftOutpost = true;
|
|
}
|
|
}
|
|
|
|
private void OnShuttleCallAttempt(ref CommunicationConsoleCallShuttleAttemptEvent ev)
|
|
{
|
|
var query = QueryActiveRules();
|
|
while (query.MoveNext(out _, out _, out var nukeops, out _))
|
|
{
|
|
// Can't call while war nukies are preparing to arrive
|
|
if (nukeops is { WarDeclaredTime: not null })
|
|
{
|
|
// Nukies must wait some time after declaration of war to get on the station
|
|
var warTime = Timing.CurTime.Subtract(nukeops.WarDeclaredTime.Value);
|
|
if (warTime < nukeops.WarNukieArriveDelay)
|
|
{
|
|
ev.Cancelled = true;
|
|
ev.Reason = Loc.GetString("war-ops-shuttle-call-unavailable");
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void OnWarDeclared(ref WarDeclaredEvent ev)
|
|
{
|
|
// TODO: this is VERY awful for multi-nukies
|
|
var query = QueryActiveRules();
|
|
while (query.MoveNext(out var uid, out _, out var nukeops, out _))
|
|
{
|
|
if (nukeops.WarDeclaredTime != null)
|
|
continue;
|
|
|
|
if (TryComp<LoadMapRuleComponent>(uid, out var mapComp) && Transform(ev.DeclaratorEntity).MapID != mapComp.Map)
|
|
continue;
|
|
|
|
var newStatus = GetWarCondition(nukeops, ev.Status);
|
|
ev.Status = newStatus;
|
|
if (newStatus == WarConditionStatus.WarReady)
|
|
{
|
|
nukeops.WarDeclaredTime = Timing.CurTime;
|
|
var timeRemain = nukeops.WarNukieArriveDelay + Timing.CurTime;
|
|
ev.DeclaratorEntity.Comp.ShuttleDisabledTime = timeRemain;
|
|
|
|
DistributeExtraTc((uid, nukeops));
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion Event Handlers
|
|
|
|
/// <summary>
|
|
/// Returns conditions for war declaration
|
|
/// </summary>
|
|
public WarConditionStatus GetWarCondition(NukeopsRuleComponent nukieRule, WarConditionStatus? oldStatus)
|
|
{
|
|
if (!nukieRule.CanEnableWarOps)
|
|
return WarConditionStatus.NoWarUnknown;
|
|
|
|
if (EntityQuery<NukeopsRoleComponent>().Count() < nukieRule.WarDeclarationMinOps)
|
|
return WarConditionStatus.NoWarSmallCrew;
|
|
|
|
if (nukieRule.LeftOutpost)
|
|
return WarConditionStatus.NoWarShuttleDeparted;
|
|
|
|
if (oldStatus == WarConditionStatus.YesWar)
|
|
return WarConditionStatus.WarReady;
|
|
|
|
return WarConditionStatus.YesWar;
|
|
}
|
|
|
|
private void DistributeExtraTc(Entity<NukeopsRuleComponent> nukieRule)
|
|
{
|
|
var enumerator = EntityQueryEnumerator<StoreComponent>();
|
|
while (enumerator.MoveNext(out var uid, out var component))
|
|
{
|
|
if (!_tag.HasTag(uid, NukeOpsUplinkTagPrototype))
|
|
continue;
|
|
|
|
if (GetOutpost(nukieRule.Owner) is not { } outpost)
|
|
continue;
|
|
|
|
if (Transform(uid).MapID != Transform(outpost).MapID) // Will receive bonus TC only on their start outpost
|
|
continue;
|
|
|
|
_store.TryAddCurrency(new () { { TelecrystalCurrencyPrototype, nukieRule.Comp.WarTcAmountPerNukie } }, uid, component);
|
|
|
|
var msg = Loc.GetString("store-currency-war-boost-given", ("target", uid));
|
|
_popupSystem.PopupEntity(msg, uid);
|
|
}
|
|
}
|
|
|
|
private void SetWinType(Entity<NukeopsRuleComponent> ent, WinType type, bool endRound = true)
|
|
{
|
|
ent.Comp.WinType = type;
|
|
|
|
if (endRound && (type == WinType.CrewMajor || type == WinType.OpsMajor))
|
|
_roundEndSystem.EndRound();
|
|
}
|
|
|
|
private void CheckRoundShouldEnd()
|
|
{
|
|
var query = QueryActiveRules();
|
|
while (query.MoveNext(out var uid, out _, out var nukeops, out _))
|
|
{
|
|
CheckRoundShouldEnd((uid, nukeops));
|
|
}
|
|
}
|
|
|
|
private void CheckRoundShouldEnd(Entity<NukeopsRuleComponent> ent)
|
|
{
|
|
var nukeops = ent.Comp;
|
|
|
|
if (nukeops.RoundEndBehavior == RoundEndBehavior.Nothing || nukeops.WinType == WinType.CrewMajor || nukeops.WinType == WinType.OpsMajor)
|
|
return;
|
|
|
|
// If there are any nuclear bombs that are active, immediately return. We're not over yet.
|
|
foreach (var nuke in EntityQuery<NukeComponent>())
|
|
{
|
|
if (nuke.Status == NukeStatus.ARMED)
|
|
return;
|
|
}
|
|
|
|
var shuttle = GetShuttle((ent, ent));
|
|
|
|
MapId? shuttleMapId = Exists(shuttle)
|
|
? Transform(shuttle.Value).MapID
|
|
: null;
|
|
|
|
MapId? targetStationMap = null;
|
|
if (nukeops.TargetStation != null && TryComp(nukeops.TargetStation, out StationDataComponent? data))
|
|
{
|
|
var grid = data.Grids.FirstOrNull();
|
|
targetStationMap = grid != null
|
|
? Transform(grid.Value).MapID
|
|
: null;
|
|
}
|
|
|
|
// Check if there are nuke operatives still alive on the same map as the shuttle,
|
|
// or on the same map as the station.
|
|
// If there are, the round can continue.
|
|
var operatives = EntityQuery<NukeOperativeComponent, MobStateComponent, TransformComponent>(true);
|
|
var operativesAlive = operatives
|
|
.Where(op =>
|
|
op.Item3.MapID == shuttleMapId
|
|
|| op.Item3.MapID == targetStationMap)
|
|
.Any(op => op.Item2.CurrentState == MobState.Alive && op.Item1.Running);
|
|
|
|
if (operativesAlive)
|
|
return; // There are living operatives than can access the shuttle, or are still on the station's map.
|
|
|
|
// Check that there are spawns available and that they can access the shuttle.
|
|
var spawnsAvailable = EntityQuery<NukeOperativeSpawnerComponent>(true).Any();
|
|
if (spawnsAvailable && CompOrNull<LoadMapRuleComponent>(ent)?.Map == shuttleMapId)
|
|
return; // Ghost spawns can still access the shuttle. Continue the round.
|
|
|
|
// The shuttle is inaccessible to both living nuke operatives and yet to spawn nuke operatives,
|
|
// and there are no nuclear operatives on the target station's map.
|
|
nukeops.WinConditions.Add(spawnsAvailable
|
|
? WinCondition.NukiesAbandoned
|
|
: WinCondition.AllNukiesDead);
|
|
|
|
SetWinType(ent, WinType.CrewMajor, false);
|
|
|
|
// WD EDIT, check for all at once gamemode
|
|
if (!GameTicker.GetActiveGameRules().Where(HasComp<RampingStationEventSchedulerComponent>).Any())
|
|
{
|
|
_roundEndSystem.DoRoundEndBehavior(
|
|
nukeops.RoundEndBehavior, nukeops.EvacShuttleTime, nukeops.RoundEndTextSender,
|
|
nukeops.RoundEndTextShuttleCall, nukeops.RoundEndTextAnnouncement);
|
|
}
|
|
|
|
// prevent it called multiple times
|
|
nukeops.RoundEndBehavior = RoundEndBehavior.Nothing;
|
|
}
|
|
|
|
// this should really go anywhere else but im tired.
|
|
private void OnAntagSelectEntity(Entity<NukeopsRuleComponent> ent, ref AntagSelectEntityEvent args)
|
|
{
|
|
if (args.Handled)
|
|
return;
|
|
|
|
var profile = args.Session != null
|
|
? _prefs.GetPreferences(args.Session.UserId).SelectedCharacter as HumanoidCharacterProfile
|
|
: HumanoidCharacterProfile.RandomWithSpecies();
|
|
|
|
if (!_prototypeManager.TryIndex(profile?.Species ?? SharedHumanoidAppearanceSystem.DefaultSpecies, out SpeciesPrototype? species))
|
|
{
|
|
species = _prototypeManager.Index<SpeciesPrototype>(SharedHumanoidAppearanceSystem.DefaultSpecies);
|
|
}
|
|
|
|
args.Entity = Spawn(species.Prototype);
|
|
_humanoid.LoadProfile(args.Entity.Value, profile);
|
|
}
|
|
|
|
private void OnAfterAntagEntSelected(Entity<NukeopsRuleComponent> ent, ref AfterAntagEntitySelectedEvent args)
|
|
{
|
|
if (ent.Comp.TargetStation is not { } station)
|
|
return;
|
|
|
|
_antag.SendBriefing(args.Session, Loc.GetString("nukeops-welcome",
|
|
("station", station),
|
|
("name", Name(ent))),
|
|
Color.Red,
|
|
ent.Comp.GreetSoundNotification);
|
|
}
|
|
|
|
/// <remarks>
|
|
/// Is this method the shitty glue holding together the last of my sanity? yes.
|
|
/// Do i have a better solution? not presently.
|
|
/// </remarks>
|
|
private EntityUid? GetOutpost(Entity<LoadMapRuleComponent?> ent)
|
|
{
|
|
if (!Resolve(ent, ref ent.Comp, false))
|
|
return null;
|
|
|
|
return ent.Comp.MapGrids.Where(e => HasComp<StationMemberComponent>(e) && !HasComp<NukeOpsShuttleComponent>(e)).FirstOrNull();
|
|
}
|
|
|
|
/// <remarks>
|
|
/// Is this method the shitty glue holding together the last of my sanity? yes.
|
|
/// Do i have a better solution? not presently.
|
|
/// </remarks>
|
|
private EntityUid? GetShuttle(Entity<NukeopsRuleComponent?> ent)
|
|
{
|
|
if (!Resolve(ent, ref ent.Comp, false))
|
|
return null;
|
|
|
|
var query = EntityQueryEnumerator<NukeOpsShuttleComponent>();
|
|
while (query.MoveNext(out var uid, out var comp))
|
|
{
|
|
if (comp.AssociatedRule == ent.Owner)
|
|
return uid;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
// WD ADDED
|
|
public void TransferRole(EntityUid transferFrom, EntityUid transferTo)
|
|
{
|
|
if (!HasComp<NukeOperativeComponent>(transferFrom))
|
|
return;
|
|
|
|
EnsureComp<NukeOperativeComponent>(transferTo);
|
|
RemComp<NukeOperativeComponent>(transferFrom);
|
|
}
|
|
}
|