# Conflicts: # .github/CODEOWNERS # .github/workflows/publish.yml # Content.Client/Administration/UI/BanPanel/BanPanel.xaml # Content.Client/Administration/UI/BanPanel/BanPanel.xaml.cs # Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTabEntry.xaml.cs # Content.Client/Entry/EntryPoint.cs # Content.Client/Hands/Systems/HandsSystem.cs # Content.Client/Humanoid/HumanoidAppearanceSystem.cs # Content.Client/Humanoid/SingleMarkingPicker.xaml.cs # Content.Client/IoC/ClientContentIoC.cs # Content.Client/Lobby/LobbyState.cs # Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs # Content.Client/Lobby/UI/Loadouts/LoadoutGroupContainer.xaml.cs # Content.Client/Lobby/UI/LobbyGui.xaml # Content.Client/NetworkConfigurator/NetworkConfiguratorConfigurationMenu.xaml # Content.Client/Options/UI/EscapeMenu.xaml # Content.Client/Stealth/StealthSystem.cs # Content.Client/SurveillanceCamera/UI/SurveillanceCameraMonitorWindow.xaml.cs # Content.Client/UserInterface/Systems/Chat/Widgets/ChatBox.xaml.cs # Content.Client/UserInterface/Systems/Emotes/EmotesUIController.cs # Content.Client/Weapons/Ranged/Systems/GunSystem.cs # Content.IntegrationTests/Tests/Commands/SuicideCommandTests.cs # Content.IntegrationTests/Tests/Damageable/DamageableTest.cs # Content.IntegrationTests/Tests/PostMapInitTest.cs # Content.Server/Administration/Commands/AdminWhoCommand.cs # Content.Server/Administration/Commands/PardonCommand.cs # Content.Server/Administration/Commands/RoleUnbanCommand.cs # Content.Server/Administration/Commands/SetOutfitCommand.cs # Content.Server/Administration/Systems/AdminVerbSystem.Antags.cs # Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs # Content.Server/AlertLevel/Commands/SetAlertLevelCommand.cs # Content.Server/Body/Components/BloodstreamComponent.cs # Content.Server/Body/Systems/BloodstreamSystem.cs # Content.Server/Body/Systems/MetabolizerSystem.cs # Content.Server/Body/Systems/RespiratorSystem.cs # Content.Server/Chat/Managers/ChatSanitizationManager.cs # Content.Server/Chat/Systems/ChatSystem.Emote.cs # Content.Server/Chat/Systems/ChatSystem.cs # Content.Server/CrewManifest/CrewManifestSystem.cs # Content.Server/Emp/EmpSystem.cs # Content.Server/Explosion/EntitySystems/TriggerSystem.cs # Content.Server/Fax/FaxSystem.cs # Content.Server/Fluids/EntitySystems/AbsorbentSystem.cs # Content.Server/GameTicking/Commands/ForceMapCommand.cs # Content.Server/GameTicking/Commands/ForcePresetCommand.cs # Content.Server/GameTicking/Presets/GamePresetPrototype.cs # Content.Server/GameTicking/Rules/ChangelingRuleSystem.cs # Content.Server/GameTicking/Rules/Components/ChangelingRuleComponent.cs # Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs # Content.Server/Ghost/Roles/GhostRoleSystem.cs # Content.Server/Implants/Components/ScramImplantComponent.cs # Content.Server/Implants/SubdermalImplantSystem.cs # Content.Server/Materials/ProduceMaterialExtractorSystem.cs # Content.Server/Medical/HealthAnalyzerSystem.cs # Content.Server/NPC/Systems/NPCCombatSystem.Ranged.cs # Content.Server/NPC/Systems/NPCSystem.cs # Content.Server/Polymorph/Systems/PolymorphSystem.cs # Content.Server/Radio/EntitySystems/HeadsetSystem.cs # Content.Server/Repairable/RepairableSystem.cs # Content.Server/Revenant/EntitySystems/RevenantSystem.cs # Content.Server/RoundEnd/RoundEndSystem.cs # Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs # Content.Server/Speech/EntitySystems/FrenchAccentSystem.cs # Content.Server/Speech/EntitySystems/FrontalLispSystem.cs # Content.Server/Speech/EntitySystems/LizardAccentSystem.cs # Content.Server/Speech/EntitySystems/MothAccentSystem.cs # Content.Server/Speech/EntitySystems/OwOAccentSystem.cs # Content.Server/Station/Systems/StationSpawningSystem.cs # Content.Server/StationEvents/Events/MeteorSwarmSystem.cs # Content.Server/Stunnable/Components/StunOnCollideComponent.cs # Content.Server/SurveillanceCamera/Components/SurveillanceCameraRouterComponent.cs # Content.Server/Weapons/Ranged/Systems/GunSystem.Cartridges.cs # Content.Server/Zombies/ZombieSystem.Transform.cs # Content.Server/Zombies/ZombieSystem.cs # Content.Shared/Actions/SharedActionsSystem.cs # Content.Shared/Bed/SharedBedSystem.cs # Content.Shared/Blocking/BlockingSystem.cs # Content.Shared/Body/Systems/SharedBodySystem.Parts.cs # Content.Shared/Chemistry/Components/SolutionRegenerationComponent.cs # Content.Shared/Chemistry/EntitySystems/HypospraySystem.cs # Content.Shared/Construction/Conditions/TileNotBlocked.cs # Content.Shared/Cuffs/SharedCuffableSystem.cs # Content.Shared/Doors/Systems/SharedDoorSystem.cs # Content.Shared/Emoting/EmoteAttemptEvent.cs # Content.Shared/Eye/Blinding/Systems/BlindableSystem.cs # Content.Shared/Eye/VisibilityFlags.cs # Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs # Content.Shared/Humanoid/HumanoidCharacterAppearance.cs # Content.Shared/Interaction/SmartEquipSystem.cs # Content.Shared/Inventory/InventorySystem.Relay.cs # Content.Shared/Medical/Cryogenics/SharedCryoPodSystem.cs # Content.Shared/Medical/Healing/HealingSystem.cs # Content.Shared/Medical/HealingComponent.cs # Content.Shared/Nutrition/EntitySystems/FoodSystem.cs # Content.Shared/Slippery/SlipperySystem.cs # Content.Shared/SprayPainter/SharedSprayPainterSystem.cs # Content.Shared/Standing/StandingStateComponent.cs # Content.Shared/Standing/StandingStateSystem.cs # Content.Shared/Station/SharedStationSpawningSystem.cs # Content.Shared/Stunnable/SharedStunSystem.cs # Content.Shared/SurveillanceCamera/SharedSurveillanceCameraMonitorSystem.cs # Content.Shared/VendingMachines/VendingMachineComponent.cs # Content.Shared/Warps/WarpPointSystem.cs # Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs # Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs # Content.Shared/Wieldable/SharedWieldableSystem.cs # Resources/Audio/Ambience/Antag/attributions.yml # Resources/Audio/Ambience/Antag/changeling_start.ogg # Resources/Audio/Effects/attributions.yml # Resources/Audio/Lobby/attributions.yml # Resources/Audio/Machines/attributions.yml # Resources/Audio/Weapons/Guns/Gunshots/attributions.yml # Resources/Locale/en-US/_strings/administration/antag.ftl # Resources/Locale/en-US/_strings/administration/commands/camera.ftl # Resources/Locale/en-US/_strings/administration/commands/dsay-command.ftl # Resources/Locale/en-US/_strings/administration/commands/follow-command.ftl # Resources/Locale/en-US/_strings/administration/smites.ftl # Resources/Locale/en-US/_strings/administration/ui/admin-camera-window.ftl # Resources/Locale/en-US/_strings/administration/ui/role-bans.ftl # Resources/Locale/en-US/_strings/alerts/alerts.ftl # Resources/Locale/en-US/_strings/atmos/gas-pressure-regulator-system.ftl # Resources/Locale/en-US/_strings/bonk/components/bonkable-component.ftl # Resources/Locale/en-US/_strings/commands/add-body-part-command.ftl # Resources/Locale/en-US/_strings/commands/admin-logs-command.ftl # Resources/Locale/en-US/_strings/commands/admin-who-command.ftl # Resources/Locale/en-US/_strings/commands/asay-command.ftl # Resources/Locale/en-US/_strings/commands/crew-manifest-command.ftl # Resources/Locale/en-US/_strings/commands/deadmin-command.ftl # Resources/Locale/en-US/_strings/commands/delete-component-command.ftl # Resources/Locale/en-US/_strings/commands/destroy-mechanism-command.ftl # Resources/Locale/en-US/_strings/commands/dirty-command.ftl # Resources/Locale/en-US/_strings/commands/dsay-command.ftl # Resources/Locale/en-US/_strings/commands/dump-reagent-guide-text-command.ftl # Resources/Locale/en-US/_strings/commands/eye-commands.ftl # Resources/Locale/en-US/_strings/commands/follow-command.ftl # Resources/Locale/en-US/_strings/commands/force-map-command.ftl # Resources/Locale/en-US/_strings/commands/force-preset-command.ftl # Resources/Locale/en-US/_strings/commands/ghost-kick-command.ftl # Resources/Locale/en-US/_strings/commands/ghost-visibility-commands.ftl # Resources/Locale/en-US/_strings/commands/go-lobby-command.ftl # Resources/Locale/en-US/_strings/commands/grid-drag-command.ftl # Resources/Locale/en-US/_strings/commands/is-afk-command.ftl # Resources/Locale/en-US/_strings/commands/makesentient-command.ftl # Resources/Locale/en-US/_strings/commands/map-commands.ftl # Resources/Locale/en-US/_strings/commands/mapping-client-side-setup-command.ftl # Resources/Locale/en-US/_strings/commands/mappingclientsidesetup-command.ftl # Resources/Locale/en-US/_strings/commands/me-command.ftl # Resources/Locale/en-US/_strings/commands/mind-info-command.ftl # Resources/Locale/en-US/_strings/commands/node-vis-commands.ftl # Resources/Locale/en-US/_strings/commands/npc-command.ftl # Resources/Locale/en-US/_strings/commands/nukecodes-command.ftl # Resources/Locale/en-US/_strings/commands/ooc-command.ftl # Resources/Locale/en-US/_strings/commands/pardon-command.ftl # Resources/Locale/en-US/_strings/commands/powerstat-command.ftl # Resources/Locale/en-US/_strings/commands/promote-host-command.ftl # Resources/Locale/en-US/_strings/commands/radiation-command.ftl # Resources/Locale/en-US/_strings/commands/readmin-command.ftl # Resources/Locale/en-US/_strings/commands/remove-extra-components-command.ftl # Resources/Locale/en-US/_strings/commands/role-commands.ftl # Resources/Locale/en-US/_strings/commands/say-command.ftl # Resources/Locale/en-US/_strings/commands/set-battery-percent-command.ftl # Resources/Locale/en-US/_strings/commands/show-ambient-command.ftl # Resources/Locale/en-US/_strings/commands/show-gun-spread-command.ftl # Resources/Locale/en-US/_strings/commands/show-htn-command.ftl # Resources/Locale/en-US/_strings/commands/showrules-command.ftl # Resources/Locale/en-US/_strings/commands/spawn-entity-list-command.ftl # Resources/Locale/en-US/_strings/commands/start-singularity-command.ftl # Resources/Locale/en-US/_strings/commands/tile-pry-command.ftl # Resources/Locale/en-US/_strings/commands/toggle-decals-command.ftl # Resources/Locale/en-US/_strings/commands/toggle-disallow-late-join-command.ftl # Resources/Locale/en-US/_strings/commands/unlocknode-command.ftl # Resources/Locale/en-US/_strings/commands/whisper-command.ftl # Resources/Locale/en-US/_strings/components/gas-pressure-regulator-component.ftl # Resources/Locale/en-US/_strings/engineer-painter/engineer-painter.ftl # Resources/Locale/en-US/_strings/game-ticking/forcemap-command.ftl # Resources/Locale/en-US/_strings/interaction/interaction-popup-component.ftl # Resources/Locale/en-US/_strings/markings/vox_tattoos.ftl # Resources/Locale/en-US/_strings/materials/material-extractor.ftl # Resources/Locale/en-US/_strings/movement/eye.ftl # Resources/Locale/en-US/_strings/nutrition/components/food-component.ftl # Resources/Locale/en-US/_strings/nutrition/components/ingestion-system.ftl # Resources/Locale/en-US/_strings/nutrition/components/sealable-component.ftl # Resources/Locale/en-US/_strings/radiation/radiation-command.ftl # Resources/Locale/en-US/_strings/reagents/meta/physical-desc.ftl # Resources/Locale/en-US/_strings/research/technologies.ftl # Resources/Locale/en-US/_strings/seeds/seeds.ftl # Resources/Locale/en-US/_strings/weapons/grenades/timer-trigger.ftl # Resources/Locale/en-US/_strings/weapons/grenades/voice-trigger.ftl # Resources/Locale/en-US/commands/mapping-client-side-setup-command.ftl # Resources/Locale/en-US/recipes/tags.ftl # Resources/Maps/_Sunrise/Station/bagel.yml # Resources/Maps/_Sunrise/Station/barratry.yml # Resources/Maps/_Sunrise/Station/box.yml # Resources/Maps/_Sunrise/Station/fland.yml # Resources/Maps/_Sunrise/Station/marathon.yml # Resources/Maps/_Sunrise/Station/oasis.yml # Resources/Maps/_Sunrise/Station/packed.yml # Resources/Maps/_Sunrise/Station/plasma.yml # Resources/Maps/amber.yml # Resources/Maps/centcomm.yml # Resources/Prototypes/Catalog/Fills/Backpacks/duffelbag.yml # Resources/Prototypes/Catalog/Fills/Lockers/security.yml # Resources/Prototypes/Catalog/Fills/Lockers/service.yml # Resources/Prototypes/Catalog/Fills/Lockers/suit_storage.yml # Resources/Prototypes/Catalog/VendingMachines/Inventories/coffee.yml # Resources/Prototypes/Catalog/VendingMachines/Inventories/sustenance.yml # Resources/Prototypes/Catalog/VendingMachines/Inventories/winterdrobe.yml # Resources/Prototypes/Entities/Clothing/Belt/belts.yml # Resources/Prototypes/Entities/Clothing/Eyes/glasses.yml # Resources/Prototypes/Entities/Clothing/Eyes/hud.yml # Resources/Prototypes/Entities/Clothing/Head/hardsuit-helmets.yml # Resources/Prototypes/Entities/Clothing/Head/hats.yml # Resources/Prototypes/Entities/Clothing/Head/helmets.yml # Resources/Prototypes/Entities/Clothing/Head/hoods.yml # Resources/Prototypes/Entities/Clothing/OuterClothing/armor.yml # Resources/Prototypes/Entities/Clothing/OuterClothing/hardsuits.yml # Resources/Prototypes/Entities/Clothing/OuterClothing/softsuits.yml # Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml # Resources/Prototypes/Entities/Mobs/NPCs/animals.yml # Resources/Prototypes/Entities/Mobs/NPCs/carp.yml # Resources/Prototypes/Entities/Mobs/NPCs/pets.yml # Resources/Prototypes/Entities/Mobs/NPCs/revenant.yml # Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml # Resources/Prototypes/Entities/Mobs/Player/clone.yml # Resources/Prototypes/Entities/Mobs/Species/base.yml # Resources/Prototypes/Entities/Mobs/Species/dwarf.yml # Resources/Prototypes/Entities/Mobs/base.yml # Resources/Prototypes/Entities/Objects/Fun/pai.yml # Resources/Prototypes/Entities/Objects/Fun/toys.yml # Resources/Prototypes/Entities/Objects/Misc/subdermal_implants.yml # Resources/Prototypes/Entities/Objects/Shields/shields.yml # Resources/Prototypes/Entities/Objects/Specific/Medical/healing.yml # Resources/Prototypes/Entities/Objects/Specific/Medical/hypospray.yml # Resources/Prototypes/Entities/Objects/Tools/access_configurator.yml # Resources/Prototypes/Entities/Objects/Tools/matches.yml # Resources/Prototypes/Entities/Objects/Weapons/Bombs/plastic.yml # Resources/Prototypes/Entities/Objects/Weapons/Bombs/spider.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Magazines/caseless_rifle.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Magazines/light_rifle.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Magazines/magnum.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/grenade.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Shotguns/shotguns.yml # Resources/Prototypes/Entities/Objects/Weapons/Melee/mining.yml # Resources/Prototypes/Entities/Objects/Weapons/Throwable/grenades.yml # Resources/Prototypes/Entities/Structures/Doors/Airlocks/airlocks.yml # Resources/Prototypes/Entities/Structures/Doors/airlock_groups.yml # Resources/Prototypes/Entities/Structures/Furniture/beds.yml # Resources/Prototypes/Entities/Structures/Machines/vending_machines.yml # Resources/Prototypes/Entities/Structures/Power/debug_power.yml # Resources/Prototypes/Entities/Structures/Storage/Crates/crates.yml # Resources/Prototypes/Entities/Structures/Wallmounts/Misc/mirror.yml # Resources/Prototypes/GameRules/subgamemodes.yml # Resources/Prototypes/Reagents/Consumable/Drink/drinks.yml # Resources/Prototypes/Reagents/Consumable/Drink/soda.yml # Resources/Prototypes/Reagents/medicine.yml # Resources/Prototypes/Recipes/Lathes/Packs/tiles.yml # Resources/Prototypes/Recipes/Lathes/categories.yml # Resources/Prototypes/Recipes/Reactions/chemicals.yml # Resources/Prototypes/Roles/Antags/changeling.yml # Resources/Prototypes/name_identifier_groups.yml # Resources/Prototypes/tool_qualities.yml # Resources/ServerInfo/Guidebook/Antagonist/Zombies.xml # Resources/ServerInfo/Guidebook/Cargo/CargoBounties.xml # Resources/ServerInfo/Guidebook/Command.xml # Resources/ServerInfo/Guidebook/Glossary.xml # Resources/ServerInfo/Guidebook/NewPlayer/YourFirstCharacter.xml # Resources/ServerInfo/Guidebook/Science/Robotics.xml # Resources/ServerInfo/Guidebook/Science/ScannersAndVessels.xml # Resources/ServerInfo/Guidebook/Science/Science.xml # Resources/ServerInfo/Guidebook/SpaceStation14.xml # Resources/ServerInfo/Guidebook/Survival.xml # Resources/Textures/Clothing/Head/Hardsuits/atmospherics.rsi/meta.json # Resources/Textures/Clothing/Head/Hardsuits/capspace.rsi/meta.json # Resources/Textures/Clothing/Head/Hardsuits/cybersun.rsi/meta.json # Resources/Textures/Clothing/Head/Hardsuits/engineering-white.rsi/meta.json # Resources/Textures/Clothing/Head/Hardsuits/engineering-white.rsi/on-equipped-HELMET.png # Resources/Textures/Clothing/Head/Hardsuits/engineering.rsi/icon.png # Resources/Textures/Clothing/Head/Hardsuits/engineering.rsi/meta.json # Resources/Textures/Clothing/Head/Hardsuits/engineering.rsi/on-equipped-HELMET.png # Resources/Textures/Clothing/Head/Hardsuits/medical.rsi/meta.json # Resources/Textures/Clothing/Head/Hardsuits/rd.rsi/meta.json # Resources/Textures/Clothing/Head/Hardsuits/salvage.rsi/meta.json # Resources/Textures/Clothing/Head/Hardsuits/security.rsi/meta.json # Resources/Textures/Clothing/Head/Hardsuits/spatiohelm.rsi/meta.json # Resources/Textures/Clothing/Head/Hardsuits/syndicate.rsi/meta.json # Resources/Textures/Clothing/Head/Hardsuits/syndiecommander.rsi/meta.json # Resources/Textures/Clothing/Head/Hardsuits/syndieelite.rsi/meta.json # Resources/Textures/Clothing/Head/Hardsuits/wizard.rsi/meta.json # Resources/Textures/Clothing/Head/Helmets/atmos_firehelmet.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Armor/captain_carapace.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Armor/security.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/atmospherics.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/capspace.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/cybersun.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/engineering-white.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/engineering.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/medical.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/paramed.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/rd.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/salvage.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/security.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/spatio.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/syndicate.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/syndiecommander.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/syndieelite.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Hardsuits/wizard.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Suits/atmos_firesuit.rsi/meta.json # Resources/Textures/Clothing/OuterClothing/Suits/eva.rsi/meta.json # Resources/Textures/Interface/Misc/job_icons.rsi/meta.json # Resources/Textures/Objects/Misc/Lights/lampgreen.rsi/meta.json # Resources/Textures/Objects/Specific/Janitorial/janitorial_cart.rsi/meta.json # Resources/Textures/Objects/Tools/spray_painter.rsi/meta.json # Resources/Textures/Objects/Weapons/Melee/baseball_bat.rsi/meta.json # Resources/engineCommandPerms.yml # Resources/keybinds.yml # Resources/migration.yml
894 lines
31 KiB
C#
894 lines
31 KiB
C#
using System.Linq;
|
|
using Content.Server.Administration.Logs;
|
|
using Content.Server.EUI;
|
|
using Content.Server.GameTicking;
|
|
using Content.Server.Ghost.Roles.Components;
|
|
using Content.Server.Ghost.Roles.Events;
|
|
using Content.Shared.Ghost.Roles.Raffles;
|
|
using Content.Server.Ghost.Roles.UI;
|
|
using Content.Shared.Administration;
|
|
using Content.Shared.CCVar;
|
|
using Content.Shared.Database;
|
|
using Content.Shared.Follower;
|
|
using Content.Shared.GameTicking;
|
|
using Content.Shared.Ghost;
|
|
using Content.Shared.Ghost.Roles;
|
|
using Content.Shared.Mind;
|
|
using Content.Shared.Mind.Components;
|
|
using Content.Shared.Mobs;
|
|
using Content.Shared.Players;
|
|
using Content.Shared.Roles;
|
|
using JetBrains.Annotations;
|
|
using Robust.Server.GameObjects;
|
|
using Robust.Server.Player;
|
|
using Robust.Shared.Configuration;
|
|
using Robust.Shared.Console;
|
|
using Robust.Shared.Enums;
|
|
using Robust.Shared.Player;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Random;
|
|
using Robust.Shared.Timing;
|
|
using Robust.Shared.Utility;
|
|
using Content.Server.Popups;
|
|
using Content.Shared.Verbs;
|
|
using Robust.Shared.Collections;
|
|
using Content.Shared.Ghost.Roles.Components;
|
|
using Content.Shared.Mobs.Systems;
|
|
using Content.Shared.Roles.Jobs;
|
|
using Content.Sunrise.Interfaces.Shared; // Sunrise-Sponsors
|
|
|
|
namespace Content.Server.Ghost.Roles;
|
|
|
|
[UsedImplicitly]
|
|
public sealed class GhostRoleSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
|
[Dependency] private readonly EuiManager _euiManager = default!;
|
|
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
|
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
[Dependency] private readonly FollowerSystem _followerSystem = default!;
|
|
[Dependency] private readonly TransformSystem _transform = default!;
|
|
[Dependency] private readonly SharedMindSystem _mindSystem = default!;
|
|
[Dependency] private readonly SharedRoleSystem _roleSystem = default!;
|
|
[Dependency] private readonly IGameTiming _timing = default!;
|
|
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
|
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
|
[Dependency] private readonly GameTicker _gameTicker = default!;
|
|
[Dependency] private readonly MobStateSystem _mobState = default!;
|
|
|
|
private ISharedSponsorsManager? _sponsorsManager; // Sunrise-Sponsors
|
|
|
|
private uint _nextRoleIdentifier;
|
|
private bool _needsUpdateGhostRoleCount = true;
|
|
|
|
private readonly Dictionary<uint, Entity<GhostRoleComponent>> _ghostRoles = new();
|
|
private readonly Dictionary<uint, Entity<GhostRoleRaffleComponent>> _ghostRoleRaffles = new();
|
|
|
|
private readonly Dictionary<ICommonSession, GhostRolesEui> _openUis = new();
|
|
private readonly Dictionary<ICommonSession, MakeGhostRoleEui> _openMakeGhostRoleUis = new();
|
|
|
|
[ViewVariables]
|
|
public IReadOnlyCollection<Entity<GhostRoleComponent>> GhostRoles => _ghostRoles.Values;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
|
|
SubscribeLocalEvent<PlayerAttachedEvent>(OnPlayerAttached);
|
|
|
|
SubscribeLocalEvent<GhostTakeoverAvailableComponent, MindAddedMessage>(OnMindAdded);
|
|
SubscribeLocalEvent<GhostTakeoverAvailableComponent, MindRemovedMessage>(OnMindRemoved);
|
|
SubscribeLocalEvent<GhostTakeoverAvailableComponent, MobStateChangedEvent>(OnMobStateChanged);
|
|
SubscribeLocalEvent<GhostTakeoverAvailableComponent, TakeGhostRoleEvent>(OnTakeoverTakeRole);
|
|
|
|
SubscribeLocalEvent<GhostRoleComponent, MapInitEvent>(OnMapInit);
|
|
SubscribeLocalEvent<GhostRoleComponent, ComponentStartup>(OnRoleStartup);
|
|
SubscribeLocalEvent<GhostRoleComponent, ComponentShutdown>(OnRoleShutdown);
|
|
SubscribeLocalEvent<GhostRoleComponent, EntityPausedEvent>(OnPaused);
|
|
SubscribeLocalEvent<GhostRoleComponent, EntityUnpausedEvent>(OnUnpaused);
|
|
|
|
SubscribeLocalEvent<GhostRoleRaffleComponent, ComponentInit>(OnRaffleInit);
|
|
SubscribeLocalEvent<GhostRoleRaffleComponent, ComponentShutdown>(OnRaffleShutdown);
|
|
|
|
SubscribeLocalEvent<GhostRoleMobSpawnerComponent, TakeGhostRoleEvent>(OnSpawnerTakeRole);
|
|
SubscribeLocalEvent<GhostRoleMobSpawnerComponent, GetVerbsEvent<Verb>>(OnVerb);
|
|
SubscribeLocalEvent<GhostRoleMobSpawnerComponent, GhostRoleRadioMessage>(OnGhostRoleRadioMessage);
|
|
_playerManager.PlayerStatusChanged += PlayerStatusChanged;
|
|
|
|
IoCManager.Instance!.TryResolveType(out _sponsorsManager); // Sunrise-Sponsors
|
|
}
|
|
|
|
private void OnMobStateChanged(Entity<GhostTakeoverAvailableComponent> component, ref MobStateChangedEvent args)
|
|
{
|
|
if (!TryComp(component, out GhostRoleComponent? ghostRole))
|
|
return;
|
|
|
|
switch (args.NewMobState)
|
|
{
|
|
case MobState.Alive:
|
|
{
|
|
if (!ghostRole.Taken)
|
|
RegisterGhostRole((component, ghostRole));
|
|
break;
|
|
}
|
|
case MobState.Critical:
|
|
case MobState.Dead:
|
|
UnregisterGhostRole((component, ghostRole));
|
|
break;
|
|
}
|
|
}
|
|
|
|
public override void Shutdown()
|
|
{
|
|
base.Shutdown();
|
|
|
|
_playerManager.PlayerStatusChanged -= PlayerStatusChanged;
|
|
}
|
|
|
|
private uint GetNextRoleIdentifier()
|
|
{
|
|
return unchecked(_nextRoleIdentifier++);
|
|
}
|
|
|
|
public void OpenEui(ICommonSession session)
|
|
{
|
|
// Sunrise-Start
|
|
if (!_gameTicker.PlayerGameStatuses.TryGetValue(session.UserId, out var status))
|
|
return;
|
|
// Sunrise-End
|
|
|
|
if (session.AttachedEntity is not { Valid: true } attached ||
|
|
!HasComp<GhostComponent>(attached))
|
|
return;
|
|
|
|
if (_openUis.ContainsKey(session))
|
|
CloseEui(session);
|
|
|
|
var eui = _openUis[session] = new GhostRolesEui();
|
|
_euiManager.OpenEui(eui, session);
|
|
eui.StateDirty();
|
|
}
|
|
|
|
public void OpenMakeGhostRoleEui(ICommonSession session, EntityUid uid)
|
|
{
|
|
if (session.AttachedEntity == null)
|
|
return;
|
|
|
|
if (_openMakeGhostRoleUis.ContainsKey(session))
|
|
CloseEui(session);
|
|
|
|
var eui = _openMakeGhostRoleUis[session] = new MakeGhostRoleEui(EntityManager, GetNetEntity(uid));
|
|
_euiManager.OpenEui(eui, session);
|
|
eui.StateDirty();
|
|
}
|
|
|
|
public void CloseEui(ICommonSession session)
|
|
{
|
|
if (!_openUis.ContainsKey(session))
|
|
return;
|
|
|
|
_openUis.Remove(session, out var eui);
|
|
|
|
eui?.Close();
|
|
}
|
|
|
|
public void CloseMakeGhostRoleEui(ICommonSession session)
|
|
{
|
|
if (_openMakeGhostRoleUis.Remove(session, out var eui))
|
|
{
|
|
eui.Close();
|
|
}
|
|
}
|
|
|
|
public void UpdateAllEui()
|
|
{
|
|
foreach (var eui in _openUis.Values)
|
|
{
|
|
eui.StateDirty();
|
|
}
|
|
// Note that this, like the EUIs, is deferred.
|
|
// This is for roughly the same reasons, too:
|
|
// Someone might spawn a ton of ghost roles at once.
|
|
_needsUpdateGhostRoleCount = true;
|
|
}
|
|
|
|
public override void Update(float frameTime)
|
|
{
|
|
base.Update(frameTime);
|
|
|
|
UpdateGhostRoleCount();
|
|
UpdateRaffles(frameTime);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Handles sending count update for the ghost role button in ghost UI, if ghost role count changed.
|
|
/// </summary>
|
|
private void UpdateGhostRoleCount()
|
|
{
|
|
if (!_needsUpdateGhostRoleCount)
|
|
return;
|
|
|
|
_needsUpdateGhostRoleCount = false;
|
|
var response = new GhostUpdateGhostRoleCountEvent(GetGhostRoleCount());
|
|
foreach (var player in _playerManager.Sessions)
|
|
{
|
|
RaiseNetworkEvent(response, player.Channel);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Handles ghost role raffle logic.
|
|
/// </summary>
|
|
private void UpdateRaffles(float frameTime)
|
|
{
|
|
var query = EntityQueryEnumerator<GhostRoleRaffleComponent, MetaDataComponent>();
|
|
while (query.MoveNext(out var entityUid, out var raffle, out var meta))
|
|
{
|
|
if (meta.EntityPaused)
|
|
continue;
|
|
|
|
// if all participants leave/were removed from the raffle, the raffle is canceled.
|
|
if (raffle.CurrentMembers.Count == 0)
|
|
{
|
|
RemoveRaffleAndUpdateEui(entityUid, raffle);
|
|
continue;
|
|
}
|
|
|
|
raffle.Countdown = raffle.Countdown.Subtract(TimeSpan.FromSeconds(frameTime));
|
|
if (raffle.Countdown.Ticks > 0)
|
|
continue;
|
|
|
|
// the raffle is over! find someone to take over the ghost role
|
|
if (!TryComp(entityUid, out GhostRoleComponent? ghostRole))
|
|
{
|
|
Log.Warning($"Ghost role raffle finished on {entityUid} but {nameof(GhostRoleComponent)} is missing");
|
|
RemoveRaffleAndUpdateEui(entityUid, raffle);
|
|
continue;
|
|
}
|
|
|
|
if (ghostRole.RaffleConfig is null)
|
|
{
|
|
Log.Warning($"Ghost role raffle finished on {entityUid} but RaffleConfig became null");
|
|
RemoveRaffleAndUpdateEui(entityUid, raffle);
|
|
continue;
|
|
}
|
|
|
|
var foundWinner = false;
|
|
var deciderPrototype = _prototype.Index(ghostRole.RaffleConfig.Decider);
|
|
|
|
// Sunrise-Sponsors-Start
|
|
var priorityMembers = new HashSet<ICommonSession>();
|
|
if (_sponsorsManager != null)
|
|
{
|
|
foreach (var member in raffle.CurrentMembers)
|
|
{
|
|
if (!_sponsorsManager.TryGetPriorityGhostRoles(member.UserId, out var priorityGhostRoles))
|
|
continue;
|
|
|
|
if (priorityGhostRoles.Contains(meta.EntityPrototype!.ID))
|
|
{
|
|
priorityMembers.Add(member);
|
|
}
|
|
}
|
|
}
|
|
|
|
var participants = priorityMembers.Count > 0 ? priorityMembers : raffle.CurrentMembers;
|
|
// Sunrise-Sponsors-End
|
|
|
|
// use the ghost role's chosen winner picker to find a winner
|
|
deciderPrototype.Decider.PickWinner(
|
|
participants.AsEnumerable(), // Sunrise-Sponsors
|
|
session =>
|
|
{
|
|
var success = TryTakeover(session, raffle.Identifier);
|
|
foundWinner |= success;
|
|
return success;
|
|
}
|
|
);
|
|
|
|
if (!foundWinner)
|
|
{
|
|
Log.Warning($"Ghost role raffle for {entityUid} ({ghostRole.RoleName}) finished without " +
|
|
$"{ghostRole.RaffleConfig?.Decider} finding a winner");
|
|
}
|
|
|
|
// raffle over
|
|
RemoveRaffleAndUpdateEui(entityUid, raffle);
|
|
}
|
|
}
|
|
|
|
private bool TryTakeover(ICommonSession player, uint identifier)
|
|
{
|
|
// TODO: the following two checks are kind of redundant since they should already be removed
|
|
// from the raffle
|
|
// can't win if you are disconnected (although you shouldn't be a candidate anyway)
|
|
if (player.Status != SessionStatus.InGame)
|
|
return false;
|
|
|
|
// Sunrise-Start
|
|
if (!_gameTicker.PlayerGameStatuses.TryGetValue(player.UserId, out var status))
|
|
return false;
|
|
// Sunrise-End
|
|
|
|
// can't win if you are no longer a ghost (e.g. if you returned to your body)
|
|
if ((player.AttachedEntity == null || !HasComp<GhostComponent>(player.AttachedEntity)) && status != PlayerGameStatus.NotReadyToPlay) // Sunrise-Edit
|
|
return false;
|
|
|
|
if (Takeover(player, identifier))
|
|
{
|
|
// takeover successful, we have a winner! remove the winner from other raffles they might be in
|
|
LeaveAllRaffles(player);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
private void RemoveRaffleAndUpdateEui(EntityUid entityUid, GhostRoleRaffleComponent raffle)
|
|
{
|
|
_ghostRoleRaffles.Remove(raffle.Identifier);
|
|
RemComp(entityUid, raffle);
|
|
UpdateAllEui();
|
|
}
|
|
|
|
private void PlayerStatusChanged(object? blah, SessionStatusEventArgs args)
|
|
{
|
|
if (args.NewStatus == SessionStatus.InGame)
|
|
{
|
|
var response = new GhostUpdateGhostRoleCountEvent(_ghostRoles.Count);
|
|
RaiseNetworkEvent(response, args.Session.Channel);
|
|
}
|
|
else
|
|
{
|
|
// people who disconnect are removed from ghost role raffles
|
|
LeaveAllRaffles(args.Session);
|
|
}
|
|
}
|
|
|
|
public void RegisterGhostRole(Entity<GhostRoleComponent> role)
|
|
{
|
|
if (_ghostRoles.ContainsValue(role))
|
|
return;
|
|
|
|
_ghostRoles[role.Comp.Identifier = GetNextRoleIdentifier()] = role;
|
|
UpdateAllEui();
|
|
}
|
|
|
|
public void UnregisterGhostRole(Entity<GhostRoleComponent> role)
|
|
{
|
|
var comp = role.Comp;
|
|
if (!_ghostRoles.ContainsKey(comp.Identifier) || _ghostRoles[comp.Identifier] != role)
|
|
return;
|
|
|
|
_ghostRoles.Remove(comp.Identifier);
|
|
if (TryComp(role.Owner, out GhostRoleRaffleComponent? raffle))
|
|
{
|
|
// if a raffle is still running, get rid of it
|
|
RemoveRaffleAndUpdateEui(role.Owner, raffle);
|
|
}
|
|
else
|
|
{
|
|
UpdateAllEui();
|
|
}
|
|
}
|
|
|
|
// probably fine to be init because it's never added during entity initialization, but much later
|
|
private void OnRaffleInit(Entity<GhostRoleRaffleComponent> ent, ref ComponentInit args)
|
|
{
|
|
if (!TryComp(ent, out GhostRoleComponent? ghostRole))
|
|
{
|
|
// can't have a raffle for a ghost role that doesn't exist
|
|
RemComp<GhostRoleRaffleComponent>(ent);
|
|
return;
|
|
}
|
|
|
|
var config = ghostRole.RaffleConfig;
|
|
if (config is null)
|
|
return; // should, realistically, never be reached but you never know
|
|
|
|
var settings = config.SettingsOverride
|
|
?? _prototype.Index<GhostRoleRaffleSettingsPrototype>(config.Settings).Settings;
|
|
|
|
if (settings.MaxDuration < settings.InitialDuration)
|
|
{
|
|
Log.Error($"Ghost role on {ent} has invalid raffle settings (max duration shorter than initial)");
|
|
ghostRole.RaffleConfig = null; // make it a non-raffle role so stuff isn't entirely broken
|
|
RemComp<GhostRoleRaffleComponent>(ent);
|
|
return;
|
|
}
|
|
|
|
var raffle = ent.Comp;
|
|
raffle.Identifier = ghostRole.Identifier;
|
|
var countdown = _cfg.GetCVar(CCVars.GhostQuickLottery)? 1 : settings.InitialDuration;
|
|
raffle.Countdown = TimeSpan.FromSeconds(countdown);
|
|
raffle.CumulativeTime = TimeSpan.FromSeconds(settings.InitialDuration);
|
|
// we copy these settings into the component because they would be cumbersome to access otherwise
|
|
raffle.JoinExtendsDurationBy = TimeSpan.FromSeconds(settings.JoinExtendsDurationBy);
|
|
raffle.MaxDuration = TimeSpan.FromSeconds(settings.MaxDuration);
|
|
}
|
|
|
|
private void OnRaffleShutdown(Entity<GhostRoleRaffleComponent> ent, ref ComponentShutdown args)
|
|
{
|
|
_ghostRoleRaffles.Remove(ent.Comp.Identifier);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Joins the given player onto a ghost role raffle, or creates it if it doesn't exist.
|
|
/// </summary>
|
|
/// <param name="player">The player.</param>
|
|
/// <param name="identifier">The ID that represents the ghost role or ghost role raffle.
|
|
/// (A raffle will have the same ID as the ghost role it's for.)</param>
|
|
private void JoinRaffle(ICommonSession player, uint identifier)
|
|
{
|
|
if (!_ghostRoles.TryGetValue(identifier, out var roleEnt))
|
|
return;
|
|
|
|
// get raffle or create a new one if it doesn't exist
|
|
var raffle = _ghostRoleRaffles.TryGetValue(identifier, out var raffleEnt)
|
|
? raffleEnt.Comp
|
|
: EnsureComp<GhostRoleRaffleComponent>(roleEnt.Owner);
|
|
|
|
_ghostRoleRaffles.TryAdd(identifier, (roleEnt.Owner, raffle));
|
|
|
|
if (!raffle.CurrentMembers.Add(player))
|
|
{
|
|
Log.Warning($"{player.Name} tried to join raffle for ghost role {identifier} but they are already in the raffle");
|
|
return;
|
|
}
|
|
|
|
// if this is the first time the player joins this raffle, and the player wasn't the starter of the raffle:
|
|
// extend the countdown, but only if doing so will not make the raffle take longer than the maximum
|
|
// duration
|
|
if (raffle.AllMembers.Add(player) && raffle.AllMembers.Count > 1
|
|
&& raffle.CumulativeTime.Add(raffle.JoinExtendsDurationBy) <= raffle.MaxDuration)
|
|
{
|
|
raffle.Countdown += raffle.JoinExtendsDurationBy;
|
|
raffle.CumulativeTime += raffle.JoinExtendsDurationBy;
|
|
}
|
|
|
|
UpdateAllEui();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Makes the given player leave the raffle corresponding to the given ID.
|
|
/// </summary>
|
|
public void LeaveRaffle(ICommonSession player, uint identifier)
|
|
{
|
|
if (!_ghostRoleRaffles.TryGetValue(identifier, out var raffleEnt))
|
|
return;
|
|
|
|
if (raffleEnt.Comp.CurrentMembers.Remove(player))
|
|
{
|
|
UpdateAllEui();
|
|
}
|
|
else
|
|
{
|
|
Log.Warning($"{player.Name} tried to leave raffle for ghost role {identifier} but they are not in the raffle");
|
|
}
|
|
|
|
// (raffle ending because all players left is handled in update())
|
|
}
|
|
|
|
/// <summary>
|
|
/// Makes the given player leave all ghost role raffles.
|
|
/// </summary>
|
|
public void LeaveAllRaffles(ICommonSession player)
|
|
{
|
|
var shouldUpdateEui = false;
|
|
|
|
foreach (var raffleEnt in _ghostRoleRaffles.Values)
|
|
{
|
|
shouldUpdateEui |= raffleEnt.Comp.CurrentMembers.Remove(player);
|
|
}
|
|
|
|
if (shouldUpdateEui)
|
|
UpdateAllEui();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Request a ghost role. If it's a raffled role starts or joins a raffle, otherwise the player immediately
|
|
/// takes over the ghost role if possible.
|
|
/// </summary>
|
|
/// <param name="player">The player.</param>
|
|
/// <param name="identifier">ID of the ghost role.</param>
|
|
public void Request(ICommonSession player, uint identifier)
|
|
{
|
|
if (!_ghostRoles.TryGetValue(identifier, out var roleEnt))
|
|
return;
|
|
|
|
if (roleEnt.Comp.RaffleConfig is not null)
|
|
{
|
|
JoinRaffle(player, identifier);
|
|
}
|
|
else
|
|
{
|
|
Takeover(player, identifier);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Attempts having the player take over the ghost role with the corresponding ID. Does not start a raffle.
|
|
/// </summary>
|
|
/// <returns>True if takeover was successful, otherwise false.</returns>
|
|
public bool Takeover(ICommonSession player, uint identifier)
|
|
{
|
|
if (!_ghostRoles.TryGetValue(identifier, out var role))
|
|
return false;
|
|
|
|
// Sunrise-Start
|
|
if (_gameTicker.PlayerGameStatuses.TryGetValue(player.UserId, out var status) && status == PlayerGameStatus.NotReadyToPlay)
|
|
_gameTicker.PlayerJoinGame(player);
|
|
// Sunrise-End
|
|
|
|
var ev = new TakeGhostRoleEvent(player);
|
|
RaiseLocalEvent(role, ref ev);
|
|
|
|
if (!ev.TookRole)
|
|
return false;
|
|
|
|
if (player.AttachedEntity != null)
|
|
_adminLogger.Add(LogType.GhostRoleTaken, LogImpact.Low, $"{player:player} took the {role.Comp.RoleName:roleName} ghost role {ToPrettyString(player.AttachedEntity.Value):entity}");
|
|
|
|
CloseEui(player);
|
|
return true;
|
|
}
|
|
|
|
public void Follow(ICommonSession player, uint identifier)
|
|
{
|
|
if (!_ghostRoles.TryGetValue(identifier, out var role))
|
|
return;
|
|
|
|
if (player.AttachedEntity == null)
|
|
return;
|
|
|
|
_followerSystem.StartFollowingEntity(player.AttachedEntity.Value, role);
|
|
}
|
|
|
|
public void GhostRoleInternalCreateMindAndTransfer(ICommonSession player, EntityUid roleUid, EntityUid mob, GhostRoleComponent? role = null)
|
|
{
|
|
if (!Resolve(roleUid, ref role))
|
|
return;
|
|
|
|
DebugTools.AssertNotNull(player.ContentData());
|
|
|
|
// After taking a ghost role, the player cannot return to the original body, so wipe the player's current mind
|
|
// unless it is a visiting mind
|
|
if(_mindSystem.TryGetMind(player.UserId, out _, out var mind) && !mind.IsVisitingEntity)
|
|
_mindSystem.WipeMind(player);
|
|
|
|
var newMind = _mindSystem.CreateMind(player.UserId,
|
|
Comp<MetaDataComponent>(mob).EntityName);
|
|
|
|
_mindSystem.SetUserId(newMind, player.UserId);
|
|
_mindSystem.TransferTo(newMind, mob);
|
|
|
|
_roleSystem.MindAddRoles(newMind.Owner, role.MindRoles, newMind.Comp);
|
|
|
|
if (_roleSystem.MindHasRole<GhostRoleMarkerRoleComponent>(newMind!, out var markerRole))
|
|
markerRole.Value.Comp2.Name = role.RoleName;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the number of available ghost roles.
|
|
/// </summary>
|
|
public int GetGhostRoleCount()
|
|
{
|
|
var metaQuery = GetEntityQuery<MetaDataComponent>();
|
|
return _ghostRoles.Count(pair => metaQuery.GetComponent(pair.Value.Owner).EntityPaused == false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns information about all available ghost roles.
|
|
/// </summary>
|
|
/// <param name="player">
|
|
/// If not null, the <see cref="GhostRoleInfo"/>s will show if the given player is in a raffle.
|
|
/// </param>
|
|
public GhostRoleInfo[] GetGhostRolesInfo(ICommonSession? player)
|
|
{
|
|
var roles = new List<GhostRoleInfo>();
|
|
var metaQuery = GetEntityQuery<MetaDataComponent>();
|
|
|
|
foreach (var (id, (uid, role)) in _ghostRoles)
|
|
{
|
|
if (metaQuery.GetComponent(uid).EntityPaused)
|
|
continue;
|
|
|
|
var prototypeId = metaQuery.GetComponent(uid).EntityPrototype!.ID; // Sunrise-Sponsors
|
|
|
|
var kind = GhostRoleKind.FirstComeFirstServe;
|
|
GhostRoleRaffleComponent? raffle = null;
|
|
|
|
if (role.RaffleConfig is not null)
|
|
{
|
|
kind = GhostRoleKind.RaffleReady;
|
|
|
|
if (_ghostRoleRaffles.TryGetValue(id, out var raffleEnt))
|
|
{
|
|
kind = GhostRoleKind.RaffleInProgress;
|
|
raffle = raffleEnt.Comp;
|
|
|
|
if (player is not null && raffle.CurrentMembers.Contains(player))
|
|
kind = GhostRoleKind.RaffleJoined;
|
|
}
|
|
}
|
|
|
|
var rafflePlayerCount = (uint?) raffle?.CurrentMembers.Count ?? 0;
|
|
var raffleEndTime = raffle is not null
|
|
? _timing.CurTime.Add(raffle.Countdown)
|
|
: TimeSpan.MinValue;
|
|
|
|
roles.Add(new GhostRoleInfo
|
|
{
|
|
Identifier = id,
|
|
PrototypeId = prototypeId, // Sunrise-Sponsors
|
|
Name = role.RoleName,
|
|
Description = role.RoleDescription,
|
|
Rules = role.RoleRules,
|
|
Requirements = role.Requirements,
|
|
Kind = kind,
|
|
RafflePlayerCount = rafflePlayerCount,
|
|
RaffleEndTime = raffleEndTime
|
|
});
|
|
}
|
|
|
|
return roles.ToArray();
|
|
}
|
|
|
|
private void OnPlayerAttached(PlayerAttachedEvent message)
|
|
{
|
|
// Close the session of any player that has a ghost roles window open and isn't a ghost anymore.
|
|
if (!_openUis.ContainsKey(message.Player))
|
|
return;
|
|
|
|
if (HasComp<GhostComponent>(message.Entity))
|
|
return;
|
|
|
|
// The player is not a ghost (anymore), so they should not be in any raffles. Remove them.
|
|
// This ensures player doesn't win a raffle after returning to their (revived) body and ends up being
|
|
// forced into a ghost role.
|
|
LeaveAllRaffles(message.Player);
|
|
CloseEui(message.Player);
|
|
}
|
|
|
|
private void OnMindAdded(EntityUid uid, GhostTakeoverAvailableComponent component, MindAddedMessage args)
|
|
{
|
|
if (!TryComp(uid, out GhostRoleComponent? ghostRole))
|
|
return;
|
|
|
|
if (ghostRole.JobProto != null)
|
|
{
|
|
_roleSystem.MindAddJobRole(args.Mind, args.Mind, silent:false,ghostRole.JobProto);
|
|
}
|
|
|
|
ghostRole.Taken = true;
|
|
UnregisterGhostRole((uid, ghostRole));
|
|
}
|
|
|
|
private void OnMindRemoved(EntityUid uid, GhostTakeoverAvailableComponent component, MindRemovedMessage args)
|
|
{
|
|
if (!TryComp(uid, out GhostRoleComponent? ghostRole))
|
|
return;
|
|
|
|
// Avoid re-registering it for duplicate entries and potential exceptions.
|
|
if (!ghostRole.ReregisterOnGhost || component.LifeStage > ComponentLifeStage.Running)
|
|
return;
|
|
|
|
// Sunrise-Start
|
|
if (!_mobState.IsAlive(uid))
|
|
return;
|
|
// Sunrise-End
|
|
|
|
ghostRole.Taken = false;
|
|
RegisterGhostRole((uid, ghostRole));
|
|
}
|
|
|
|
public void Reset(RoundRestartCleanupEvent ev)
|
|
{
|
|
foreach (var session in _openUis.Keys)
|
|
{
|
|
CloseEui(session);
|
|
}
|
|
|
|
_openUis.Clear();
|
|
_ghostRoles.Clear();
|
|
_ghostRoleRaffles.Clear();
|
|
_nextRoleIdentifier = 0;
|
|
}
|
|
|
|
private void OnPaused(EntityUid uid, GhostRoleComponent component, ref EntityPausedEvent args)
|
|
{
|
|
if (HasComp<ActorComponent>(uid))
|
|
return;
|
|
|
|
UpdateAllEui();
|
|
}
|
|
|
|
private void OnUnpaused(EntityUid uid, GhostRoleComponent component, ref EntityUnpausedEvent args)
|
|
{
|
|
if (HasComp<ActorComponent>(uid))
|
|
return;
|
|
|
|
UpdateAllEui();
|
|
}
|
|
|
|
private void OnMapInit(Entity<GhostRoleComponent> ent, ref MapInitEvent args)
|
|
{
|
|
if (ent.Comp.Probability < 1f && !_random.Prob(ent.Comp.Probability))
|
|
RemCompDeferred<GhostRoleComponent>(ent);
|
|
}
|
|
|
|
private void OnRoleStartup(Entity<GhostRoleComponent> ent, ref ComponentStartup args)
|
|
{
|
|
RegisterGhostRole(ent);
|
|
}
|
|
|
|
private void OnRoleShutdown(Entity<GhostRoleComponent> role, ref ComponentShutdown args)
|
|
{
|
|
UnregisterGhostRole(role);
|
|
}
|
|
|
|
private void OnSpawnerTakeRole(EntityUid uid, GhostRoleMobSpawnerComponent component, ref TakeGhostRoleEvent args)
|
|
{
|
|
if (!TryComp(uid, out GhostRoleComponent? ghostRole) ||
|
|
!CanTakeGhost(uid, ghostRole))
|
|
{
|
|
args.TookRole = false;
|
|
return;
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(component.Prototype))
|
|
throw new NullReferenceException("Prototype string cannot be null or empty!");
|
|
|
|
var mob = Spawn(component.Prototype, Transform(uid).Coordinates);
|
|
_transform.AttachToGridOrMap(mob);
|
|
|
|
var spawnedEvent = new GhostRoleSpawnerUsedEvent(uid, mob);
|
|
RaiseLocalEvent(mob, spawnedEvent);
|
|
|
|
if (ghostRole.MakeSentient)
|
|
_mindSystem.MakeSentient(mob, ghostRole.AllowMovement, ghostRole.AllowSpeech);
|
|
|
|
EnsureComp<MindContainerComponent>(mob);
|
|
|
|
GhostRoleInternalCreateMindAndTransfer(args.Player, uid, mob, ghostRole);
|
|
|
|
if (++component.CurrentTakeovers < component.AvailableTakeovers)
|
|
{
|
|
args.TookRole = true;
|
|
return;
|
|
}
|
|
|
|
ghostRole.Taken = true;
|
|
|
|
if (component.DeleteOnSpawn)
|
|
QueueDel(uid);
|
|
|
|
args.TookRole = true;
|
|
}
|
|
|
|
private bool CanTakeGhost(EntityUid uid, GhostRoleComponent? component = null)
|
|
{
|
|
return Resolve(uid, ref component, false) &&
|
|
!component.Taken &&
|
|
!MetaData(uid).EntityPaused;
|
|
}
|
|
|
|
private void OnTakeoverTakeRole(EntityUid uid, GhostTakeoverAvailableComponent component, ref TakeGhostRoleEvent args)
|
|
{
|
|
if (!TryComp(uid, out GhostRoleComponent? ghostRole) ||
|
|
!CanTakeGhost(uid, ghostRole))
|
|
{
|
|
args.TookRole = false;
|
|
return;
|
|
}
|
|
|
|
ghostRole.Taken = true;
|
|
|
|
var mind = EnsureComp<MindContainerComponent>(uid);
|
|
|
|
if (mind.HasMind)
|
|
{
|
|
args.TookRole = false;
|
|
return;
|
|
}
|
|
|
|
if (ghostRole.MakeSentient)
|
|
_mindSystem.MakeSentient(uid, ghostRole.AllowMovement, ghostRole.AllowSpeech);
|
|
|
|
GhostRoleInternalCreateMindAndTransfer(args.Player, uid, uid, ghostRole);
|
|
UnregisterGhostRole((uid, ghostRole));
|
|
|
|
args.TookRole = true;
|
|
}
|
|
|
|
private void OnVerb(EntityUid uid, GhostRoleMobSpawnerComponent component, GetVerbsEvent<Verb> args)
|
|
{
|
|
var prototypes = component.SelectablePrototypes;
|
|
if (prototypes.Count < 1)
|
|
return;
|
|
|
|
if (!args.CanAccess || !args.CanInteract || args.Hands == null)
|
|
return;
|
|
|
|
var verbs = new ValueList<Verb>();
|
|
|
|
foreach (var prototypeID in prototypes)
|
|
{
|
|
if (_prototype.TryIndex<GhostRolePrototype>(prototypeID, out var prototype))
|
|
{
|
|
var verb = CreateVerb(uid, component, args.User, prototype);
|
|
verbs.Add(verb);
|
|
}
|
|
}
|
|
|
|
args.Verbs.UnionWith(verbs);
|
|
}
|
|
|
|
private Verb CreateVerb(EntityUid uid, GhostRoleMobSpawnerComponent component, EntityUid userUid, GhostRolePrototype prototype)
|
|
{
|
|
var verbText = Loc.GetString(prototype.Name);
|
|
|
|
return new Verb()
|
|
{
|
|
Text = verbText,
|
|
Disabled = component.Prototype == prototype.EntityPrototype,
|
|
Category = VerbCategory.SelectType,
|
|
Act = () => SetMode(uid, prototype, verbText, component, userUid)
|
|
};
|
|
}
|
|
|
|
public void SetMode(EntityUid uid, GhostRolePrototype prototype, string verbText, GhostRoleMobSpawnerComponent? component, EntityUid? userUid = null)
|
|
{
|
|
if (!Resolve(uid, ref component))
|
|
return;
|
|
|
|
var ghostrolecomp = EnsureComp<GhostRoleComponent>(uid);
|
|
|
|
component.Prototype = prototype.EntityPrototype;
|
|
ghostrolecomp.RoleName = verbText;
|
|
ghostrolecomp.RoleDescription = prototype.Description;
|
|
ghostrolecomp.RoleRules = prototype.Rules;
|
|
|
|
// Dirty(ghostrolecomp);
|
|
|
|
if (userUid != null)
|
|
{
|
|
var msg = Loc.GetString("ghostrole-spawner-select", ("mode", verbText));
|
|
_popupSystem.PopupEntity(msg, uid, userUid.Value);
|
|
}
|
|
}
|
|
|
|
public void OnGhostRoleRadioMessage(Entity<GhostRoleMobSpawnerComponent> entity, ref GhostRoleRadioMessage args)
|
|
{
|
|
if (!_prototype.TryIndex(args.ProtoId, out var ghostRoleProto))
|
|
return;
|
|
|
|
// if the prototype chosen isn't actually part of the selectable options, ignore it
|
|
foreach (var selectableProto in entity.Comp.SelectablePrototypes)
|
|
{
|
|
if (selectableProto == ghostRoleProto.EntityPrototype.Id)
|
|
return;
|
|
}
|
|
|
|
SetMode(entity.Owner, ghostRoleProto, ghostRoleProto.Name, entity.Comp);
|
|
}
|
|
}
|
|
|
|
[AnyCommand]
|
|
public sealed class GhostRoles : IConsoleCommand
|
|
{
|
|
[Dependency] private readonly IEntityManager _e = default!;
|
|
|
|
public string Command => "ghostroles";
|
|
public string Description => "Opens the ghost role request window.";
|
|
public string Help => $"{Command}";
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
{
|
|
if (shell.Player != null)
|
|
_e.System<GhostRoleSystem>().OpenEui(shell.Player);
|
|
else
|
|
shell.WriteLine("You can only open the ghost roles UI on a client.");
|
|
}
|
|
}
|