Files
space-station-14/Content.Server/Objectives/Systems/HijackShuttleConditionSystem.cs
pathetic meowmeow 8cf744ec55 Visual nubody (humanoid appearance refactor) (#42476)
* initial visual nubody

* oops overlay

* im so pheeming rn

* conversion...

* tests

* comeback of the underwear

* oops eyes

* blabbl

* zeds

* yaml linted

* search and visible count constraints

* reordering

* preserve previously selected markings colors

* fix test

* some ui niceties

* ordering

* make DB changes backwards-compatible/downgrade-friendly

* fix things again

* fix migration

* vulpkanin markings limit increase

* wrapping

* code cleanup and more code cleanup and more code cleanup and more code cleanup and

* fix slop ports

* better sampling API

* make filter work + use the method i made for its intended purpose

* fix test fails real quick

* magic mirror cleanup, remove TODO

* don't 0-init the organ profile data

* remove deltastates

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
2026-01-20 07:07:53 +00:00

105 lines
3.5 KiB
C#

using Content.Server.Objectives.Components;
using Content.Server.Shuttles.Components;
using Content.Server.Shuttles.Systems;
using Content.Shared.Cuffs.Components;
using Content.Shared.Humanoid;
using Content.Shared.Mind;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Objectives.Components;
using Content.Shared.Roles;
using Robust.Shared.Player;
namespace Content.Server.Objectives.Systems;
public sealed class HijackShuttleConditionSystem : EntitySystem
{
[Dependency] private readonly EmergencyShuttleSystem _emergencyShuttle = default!;
[Dependency] private readonly SharedMindSystem _mind = default!;
[Dependency] private readonly SharedRoleSystem _role = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<HijackShuttleConditionComponent, ObjectiveGetProgressEvent>(OnGetProgress);
}
private void OnGetProgress(EntityUid uid, HijackShuttleConditionComponent comp, ref ObjectiveGetProgressEvent args)
{
args.Progress = GetProgress(args.MindId, args.Mind);
}
private float GetProgress(EntityUid mindId, MindComponent mind)
{
// Not escaping alive if you're deleted/dead
if (mind.OwnedEntity == null || _mind.IsCharacterDeadIc(mind))
return 0f;
// You're not escaping if you're restrained!
if (TryComp<CuffableComponent>(mind.OwnedEntity, out var cuffed) && cuffed.CuffedHandCount > 0)
return 0f;
// There no emergency shuttles
if (!_emergencyShuttle.EmergencyShuttleArrived)
return 0f;
// Check hijack for each emergency shuttle
foreach (var stationData in EntityQuery<StationEmergencyShuttleComponent>())
{
if (stationData.EmergencyShuttle == null)
continue;
if (IsShuttleHijacked(stationData.EmergencyShuttle.Value, mindId))
return 1f;
}
return 0f;
}
private bool IsShuttleHijacked(EntityUid shuttleGridId, EntityUid mindId)
{
var gridPlayers = Filter.BroadcastGrid(shuttleGridId).Recipients;
var humanoids = GetEntityQuery<HumanoidProfileComponent>();
var cuffable = GetEntityQuery<CuffableComponent>();
EntityQuery<MobStateComponent>();
var agentOnShuttle = false;
foreach (var player in gridPlayers)
{
if (player.AttachedEntity == null ||
!_mind.TryGetMind(player.AttachedEntity.Value, out var crewMindId, out _))
continue;
if (mindId == crewMindId)
{
agentOnShuttle = true;
continue;
}
var isHumanoid = humanoids.HasComponent(player.AttachedEntity.Value);
if (!isHumanoid) // Only humanoids count as enemies
continue;
var isAntagonist = _role.MindIsAntagonist(mindId);
if (isAntagonist) // Allow antagonist
continue;
var isPersonIncapacitated = _mobState.IsIncapacitated(player.AttachedEntity.Value);
if (isPersonIncapacitated) // Allow dead and crit
continue;
var isPersonCuffed =
cuffable.TryGetComponent(player.AttachedEntity.Value, out var cuffed)
&& cuffed.CuffedHandCount > 0;
if (isPersonCuffed) // Allow handcuffed
continue;
return false;
}
return agentOnShuttle;
}
}