# 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
737 lines
27 KiB
C#
737 lines
27 KiB
C#
using System.Diagnostics.CodeAnalysis;
|
|
using System.Linq;
|
|
using Content.Shared.Administration.Logs;
|
|
using Content.Shared.CCVar;
|
|
using Content.Shared.Database;
|
|
using Content.Shared.GameTicking;
|
|
using Content.Shared.Mind;
|
|
using Content.Shared.Roles.Jobs;
|
|
using Content.Shared.Whitelist;
|
|
using Robust.Shared.Audio;
|
|
using Robust.Shared.Audio.Systems;
|
|
using Robust.Shared.Configuration;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Player;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Serialization;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Content.Shared.Roles;
|
|
|
|
public abstract class SharedRoleSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
|
[Dependency] protected readonly ISharedPlayerManager Player = default!;
|
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
|
[Dependency] private readonly EntityWhitelistSystem _whitelist = default!;
|
|
[Dependency] private readonly SharedMindSystem _minds = default!;
|
|
[Dependency] private readonly IPrototypeManager _prototypes = default!;
|
|
|
|
private JobRequirementOverridePrototype? _requirementOverride;
|
|
|
|
public override void Initialize()
|
|
{
|
|
Subs.CVar(_cfg, CCVars.GameRoleTimerOverride, SetRequirementOverride, true);
|
|
|
|
SubscribeLocalEvent<MindRoleComponent, ComponentShutdown>(OnComponentShutdown);
|
|
SubscribeLocalEvent<StartingMindRoleComponent, PlayerSpawnCompleteEvent>(OnSpawn);
|
|
}
|
|
|
|
private void OnSpawn(EntityUid uid, StartingMindRoleComponent component, PlayerSpawnCompleteEvent args)
|
|
{
|
|
if (!_minds.TryGetMind(uid, out var mindId, out var mindComp))
|
|
return;
|
|
|
|
MindAddRole(mindId, component.MindRole, mind: mindComp, silent: component.Silent);
|
|
}
|
|
|
|
private void SetRequirementOverride(string value)
|
|
{
|
|
if (string.IsNullOrEmpty(value))
|
|
{
|
|
_requirementOverride = null;
|
|
return;
|
|
}
|
|
|
|
if (!_prototypes.TryIndex(value, out _requirementOverride ))
|
|
Log.Error($"Unknown JobRequirementOverridePrototype: {value}");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Adds multiple mind roles to a mind
|
|
/// </summary>
|
|
/// <param name="mindId">The mind entity to add the role to</param>
|
|
/// <param name="roles">The list of mind roles to add</param>
|
|
/// <param name="mind">If the mind component is provided, it will be checked if it belongs to the mind entity</param>
|
|
/// <param name="silent">If true, no briefing will be generated upon receiving the mind role</param>
|
|
public void MindAddRoles(EntityUid mindId,
|
|
List<EntProtoId>? roles,
|
|
MindComponent? mind = null,
|
|
bool silent = false)
|
|
{
|
|
if (roles is null || roles.Count == 0)
|
|
return;
|
|
|
|
foreach (var proto in roles)
|
|
{
|
|
MindAddRole(mindId, proto, mind, silent);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Adds a mind role to a mind
|
|
/// </summary>
|
|
/// <param name="mindId">The mind entity to add the role to</param>
|
|
/// <param name="protoId">The mind role to add</param>
|
|
/// <param name="mind">If the mind component is provided, it will be checked if it belongs to the mind entity</param>
|
|
/// <param name="silent">If true, no briefing will be generated upon receiving the mind role</param>
|
|
public void MindAddRole(EntityUid mindId,
|
|
EntProtoId protoId,
|
|
MindComponent? mind = null,
|
|
bool silent = false)
|
|
{
|
|
if (protoId == "MindRoleJob")
|
|
MindAddJobRole(mindId, mind, silent, "");
|
|
else
|
|
MindAddRoleDo(mindId, protoId, mind, silent);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Adds a Job mind role with the specified job prototype
|
|
/// </summary>
|
|
/// /// <param name="mindId">The mind entity to add the job role to</param>
|
|
/// <param name="mind">If the mind component is provided, it will be checked if it belongs to the mind entity</param>
|
|
/// <param name="silent">If true, no briefing will be generated upon receiving the mind role</param>
|
|
/// <param name="jobPrototype">The Job prototype for the new role</param>
|
|
public void MindAddJobRole(EntityUid mindId,
|
|
MindComponent? mind = null,
|
|
bool silent = false,
|
|
string? jobPrototype = null)
|
|
{
|
|
if (!Resolve(mindId, ref mind))
|
|
return;
|
|
|
|
// Can't have someone get paid for two jobs now, can we
|
|
if (MindHasRole<JobRoleComponent>((mindId, mind), out var jobRole)
|
|
&& jobRole.Value.Comp1.JobPrototype != jobPrototype)
|
|
{
|
|
_adminLogger.Add(LogType.Mind,
|
|
LogImpact.Low,
|
|
$"Job Role of {ToPrettyString(mind.OwnedEntity)} changed from '{jobRole.Value.Comp1.JobPrototype}' to '{jobPrototype}'");
|
|
|
|
jobRole.Value.Comp1.JobPrototype = jobPrototype;
|
|
}
|
|
else
|
|
MindAddRoleDo(mindId, "MindRoleJob", mind, silent, jobPrototype);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates a Mind Role
|
|
/// </summary>
|
|
private void MindAddRoleDo(EntityUid mindId,
|
|
EntProtoId protoId,
|
|
MindComponent? mind = null,
|
|
bool silent = false,
|
|
string? jobPrototype = null)
|
|
{
|
|
if (!Resolve(mindId, ref mind))
|
|
{
|
|
Log.Error($"Failed to add role {protoId} to {ToPrettyString(mindId)} : Mind does not match provided mind component");
|
|
return;
|
|
}
|
|
|
|
if (!_prototypes.TryIndex(protoId, out var protoEnt))
|
|
{
|
|
Log.Error($"Failed to add role {protoId} to {ToPrettyString(mindId)} : Role prototype does not exist");
|
|
return;
|
|
}
|
|
|
|
//TODO don't let a prototype being added a second time
|
|
//If that was somehow to occur, a second mindrole for that comp would be created
|
|
//Meaning any mind role checks could return wrong results, since they just return the first match they find
|
|
|
|
var mindRoleId = Spawn(protoId, MapCoordinates.Nullspace);
|
|
EnsureComp<MindRoleComponent>(mindRoleId);
|
|
var mindRoleComp = Comp<MindRoleComponent>(mindRoleId);
|
|
|
|
mindRoleComp.Mind = (mindId,mind);
|
|
if (jobPrototype is not null)
|
|
{
|
|
mindRoleComp.JobPrototype = jobPrototype;
|
|
EnsureComp<JobRoleComponent>(mindRoleId);
|
|
DebugTools.AssertNull(mindRoleComp.AntagPrototype);
|
|
DebugTools.Assert(!mindRoleComp.Antag);
|
|
DebugTools.Assert(!mindRoleComp.ExclusiveAntag);
|
|
}
|
|
|
|
mind.MindRoles.Add(mindRoleId);
|
|
|
|
var update = MindRolesUpdate((mindId, mind));
|
|
|
|
// RoleType refresh, Role time tracking, Update Admin playerlist
|
|
|
|
var message = new RoleAddedEvent(mindId, mind, update, silent);
|
|
RaiseLocalEvent(mindId, message, true);
|
|
|
|
var name = Loc.GetString(protoEnt.Name);
|
|
if (mind.OwnedEntity is not null)
|
|
{
|
|
_adminLogger.Add(LogType.Mind,
|
|
LogImpact.Low,
|
|
$"{name} added to mind of {ToPrettyString(mind.OwnedEntity)}");
|
|
}
|
|
else
|
|
{
|
|
//TODO: This is not tied to the player on the Admin Log filters.
|
|
//Probably only happens when Job Role is added on initial spawn, before the mind entity is put in a mob
|
|
Log.Error($"{ToPrettyString(mindId)} does not have an OwnedEntity!");
|
|
_adminLogger.Add(LogType.Mind,
|
|
LogImpact.Low,
|
|
$"{name} added to {ToPrettyString(mindId)}");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Select the mind's currently "active" mind role entity, and update the mind's role type, if necessary
|
|
/// </summary>
|
|
/// <returns>
|
|
/// True if this changed the mind's role type
|
|
/// </returns>>
|
|
private bool MindRolesUpdate(Entity<MindComponent?> ent)
|
|
{
|
|
if(!Resolve(ent.Owner, ref ent.Comp))
|
|
return false;
|
|
|
|
//get the most important/latest mind role
|
|
var (roleType, subtype) = GetRoleTypeByTime(ent.Comp);
|
|
|
|
if (ent.Comp.RoleType == roleType && ent.Comp.Subtype == subtype)
|
|
return false;
|
|
|
|
SetRoleType(ent.Owner, roleType, subtype);
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Return the most recently specified role type and subtype, or Neutral
|
|
/// </summary>
|
|
private (ProtoId<RoleTypePrototype>, LocId?) GetRoleTypeByTime(MindComponent mind)
|
|
{
|
|
var role = GetRoleCompByTime(mind);
|
|
return (role?.Comp?.RoleType ?? "Neutral", role?.Comp?.Subtype);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Return the most recently specified role type's mind role entity, or null
|
|
/// </summary>
|
|
public Entity<MindRoleComponent>? GetRoleCompByTime(MindComponent mind)
|
|
{
|
|
var roles = new List<Entity<MindRoleComponent>>();
|
|
|
|
foreach (var role in mind.MindRoles)
|
|
{
|
|
var comp = Comp<MindRoleComponent>(role);
|
|
if (comp.RoleType is not null)
|
|
roles.Add((role, comp));
|
|
}
|
|
|
|
Entity<MindRoleComponent>? result = roles.Count > 0 ? roles.LastOrDefault() : null;
|
|
return (result);
|
|
}
|
|
|
|
private void SetRoleType(EntityUid mind, ProtoId<RoleTypePrototype> roleTypeId, LocId? subtype)
|
|
{
|
|
if (!TryComp<MindComponent>(mind, out var comp))
|
|
{
|
|
Log.Error($"Failed to update Role Type of mind entity {ToPrettyString(mind)} to {roleTypeId}, {subtype}. MindComponent not found.");
|
|
return;
|
|
}
|
|
|
|
if (!_prototypes.HasIndex(roleTypeId))
|
|
{
|
|
Log.Error($"Failed to change Role Type of {_minds.MindOwnerLoggingString(comp)} to {roleTypeId}, {subtype}. Invalid role");
|
|
return;
|
|
}
|
|
|
|
comp.RoleType = roleTypeId;
|
|
comp.Subtype = subtype;
|
|
Dirty(mind, comp);
|
|
|
|
// Update player character window
|
|
if (Player.TryGetSessionById(comp.UserId, out var session))
|
|
RaiseNetworkEvent(new MindRoleTypeChangedEvent(), session.Channel);
|
|
else
|
|
{
|
|
var error = $"The Character Window of {_minds.MindOwnerLoggingString(comp)} potentially did not update immediately : session error";
|
|
_adminLogger.Add(LogType.Mind, LogImpact.Medium, $"{error}");
|
|
}
|
|
|
|
if (comp.OwnedEntity is null)
|
|
{
|
|
Log.Error($"{ToPrettyString(mind)} does not have an OwnedEntity!");
|
|
_adminLogger.Add(LogType.Mind,
|
|
LogImpact.Medium,
|
|
$"Role Type of {ToPrettyString(mind)} changed to {roleTypeId}, {subtype}");
|
|
return;
|
|
}
|
|
|
|
_adminLogger.Add(LogType.Mind,
|
|
LogImpact.High,
|
|
$"Role Type of {ToPrettyString(comp.OwnedEntity)} changed to {roleTypeId}, {subtype}");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Finds and removes all mind roles of a specific type
|
|
/// </summary>
|
|
/// <param name="mind">The mind to remove the role from.</param>
|
|
/// <typeparam name="T">The type of the role to remove.</typeparam>
|
|
/// <returns>True if the role existed and was removed</returns>>
|
|
public bool MindRemoveRole<T>(Entity<MindComponent?> mind) where T : IComponent
|
|
{
|
|
if (typeof(T) == typeof(MindRoleComponent))
|
|
throw new InvalidOperationException();
|
|
|
|
if (!Resolve(mind.Owner, ref mind.Comp))
|
|
return false;
|
|
|
|
var delete = new List<EntityUid>();
|
|
// If there were no matches and thus no mind role entity names, we'll need the component's name, to report what role failed to be removed
|
|
var original = "'" + typeof(T).Name + "'";
|
|
var deleteName = original;
|
|
|
|
foreach (var role in mind.Comp.MindRoles)
|
|
{
|
|
if (!HasComp<MindRoleComponent>(role))
|
|
{
|
|
Log.Error($"Encountered mind role entity {ToPrettyString(role)} without a {nameof(MindRoleComponent)}");
|
|
continue;
|
|
}
|
|
|
|
if (!HasComp<T>(role))
|
|
continue;
|
|
|
|
delete.Add(role);
|
|
deleteName = RemoveRoleLogNameGeneration(deleteName, MetaData(role).EntityName, original);
|
|
}
|
|
|
|
return MindRemoveRoleDo(mind, delete, deleteName);
|
|
}
|
|
|
|
private string RemoveRoleLogNameGeneration(string name, string newName, string original)
|
|
{
|
|
// If there were matches for deletion, this will run, and we get a new name to replace the original input
|
|
if (name == original)
|
|
name = "'" + newName + "'";
|
|
// It is theoretically possible to get multiple matches
|
|
// If they have different names, then we want all of them listed
|
|
else if (!name.Contains(newName))
|
|
// and we can't just drop the multiple names within a single ' ' section later, because that would
|
|
// make it look like it's one name that is just formatted to look like a list
|
|
name = name + ", " + "'" + newName + "'";
|
|
|
|
return name;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Finds and removes all mind roles of a specific type
|
|
/// </summary>
|
|
/// <param name="mindId">The mind entity</param>
|
|
/// <typeparam name="T">The type of the role to remove.</typeparam>
|
|
/// <returns>True if the role existed and was removed</returns>
|
|
public bool MindRemoveRole<T>(EntityUid mindId) where T : IComponent
|
|
{
|
|
if (!TryComp<MindComponent>(mindId, out var mind))
|
|
{
|
|
Log.Error($"The specified mind entity '{ToPrettyString(mindId)}' does not have a {nameof(MindComponent)}");
|
|
return false;
|
|
}
|
|
|
|
return MindRemoveRole<T>((mindId, mind));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Finds and removes all mind roles of a specific type
|
|
/// </summary>
|
|
/// <param name="mind">The mind entity and component</param>
|
|
/// /// <param name="protoId">The prototype ID of the mind role to be removed</param>
|
|
/// <returns>True if the role existed and was removed</returns>
|
|
public bool MindRemoveRole(Entity<MindComponent?> mind, EntProtoId<MindRoleComponent> protoId)
|
|
{
|
|
if ( !Resolve(mind.Owner, ref mind.Comp))
|
|
return false;
|
|
|
|
// If there were no matches and thus no mind role entity names, we'll need the protoId, to report what role failed to be removed
|
|
var original = "'" + protoId + "'";
|
|
var deleteName = original;
|
|
var delete = new List<EntityUid>();
|
|
foreach (var role in mind.Comp.MindRoles)
|
|
{
|
|
if (!HasComp<MindRoleComponent>(role))
|
|
{
|
|
Log.Error($"Encountered mind role entity {ToPrettyString(role)} without a {nameof(MindRoleComponent)}");
|
|
continue;
|
|
}
|
|
|
|
var id = MetaData(role).EntityPrototype?.ID;
|
|
if (id is null || id != protoId)
|
|
continue;
|
|
|
|
delete.Add(role);
|
|
deleteName = RemoveRoleLogNameGeneration(deleteName, MetaData(role).EntityName, original);
|
|
}
|
|
|
|
return MindRemoveRoleDo(mind, delete, deleteName);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Performs the actual role entity deletion.
|
|
/// </summary>
|
|
private bool MindRemoveRoleDo(Entity<MindComponent?> mind, List<EntityUid> delete, string? logName = "")
|
|
{
|
|
if ( !Resolve(mind.Owner, ref mind.Comp))
|
|
return false;
|
|
|
|
if (delete.Count <= 0)
|
|
{
|
|
Log.Warning($"Failed to remove mind role {logName} from {ToPrettyString(mind.Owner)} : mind does not have this role ");
|
|
return false;
|
|
}
|
|
|
|
foreach (var role in delete)
|
|
{
|
|
_entityManager.DeleteEntity(role);
|
|
}
|
|
|
|
var update = MindRolesUpdate(mind);
|
|
|
|
var message = new RoleRemovedEvent(mind.Owner, mind.Comp, update);
|
|
RaiseLocalEvent(mind, message, true);
|
|
|
|
_adminLogger.Add(LogType.Mind,
|
|
LogImpact.Low,
|
|
$"All roles of type {logName} removed from mind of {ToPrettyString(mind.Comp.OwnedEntity)}");
|
|
|
|
return true;
|
|
}
|
|
|
|
// Removing the mind role's reference on component shutdown
|
|
// to make sure the reference gets removed even if the mind role entity was deleted by outside code
|
|
private void OnComponentShutdown(Entity<MindRoleComponent> ent, ref ComponentShutdown args)
|
|
{
|
|
//TODO: Just ensure that the tests don't spawn unassociated mind role entities
|
|
if (ent.Comp.Mind.Comp is null)
|
|
return;
|
|
|
|
ent.Comp.Mind.Comp.MindRoles.Remove(ent.Owner);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Finds the first mind role of a specific T type on a mind entity.
|
|
/// Outputs entity components for the mind role's MindRoleComponent and for T
|
|
/// </summary>
|
|
/// <param name="mind">The mind entity</param>
|
|
/// <typeparam name="T">The type of the role to find.</typeparam>
|
|
/// <param name="role">The Mind Role entity component</param>
|
|
/// <returns>True if the role is found</returns>
|
|
public bool MindHasRole<T>(Entity<MindComponent?> mind,
|
|
[NotNullWhen(true)] out Entity<MindRoleComponent, T>? role) where T : IComponent
|
|
{
|
|
role = null;
|
|
if (!Resolve(mind.Owner, ref mind.Comp))
|
|
return false;
|
|
|
|
foreach (var roleEnt in mind.Comp.MindRoles)
|
|
{
|
|
if (!TryComp(roleEnt, out T? tcomp))
|
|
continue;
|
|
|
|
if (!TryComp(roleEnt, out MindRoleComponent? roleComp))
|
|
{
|
|
Log.Error($"Encountered mind role entity {ToPrettyString(roleEnt)} without a {nameof(MindRoleComponent)}");
|
|
continue;
|
|
}
|
|
|
|
role = (roleEnt, roleComp, tcomp);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Finds the first mind role of a specific type on a mind entity.
|
|
/// Outputs an entity component for the mind role's MindRoleComponent
|
|
/// </summary>
|
|
/// <param name="mindId">The mind entity</param>
|
|
/// <param name="type">The Type to look for</param>
|
|
/// <param name="role">The output role</param>
|
|
/// <returns>True if the role is found</returns>
|
|
public bool MindHasRole(EntityUid mindId,
|
|
Type type,
|
|
[NotNullWhen(true)] out Entity<MindRoleComponent>? role)
|
|
{
|
|
role = null;
|
|
// All MindRoles have this component, it would just return the first one.
|
|
// Order might not be what is expected.
|
|
// Better to report null
|
|
if (type == Type.GetType("MindRoleComponent"))
|
|
{
|
|
Log.Error($"Something attempted to query mind role 'MindRoleComponent' on mind {mindId}. This component is present on every single mind role.");
|
|
return false;
|
|
}
|
|
|
|
if (!TryComp<MindComponent>(mindId, out var mind))
|
|
return false;
|
|
|
|
var found = false;
|
|
|
|
foreach (var roleEnt in mind.MindRoles)
|
|
{
|
|
if (!HasComp(roleEnt, type))
|
|
continue;
|
|
|
|
if (!TryComp(roleEnt, out MindRoleComponent? roleComp))
|
|
{
|
|
Log.Error($"Encountered mind role entity {ToPrettyString(roleEnt)} without a {nameof(MindRoleComponent)}");
|
|
continue;
|
|
}
|
|
|
|
role = (roleEnt, roleComp);
|
|
found = true;
|
|
break;
|
|
}
|
|
|
|
return found;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns true if a mind has a role that matches a whitelist.
|
|
/// </summary>
|
|
public bool MindHasRole(Entity<MindComponent> mind, EntityWhitelist whitelist)
|
|
{
|
|
foreach (var roleEnt in mind.Comp.MindRoles)
|
|
{
|
|
if (_whitelist.IsWhitelistPass(whitelist, roleEnt))
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Finds the first mind role of a specific type on a mind entity.
|
|
/// </summary>
|
|
/// <param name="mindId">The mind entity</param>
|
|
/// <typeparam name="T">The type of the role to find.</typeparam>
|
|
/// <returns>True if the role is found</returns>
|
|
public bool MindHasRole<T>(EntityUid mindId) where T : IComponent
|
|
{
|
|
return MindHasRole<T>(mindId, out _);
|
|
}
|
|
|
|
//TODO: Delete this later
|
|
/// <summary>
|
|
/// Returns the first mind role of a specific type
|
|
/// </summary>
|
|
/// <param name="mindId">The mind entity</param>
|
|
/// <returns>Entity Component of the mind role</returns>
|
|
[Obsolete("Use MindHasRole's output value")]
|
|
public Entity<MindRoleComponent>? MindGetRole<T>(EntityUid mindId) where T : IComponent
|
|
{
|
|
Entity<MindRoleComponent>? result = null;
|
|
|
|
var mind = Comp<MindComponent>(mindId);
|
|
|
|
foreach (var uid in mind.MindRoles)
|
|
{
|
|
if (HasComp<T>(uid) && TryComp<MindRoleComponent>(uid, out var comp))
|
|
result = (uid,comp);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Reads all Roles of a mind Entity and returns their data as RoleInfo
|
|
/// </summary>
|
|
/// <param name="mind">The mind entity</param>
|
|
/// <returns>RoleInfo list</returns>
|
|
public List<RoleInfo> MindGetAllRoleInfo(Entity<MindComponent?> mind)
|
|
{
|
|
var roleInfo = new List<RoleInfo>();
|
|
|
|
if (!Resolve(mind.Owner, ref mind.Comp))
|
|
return roleInfo;
|
|
|
|
foreach (var role in mind.Comp.MindRoles)
|
|
{
|
|
var valid = false;
|
|
var name = "game-ticker-unknown-role";
|
|
var prototype = "";
|
|
string? playTimeTracker = null;
|
|
|
|
if (!TryComp(role, out MindRoleComponent? comp))
|
|
{
|
|
Log.Error($"Encountered mind role entity {ToPrettyString(role)} without a {nameof(MindRoleComponent)}");
|
|
continue;
|
|
}
|
|
|
|
if (comp.AntagPrototype is not null)
|
|
prototype = comp.AntagPrototype;
|
|
|
|
if (comp.JobPrototype is not null && comp.AntagPrototype is null)
|
|
{
|
|
prototype = comp.JobPrototype;
|
|
if (_prototypes.TryIndex(comp.JobPrototype, out var job))
|
|
{
|
|
playTimeTracker = job.PlayTimeTracker;
|
|
name = job.Name;
|
|
valid = true;
|
|
}
|
|
else
|
|
{
|
|
Log.Error($" Mind Role Prototype '{role.Id}' contains invalid Job prototype: '{comp.JobPrototype}'");
|
|
}
|
|
}
|
|
else if (comp.AntagPrototype is not null && comp.JobPrototype is null)
|
|
{
|
|
prototype = comp.AntagPrototype;
|
|
if (_prototypes.TryIndex(comp.AntagPrototype, out var antag))
|
|
{
|
|
playTimeTracker = antag.PlayTimeTracker;
|
|
name = antag.Name;
|
|
valid = true;
|
|
}
|
|
else
|
|
{
|
|
Log.Error($" Mind Role Prototype '{role.Id}' contains invalid Antagonist prototype: '{comp.AntagPrototype}'");
|
|
}
|
|
}
|
|
else if (comp.JobPrototype is not null && comp.AntagPrototype is not null)
|
|
{
|
|
Log.Error($" Mind Role Prototype '{role.Id}' contains both Job and Antagonist prototypes");
|
|
}
|
|
|
|
if (valid)
|
|
roleInfo.Add(new RoleInfo(name, comp.Antag, playTimeTracker, prototype));
|
|
}
|
|
return roleInfo;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Does this mind possess an antagonist role
|
|
/// </summary>
|
|
/// <param name="mindId">The mind entity</param>
|
|
/// <returns>True if the mind possesses any antag roles</returns>
|
|
public bool MindIsAntagonist(EntityUid? mindId)
|
|
{
|
|
if (mindId is null)
|
|
return false;
|
|
|
|
return CheckAntagonistStatus(mindId.Value).Antag;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Does this mind possess an exclusive antagonist role
|
|
/// </summary>
|
|
/// <param name="mindId">The mind entity</param>
|
|
/// <returns>True if the mind possesses any exclusive antag roles</returns>
|
|
public bool MindIsExclusiveAntagonist(EntityUid? mindId)
|
|
{
|
|
if (mindId is null)
|
|
return false;
|
|
|
|
return CheckAntagonistStatus(mindId.Value).ExclusiveAntag;
|
|
}
|
|
|
|
private (bool Antag, bool ExclusiveAntag) CheckAntagonistStatus(Entity<MindComponent?> mind)
|
|
{
|
|
if (!Resolve(mind.Owner, ref mind.Comp))
|
|
return (false, false);
|
|
|
|
var antagonist = false;
|
|
var exclusiveAntag = false;
|
|
foreach (var role in mind.Comp.MindRoles)
|
|
{
|
|
if (!TryComp<MindRoleComponent>(role, out var roleComp))
|
|
{
|
|
Log.Error($"Mind Role Entity {ToPrettyString(role)} does not have a MindRoleComponent, despite being listed as a role belonging to {ToPrettyString(mind)}|");
|
|
continue;
|
|
}
|
|
|
|
antagonist |= roleComp.Antag;
|
|
exclusiveAntag |= roleComp.ExclusiveAntag;
|
|
}
|
|
|
|
return (antagonist, exclusiveAntag);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Play a sound for the mind, if it has a session attached.
|
|
/// Use this for role greeting sounds.
|
|
/// </summary>
|
|
public void MindPlaySound(EntityUid mindId, SoundSpecifier? sound, MindComponent? mind = null)
|
|
{
|
|
if (!Resolve(mindId, ref mind))
|
|
return;
|
|
|
|
if (Player.TryGetSessionById(mind.UserId, out var session))
|
|
_audio.PlayGlobal(sound, session);
|
|
}
|
|
|
|
// TODO ROLES Change to readonly.
|
|
// Passing around a reference to a prototype's hashset makes me uncomfortable because it might be accidentally
|
|
// mutated.
|
|
public HashSet<JobRequirement>? GetJobRequirement(JobPrototype job)
|
|
{
|
|
if (_requirementOverride != null && _requirementOverride.Jobs.TryGetValue(job.ID, out var req))
|
|
return req;
|
|
|
|
return job.Requirements;
|
|
}
|
|
|
|
// TODO ROLES Change to readonly.
|
|
public HashSet<JobRequirement>? GetJobRequirement(ProtoId<JobPrototype> job)
|
|
{
|
|
if (_requirementOverride != null && _requirementOverride.Jobs.TryGetValue(job, out var req))
|
|
return req;
|
|
|
|
return _prototypes.Index(job).Requirements;
|
|
}
|
|
|
|
// TODO ROLES Change to readonly.
|
|
public HashSet<JobRequirement>? GetAntagRequirement(ProtoId<AntagPrototype> antag)
|
|
{
|
|
if (_requirementOverride != null && _requirementOverride.Antags.TryGetValue(antag, out var req))
|
|
return req;
|
|
|
|
return _prototypes.Index(antag).Requirements;
|
|
}
|
|
|
|
// TODO ROLES Change to readonly.
|
|
public HashSet<JobRequirement>? GetAntagRequirement(AntagPrototype antag)
|
|
{
|
|
if (_requirementOverride != null && _requirementOverride.Antags.TryGetValue(antag.ID, out var req))
|
|
return req;
|
|
|
|
return antag.Requirements;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the localized name of a role type's subtype. If the provided subtype parameter turns out to be empty, it returns the localized name of the role type instead.
|
|
/// </summary>
|
|
public string GetRoleSubtypeLabel(LocId roleType, LocId? subtype)
|
|
{
|
|
return string.IsNullOrEmpty(subtype) ? Loc.GetString(roleType) : Loc.GetString(subtype);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Raised on the client to update Role Type on the character window, in case it happened to be open.
|
|
/// </summary>
|
|
[Serializable, NetSerializable]
|
|
public sealed class MindRoleTypeChangedEvent : EntityEventArgs
|
|
{
|
|
|
|
}
|