# Conflicts: # Content.Client/Construction/UI/ConstructionMenu.xaml # Content.Client/Construction/UI/ConstructionMenu.xaml.cs # Content.Client/Construction/UI/ConstructionMenuPresenter.cs # Content.Server/Warps/WarpPointSystem.cs # Content.Server/Weapons/Ranged/Systems/GunSystem.Battery.cs # Content.Server/Weapons/Ranged/Systems/GunSystem.cs # Content.Shared/Construction/Steps/ArbitraryInsertConstructionGraphStep.cs # Content.Shared/Construction/Steps/MaterialConstructionGraphStep.cs # Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs # Content.Shared/Inventory/InventorySystem.Relay.cs # Content.Shared/Weapons/Reflect/ReflectSystem.cs # Resources/Locale/en-US/_strings/plants/mutations.ftl # Resources/Locale/en-US/_strings/stack/stacks.ftl # Resources/Locale/en-US/_strings/teleportation/teleportation-menu-gui.ftl # Resources/Prototypes/Catalog/Fills/Backpacks/duffelbag.yml # Resources/Prototypes/Catalog/Fills/Lockers/heads.yml # Resources/Prototypes/Catalog/VendingMachines/Inventories/winterdrobe.yml # Resources/Prototypes/Entities/Clothing/Eyes/glasses.yml # Resources/Prototypes/Entities/Clothing/OuterClothing/armor.yml # Resources/Prototypes/Entities/Objects/Power/powercells.yml # Resources/Prototypes/Entities/Objects/Specific/Cargo/cargo_pallet.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/shotgun.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml # Resources/Prototypes/Entities/Objects/Weapons/Melee/sword.yml # Resources/Prototypes/Entities/Stations/base.yml # Resources/Prototypes/Entities/Structures/Machines/nuke.yml # Resources/Prototypes/Reagents/toxins.yml # Resources/Prototypes/Recipes/Construction/Graphs/clothing/clown_banana.yml # Resources/Prototypes/Recipes/Construction/Graphs/machines/computer.yml # Resources/Prototypes/Recipes/Construction/Graphs/mechs/hamtr_construction.yml # Resources/Prototypes/Recipes/Construction/Graphs/mechs/honker_construction.yml # Resources/Prototypes/Recipes/Construction/Graphs/mechs/ripley_construction.yml # Resources/Prototypes/Recipes/Construction/Graphs/mechs/vim_construction.yml # Resources/Prototypes/Recipes/Construction/Graphs/structures/airlock.yml # Resources/Prototypes/Recipes/Construction/Graphs/structures/airlock_clockwork.yml # Resources/Prototypes/Recipes/Construction/Graphs/structures/blast_door.yml # Resources/Prototypes/Recipes/Construction/Graphs/structures/conveyor.yml # Resources/Prototypes/Recipes/Construction/Graphs/structures/firelock.yml # Resources/Prototypes/Recipes/Construction/Graphs/structures/glassbox.yml # Resources/Prototypes/Recipes/Construction/Graphs/structures/secretdoor.yml # Resources/Prototypes/Recipes/Construction/Graphs/structures/shutter.yml # Resources/Prototypes/Recipes/Construction/Graphs/structures/shuttle.yml # Resources/Prototypes/Recipes/Construction/Graphs/structures/windoor.yml # Resources/Prototypes/Recipes/Construction/Graphs/tools/logic_gate.yml # Resources/Prototypes/Recipes/Construction/Graphs/utilities/APC.yml # Resources/Prototypes/Recipes/Construction/Graphs/utilities/air_alarms.yml # Resources/Prototypes/Recipes/Construction/Graphs/utilities/disposal_machines.yml # Resources/Prototypes/Recipes/Construction/Graphs/utilities/intercom.yml # Resources/Prototypes/Recipes/Construction/Graphs/utilities/lighting.yml # Resources/Prototypes/Recipes/Construction/Graphs/utilities/solarpanel.yml # Resources/Prototypes/Recipes/Construction/Graphs/utilities/station_maps.yml # Resources/Prototypes/Recipes/Construction/Graphs/utilities/wallmount_generator.yml # Resources/Prototypes/Recipes/Construction/Graphs/utilities/wallmount_substation.yml # Resources/Prototypes/Recipes/Construction/Graphs/weapons/bladed_hats.yml # Resources/Prototypes/Recipes/Construction/Graphs/weapons/bola.yml # Resources/Prototypes/Recipes/Construction/Graphs/weapons/improvised_arrow.yml # Resources/Prototypes/Recipes/Construction/Graphs/weapons/modular_grenade.yml # Resources/Prototypes/Recipes/Construction/Graphs/weapons/modular_mine.yml # Resources/Prototypes/Recipes/Construction/Graphs/weapons/shiv.yml # Resources/Prototypes/Recipes/Construction/Graphs/weapons/spear.yml # Resources/Prototypes/Recipes/Construction/structures.yml # Resources/Prototypes/Recipes/Crafting/Graphs/bots/cleanbot.yml # Resources/Prototypes/Recipes/Crafting/Graphs/bots/firebot.yml # Resources/Prototypes/Recipes/Crafting/Graphs/bots/honkbot.yml # Resources/Prototypes/Recipes/Crafting/Graphs/bots/medibot.yml # Resources/Prototypes/Recipes/Crafting/Graphs/bots/mimebot.yml # Resources/Prototypes/Recipes/Crafting/Graphs/bots/supplybot.yml # Resources/Prototypes/Recipes/Crafting/Graphs/improvised/firebomb.yml # Resources/Prototypes/Recipes/Crafting/Graphs/improvised/improvised_shotgun.yml # Resources/Prototypes/Recipes/Crafting/Graphs/improvised/improvised_shotgun_shell.yml # Resources/Prototypes/Recipes/Crafting/Graphs/improvised/makeshiftstunprod.yml # Resources/Prototypes/Recipes/Crafting/Graphs/improvised/pipebomb.yml # Resources/Prototypes/Recipes/Crafting/Graphs/improvised/pneumatic_cannon.yml # Resources/Prototypes/Recipes/Crafting/Graphs/improvised/potato.yml # Resources/Prototypes/Recipes/Crafting/Graphs/storage/cratefreezer.yml # Resources/Prototypes/Recipes/Crafting/Graphs/storage/tallbox.yml # Resources/Prototypes/Recipes/Crafting/Graphs/strawhat.yml # Resources/Prototypes/Recipes/Crafting/Graphs/toys.yml # Resources/Prototypes/Recipes/Crafting/improvised.yml # Resources/Prototypes/Recipes/Reactions/medicine.yml # Resources/Prototypes/Roles/Jobs/CentComm/official.yml # Resources/Textures/Clothing/Neck/mantles/cemantle.rsi/equipped-NECK.png # Resources/Textures/Clothing/Neck/mantles/cemantle.rsi/icon.png # Resources/Textures/Clothing/Neck/mantles/cemantle.rsi/meta.json # Resources/Textures/Clothing/Uniforms/Jumpskirt/mime.rsi/equipped-INNERCLOTHING.png # Resources/Textures/Clothing/Uniforms/Jumpskirt/mime.rsi/icon.png # Resources/Textures/Clothing/Uniforms/Jumpskirt/mime.rsi/inhand-left.png # Resources/Textures/Clothing/Uniforms/Jumpskirt/mime.rsi/inhand-right.png # Resources/Textures/Clothing/Uniforms/Jumpskirt/mime.rsi/meta.json # Resources/Textures/Clothing/Uniforms/Jumpsuit/mime.rsi/equipped-INNERCLOTHING.png # Resources/Textures/Clothing/Uniforms/Jumpsuit/mime.rsi/icon.png # Resources/Textures/Clothing/Uniforms/Jumpsuit/mime.rsi/inhand-left.png # Resources/Textures/Clothing/Uniforms/Jumpsuit/mime.rsi/inhand-right.png # Resources/Textures/Clothing/Uniforms/Jumpsuit/mime.rsi/meta.json
91 lines
3.4 KiB
C#
91 lines
3.4 KiB
C#
using Content.Server._Sunrise.TraitorTarget;
|
|
using Content.Server.Objectives.Components;
|
|
using Content.Server.Shuttles.Systems;
|
|
using Content.Shared.CCVar;
|
|
using Content.Shared.Humanoid;
|
|
using Content.Shared.Mind;
|
|
using Content.Shared.Objectives.Components;
|
|
using Robust.Shared.Configuration;
|
|
using Content.Shared.Mobs.Systems;
|
|
using Content.Shared.Mobs.Components;
|
|
|
|
namespace Content.Server.Objectives.Systems;
|
|
|
|
/// <summary>
|
|
/// Handles kill person condition logic and picking random kill targets.
|
|
/// </summary>
|
|
public sealed class KillPersonConditionSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly EmergencyShuttleSystem _emergencyShuttle = default!;
|
|
[Dependency] private readonly IConfigurationManager _config = default!;
|
|
[Dependency] private readonly SharedMindSystem _mind = default!;
|
|
[Dependency] private readonly TargetObjectiveSystem _target = default!;
|
|
[Dependency] private readonly MobStateSystem _mobState = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<KillPersonConditionComponent, ObjectiveGetProgressEvent>(OnGetProgress);
|
|
}
|
|
|
|
private void OnGetProgress(EntityUid uid, KillPersonConditionComponent comp, ref ObjectiveGetProgressEvent args)
|
|
{
|
|
if (!_target.GetTarget(uid, out var target))
|
|
return;
|
|
|
|
args.Progress = GetProgress(target.Value, comp.RequireDead, comp.RequireMaroon);
|
|
}
|
|
|
|
private float GetProgress(EntityUid target, bool requireDead, bool requireMaroon)
|
|
{
|
|
// deleted or gibbed or something, counts as dead
|
|
if (!TryComp<MindComponent>(target, out var mind) || mind.OwnedEntity == null)
|
|
return 1f;
|
|
|
|
var targetDead = _mind.IsCharacterDeadIc(mind);
|
|
var targetOnShuttle = _emergencyShuttle.IsTargetEscaping(mind.OwnedEntity.Value);
|
|
if (!_config.GetCVar(CCVars.EmergencyShuttleEnabled) && requireMaroon)
|
|
{
|
|
requireDead = true;
|
|
requireMaroon = false;
|
|
}
|
|
|
|
if (requireDead && !targetDead)
|
|
return 0f;
|
|
|
|
// Always failed if the target needs to be marooned and the shuttle hasn't even arrived yet
|
|
if (requireMaroon && !_emergencyShuttle.EmergencyShuttleArrived)
|
|
return 0f;
|
|
|
|
// If the shuttle hasn't left, give 50% progress if the target isn't on the shuttle as a "almost there!"
|
|
if (requireMaroon && !_emergencyShuttle.ShuttlesLeft)
|
|
return targetOnShuttle ? 0f : 0.5f;
|
|
|
|
// If the shuttle has already left, and the target isn't on it, 100%
|
|
if (requireMaroon && _emergencyShuttle.ShuttlesLeft)
|
|
return targetOnShuttle ? 0f : 1f;
|
|
|
|
return 1f; // Good job you did it woohoo
|
|
}
|
|
|
|
// Sunrise-Start
|
|
public HashSet<Entity<MindComponent>> GetAliveTargetsExcept(EntityUid exclude)
|
|
{
|
|
var allTargets = new HashSet<Entity<MindComponent>>();
|
|
|
|
var query = EntityQueryEnumerator<MobStateComponent, AntagTargetComponent, HumanoidAppearanceComponent>();
|
|
while (query.MoveNext(out var uid, out var mobState, out var antagTarget, out _))
|
|
{
|
|
if (!_mind.TryGetMind(uid, out var mind, out var mindComp) ||
|
|
mind == exclude || !_mobState.IsAlive(uid, mobState) ||
|
|
antagTarget.KillerMind != null)
|
|
continue;
|
|
|
|
allTargets.Add(new Entity<MindComponent>(mind, mindComp));
|
|
}
|
|
|
|
return allTargets;
|
|
}
|
|
// Sunrise-End
|
|
}
|