From 38ea52b082396ee009a99f5b93e7e72224039139 Mon Sep 17 00:00:00 2001 From: Zack Backmen Date: Sat, 23 Nov 2024 00:59:52 +0300 Subject: [PATCH 1/3] =?UTF-8?q?=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20whitelist=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=B2=20ui,=20=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=82=D1=80=D0=B5=D0=B1=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=B9=20=D1=83=20=D1=86=D0=BA=20=D1=80=D0=BE?= =?UTF-8?q?=D0=BB=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Ghost/Controls/Roles/GhostRolesEui.cs | 14 ++++--- .../Reinforcement/ReinforcementSystem.cs | 39 ++++++++++++++++--- Content.Server/Ghost/Roles/GhostRoleSystem.cs | 27 ++++++++++++- .../Ghost/Roles/GhostRolesEuiMessages.cs | 1 + Resources/Locale/en-US/backmen/playtime.ftl | 1 + Resources/Locale/ru-RU/backmen/playtime.ftl | 1 + .../_Backmen/CentComm/BKCCAssistant.yml | 3 +- .../_Backmen/CentComm/BKCCCargo.yml | 3 +- .../_Backmen/CentComm/BKCCOperator.yml | 2 +- .../Loadouts/Jobs/CentCom/BKCCCargo.yml | 12 ++++++ .../_Backmen/Roles/Jobs/CentCom/cargotech.yml | 1 + .../Roles/Jobs/CentCom/centcom_official.yml | 1 + .../Roles/Jobs/CentCom/head_of_security.yml | 1 + .../_Backmen/Roles/Jobs/CentCom/intern.yml | 1 + .../_Backmen/Roles/Jobs/CentCom/operator.yml | 1 + .../Roles/Jobs/CentCom/private_officer.yml | 1 + 16 files changed, 94 insertions(+), 15 deletions(-) diff --git a/Content.Client/UserInterface/Systems/Ghost/Controls/Roles/GhostRolesEui.cs b/Content.Client/UserInterface/Systems/Ghost/Controls/Roles/GhostRolesEui.cs index 8fb8cc349f0..5e3c527a996 100644 --- a/Content.Client/UserInterface/Systems/Ghost/Controls/Roles/GhostRolesEui.cs +++ b/Content.Client/UserInterface/Systems/Ghost/Controls/Roles/GhostRolesEui.cs @@ -3,6 +3,7 @@ using Content.Client.Players.PlayTimeTracking; using Content.Shared.Eui; using Content.Shared.Ghost.Roles; +using Content.Shared.Players.JobWhitelist; using JetBrains.Annotations; using Robust.Client.GameObjects; using Robust.Shared.Utility; @@ -94,7 +95,7 @@ public override void HandleState(EuiStateBase state) // TODO: role.Requirements value doesn't work at all as an equality key, this must be fixed // Grouping roles var groupedRoles = ghostState.GhostRoles.GroupBy( - role => (role.Name, role.Description, role.Requirements, role.WhitelistRequired)); //backmen: whitelist + role => (role.Name, role.Description, role.Requirements, role.WhitelistRequired, role.DiscordRequired)); //backmen: whitelist //start-backmen: whitelist var cfg = IoCManager.Resolve(); @@ -109,15 +110,16 @@ public override void HandleState(EuiStateBase state) FormattedMessage? reason; //start-backmen: whitelist - if ( - group.Key.WhitelistRequired && - cfg.GetCVar(Shared.Backmen.CCVar.CCVars.WhitelistRolesEnabled) && - !requirementsManager.IsWhitelisted() - ) + if (group.Key.WhitelistRequired) { hasAccess = false; reason = FormattedMessage.FromMarkupOrThrow(Loc.GetString("playtime-deny-reason-not-whitelisted")); } + else if (group.Key.DiscordRequired) + { + hasAccess = false; + reason = FormattedMessage.FromMarkupOrThrow(Loc.GetString("playtime-deny-reason-discord")); + } else //end-backmen: whitelist if (!requirementsManager.CheckRoleRequirements(group.Key.Requirements, null, out reason)) diff --git a/Content.Server/Backmen/Reinforcement/ReinforcementSystem.cs b/Content.Server/Backmen/Reinforcement/ReinforcementSystem.cs index 23d0d691a04..a0f656aac1b 100644 --- a/Content.Server/Backmen/Reinforcement/ReinforcementSystem.cs +++ b/Content.Server/Backmen/Reinforcement/ReinforcementSystem.cs @@ -7,6 +7,7 @@ using Content.Server.Ghost.Roles.Components; using Content.Server.Ghost.Roles.Raffles; using Content.Server.Mind; +using Content.Server.Players.JobWhitelist; using Content.Server.Players.PlayTimeTracking; using Content.Server.Popups; using Content.Server.Roles; @@ -71,6 +72,8 @@ public sealed class ReinforcementSystem : SharedReinforcementSystem [Dependency] private readonly IAdminLogManager _adminLogger = default!; [Dependency] private readonly StationJobsSystem _stationJobs = default!; [Dependency] private readonly IChatManager _chatManager = default!; + [Dependency] private readonly GameTicker _ticker = default!; + [Dependency] private readonly JobWhitelistManager _jobWhitelistManager = default!; public override void Initialize() { @@ -153,7 +156,10 @@ private void OnSpawnPlayer(ReinforcementSpawnPlayer args) if (station == null) return; - var character = HumanoidCharacterProfile.Random(); + var character = _ticker.GetPlayerProfile(args.Player).Clone(); + character.Name = HumanoidCharacterProfile.GetName(character.Species, character.Gender); + + //var character = HumanoidCharacterProfile.RandomWithSpecies(); var newMind = _mind.CreateMind(args.Player.UserId, character.Name); _mind.SetUserId(newMind, args.Player.UserId); @@ -206,26 +212,35 @@ private void OnTakeoverTakeRole(Entity ent, ref T var row = ent.Comp.Linked.Comp.Members.FirstOrDefault(x => x.Owner == ent.Owner); if (row == null) { + ent.Comp.Used = false; return; } var proto = ent.Comp.Linked.Comp.GetById(row.Id, _prototype); if (proto == null) { + ent.Comp.Used = false; return; } - if (_banManager.GetRoleBans(args.Player.UserId)?.Contains("Job:"+proto.Job) ?? false) + if (_banManager.GetJobBans(args.Player.UserId)?.Contains(proto.Job) ?? false) { - _popup.PopupCursor(Loc.GetString("role-ban"), args.Player, PopupType.LargeCaution); ent.Comp.Used = false; + SendChatMsg(args.Player, Loc.GetString("role-ban")); return; } if (!_playTimeTrackings.IsAllowed(args.Player,proto.Job)) { - _popup.PopupCursor(Loc.GetString("role-timer-locked"), args.Player, PopupType.LargeCaution); ent.Comp.Used = false; + SendChatMsg(args.Player, Loc.GetString("role-timer-locked")); + return; + } + + if (!_jobWhitelistManager.IsAllowed(args.Player, proto.Job)) + { + ent.Comp.Used = false; + SendChatMsg(args.Player, Loc.GetString("role-not-whitelisted")); return; } @@ -302,7 +317,9 @@ private void OnStartCall(Entity ent, ref CallRein ghost.Requirements = new HashSet(job.Requirements); } - ghost.WhitelistRequired = job.Whitelisted; + ghost.JobProto = job.ID; + + //ghost.WhitelistRequired = job.Whitelisted; } UpdateUserInterface(ent); @@ -398,4 +415,16 @@ private void UpdateUserInterface(Entity uid) _ui.SetUiState(uid.Owner, ReinforcementConsoleKey.Key, msg); } + + private void SendChatMsg(ICommonSession sess, string message) + { + _popup.PopupCursor(message, sess, PopupType.LargeCaution); + _chatManager.ChatMessageToOne(Shared.Chat.ChatChannel.Server, + message, + Loc.GetString("chat-manager-server-wrap-message", ("message", message)), + default, + false, + sess.Channel, + Color.Red); + } } diff --git a/Content.Server/Ghost/Roles/GhostRoleSystem.cs b/Content.Server/Ghost/Roles/GhostRoleSystem.cs index 8c54e609897..02439fd9cea 100644 --- a/Content.Server/Ghost/Roles/GhostRoleSystem.cs +++ b/Content.Server/Ghost/Roles/GhostRoleSystem.cs @@ -6,6 +6,7 @@ using Content.Shared.Ghost.Roles.Raffles; using Content.Server.Ghost.Roles.UI; using Content.Server.Mind.Commands; +using Content.Server.Players.JobWhitelist; using Content.Shared.Administration; using Content.Shared.CCVar; using Content.Shared.Database; @@ -54,6 +55,8 @@ public sealed class GhostRoleSystem : EntitySystem [Dependency] private readonly IPrototypeManager _prototype = default!; [Dependency] private readonly Backmen.RoleWhitelist.WhitelistSystem _roleWhitelist = default!; // backmen: whitelist + [Dependency] private readonly JobWhitelistManager _wlRole = default!; // backmen: whitelist + [Dependency] private readonly Content.Corvax.Interfaces.Server.IServerDiscordAuthManager _discordAuthManager = default!; // backmen: whitelist private uint _nextRoleIdentifier; private bool _needsUpdateGhostRoleCount = true; @@ -578,6 +581,27 @@ public GhostRoleInfo[] GetGhostRolesInfo(ICommonSession? player) ? _timing.CurTime.Add(raffle.Countdown) : TimeSpan.MinValue; + // start-backmen: whitelist + var whitelistRequired = false; + var discordRequired = false; + if (_prototype.TryIndex(role.JobProto, out var job) && player != null) + { + if (role.WhitelistRequired) + { + whitelistRequired = true; + } + else if (!_wlRole.IsAllowed(player, job)) + { + whitelistRequired = true; + } + + if (_discordAuthManager.IsEnabled && job.DiscordRequired) + { + discordRequired = true; + } + } + // end-backmen: whitelist + roles.Add(new GhostRoleInfo { Identifier = id, @@ -588,7 +612,8 @@ public GhostRoleInfo[] GetGhostRolesInfo(ICommonSession? player) Kind = kind, RafflePlayerCount = rafflePlayerCount, RaffleEndTime = raffleEndTime, - WhitelistRequired = role.WhitelistRequired // backmen: whitelist + WhitelistRequired = whitelistRequired, // backmen: whitelist + DiscordRequired = discordRequired, // backmen: whitelist }); } diff --git a/Content.Shared/Ghost/Roles/GhostRolesEuiMessages.cs b/Content.Shared/Ghost/Roles/GhostRolesEuiMessages.cs index 7eacfe94d31..c3eed3ea647 100644 --- a/Content.Shared/Ghost/Roles/GhostRolesEuiMessages.cs +++ b/Content.Shared/Ghost/Roles/GhostRolesEuiMessages.cs @@ -12,6 +12,7 @@ public struct GhostRoleInfo public string Description { get; set; } public string Rules { get; set; } public bool WhitelistRequired { get; set; } // backmen: Whitelist + public bool DiscordRequired { get; set; } // backmen: Whitelist // TODO ROLE TIMERS // Actually make use of / enforce this requirement? diff --git a/Resources/Locale/en-US/backmen/playtime.ftl b/Resources/Locale/en-US/backmen/playtime.ftl index 2b1aa1c9258..c9c714825b4 100644 --- a/Resources/Locale/en-US/backmen/playtime.ftl +++ b/Resources/Locale/en-US/backmen/playtime.ftl @@ -1,3 +1,4 @@ playtime-deny-reason-not-whitelisted = You need be [color=yellow]Whitelist[/color] to keep this role +playtime-deny-reason-discord = You should complete [color=yellow]Discord[/color]-auth to keep this role ghost-role-whitelist-text = {$num} roles are not shown because they require whitelisting to play. ghost-role-whitelist-text-one = One role is not shown because it requires whitelisting to play. diff --git a/Resources/Locale/ru-RU/backmen/playtime.ftl b/Resources/Locale/ru-RU/backmen/playtime.ftl index 4a276f50ea5..df7037875f2 100644 --- a/Resources/Locale/ru-RU/backmen/playtime.ftl +++ b/Resources/Locale/ru-RU/backmen/playtime.ftl @@ -1,4 +1,5 @@ playtime-deny-reason-not-whitelisted = Вам нужно быть в [color=yellow]Whitelist[/color], чтобы взять эту роль +playtime-deny-reason-discord = Вам нужно пройти [color=yellow]Discord[/color] авторизацию, чтобы взять эту роль ghost-role-whitelist-text = { $num } роли(-ей) не показываются, т.к. вы не в Whitelist ghost-role-whitelist-text-one = Одна(или больше) ролей не показываются, т.к. вы не в Whitelist ui-escape-discord = Написать заявку можно в дискорде diff --git a/Resources/Prototypes/_Backmen/CentComm/BKCCAssistant.yml b/Resources/Prototypes/_Backmen/CentComm/BKCCAssistant.yml index 67bec8c2040..ac832d7276b 100644 --- a/Resources/Prototypes/_Backmen/CentComm/BKCCAssistant.yml +++ b/Resources/Prototypes/_Backmen/CentComm/BKCCAssistant.yml @@ -36,9 +36,10 @@ - type: entity name: Ассистент ЦК - suffix: Спавнер, Директор Событий + suffix: Директор Событий parent: MobHumanCombine id: MobHumanCMBKCCAssistant + description: "" components: - type: Icon sprite: Markers/jobs.rsi diff --git a/Resources/Prototypes/_Backmen/CentComm/BKCCCargo.yml b/Resources/Prototypes/_Backmen/CentComm/BKCCCargo.yml index 3237c5cb560..e738ecd408b 100644 --- a/Resources/Prototypes/_Backmen/CentComm/BKCCCargo.yml +++ b/Resources/Prototypes/_Backmen/CentComm/BKCCCargo.yml @@ -41,6 +41,7 @@ suffix: Директор Событий parent: MobHumanCombine id: MobHumanCMBKCCCargo + description: "" components: - type: Icon sprite: Markers/jobs.rsi @@ -55,7 +56,7 @@ factions: - CentralCommand - type: Loadout - prototypes: [CCCargo] + prototypes: [CCCargoFull] - type: RandomHumanoidAppearance randomizeName: true - type: AntagImmune diff --git a/Resources/Prototypes/_Backmen/CentComm/BKCCOperator.yml b/Resources/Prototypes/_Backmen/CentComm/BKCCOperator.yml index 29505565c36..70897112e5f 100644 --- a/Resources/Prototypes/_Backmen/CentComm/BKCCOperator.yml +++ b/Resources/Prototypes/_Backmen/CentComm/BKCCOperator.yml @@ -38,7 +38,7 @@ name: Оператор ЦК suffix: Директор Событий parent: MobHumanCombine - description: Офисный клерк. + description: Офисный клерк id: MobHumanCMBKCCOperator components: - type: Icon diff --git a/Resources/Prototypes/_Backmen/Loadouts/Jobs/CentCom/BKCCCargo.yml b/Resources/Prototypes/_Backmen/Loadouts/Jobs/CentCom/BKCCCargo.yml index 1d4b34fa416..6242b7a138c 100644 --- a/Resources/Prototypes/_Backmen/Loadouts/Jobs/CentCom/BKCCCargo.yml +++ b/Resources/Prototypes/_Backmen/Loadouts/Jobs/CentCom/BKCCCargo.yml @@ -7,6 +7,18 @@ shoes: ClothingShoesColorBlack head: ClothingHeadHatCargosoft +- type: startingGear + id: CCCargoFull + equipment: + id: CCCargoPDA + ears: ClothingHeadsetCentCom + pocket1: AppraisalTool + shoes: ClothingShoesColorBlack + head: ClothingHeadHatCargosoft + jumpsuit: ClothingUniformJumpsuitCargo + neck: ClothingNeckCloakCap + back: ClothingBackpack + # Jumpsuit - type: loadout diff --git a/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/cargotech.yml b/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/cargotech.yml index a67090659e3..cedba87c09b 100644 --- a/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/cargotech.yml +++ b/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/cargotech.yml @@ -11,6 +11,7 @@ weight: 1 requireAdminNotify: true joinNotifyCrew: true + discordRequired: true requirements: - !type:DepartmentTimeRequirement department: Cargo diff --git a/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/centcom_official.yml b/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/centcom_official.yml index 49fa96d389a..010a51db158 100644 --- a/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/centcom_official.yml +++ b/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/centcom_official.yml @@ -12,6 +12,7 @@ requireAdminNotify: true joinNotifyCrew: true whitelisted: true + discordRequired: true requirements: - !type:DepartmentTimeRequirement department: CentCom diff --git a/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/head_of_security.yml b/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/head_of_security.yml index e530ebf9550..b7a55c80582 100644 --- a/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/head_of_security.yml +++ b/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/head_of_security.yml @@ -12,6 +12,7 @@ requireAdminNotify: true joinNotifyCrew: true whitelisted: true + discordRequired: true requirements: - !type:RoleTimeRequirement role: JobCentralCommandAssistant diff --git a/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/intern.yml b/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/intern.yml index 80fb5858e26..8d779607251 100644 --- a/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/intern.yml +++ b/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/intern.yml @@ -11,6 +11,7 @@ weight: 1 requireAdminNotify: true joinNotifyCrew: true + discordRequired: true requirements: - !type:DepartmentTimeRequirement department: Engineering diff --git a/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/operator.yml b/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/operator.yml index 5a7eace4304..ac65ab0ebc9 100644 --- a/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/operator.yml +++ b/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/operator.yml @@ -12,6 +12,7 @@ requireAdminNotify: true joinNotifyCrew: true whitelisted: true + discordRequired: true requirements: - !type:RoleTimeRequirement role: JobCentralCommandAssistant diff --git a/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/private_officer.yml b/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/private_officer.yml index 1b32a1ac3a9..1899a1bb9a5 100644 --- a/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/private_officer.yml +++ b/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/private_officer.yml @@ -11,6 +11,7 @@ weight: 1 requireAdminNotify: true joinNotifyCrew: true + discordRequired: true requirements: - !type:DepartmentTimeRequirement department: Security From 0c6e0cbfc51bddb460573da4a1765165e00657bf Mon Sep 17 00:00:00 2001 From: Zack Backmen Date: Sat, 23 Nov 2024 01:06:04 +0300 Subject: [PATCH 2/3] =?UTF-8?q?=D1=82=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20?= =?UTF-8?q?=D1=86=D0=BA=20=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE=20=D0=B2=D0=B7?= =?UTF-8?q?=D0=BE=D1=80=D0=B2=D0=B0=D1=82=D1=8C!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Resources/Maps/centcomm.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/Resources/Maps/centcomm.yml b/Resources/Maps/centcomm.yml index 6a95de42aa2..b3a82c184bc 100644 --- a/Resources/Maps/centcomm.yml +++ b/Resources/Maps/centcomm.yml @@ -2728,7 +2728,6 @@ entities: - type: GasTileOverlay - type: SpreaderGrid - type: GridPathfinding - - type: ProtectedGrid - proto: AcousticGuitarInstrument entities: - uid: 1455 From 6cf913917c8a287802e895d607c1056f8ae9417b Mon Sep 17 00:00:00 2001 From: Zack Backmen Date: Sat, 23 Nov 2024 01:20:19 +0300 Subject: [PATCH 3/3] fix --- Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/blueshield.yml | 1 + .../Prototypes/_Backmen/Roles/Jobs/CentCom/centcom_admiral.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/blueshield.yml b/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/blueshield.yml index 7a9614ff17e..6b8c22859e7 100644 --- a/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/blueshield.yml +++ b/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/blueshield.yml @@ -7,6 +7,7 @@ requireAdminNotify: true joinNotifyCrew: true whitelisted: true + discordRequired: true requirements: - !type:RoleTimeRequirement role: JobHeadOfSecurity diff --git a/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/centcom_admiral.yml b/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/centcom_admiral.yml index de5b5263213..faa2799297c 100644 --- a/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/centcom_admiral.yml +++ b/Resources/Prototypes/_Backmen/Roles/Jobs/CentCom/centcom_admiral.yml @@ -12,6 +12,7 @@ requireAdminNotify: true joinNotifyCrew: true whitelisted: true + discordRequired: true requirements: - !type:RoleTimeRequirement role: JobCentralCommandOperator